Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * xxHash - Extremely Fast Hash algorithm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2012-2016, Yann Collet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * modification, are permitted provided that the following conditions are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *   * Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *     notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *   * Redistributions in binary form must reproduce the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *     copyright notice, this list of conditions and the following disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *     in the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *     distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * This program is free software; you can redistribute it and/or modify it under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * the terms of the GNU General Public License version 2 as published by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * Free Software Foundation. This program is dual-licensed; you may select
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * either version 2 of the GNU General Public License ("GPL") or BSD license
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * ("BSD").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * You can contact the author at:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * - xxHash homepage: https://cyan4973.github.io/xxHash/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * - xxHash source repository: https://github.com/Cyan4973/xxHash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #include <linux/xxhash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /*-*************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * Macros
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  **************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define xxh_rotl32(x, r) ((x << r) | (x >> (32 - r)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define xxh_rotl64(x, r) ((x << r) | (x >> (64 - r)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #ifdef __LITTLE_ENDIAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) # define XXH_CPU_LITTLE_ENDIAN 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) # define XXH_CPU_LITTLE_ENDIAN 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) /*-*************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * Constants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  **************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static const uint32_t PRIME32_1 = 2654435761U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) static const uint32_t PRIME32_2 = 2246822519U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static const uint32_t PRIME32_3 = 3266489917U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) static const uint32_t PRIME32_4 =  668265263U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) static const uint32_t PRIME32_5 =  374761393U;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) static const uint64_t PRIME64_1 = 11400714785074694791ULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) static const uint64_t PRIME64_2 = 14029467366897019727ULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) static const uint64_t PRIME64_3 =  1609587929392839161ULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) static const uint64_t PRIME64_4 =  9650029242287828579ULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static const uint64_t PRIME64_5 =  2870177450012600261ULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) /*-**************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *  Utils
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  ***************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) void xxh32_copy_state(struct xxh32_state *dst, const struct xxh32_state *src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	memcpy(dst, src, sizeof(*dst));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) EXPORT_SYMBOL(xxh32_copy_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) void xxh64_copy_state(struct xxh64_state *dst, const struct xxh64_state *src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	memcpy(dst, src, sizeof(*dst));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) EXPORT_SYMBOL(xxh64_copy_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) /*-***************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * Simple Hash Functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  ****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static uint32_t xxh32_round(uint32_t seed, const uint32_t input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	seed += input * PRIME32_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	seed = xxh_rotl32(seed, 13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	seed *= PRIME32_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return seed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) uint32_t xxh32(const void *input, const size_t len, const uint32_t seed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	const uint8_t *p = (const uint8_t *)input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	const uint8_t *b_end = p + len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	uint32_t h32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	if (len >= 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		const uint8_t *const limit = b_end - 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		uint32_t v1 = seed + PRIME32_1 + PRIME32_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		uint32_t v2 = seed + PRIME32_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		uint32_t v3 = seed + 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		uint32_t v4 = seed - PRIME32_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			v1 = xxh32_round(v1, get_unaligned_le32(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			v2 = xxh32_round(v2, get_unaligned_le32(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			v3 = xxh32_round(v3, get_unaligned_le32(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			v4 = xxh32_round(v4, get_unaligned_le32(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		} while (p <= limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		h32 = xxh_rotl32(v1, 1) + xxh_rotl32(v2, 7) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			xxh_rotl32(v3, 12) + xxh_rotl32(v4, 18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		h32 = seed + PRIME32_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	h32 += (uint32_t)len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	while (p + 4 <= b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		h32 += get_unaligned_le32(p) * PRIME32_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		h32 = xxh_rotl32(h32, 17) * PRIME32_4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	while (p < b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		h32 += (*p) * PRIME32_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		h32 = xxh_rotl32(h32, 11) * PRIME32_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		p++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	h32 ^= h32 >> 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	h32 *= PRIME32_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	h32 ^= h32 >> 13;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	h32 *= PRIME32_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	h32 ^= h32 >> 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	return h32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) EXPORT_SYMBOL(xxh32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) static uint64_t xxh64_round(uint64_t acc, const uint64_t input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	acc += input * PRIME64_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	acc = xxh_rotl64(acc, 31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	acc *= PRIME64_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	return acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static uint64_t xxh64_merge_round(uint64_t acc, uint64_t val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	val = xxh64_round(0, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	acc ^= val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	acc = acc * PRIME64_1 + PRIME64_4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	return acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) uint64_t xxh64(const void *input, const size_t len, const uint64_t seed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	const uint8_t *p = (const uint8_t *)input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	const uint8_t *const b_end = p + len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	uint64_t h64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (len >= 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		const uint8_t *const limit = b_end - 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		uint64_t v1 = seed + PRIME64_1 + PRIME64_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		uint64_t v2 = seed + PRIME64_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		uint64_t v3 = seed + 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		uint64_t v4 = seed - PRIME64_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			v1 = xxh64_round(v1, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			v2 = xxh64_round(v2, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			v3 = xxh64_round(v3, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			v4 = xxh64_round(v4, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		} while (p <= limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		h64 = xxh_rotl64(v1, 1) + xxh_rotl64(v2, 7) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 			xxh_rotl64(v3, 12) + xxh_rotl64(v4, 18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		h64 = xxh64_merge_round(h64, v1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		h64 = xxh64_merge_round(h64, v2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		h64 = xxh64_merge_round(h64, v3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		h64 = xxh64_merge_round(h64, v4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		h64  = seed + PRIME64_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	h64 += (uint64_t)len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	while (p + 8 <= b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		const uint64_t k1 = xxh64_round(0, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		h64 ^= k1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		h64 = xxh_rotl64(h64, 27) * PRIME64_1 + PRIME64_4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (p + 4 <= b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		h64 ^= (uint64_t)(get_unaligned_le32(p)) * PRIME64_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		h64 = xxh_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	while (p < b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		h64 ^= (*p) * PRIME64_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		h64 = xxh_rotl64(h64, 11) * PRIME64_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		p++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	h64 ^= h64 >> 33;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	h64 *= PRIME64_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	h64 ^= h64 >> 29;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	h64 *= PRIME64_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	h64 ^= h64 >> 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	return h64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) EXPORT_SYMBOL(xxh64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) /*-**************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  * Advanced Hash Functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  ***************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) void xxh32_reset(struct xxh32_state *statePtr, const uint32_t seed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	/* use a local state for memcpy() to avoid strict-aliasing warnings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	struct xxh32_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	memset(&state, 0, sizeof(state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	state.v1 = seed + PRIME32_1 + PRIME32_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	state.v2 = seed + PRIME32_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	state.v3 = seed + 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	state.v4 = seed - PRIME32_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	memcpy(statePtr, &state, sizeof(state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) EXPORT_SYMBOL(xxh32_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) void xxh64_reset(struct xxh64_state *statePtr, const uint64_t seed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	/* use a local state for memcpy() to avoid strict-aliasing warnings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	struct xxh64_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	memset(&state, 0, sizeof(state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	state.v1 = seed + PRIME64_1 + PRIME64_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	state.v2 = seed + PRIME64_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	state.v3 = seed + 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	state.v4 = seed - PRIME64_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	memcpy(statePtr, &state, sizeof(state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) EXPORT_SYMBOL(xxh64_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) int xxh32_update(struct xxh32_state *state, const void *input, const size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	const uint8_t *p = (const uint8_t *)input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	const uint8_t *const b_end = p + len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	if (input == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	state->total_len_32 += (uint32_t)len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	state->large_len |= (len >= 16) | (state->total_len_32 >= 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	if (state->memsize + len < 16) { /* fill in tmp buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		memcpy((uint8_t *)(state->mem32) + state->memsize, input, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		state->memsize += (uint32_t)len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	if (state->memsize) { /* some data left from previous update */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		const uint32_t *p32 = state->mem32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		memcpy((uint8_t *)(state->mem32) + state->memsize, input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 			16 - state->memsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		state->v1 = xxh32_round(state->v1, get_unaligned_le32(p32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		p32++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		state->v2 = xxh32_round(state->v2, get_unaligned_le32(p32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		p32++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		state->v3 = xxh32_round(state->v3, get_unaligned_le32(p32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		p32++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		state->v4 = xxh32_round(state->v4, get_unaligned_le32(p32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		p32++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		p += 16-state->memsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		state->memsize = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	if (p <= b_end - 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		const uint8_t *const limit = b_end - 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		uint32_t v1 = state->v1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		uint32_t v2 = state->v2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 		uint32_t v3 = state->v3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		uint32_t v4 = state->v4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 			v1 = xxh32_round(v1, get_unaligned_le32(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 			p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			v2 = xxh32_round(v2, get_unaligned_le32(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			v3 = xxh32_round(v3, get_unaligned_le32(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 			p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 			v4 = xxh32_round(v4, get_unaligned_le32(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		} while (p <= limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 		state->v1 = v1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		state->v2 = v2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		state->v3 = v3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		state->v4 = v4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	if (p < b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		memcpy(state->mem32, p, (size_t)(b_end-p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		state->memsize = (uint32_t)(b_end-p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) EXPORT_SYMBOL(xxh32_update);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) uint32_t xxh32_digest(const struct xxh32_state *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	const uint8_t *p = (const uint8_t *)state->mem32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	const uint8_t *const b_end = (const uint8_t *)(state->mem32) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		state->memsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	uint32_t h32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	if (state->large_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		h32 = xxh_rotl32(state->v1, 1) + xxh_rotl32(state->v2, 7) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 			xxh_rotl32(state->v3, 12) + xxh_rotl32(state->v4, 18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		h32 = state->v3 /* == seed */ + PRIME32_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	h32 += state->total_len_32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	while (p + 4 <= b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		h32 += get_unaligned_le32(p) * PRIME32_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		h32 = xxh_rotl32(h32, 17) * PRIME32_4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	while (p < b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		h32 += (*p) * PRIME32_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		h32 = xxh_rotl32(h32, 11) * PRIME32_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		p++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	h32 ^= h32 >> 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	h32 *= PRIME32_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	h32 ^= h32 >> 13;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	h32 *= PRIME32_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	h32 ^= h32 >> 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	return h32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) EXPORT_SYMBOL(xxh32_digest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) int xxh64_update(struct xxh64_state *state, const void *input, const size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	const uint8_t *p = (const uint8_t *)input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	const uint8_t *const b_end = p + len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	if (input == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	state->total_len += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	if (state->memsize + len < 32) { /* fill in tmp buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		memcpy(((uint8_t *)state->mem64) + state->memsize, input, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		state->memsize += (uint32_t)len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	if (state->memsize) { /* tmp buffer is full */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		uint64_t *p64 = state->mem64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		memcpy(((uint8_t *)p64) + state->memsize, input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			32 - state->memsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		state->v1 = xxh64_round(state->v1, get_unaligned_le64(p64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		p64++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		state->v2 = xxh64_round(state->v2, get_unaligned_le64(p64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		p64++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		state->v3 = xxh64_round(state->v3, get_unaligned_le64(p64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		p64++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		state->v4 = xxh64_round(state->v4, get_unaligned_le64(p64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		p += 32 - state->memsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		state->memsize = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	if (p + 32 <= b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		const uint8_t *const limit = b_end - 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		uint64_t v1 = state->v1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		uint64_t v2 = state->v2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		uint64_t v3 = state->v3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		uint64_t v4 = state->v4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			v1 = xxh64_round(v1, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 			p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 			v2 = xxh64_round(v2, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 			v3 = xxh64_round(v3, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 			p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 			v4 = xxh64_round(v4, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 			p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		} while (p <= limit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		state->v1 = v1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 		state->v2 = v2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		state->v3 = v3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		state->v4 = v4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	if (p < b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		memcpy(state->mem64, p, (size_t)(b_end-p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		state->memsize = (uint32_t)(b_end - p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) EXPORT_SYMBOL(xxh64_update);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) uint64_t xxh64_digest(const struct xxh64_state *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	const uint8_t *p = (const uint8_t *)state->mem64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	const uint8_t *const b_end = (const uint8_t *)state->mem64 +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		state->memsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	uint64_t h64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	if (state->total_len >= 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		const uint64_t v1 = state->v1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		const uint64_t v2 = state->v2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		const uint64_t v3 = state->v3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 		const uint64_t v4 = state->v4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 		h64 = xxh_rotl64(v1, 1) + xxh_rotl64(v2, 7) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 			xxh_rotl64(v3, 12) + xxh_rotl64(v4, 18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		h64 = xxh64_merge_round(h64, v1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		h64 = xxh64_merge_round(h64, v2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		h64 = xxh64_merge_round(h64, v3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 		h64 = xxh64_merge_round(h64, v4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		h64  = state->v3 + PRIME64_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	h64 += (uint64_t)state->total_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	while (p + 8 <= b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 		const uint64_t k1 = xxh64_round(0, get_unaligned_le64(p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		h64 ^= k1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 		h64 = xxh_rotl64(h64, 27) * PRIME64_1 + PRIME64_4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		p += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	if (p + 4 <= b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 		h64 ^= (uint64_t)(get_unaligned_le32(p)) * PRIME64_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 		h64 = xxh_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		p += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	while (p < b_end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		h64 ^= (*p) * PRIME64_5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 		h64 = xxh_rotl64(h64, 11) * PRIME64_1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		p++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	h64 ^= h64 >> 33;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	h64 *= PRIME64_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	h64 ^= h64 >> 29;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	h64 *= PRIME64_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	h64 ^= h64 >> 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	return h64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) EXPORT_SYMBOL(xxh64_digest);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) MODULE_LICENSE("Dual BSD/GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) MODULE_DESCRIPTION("xxHash");