/* Provide an API suitable for smhasher */ void PMurHash32_test(const void *key, int len, uint32_t seed, void *out) { uint32_t h1=seed, carry=0; const uint8_t *ptr = (uint8_t*)key; const uint8_t *end = ptr + len; PMurHash32_Process(&h1, &carry, ptr, (int)(end-ptr)); h1 = PMurHash32_Result(h1, carry, len); *(uint32_t*)out = h1; }
/* Provide an API suitable for smhasher */ void PMurHash32_test(const void *key, int len, uint32_t seed, void *out) { uint32_t h1=seed, carry=0; const uint8_t *ptr = (uint8_t*)key; const uint8_t *end = ptr + len; #if 0 /* Exercise the progressive processing */ while(ptr < end) { //const uint8_t *mid = ptr + rand()%(end-ptr)+1; const uint8_t *mid = ptr + (rand()&0xF); mid = mid<end?mid:end; PMurHash32_Process(&h1, &carry, ptr, mid-ptr); ptr = mid; } #else PMurHash32_Process(&h1, &carry, ptr, (int)(end-ptr)); #endif h1 = PMurHash32_Result(h1, carry, len); *(uint32_t*)out = h1; }
/* Murmur3A compatable all-at-once */ uint32_t PMurHash32(uint32_t seed, const void *key, int len) { uint32_t h1=seed, carry=0; PMurHash32_Process(&h1, &carry, key, len); return PMurHash32_Result(h1, carry, len); }