2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
16 #include "libhashkit/common.h"
18 #if __WORDSIZE == 64 && defined(HAVE_FNV64_HASH)
20 /* FNV hash'es lifted from Dustin Sallings work */
21 static uint64_t FNV_64_INIT
= 0xcbf29ce484222325;
22 static uint64_t FNV_64_PRIME
= 0x100000001b3;
24 uint32_t hashkit_fnv1_64(const char *key
, size_t key_length
, void *) {
25 /* Thanks to pierre@demartines.com for the pointer */
26 uint64_t hash
= FNV_64_INIT
;
28 for (size_t x
= 0; x
< key_length
; x
++) {
30 hash
^= (uint64_t) key
[x
];
33 return (uint32_t) hash
;
36 uint32_t hashkit_fnv1a_64(const char *key
, size_t key_length
, void *) {
37 uint32_t hash
= (uint32_t) FNV_64_INIT
;
39 for (size_t x
= 0; x
< key_length
; x
++) {
40 uint32_t val
= (uint32_t) key
[x
];
42 hash
*= (uint32_t) FNV_64_PRIME
;
49 uint32_t hashkit_fnv1_64(const char *, size_t, void *) {
53 uint32_t hashkit_fnv1a_64(const char *, size_t, void *) {