24#define RABINKARP_MULT2 0xa5b71959U
29#define PAR2X1(hash,buf,i) (RABINKARP_MULT2*(hash) + \
30 RABINKARP_MULT*buf[i] + \
32#define PAR2X2(hash,buf,i) PAR2X1(PAR2X1(hash,buf,i),buf,i+2)
33#define PAR2X4(hash,buf,i) PAR2X2(PAR2X2(hash,buf,i),buf,i+4)
34#define PAR2X8(hash,buf) PAR2X4(PAR2X4(hash,buf,0),buf,8)
37const static uint32_t RABINKARP_MULT_POW2[32] = {
73static inline uint32_t rabinkarp_pow(uint32_t n)
75 const uint32_t *m = RABINKARP_MULT_POW2;
87void rabinkarp_update(rabinkarp_t *sum,
const unsigned char *buf,
size_t len)
90 uint32_t hash = sum->hash;
93 hash = PAR2X8(hash, buf);
98 hash = RABINKARP_MULT * hash + *buf++;
103 sum->mult *= rabinkarp_pow((uint32_t)len);