mirror of
https://github.com/php/php-src.git
synced 2024-11-26 19:33:55 +08:00
72e91e9fc8
The implementation is based on the upstream PMurHash. The following variants are implemented - murmur3a, 32-bit hash - murmur3c, 128-bit hash for x86 - murmur3f, 128-bit hash for x64 The custom seed support is not targeted by this implementation. It will need a major change to the API, so then custom arguments can be passed through `hash_init`. For now, the starting hash is always zero. Fixes bug #68109, closes #6059 Signed-off-by: Anatol Belski <ab@php.net> Co-Developed-by: Michael Wallner <mike@php.net> Signed-off-by: Michael Wallner <mike@php.net>
32 lines
891 B
C
32 lines
891 B
C
/*-----------------------------------------------------------------------------
|
|
* MurmurHash3 was written by Austin Appleby, and is placed in the public
|
|
* domain.
|
|
*
|
|
* This implementation was written by Shane Day, and is also public domain.
|
|
*
|
|
* This implementation was modified to match PMurHash128.cpp.
|
|
*/
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
// Microsoft Visual Studio
|
|
|
|
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
|
|
|
typedef unsigned char uint8_t;
|
|
typedef unsigned int uint32_t;
|
|
|
|
// Other compilers
|
|
|
|
#else // defined(_MSC_VER)
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif // !defined(_MSC_VER)
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
/* Prototypes */
|
|
|
|
void PMurHash32_Process(uint32_t *ph1, uint32_t *pcarry, const void *key, int len);
|
|
uint32_t PMurHash32_Result(uint32_t h1, uint32_t carry, uint32_t total_length);
|