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