"Fossies" - the Fresh Open Source Software Archive 
Member "qt-everywhere-src-6.3.1/qtwebengine/src/3rdparty/chromium/base/third_party/cityhash/patches/0000-build-bots-jumbo.patch" (8 Jun 2022, 7580 Bytes) of package /linux/misc/qt-everywhere-src-6.3.1.tar.xz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Diff source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 diff --git a/base/third_party/cityhash/city.cc b/base/third_party/cityhash/city.cc
2 index 41cd5ee16993..22e3b4981ff5 100644
3 --- a/base/third_party/cityhash/city.cc
4 +++ b/base/third_party/cityhash/city.cc
5 @@ -27,25 +27,13 @@
6 // possible hash functions, by using SIMD instructions, or by
7 // compromising on hash quality.
8
9 -#include "config.h"
10 -#include <city.h>
11 +#include "city.h"
12
13 #include <algorithm>
14 #include <string.h> // for memcpy and memset
15
16 -using namespace std;
17 -
18 -static uint64 UNALIGNED_LOAD64(const char *p) {
19 - uint64 result;
20 - memcpy(&result, p, sizeof(result));
21 - return result;
22 -}
23 -
24 -static uint32 UNALIGNED_LOAD32(const char *p) {
25 - uint32 result;
26 - memcpy(&result, p, sizeof(result));
27 - return result;
28 -}
29 +using std::make_pair;
30 +using std::pair;
31
32 #ifdef _MSC_VER
33
34 @@ -89,10 +77,19 @@ static uint32 UNALIGNED_LOAD32(const char *p) {
35
36 #else
37
38 -#include <byteswap.h>
39 +// XXX(cavalcanti): building 'native_client' fails with this header.
40 +//#include <byteswap.h>
41 +
42 +// Falling back to compiler builtins instead.
43 +#define bswap_32(x) __builtin_bswap32(x)
44 +#define bswap_64(x) __builtin_bswap64(x)
45
46 #endif
47
48 +namespace base {
49 +namespace internal {
50 +namespace cityhash_v111 {
51 +
52 #ifdef WORDS_BIGENDIAN
53 #define uint32_in_expected_order(x) (bswap_32(x))
54 #define uint64_in_expected_order(x) (bswap_64(x))
55 @@ -109,6 +106,18 @@ static uint32 UNALIGNED_LOAD32(const char *p) {
56 #endif
57 #endif
58
59 +static uint64 UNALIGNED_LOAD64(const char *p) {
60 + uint64 result;
61 + memcpy(&result, p, sizeof(result));
62 + return result;
63 +}
64 +
65 +static uint32 UNALIGNED_LOAD32(const char *p) {
66 + uint32 result;
67 + memcpy(&result, p, sizeof(result));
68 + return result;
69 +}
70 +
71 static uint64 Fetch64(const char *p) {
72 return uint64_in_expected_order(UNALIGNED_LOAD64(p));
73 }
74 @@ -217,11 +226,11 @@ uint32 CityHash32(const char *s, size_t len) {
75 f = f * 5 + 0xe6546b64;
76 size_t iters = (len - 1) / 20;
77 do {
78 - uint32 a0 = Rotate32(Fetch32(s) * c1, 17) * c2;
79 - uint32 a1 = Fetch32(s + 4);
80 - uint32 a2 = Rotate32(Fetch32(s + 8) * c1, 17) * c2;
81 - uint32 a3 = Rotate32(Fetch32(s + 12) * c1, 17) * c2;
82 - uint32 a4 = Fetch32(s + 16);
83 + a0 = Rotate32(Fetch32(s) * c1, 17) * c2;
84 + a1 = Fetch32(s + 4);
85 + a2 = Rotate32(Fetch32(s + 8) * c1, 17) * c2;
86 + a3 = Rotate32(Fetch32(s + 12) * c1, 17) * c2;
87 + a4 = Fetch32(s + 16);
88 h ^= a0;
89 h = Rotate32(h, 18);
90 h = h * 5 + 0xe6546b64;
91 @@ -512,135 +521,7 @@ uint128 CityHash128(const char *s, size_t len) {
92 CityHash128WithSeed(s, len, uint128(k0, k1));
93 }
94
95 -#ifdef __SSE4_2__
96 -#include <citycrc.h>
97 -#include <nmmintrin.h>
98 -
99 -// Requires len >= 240.
100 -static void CityHashCrc256Long(const char *s, size_t len,
101 - uint32 seed, uint64 *result) {
102 - uint64 a = Fetch64(s + 56) + k0;
103 - uint64 b = Fetch64(s + 96) + k0;
104 - uint64 c = result[0] = HashLen16(b, len);
105 - uint64 d = result[1] = Fetch64(s + 120) * k0 + len;
106 - uint64 e = Fetch64(s + 184) + seed;
107 - uint64 f = 0;
108 - uint64 g = 0;
109 - uint64 h = c + d;
110 - uint64 x = seed;
111 - uint64 y = 0;
112 - uint64 z = 0;
113 -
114 - // 240 bytes of input per iter.
115 - size_t iters = len / 240;
116 - len -= iters * 240;
117 - do {
118 -#undef CHUNK
119 -#define CHUNK(r) \
120 - PERMUTE3(x, z, y); \
121 - b += Fetch64(s); \
122 - c += Fetch64(s + 8); \
123 - d += Fetch64(s + 16); \
124 - e += Fetch64(s + 24); \
125 - f += Fetch64(s + 32); \
126 - a += b; \
127 - h += f; \
128 - b += c; \
129 - f += d; \
130 - g += e; \
131 - e += z; \
132 - g += x; \
133 - z = _mm_crc32_u64(z, b + g); \
134 - y = _mm_crc32_u64(y, e + h); \
135 - x = _mm_crc32_u64(x, f + a); \
136 - e = Rotate(e, r); \
137 - c += e; \
138 - s += 40
139 -
140 - CHUNK(0); PERMUTE3(a, h, c);
141 - CHUNK(33); PERMUTE3(a, h, f);
142 - CHUNK(0); PERMUTE3(b, h, f);
143 - CHUNK(42); PERMUTE3(b, h, d);
144 - CHUNK(0); PERMUTE3(b, h, e);
145 - CHUNK(33); PERMUTE3(a, h, e);
146 - } while (--iters > 0);
147 -
148 - while (len >= 40) {
149 - CHUNK(29);
150 - e ^= Rotate(a, 20);
151 - h += Rotate(b, 30);
152 - g ^= Rotate(c, 40);
153 - f += Rotate(d, 34);
154 - PERMUTE3(c, h, g);
155 - len -= 40;
156 - }
157 - if (len > 0) {
158 - s = s + len - 40;
159 - CHUNK(33);
160 - e ^= Rotate(a, 43);
161 - h += Rotate(b, 42);
162 - g ^= Rotate(c, 41);
163 - f += Rotate(d, 40);
164 - }
165 - result[0] ^= h;
166 - result[1] ^= g;
167 - g += h;
168 - a = HashLen16(a, g + z);
169 - x += y << 32;
170 - b += x;
171 - c = HashLen16(c, z) + h;
172 - d = HashLen16(d, e + result[0]);
173 - g += e;
174 - h += HashLen16(x, f);
175 - e = HashLen16(a, d) + g;
176 - z = HashLen16(b, c) + a;
177 - y = HashLen16(g, h) + c;
178 - result[0] = e + z + y + x;
179 - a = ShiftMix((a + y) * k0) * k0 + b;
180 - result[1] += a + result[0];
181 - a = ShiftMix(a * k0) * k0 + c;
182 - result[2] = a + result[1];
183 - a = ShiftMix((a + e) * k0) * k0;
184 - result[3] = a + result[2];
185 -}
186 -
187 -// Requires len < 240.
188 -static void CityHashCrc256Short(const char *s, size_t len, uint64 *result) {
189 - char buf[240];
190 - memcpy(buf, s, len);
191 - memset(buf + len, 0, 240 - len);
192 - CityHashCrc256Long(buf, 240, ~static_cast<uint32>(len), result);
193 -}
194 +} // namespace cityhash_v111
195 +} // namespace internal
196 +} // namespace base
197
198 -void CityHashCrc256(const char *s, size_t len, uint64 *result) {
199 - if (LIKELY(len >= 240)) {
200 - CityHashCrc256Long(s, len, 0, result);
201 - } else {
202 - CityHashCrc256Short(s, len, result);
203 - }
204 -}
205 -
206 -uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed) {
207 - if (len <= 900) {
208 - return CityHash128WithSeed(s, len, seed);
209 - } else {
210 - uint64 result[4];
211 - CityHashCrc256(s, len, result);
212 - uint64 u = Uint128High64(seed) + result[0];
213 - uint64 v = Uint128Low64(seed) + result[1];
214 - return uint128(HashLen16(u, v + result[2]),
215 - HashLen16(Rotate(v, 32), u * k0 + result[3]));
216 - }
217 -}
218 -
219 -uint128 CityHashCrc128(const char *s, size_t len) {
220 - if (len <= 900) {
221 - return CityHash128(s, len);
222 - } else {
223 - uint64 result[4];
224 - CityHashCrc256(s, len, result);
225 - return uint128(result[2], result[3]);
226 - }
227 -}
228 -
229 -#endif
230 diff --git a/base/third_party/cityhash/city.h b/base/third_party/cityhash/city.h
231 index 94499ce419c7..e4672f6d44da 100644
232 --- a/base/third_party/cityhash/city.h
233 +++ b/base/third_party/cityhash/city.h
234 @@ -59,13 +59,20 @@
235 // of a+b is easily derived from the hashes of a and b. This property
236 // doesn't hold for any hash functions in this file.
237
238 -#ifndef CITY_HASH_H_
239 -#define CITY_HASH_H_
240 +#ifndef BASE_THIRD_PARTY_CITYHASH_CITY_H_
241 +#define BASE_THIRD_PARTY_CITYHASH_CITY_H_
242
243 #include <stdlib.h> // for size_t.
244 #include <stdint.h>
245 #include <utility>
246
247 +// XXX(cavalcantii): Declaring it inside of the 'base' namespace allows to
248 +// handle linker symbol clash error with deprecated CityHash from
249 +// third_party/smhasher in a few unit tests.
250 +namespace base {
251 +namespace internal {
252 +namespace cityhash_v111 {
253 +
254 typedef uint8_t uint8;
255 typedef uint32_t uint32;
256 typedef uint64_t uint64;
257 @@ -109,4 +116,8 @@ inline uint64 Hash128to64(const uint128& x) {
258 return b;
259 }
260
261 +} // namespace cityhash_v111
262 +} // namespace internal
263 +} // namespace base
264 +
265 #endif // CITY_HASH_H_