Lines Matching +full:- +full:seed
2 * xxHash - Extremely Fast Hash algorithm
3 * Copyright (C) 2012-2016, Yann Collet.
5 * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
32 * Free Software Foundation. This program is dual-licensed; you may select
37 * - xxHash homepage: https://cyan4973.github.io/xxHash/
38 * - xxHash source repository: https://github.com/Cyan4973/xxHash
49 /*-*************************************
52 #define xxh_rotl32(x, r) ((x << r) | (x >> (32 - r)))
53 #define xxh_rotl64(x, r) ((x << r) | (x >> (64 - r)))
61 /*-*************************************
76 /*-**************************
91 /*-***************************
94 static uint32_t xxh32_round(uint32_t seed, const uint32_t input) in xxh32_round() argument
96 seed += input * PRIME32_2; in xxh32_round()
97 seed = xxh_rotl32(seed, 13); in xxh32_round()
98 seed *= PRIME32_1; in xxh32_round()
99 return seed; in xxh32_round()
102 uint32_t xxh32(const void *input, const size_t len, const uint32_t seed) in xxh32() argument
109 const uint8_t *const limit = b_end - 16; in xxh32()
110 uint32_t v1 = seed + PRIME32_1 + PRIME32_2; in xxh32()
111 uint32_t v2 = seed + PRIME32_2; in xxh32()
112 uint32_t v3 = seed + 0; in xxh32()
113 uint32_t v4 = seed - PRIME32_1; in xxh32()
129 h32 = seed + PRIME32_5; in xxh32()
172 uint64_t xxh64(const void *input, const size_t len, const uint64_t seed) in xxh64() argument
179 const uint8_t *const limit = b_end - 32; in xxh64()
180 uint64_t v1 = seed + PRIME64_1 + PRIME64_2; in xxh64()
181 uint64_t v2 = seed + PRIME64_2; in xxh64()
182 uint64_t v3 = seed + 0; in xxh64()
183 uint64_t v4 = seed - PRIME64_1; in xxh64()
204 h64 = seed + PRIME64_5; in xxh64()
239 /*-**************************************************
242 void xxh32_reset(struct xxh32_state *statePtr, const uint32_t seed) in xxh32_reset() argument
244 /* use a local state for memcpy() to avoid strict-aliasing warnings */ in xxh32_reset()
248 state.v1 = seed + PRIME32_1 + PRIME32_2; in xxh32_reset()
249 state.v2 = seed + PRIME32_2; in xxh32_reset()
250 state.v3 = seed + 0; in xxh32_reset()
251 state.v4 = seed - PRIME32_1; in xxh32_reset()
256 void xxh64_reset(struct xxh64_state *statePtr, const uint64_t seed) in xxh64_reset() argument
258 /* use a local state for memcpy() to avoid strict-aliasing warnings */ in xxh64_reset()
262 state.v1 = seed + PRIME64_1 + PRIME64_2; in xxh64_reset()
263 state.v2 = seed + PRIME64_2; in xxh64_reset()
264 state.v3 = seed + 0; in xxh64_reset()
265 state.v4 = seed - PRIME64_1; in xxh64_reset()
276 return -EINVAL; in xxh32_update()
278 state->total_len_32 += (uint32_t)len; in xxh32_update()
279 state->large_len |= (len >= 16) | (state->total_len_32 >= 16); in xxh32_update()
281 if (state->memsize + len < 16) { /* fill in tmp buffer */ in xxh32_update()
282 memcpy((uint8_t *)(state->mem32) + state->memsize, input, len); in xxh32_update()
283 state->memsize += (uint32_t)len; in xxh32_update()
287 if (state->memsize) { /* some data left from previous update */ in xxh32_update()
288 const uint32_t *p32 = state->mem32; in xxh32_update()
290 memcpy((uint8_t *)(state->mem32) + state->memsize, input, in xxh32_update()
291 16 - state->memsize); in xxh32_update()
293 state->v1 = xxh32_round(state->v1, get_unaligned_le32(p32)); in xxh32_update()
295 state->v2 = xxh32_round(state->v2, get_unaligned_le32(p32)); in xxh32_update()
297 state->v3 = xxh32_round(state->v3, get_unaligned_le32(p32)); in xxh32_update()
299 state->v4 = xxh32_round(state->v4, get_unaligned_le32(p32)); in xxh32_update()
302 p += 16-state->memsize; in xxh32_update()
303 state->memsize = 0; in xxh32_update()
306 if (p <= b_end - 16) { in xxh32_update()
307 const uint8_t *const limit = b_end - 16; in xxh32_update()
308 uint32_t v1 = state->v1; in xxh32_update()
309 uint32_t v2 = state->v2; in xxh32_update()
310 uint32_t v3 = state->v3; in xxh32_update()
311 uint32_t v4 = state->v4; in xxh32_update()
324 state->v1 = v1; in xxh32_update()
325 state->v2 = v2; in xxh32_update()
326 state->v3 = v3; in xxh32_update()
327 state->v4 = v4; in xxh32_update()
331 memcpy(state->mem32, p, (size_t)(b_end-p)); in xxh32_update()
332 state->memsize = (uint32_t)(b_end-p); in xxh32_update()
341 const uint8_t *p = (const uint8_t *)state->mem32; in xxh32_digest()
342 const uint8_t *const b_end = (const uint8_t *)(state->mem32) + in xxh32_digest()
343 state->memsize; in xxh32_digest()
346 if (state->large_len) { in xxh32_digest()
347 h32 = xxh_rotl32(state->v1, 1) + xxh_rotl32(state->v2, 7) + in xxh32_digest()
348 xxh_rotl32(state->v3, 12) + xxh_rotl32(state->v4, 18); in xxh32_digest()
350 h32 = state->v3 /* == seed */ + PRIME32_5; in xxh32_digest()
353 h32 += state->total_len_32; in xxh32_digest()
383 return -EINVAL; in xxh64_update()
385 state->total_len += len; in xxh64_update()
387 if (state->memsize + len < 32) { /* fill in tmp buffer */ in xxh64_update()
388 memcpy(((uint8_t *)state->mem64) + state->memsize, input, len); in xxh64_update()
389 state->memsize += (uint32_t)len; in xxh64_update()
393 if (state->memsize) { /* tmp buffer is full */ in xxh64_update()
394 uint64_t *p64 = state->mem64; in xxh64_update()
396 memcpy(((uint8_t *)p64) + state->memsize, input, in xxh64_update()
397 32 - state->memsize); in xxh64_update()
399 state->v1 = xxh64_round(state->v1, get_unaligned_le64(p64)); in xxh64_update()
401 state->v2 = xxh64_round(state->v2, get_unaligned_le64(p64)); in xxh64_update()
403 state->v3 = xxh64_round(state->v3, get_unaligned_le64(p64)); in xxh64_update()
405 state->v4 = xxh64_round(state->v4, get_unaligned_le64(p64)); in xxh64_update()
407 p += 32 - state->memsize; in xxh64_update()
408 state->memsize = 0; in xxh64_update()
412 const uint8_t *const limit = b_end - 32; in xxh64_update()
413 uint64_t v1 = state->v1; in xxh64_update()
414 uint64_t v2 = state->v2; in xxh64_update()
415 uint64_t v3 = state->v3; in xxh64_update()
416 uint64_t v4 = state->v4; in xxh64_update()
429 state->v1 = v1; in xxh64_update()
430 state->v2 = v2; in xxh64_update()
431 state->v3 = v3; in xxh64_update()
432 state->v4 = v4; in xxh64_update()
436 memcpy(state->mem64, p, (size_t)(b_end-p)); in xxh64_update()
437 state->memsize = (uint32_t)(b_end - p); in xxh64_update()
446 const uint8_t *p = (const uint8_t *)state->mem64; in xxh64_digest()
447 const uint8_t *const b_end = (const uint8_t *)state->mem64 + in xxh64_digest()
448 state->memsize; in xxh64_digest()
451 if (state->total_len >= 32) { in xxh64_digest()
452 const uint64_t v1 = state->v1; in xxh64_digest()
453 const uint64_t v2 = state->v2; in xxh64_digest()
454 const uint64_t v3 = state->v3; in xxh64_digest()
455 const uint64_t v4 = state->v4; in xxh64_digest()
464 h64 = state->v3 + PRIME64_5; in xxh64_digest()
467 h64 += (uint64_t)state->total_len; in xxh64_digest()