LAMMP 4.2.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
xxhash.c 文件参考
+ xxhash.c 的引用(Include)关系图:

浏览源代码.

宏定义

#define PRIME64_1   0x9E3779B185EBCA87ULL
 Copyright (C) 2026 HJimmyK(Jericho Knox)
 
#define PRIME64_2   0xC2B2AE3D27D4EB4FULL
 
#define PRIME64_3   0x165667B19E3779F9ULL
 
#define PRIME64_4   0x85EBCA77C2B2AE63ULL
 
#define PRIME64_5   0x27D4EB2F165667C5ULL
 

函数

uint64_t lmmp_xxhash_ (mp_srcptr in, mp_size_t inlen, srckey64_t key)
 xxhash 函数(非标准处理任意字节流的 xxhash)
 
static uint64_t rotl64 (uint64_t x, int b)
 

宏定义说明

◆ PRIME64_1

#define PRIME64_1   0x9E3779B185EBCA87ULL

Copyright (C) 2026 HJimmyK(Jericho Knox)

This file is part of LAMMP.

LAMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed WITHOUT ANY WARRANTY.

See https://www.gnu.org/licenses/.

在文件 xxhash.c18 行定义.

◆ PRIME64_2

#define PRIME64_2   0xC2B2AE3D27D4EB4FULL

在文件 xxhash.c19 行定义.

◆ PRIME64_3

#define PRIME64_3   0x165667B19E3779F9ULL

在文件 xxhash.c20 行定义.

◆ PRIME64_4

#define PRIME64_4   0x85EBCA77C2B2AE63ULL

在文件 xxhash.c21 行定义.

◆ PRIME64_5

#define PRIME64_5   0x27D4EB2F165667C5ULL

在文件 xxhash.c22 行定义.

函数说明

◆ lmmp_xxhash_()

uint64_t lmmp_xxhash_ ( mp_srcptr  in,
mp_size_t  inlen,
srckey64_t  key 
)

xxhash 函数(非标准处理任意字节流的 xxhash)

参数
in输入数据,可以为 NULL
inlen输入数据长度
key64-bit 秘钥,可以为 NULL
警告
若 key 为 NULL,则使用全零秘钥
返回
64-bit hash 值

在文件 xxhash.c29 行定义.

29 {
30 uint64_t seed = key == NULL ? 0 : key[0];
31 if (in == NULL || inlen == 0) {
32 seed += PRIME64_5;
33 seed += 0; // len = 0
34 seed ^= seed >> 33;
35 seed *= PRIME64_2;
36 seed ^= seed >> 29;
37 seed *= PRIME64_3;
38 seed ^= seed >> 32;
39 return seed;
40 }
41
42 const uint64_t* p = in;
43 const uint64_t* const end = in + inlen;
44 uint64_t h64;
45
46 if (inlen >= 4) {
47 const uint64_t* const limit = end - 4;
48 uint64_t v1 = seed + PRIME64_1 + PRIME64_2;
49 uint64_t v2 = seed + PRIME64_2;
50 uint64_t v3 = seed + 0;
51 uint64_t v4 = seed - PRIME64_1;
52
53 do {
54 v1 += *p * PRIME64_2;
55 v1 = rotl64(v1, 31);
56 v1 *= PRIME64_1;
57 p++;
58
59 v2 += *p * PRIME64_2;
60 v2 = rotl64(v2, 31);
61 v2 *= PRIME64_1;
62 p++;
63
64 v3 += *p * PRIME64_2;
65 v3 = rotl64(v3, 31);
66 v3 *= PRIME64_1;
67 p++;
68
69 v4 += *p * PRIME64_2;
70 v4 = rotl64(v4, 31);
71 v4 *= PRIME64_1;
72 p++;
73 } while (p <= limit);
74
75 h64 = rotl64(v1, 1) + rotl64(v2, 7) + rotl64(v3, 12) + rotl64(v4, 18);
76
77 v1 *= PRIME64_2;
78 v1 = rotl64(v1, 31);
79 v1 *= PRIME64_1;
80 h64 ^= v1;
82
83 v2 *= PRIME64_2;
84 v2 = rotl64(v2, 31);
85 v2 *= PRIME64_1;
86 h64 ^= v2;
88
89 v3 *= PRIME64_2;
90 v3 = rotl64(v3, 31);
91 v3 *= PRIME64_1;
92 h64 ^= v3;
94
95 v4 *= PRIME64_2;
96 v4 = rotl64(v4, 31);
97 v4 *= PRIME64_1;
98 h64 ^= v4;
100 } else {
101 h64 = seed + PRIME64_5;
102 }
103
104 h64 += (uint64_t)(inlen * sizeof(mp_limb_t));
105
106 while (p < end) {
107 uint64_t k1 = *p;
108 k1 *= PRIME64_2;
109 k1 = rotl64(k1, 31);
110 k1 *= PRIME64_1;
111 h64 ^= k1;
112 h64 = rotl64(h64, 27) * PRIME64_1 + PRIME64_4;
113 p++;
114 }
115
116 h64 ^= h64 >> 33;
117 h64 *= PRIME64_2;
118 h64 ^= h64 >> 29;
119 h64 *= PRIME64_3;
120 h64 ^= h64 >> 32;
121
122 return h64;
123}
uint64_t mp_limb_t
Definition lmmp.h:76
#define v1
#define v2
#define n
#define PRIME64_4
Definition xxhash.c:21
static uint64_t rotl64(uint64_t x, int b)
Definition xxhash.c:24
#define PRIME64_1
Copyright (C) 2026 HJimmyK(Jericho Knox)
Definition xxhash.c:18
#define PRIME64_5
Definition xxhash.c:22
#define PRIME64_3
Definition xxhash.c:20
#define PRIME64_2
Definition xxhash.c:19

引用了 n, PRIME64_1, PRIME64_2, PRIME64_3, PRIME64_4, PRIME64_5, rotl64(), v1 , 以及 v2.

+ 函数调用图:

◆ rotl64()

static uint64_t rotl64 ( uint64_t  x,
int  b 
)
inlinestatic

在文件 xxhash.c24 行定义.

24 {
25 b &= 63;
26 return (x << b) | (x >> (64 - b));
27}

引用了 n.

被这些函数引用 lmmp_xxhash_().

+ 这是这个函数的调用关系图: