summaryrefslogtreecommitdiffstats
path: root/src/H5Iprivate.h
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-12-12 18:40:09 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-12-12 18:40:09 (GMT)
commit47d88766dbee3c631c842639d44c362c2b7b8e44 (patch)
tree77058751c8bcb0260593674f609cb5df1224198c /src/H5Iprivate.h
parent6e9c0514fb45ddb358d36832237a3beace6ffb6b (diff)
downloadhdf5-47d88766dbee3c631c842639d44c362c2b7b8e44.zip
hdf5-47d88766dbee3c631c842639d44c362c2b7b8e44.tar.gz
hdf5-47d88766dbee3c631c842639d44c362c2b7b8e44.tar.bz2
[svn-r4706] Purpose:
Code cleanup Description: Tweaked internal error handling macros to reduce the size of the library's object code by about 10-20%. Also cleaned up some compiler warnings... Platforms tested: FreeBSD 4.4 (sleipnir)
Diffstat (limited to 'src/H5Iprivate.h')
-rw-r--r--src/H5Iprivate.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h
index bb289a0..a928590 100644
--- a/src/H5Iprivate.h
+++ b/src/H5Iprivate.h
@@ -41,6 +41,56 @@
#define H5I_GENPROPOBJ_HASHSIZE 128
/*
+ * Define the following macro for fast hash calculations (but limited
+ * hash sizes)
+ */
+#define HASH_SIZE_POWER_2
+
+/* Define the following macro for atom caching over all the atoms */
+#define IDS_ARE_CACHED
+
+#ifdef IDS_ARE_CACHED
+# define ID_CACHE_SIZE 4 /*# of previous atoms cached */
+#endif
+
+/*
+ * Number of bits to use for Group ID in each atom. Increase if H5I_NGROUPS
+ * becomes too large (an assertion would fail in H5I_init_interface). This is
+ * the only number that must be changed since all other bit field sizes and
+ * masks are calculated from GROUP_BITS.
+ */
+#define GROUP_BITS 5
+#define GROUP_MASK ((1<<GROUP_BITS)-1)
+
+/*
+ * Number of bits to use for the Atom index in each atom (assumes 8-bit
+ * bytes). We don't use the sign bit.
+ */
+#define ID_BITS ((sizeof(hid_t)*8)-(GROUP_BITS+1))
+#define ID_MASK ((1<<ID_BITS)-1)
+
+/* Map an atom to a Group number */
+#define H5I_GROUP(a) ((H5I_type_t)(((hid_t)(a)>>ID_BITS) & GROUP_MASK))
+
+#ifdef HASH_SIZE_POWER_2
+/*
+ * Map an ID to a hash location (assumes s is a power of 2 and smaller
+ * than the ID_MASK constant).
+ */
+# define H5I_LOC(a,s) ((hid_t)((size_t)(a)&((s)-1)))
+# define POWER_OF_TWO(n) ((((n) - 1) & (n)) == 0 && (n) > 0)
+#else
+/*
+ * Map an ID to a hash location.
+ */
+# define H5I_LOC(a,s) (((hid_t)(a)&ID_MASK)%(s))
+#endif
+
+/* Combine a Group number and an atom index into an atom */
+#define H5I_MAKE(g,i) ((((hid_t)(g)&GROUP_MASK)<<ID_BITS)| \
+ ((hid_t)(i)&ID_MASK))
+
+/*
* Function for freeing objects. This function will be called with an object
* ID group number (object type) and a pointer to the object. The function
* should free the object and return non-negative to indicate that the object