X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Fhash.c;h=56c5086e742552480a23e81a8e2a7baafe583d73;hp=1359cfecd66dc6280e3314e78fd2e7e5ea91c8bd;hb=c8f6f8c2dea76042f74c02eff048847e62adcca6;hpb=97224cbbe29e76522ec38d031c54b1cadce8ae03 diff --git a/ccan/tdb2/hash.c b/ccan/tdb2/hash.c index 1359cfec..56c5086e 100644 --- a/ccan/tdb2/hash.c +++ b/ccan/tdb2/hash.c @@ -16,8 +16,20 @@ License along with this library; if not, see . */ #include "private.h" +#include #include +/* Default hash function. */ +uint64_t tdb_jenkins_hash(const void *key, size_t length, uint64_t seed, + void *unused) +{ + uint64_t ret; + /* hash64_stable assumes lower bits are more important; they are a + * slightly better hash. We use the upper bits first, so swap them. */ + ret = hash64_stable((const unsigned char *)key, length, seed); + return (ret >> 32) | (ret << 32); +} + uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len) { return tdb->hash_fn(ptr, len, tdb->hash_seed, tdb->hash_data);