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) /* SPDX-License-Identifier: LGPL-2.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Based on Paul Hsieh's (LGPG 2.1) hash function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * From: http://www.azillionmonkeys.com/qed/hash.html
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #define get16bits(d) (*((const __u16 *) (d)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) static __always_inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) __u32 SuperFastHash (const char *data, int len, __u32 initval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 	__u32 hash = initval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 	__u32 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 	int rem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	if (len <= 0 || data == NULL) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	rem = len & 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	len >>= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	/* Main loop */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #pragma clang loop unroll(full)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	for (;len > 0; len--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		hash  += get16bits (data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		tmp    = (get16bits (data+2) << 11) ^ hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		hash   = (hash << 16) ^ tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		data  += 2*sizeof (__u16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		hash  += hash >> 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	/* Handle end cases */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	switch (rem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)         case 3: hash += get16bits (data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)                 hash ^= hash << 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)                 hash ^= ((signed char)data[sizeof (__u16)]) << 18;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)                 hash += hash >> 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)                 break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)         case 2: hash += get16bits (data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)                 hash ^= hash << 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)                 hash += hash >> 17;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)                 break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)         case 1: hash += (signed char)*data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)                 hash ^= hash << 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)                 hash += hash >> 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	/* Force "avalanching" of final 127 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	hash ^= hash << 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	hash += hash >> 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	hash ^= hash << 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	hash += hash >> 17;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	hash ^= hash << 25;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	hash += hash >> 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	return hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }