Add macro M_HASH_FINAL

This commit is contained in:
Patrick Pelissier committed 2017-08-17 20:22:01 +02:00
1 parent 23d29aa981
commit ffc383884d
7 files changed
+8 -7

No files matched your search

+1 -1
View File
@@ -733,7 +733,7 @@
size_t hi = M_GET_HASH oplist (array->ptr[i]); \
M_HASH_UP(hash, hi); \
} \
return hash; \
return M_HASH_FINAL (hash); \
} \
, /* no HASH */ ) \
+1 -1
View File
@@ -627,7 +627,7 @@ bitset_hash(const bitset_t dest)
size_t mask = (1UL << m) - 1;
M_HASH_UP(hash, (dest->ptr[n] & mask));
}
return hash;
return M_HASH_FINAL (hash);
}
#define BITSET_OPLIST \
+2 -1
View File
@@ -668,7 +668,8 @@
#endif
#define M_HASH_DECL(hash) size_t hash = M_HASH_INIT ^ M_HASH_SEED
#define M_HASH_UP(hash,h) hash = M_HASH_CALC(hash, (h))
#define M_HASH_UP(hash,h) do { hash = M_HASH_CALC(hash, (h)); } while (0)
#define M_HASH_FINAL(hash) (hash)
/* Safe, efficient, and portable Rotate:
It should be recognized by any compiler and generate a single roll instruction */
+1 -1
View File
@@ -582,7 +582,7 @@
size_t hi = M_GET_HASH oplist (*item); \
M_HASH_UP(hash, hi); \
} \
return hash; \
return M_HASH_FINAL (hash); \
} \
, /* no hash */ ) \
+1 -1
View File
@@ -892,7 +892,7 @@ typedef enum {
const type *ref1 = M_C(name, _cref)(it1); \
M_HASH_UP(hash, M_GET_HASH oplist (*ref1)); \
} \
return hash; \
return M_HASH_FINAL (hash); \
} \
, /* NO HASH METHOD */ ) \
\
+1 -1
View File
@@ -189,7 +189,7 @@
static inline size_t M_C(name, _hash)(M_C(name,_t) const e1) { \
M_HASH_DECL(hash); \
M_MAP(TUPLE_DEFINE_HASH_FUNC , __VA_ARGS__) \
return hash; \
return M_HASH_FINAL (hash); \
}
#define TUPLE_DEFINE_HASH_FUNC(a) \
M_HASH_UP(hash, TUPLE_GET_HASH a ( e1 -> TUPLE_GET_FIELD a) );
+1 -1
View File
@@ -241,7 +241,7 @@
M_MAP2(VARIANTI_DEFINE_HASH_FUNC , name, __VA_ARGS__) \
default: assert(false); break; \
} \
return hash; \
return M_HASH_FINAL (hash); \
}
#define VARIANTI_DEFINE_HASH_FUNC(name, a) \
case M_C3(name, _, VARIANTI_GET_FIELD a): \