64static 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);
79static inline size_t weaksum_count(
weaksum_t *sum)
82 return sum->sum.rs.
count;
85static 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);
94static 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);
103static 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);
111static 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);
119static 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);
rs_weak_sum_t rs_calc_weak_sum(weaksum_kind_t kind, void const *buf, size_t len)
Calculate a weaksum.
strongsum_kind_t
Strongsum implementations.
weaksum_kind_t
Weaksum implementations.
struct weaksum weaksum_t
Abstract wrapper around weaksum implementations.
void rs_calc_strong_sum(strongsum_kind_t kind, void const *buf, size_t len, rs_strong_sum_t *sum)
Calculate a strongsum.
A generic open addressing hashtable.
static unsigned mix32(unsigned h)
MurmurHash3 finalization mix function.
Public header for librsync.
The rabinkarp class implementation of the RabinKarp rollsum.
The Rollsum class implementation of the original rsync rollsum.
size_t count
count of bytes included in sum
The rabinkarp_t state type.
Abstract wrapper around weaksum implementations.