33 # define ROLLSUM_CHAR_OFFSET 31 42 void RollsumUpdate(
Rollsum *sum,
const unsigned char *buf,
size_t len);
46 static inline void RollsumInit(
Rollsum *sum)
51 static inline void RollsumRotate(
Rollsum *sum,
unsigned char out,
55 sum->
s2 += sum->
s1 - (uint_fast16_t)sum->
count * (out + ROLLSUM_CHAR_OFFSET);
58 static inline void RollsumRollin(
Rollsum *sum,
unsigned char in)
60 sum->
s1 += in + ROLLSUM_CHAR_OFFSET;
65 static inline void RollsumRollout(
Rollsum *sum,
unsigned char out)
67 sum->
s1 -= out + ROLLSUM_CHAR_OFFSET;
68 sum->
s2 -= (uint_fast16_t)sum->
count * (out + ROLLSUM_CHAR_OFFSET);
72 static inline uint32_t RollsumDigest(
Rollsum *sum)
74 return ((uint32_t)sum->
s2 << 16) | ((uint32_t)sum->
s1 & 0xffff);
size_t count
count of bytes included in sum
struct Rollsum Rollsum
The Rollsum state type.
uint_fast16_t s1
s1 part of sum
uint_fast16_t s2
s2 part of sum