Add macro M_HASH_FINAL
This commit is contained in:
1 parent
23d29aa981
commit
ffc383884d
7 files changed
+8
-7
No files matched your search
@@ -733,7 +733,7 @@
|
|||||||
size_t hi = M_GET_HASH oplist (array->ptr[i]); \
|
size_t hi = M_GET_HASH oplist (array->ptr[i]); \
|
||||||
M_HASH_UP(hash, hi); \
|
M_HASH_UP(hash, hi); \
|
||||||
} \
|
} \
|
||||||
return hash; \
|
return M_HASH_FINAL (hash); \
|
||||||
} \
|
} \
|
||||||
, /* no HASH */ ) \
|
, /* no HASH */ ) \
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -627,7 +627,7 @@ bitset_hash(const bitset_t dest)
|
|||||||
size_t mask = (1UL << m) - 1;
|
size_t mask = (1UL << m) - 1;
|
||||||
M_HASH_UP(hash, (dest->ptr[n] & mask));
|
M_HASH_UP(hash, (dest->ptr[n] & mask));
|
||||||
}
|
}
|
||||||
return hash;
|
return M_HASH_FINAL (hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BITSET_OPLIST \
|
#define BITSET_OPLIST \
|
||||||
|
|||||||
@@ -668,7 +668,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define M_HASH_DECL(hash) size_t hash = M_HASH_INIT ^ M_HASH_SEED
|
#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:
|
/* Safe, efficient, and portable Rotate:
|
||||||
It should be recognized by any compiler and generate a single roll instruction */
|
It should be recognized by any compiler and generate a single roll instruction */
|
||||||
|
|||||||
@@ -582,7 +582,7 @@
|
|||||||
size_t hi = M_GET_HASH oplist (*item); \
|
size_t hi = M_GET_HASH oplist (*item); \
|
||||||
M_HASH_UP(hash, hi); \
|
M_HASH_UP(hash, hi); \
|
||||||
} \
|
} \
|
||||||
return hash; \
|
return M_HASH_FINAL (hash); \
|
||||||
} \
|
} \
|
||||||
, /* no hash */ ) \
|
, /* no hash */ ) \
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -892,7 +892,7 @@ typedef enum {
|
|||||||
const type *ref1 = M_C(name, _cref)(it1); \
|
const type *ref1 = M_C(name, _cref)(it1); \
|
||||||
M_HASH_UP(hash, M_GET_HASH oplist (*ref1)); \
|
M_HASH_UP(hash, M_GET_HASH oplist (*ref1)); \
|
||||||
} \
|
} \
|
||||||
return hash; \
|
return M_HASH_FINAL (hash); \
|
||||||
} \
|
} \
|
||||||
, /* NO HASH METHOD */ ) \
|
, /* NO HASH METHOD */ ) \
|
||||||
\
|
\
|
||||||
|
|||||||
@@ -189,7 +189,7 @@
|
|||||||
static inline size_t M_C(name, _hash)(M_C(name,_t) const e1) { \
|
static inline size_t M_C(name, _hash)(M_C(name,_t) const e1) { \
|
||||||
M_HASH_DECL(hash); \
|
M_HASH_DECL(hash); \
|
||||||
M_MAP(TUPLE_DEFINE_HASH_FUNC , __VA_ARGS__) \
|
M_MAP(TUPLE_DEFINE_HASH_FUNC , __VA_ARGS__) \
|
||||||
return hash; \
|
return M_HASH_FINAL (hash); \
|
||||||
}
|
}
|
||||||
#define TUPLE_DEFINE_HASH_FUNC(a) \
|
#define TUPLE_DEFINE_HASH_FUNC(a) \
|
||||||
M_HASH_UP(hash, TUPLE_GET_HASH a ( e1 -> TUPLE_GET_FIELD a) );
|
M_HASH_UP(hash, TUPLE_GET_HASH a ( e1 -> TUPLE_GET_FIELD a) );
|
||||||
|
|||||||
+1
-1
@@ -241,7 +241,7 @@
|
|||||||
M_MAP2(VARIANTI_DEFINE_HASH_FUNC , name, __VA_ARGS__) \
|
M_MAP2(VARIANTI_DEFINE_HASH_FUNC , name, __VA_ARGS__) \
|
||||||
default: assert(false); break; \
|
default: assert(false); break; \
|
||||||
} \
|
} \
|
||||||
return hash; \
|
return M_HASH_FINAL (hash); \
|
||||||
}
|
}
|
||||||
#define VARIANTI_DEFINE_HASH_FUNC(name, a) \
|
#define VARIANTI_DEFINE_HASH_FUNC(name, a) \
|
||||||
case M_C3(name, _, VARIANTI_GET_FIELD a): \
|
case M_C3(name, _, VARIANTI_GET_FIELD a): \
|
||||||
|
|||||||
Reference in new issue
Block a user