Line data Source code
1 : #include "fd_murmur3.h" 2 : 3 : static uint 4 : fd_murmur3_32_( void const * _data, 5 : ulong sz, 6 1364113 : uint seed ) { 7 : 8 1364113 : uchar const * data = _data; 9 1364113 : uint sz_tag = (uint)sz; 10 : 11 1364113 : uint c1 = 0xcc9e2d51U; 12 1364113 : uint c2 = 0x1b873593U; 13 1364113 : int r1 = 15; 14 1364113 : int r2 = 13; 15 1364113 : uint m = 5; 16 1364113 : uint n = 0xe6546b64U; 17 : 18 1364113 : uint hash = seed; 19 : 20 5572025 : while( sz>=4 ) { 21 4207912 : uint k = FD_LOAD( uint, data ); 22 4207912 : k *= c1; 23 4207912 : k = fd_uint_rotate_left( k, r1 ); 24 4207912 : k *= c2; 25 : 26 4207912 : hash ^= k; 27 4207912 : hash = fd_uint_rotate_left( hash, r2 ); 28 4207912 : hash = hash*m + n; 29 : 30 4207912 : data+=4UL; 31 4207912 : sz -=4UL; 32 4207912 : } 33 : 34 1364113 : uint rem = 0; 35 1364113 : switch( sz ) { 36 254716 : case 3: rem ^= (uint)data[2]<<16U; __attribute__((fallthrough)); 37 477267 : case 2: rem ^= (uint)data[1]<<8U; __attribute__((fallthrough)); 38 940542 : case 1: rem ^= (uint)data[0]; 39 940542 : rem *= c1; 40 940542 : rem = fd_uint_rotate_left( rem, r1 ); 41 940542 : rem *= c2; 42 940542 : hash ^= rem; __attribute__((fallthrough)); 43 1391657 : case 0: break; 44 1364113 : } 45 : 46 1364279 : hash ^= sz_tag; 47 1364279 : hash ^= hash>>16U; 48 1364279 : hash *= 0x85ebca6bU; 49 1364279 : hash ^= hash>>13U; 50 1364279 : hash *= 0xc2b2ae35U; 51 1364279 : hash ^= hash>>16U; 52 : 53 1364279 : return hash; 54 1364113 : } 55 : 56 : uint 57 : fd_murmur3_32( void const * _data, 58 : ulong sz, 59 1364166 : uint seed ) { 60 1364166 : return fd_murmur3_32_( _data, sz, seed ); 61 1364166 : }