def3d745f86f0d967ac8af53c4b5f75935ae5b6d
2 +--------------------------------------------------------------------+
3 | libmemcached-awesome - 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-2021 Michael Wallner https://awesome.co/ |
13 +--------------------------------------------------------------------+
16 /* By Paul Hsieh (C) 2004, 2005. Covered under the Paul Hsieh
18 * See: http://www.azillionmonkeys.com/qed/weblicense.html for license
20 * http://www.azillionmonkeys.com/qed/hash.html
23 #include "libhashkit/common.h"
26 #if (defined(__GNUC__) && defined(__i386__))
27 # define get16bits(d) (*((const uint16_t *) (d)))
30 #if !defined(get16bits)
31 # define get16bits(d) \
32 ((((uint32_t)(((const uint8_t *) (d))[1])) << 8) + (uint32_t)(((const uint8_t *) (d))[0]))
35 #ifdef HAVE_HSIEH_HASH
36 uint32_t hashkit_hsieh(const char *key
, size_t key_length
, void *) {
37 uint32_t hash
= 0, tmp
;
40 if (key_length
<= 0 || key
== NULL
)
47 for (; key_length
> 0; key_length
--) {
48 hash
+= get16bits(key
);
49 tmp
= (get16bits(key
+ 2) << 11) ^ hash
;
50 hash
= (hash
<< 16) ^ tmp
;
51 key
+= 2 * sizeof(uint16_t);
55 /* Handle end cases */
58 hash
+= get16bits(key
);
60 hash
^= (uint32_t) key
[sizeof(uint16_t)] << 18;
64 hash
+= get16bits(key
);
69 hash
+= (unsigned char) (*key
);
76 /* Force "avalanching" of final 127 bits */
87 uint32_t hashkit_hsieh(const char *, size_t, void *) {