• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-----------------------------------------------------------------------------
2  * MurmurHash3 was written by Austin Appleby, and is placed in the public
3  * domain.
4  *
5  * This implementation was written by Shane Day, and is also public domain.
6  *
7  * This is a portable ANSI C implementation of MurmurHash3_x86_32 (Murmur3A)
8  * with support for progressive processing.
9  */
10 
11 /* ------------------------------------------------------------------------- */
12 /* Determine what native type to use for uint32_t */
13 
14 /* We can't use the name 'uint32_t' here because it will conflict with
15  * any version provided by the system headers or application. */
16 
17 /* First look for special cases */
18 #if defined(_MSC_VER)
19 #    define MH_UINT32 unsigned long
20 #endif
21 
22 /* If the compiler says it's C99 then take its word for it */
23 #if !defined(MH_UINT32) && (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
24 #    include <stdint.h>
25 #    define MH_UINT32 uint32_t
26 #endif
27 
28 /* Otherwise try testing against max value macros from limit.h */
29 #if !defined(MH_UINT32)
30 #    include <limits.h>
31 #    if (USHRT_MAX == 0xffffffffUL)
32 #        define MH_UINT32 unsigned short
33 #    elif (UINT_MAX == 0xffffffffUL)
34 #        define MH_UINT32 unsigned int
35 #    elif (ULONG_MAX == 0xffffffffUL)
36 #        define MH_UINT32 unsigned long
37 #    endif
38 #endif
39 
40 #if !defined(MH_UINT32)
41 #    error Unable to determine type name for unsigned 32-bit int
42 #endif
43 
44 /* I'm yet to work on a platform where 'unsigned char' is not 8 bits */
45 #define MH_UINT8 unsigned char
46 
47 /* ------------------------------------------------------------------------- */
48 /* Prototypes */
49 
50 namespace angle
51 {
52 void PMurHash32_Process(MH_UINT32 *ph1, MH_UINT32 *pcarry, const void *key, int len);
53 MH_UINT32 PMurHash32_Result(MH_UINT32 h1, MH_UINT32 carry, MH_UINT32 total_length);
54 MH_UINT32 PMurHash32(MH_UINT32 seed, const void *key, int len);
55 
56 void PMurHash32_test(const void *key, int len, MH_UINT32 seed, void *out);
57 }  // namespace angle
58