64 static inline void weaksum_reset(
weaksum_t *sum)
66 if (sum->kind == RS_ROLLSUM)
67 RollsumInit(&sum->sum.rs);
69 rabinkarp_init(&sum->sum.rk);
74 assert(kind == RS_ROLLSUM || kind == RS_RABINKARP);
79 static inline size_t weaksum_count(
weaksum_t *sum)
82 return sum->sum.rs.
count;
85 static inline void weaksum_update(
weaksum_t *sum,
const unsigned char *buf,
88 if (sum->kind == RS_ROLLSUM)
89 RollsumUpdate(&sum->sum.rs, buf, len);
91 rabinkarp_update(&sum->sum.rk, buf, len);
94 static inline void weaksum_rotate(
weaksum_t *sum,
unsigned char out,
97 if (sum->kind == RS_ROLLSUM)
98 RollsumRotate(&sum->sum.rs, out, in);
100 rabinkarp_rotate(&sum->sum.rk, out, in);
103 static inline void weaksum_rollin(
weaksum_t *sum,
unsigned char in)
105 if (sum->kind == RS_ROLLSUM)
106 RollsumRollin(&sum->sum.rs, in);
108 rabinkarp_rollin(&sum->sum.rk, in);
111 static inline void weaksum_rollout(
weaksum_t *sum,
unsigned char out)
113 if (sum->kind == RS_ROLLSUM)
114 RollsumRollout(&sum->sum.rs, out);
116 rabinkarp_rollout(&sum->sum.rk, out);
119 static inline rs_weak_sum_t weaksum_digest(
weaksum_t *sum)
121 if (sum->kind == RS_ROLLSUM)
123 return mix32(RollsumDigest(&sum->sum.rs));
125 return rabinkarp_digest(&sum->sum.rk);
139 rs_strong_sum_t *sum);
The Rollsum class implementation of the original rsync rollsum.
void rs_calc_strong_sum(strongsum_kind_t kind, void const *buf, size_t len, rs_strong_sum_t *sum)
Calculate a strongsum.
size_t count
count of bytes included in sum
rs_weak_sum_t rs_calc_weak_sum(weaksum_kind_t kind, void const *buf, size_t len)
Calculate a weaksum.
static unsigned mix32(unsigned h)
MurmurHash3 finalization mix function.
Public header for librsync.
strongsum_kind_t
Strongsum implementations.
weaksum_kind_t
Weaksum implementations.
The rabinkarp class implementation of the RabinKarp rollsum.
The rabinkarp_t state type.
A generic open addressing hashtable.
Abstract wrapper around weaksum implementations.
struct weaksum weaksum_t
Abstract wrapper around weaksum implementations.