1 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 3 #include "memcached.h" 4 #include "jenkins_hash.h" 5 #include "murmur3_hash.h" 6 #define XXH_INLINE_ALL // modifier for xxh3's include below 7 #include "xxhash.h" 8 9 hash_func hash; 10 XXH3_hash(const void * key,size_t length)11static uint32_t XXH3_hash(const void *key, size_t length) { 12 return (uint32_t)XXH3_64bits(key, length); 13 } 14 hash_init(enum hashfunc_type type)15int hash_init(enum hashfunc_type type) { 16 switch(type) { 17 case JENKINS_HASH: 18 hash = jenkins_hash; 19 settings.hash_algorithm = "jenkins"; 20 break; 21 case MURMUR3_HASH: 22 hash = MurmurHash3_x86_32; 23 settings.hash_algorithm = "murmur3"; 24 break; 25 case XXH3_HASH: 26 hash = XXH3_hash; 27 settings.hash_algorithm = "xxh3"; 28 break; 29 default: 30 return -1; 31 } 32 return 0; 33 } 34