vppinfra: add os_get_online_cpu_core() and os_get_online_cpu_node()
[vpp.git] / src / vppinfra / hash.h
index 23b91b1..3c754c8 100644 (file)
@@ -96,18 +96,11 @@ typedef struct hash_header
   uword *is_user;
 } hash_t;
 
-/* Hash header size in bytes */
-always_inline uword
-hash_header_bytes (void *v)
-{
-  return sizeof (hash_t);
-}
-
 /* Returns a pointer to the hash header given the vector pointer */
 always_inline hash_t *
 hash_header (void *v)
 {
-  return vec_header (v, hash_header_bytes (v));
+  return vec_header (v);
 }
 
 /* Number of elements in the hash table */
@@ -130,8 +123,9 @@ always_inline uword
 hash_is_user (void *v, uword i)
 {
   hash_t *h = hash_header (v);
-  uword i0 = i / BITS (h->is_user[0]);
-  uword i1 = i % BITS (h->is_user[0]);
+  uword bits = BITS (h->is_user[0]);
+  uword i0 = i / bits;
+  uword i1 = i % bits;
   return (h->is_user[i0] & ((uword) 1 << i1)) != 0;
 }
 
@@ -534,6 +528,12 @@ do {                                               \
 #define hash_mix64_step_3(a,b,c) hash_mix_step(a,b,c,35,49,11)
 #define hash_mix64_step_4(a,b,c) hash_mix_step(a,b,c,12,18,22)
 
+#if uword_bits == 64
+#define hash_mix(a, b, c) hash_mix64 (a, b, c)
+#else
+#define hash_mix(a, b, c) hash_mix32 (a, b, c)
+#endif
+
 /* Hash function based on that of Bob Jenkins (bob_jenkins@compuserve.com).
    Thanks, Bob. */
 #define hash_mix64(a0,b0,c0)                   \