PMurHash.h

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------
00002  * MurmurHash3 was written by Austin Appleby, and is placed in the public
00003  * domain.
00004  *
00005  * This implementation was written by Shane Day, and is also public domain.
00006  *
00007  * This is a portable ANSI C implementation of MurmurHash3_x86_32 (Murmur3A)
00008  * with support for progressive processing.
00009  */
00010 
00011 /* ------------------------------------------------------------------------- */
00012 /* Determine what native type to use for uint32_t */
00013 
00014 /* We can't use the name 'uint32_t' here because it will conflict with
00015  * any version provided by the system headers or application. */
00016 
00017 /* First look for special cases */
00018 #if defined(_MSC_VER)
00019   #define MH_UINT32 unsigned long
00020 #endif
00021 
00022 /* If the compiler says it's C99 then take its word for it */
00023 #if !defined(MH_UINT32) && ( \
00024      defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L )
00025   #include <stdint.h>
00026   #define MH_UINT32 uint32_t
00027 #endif
00028 
00029 /* Otherwise try testing against max value macros from limit.h */
00030 #if !defined(MH_UINT32)
00031   #include  <limits.h>
00032   #if   (USHRT_MAX == 0xffffffffUL)
00033     #define MH_UINT32 unsigned short
00034   #elif (UINT_MAX == 0xffffffffUL)
00035     #define MH_UINT32 unsigned int
00036   #elif (ULONG_MAX == 0xffffffffUL)
00037     #define MH_UINT32 unsigned long
00038   #endif
00039 #endif
00040 
00041 #if !defined(MH_UINT32)
00042   #error Unable to determine type name for unsigned 32-bit int
00043 #endif
00044 
00045 /* I'm yet to work on a platform where 'unsigned char' is not 8 bits */
00046 #define MH_UINT8  unsigned char
00047 
00048 
00049 /* ------------------------------------------------------------------------- */
00050 /* Prototypes */
00051 
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055 
00056 void PMurHash32_Process(MH_UINT32 *ph1, MH_UINT32 *pcarry, const void *key, int len);
00057 MH_UINT32 PMurHash32_Result(MH_UINT32 h1, MH_UINT32 carry, MH_UINT32 total_length);
00058 MH_UINT32 PMurHash32(MH_UINT32 seed, const void *key, int len);
00059 
00060 void PMurHash32_test(const void *key, int len, MH_UINT32 seed, void *out);
00061 
00062 #ifdef __cplusplus
00063 }
00064 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation