| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
#if defined(__cplusplus) && !defined(XXH_NO_EXTERNC_GUARD) |
| 251 |
extern "C" { |
| 252 |
#endif |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
#ifdef XXH_DOXYGEN |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
# define XXH_STATIC_LINKING_ONLY |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
# define XXH_IMPLEMENTATION |
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
# define XXH_INLINE_ALL |
| 309 |
# undef XXH_INLINE_ALL |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
# define XXH_PRIVATE_API |
| 314 |
# undef XXH_PRIVATE_API |
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
# define XXH_NAMESPACE |
| 329 |
# undef XXH_NAMESPACE |
| 330 |
#endif |
| 331 |
|
| 332 |
#define XXH_CAT(A, B) A##B |
| 333 |
#define XXH_NAME2(A, B) XXH_CAT(A, B) |
| 334 |
#define XXH_IPREF(Id) XXH_NAME2(XXH_NAMESPACE, Id) |
| 335 |
|
| 336 |
#if (defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)) && !defined(XXH_INLINE_ALL_31684351384) |
| 337 |
|
| 338 |
# define XXH_INLINE_ALL_31684351384 |
| 339 |
|
| 340 |
# undef XXH_STATIC_LINKING_ONLY |
| 341 |
# define XXH_STATIC_LINKING_ONLY |
| 342 |
|
| 343 |
# undef XXH_PUBLIC_API |
| 344 |
# if defined(__GNUC__) |
| 345 |
# define XXH_PUBLIC_API static __inline __attribute__((__unused__)) |
| 346 |
# elif defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ) |
| 347 |
# define XXH_PUBLIC_API static inline |
| 348 |
# elif defined(_MSC_VER) |
| 349 |
# define XXH_PUBLIC_API static __inline |
| 350 |
# else |
| 351 |
|
| 352 |
# define XXH_PUBLIC_API static |
| 353 |
# endif |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
# undef XXH_versionNumber |
| 369 |
|
| 370 |
# undef XXH32 |
| 371 |
# undef XXH32_createState |
| 372 |
# undef XXH32_freeState |
| 373 |
# undef XXH32_reset |
| 374 |
# undef XXH32_update |
| 375 |
# undef XXH32_digest |
| 376 |
# undef XXH32_copyState |
| 377 |
# undef XXH32_canonicalFromHash |
| 378 |
# undef XXH32_hashFromCanonical |
| 379 |
|
| 380 |
# undef XXH64 |
| 381 |
# undef XXH64_createState |
| 382 |
# undef XXH64_freeState |
| 383 |
# undef XXH64_reset |
| 384 |
# undef XXH64_update |
| 385 |
# undef XXH64_digest |
| 386 |
# undef XXH64_copyState |
| 387 |
# undef XXH64_canonicalFromHash |
| 388 |
# undef XXH64_hashFromCanonical |
| 389 |
|
| 390 |
# undef XXH3_64bits |
| 391 |
# undef XXH3_64bits_withSecret |
| 392 |
# undef XXH3_64bits_withSeed |
| 393 |
# undef XXH3_64bits_withSecretandSeed |
| 394 |
# undef XXH3_createState |
| 395 |
# undef XXH3_freeState |
| 396 |
# undef XXH3_copyState |
| 397 |
# undef XXH3_64bits_reset |
| 398 |
# undef XXH3_64bits_reset_withSeed |
| 399 |
# undef XXH3_64bits_reset_withSecret |
| 400 |
# undef XXH3_64bits_update |
| 401 |
# undef XXH3_64bits_digest |
| 402 |
# undef XXH3_generateSecret |
| 403 |
|
| 404 |
# undef XXH128 |
| 405 |
# undef XXH3_128bits |
| 406 |
# undef XXH3_128bits_withSeed |
| 407 |
# undef XXH3_128bits_withSecret |
| 408 |
# undef XXH3_128bits_reset |
| 409 |
# undef XXH3_128bits_reset_withSeed |
| 410 |
# undef XXH3_128bits_reset_withSecret |
| 411 |
# undef XXH3_128bits_reset_withSecretandSeed |
| 412 |
# undef XXH3_128bits_update |
| 413 |
# undef XXH3_128bits_digest |
| 414 |
# undef XXH128_isEqual |
| 415 |
# undef XXH128_cmp |
| 416 |
# undef XXH128_canonicalFromHash |
| 417 |
# undef XXH128_hashFromCanonical |
| 418 |
|
| 419 |
# undef XXH_NAMESPACE |
| 420 |
|
| 421 |
|
| 422 |
# define XXH_NAMESPACE XXH_INLINE_ |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
# define XXH_OK XXH_IPREF(XXH_OK) |
| 431 |
# define XXH_ERROR XXH_IPREF(XXH_ERROR) |
| 432 |
# define XXH_errorcode XXH_IPREF(XXH_errorcode) |
| 433 |
# define XXH32_canonical_t XXH_IPREF(XXH32_canonical_t) |
| 434 |
# define XXH64_canonical_t XXH_IPREF(XXH64_canonical_t) |
| 435 |
# define XXH128_canonical_t XXH_IPREF(XXH128_canonical_t) |
| 436 |
# define XXH32_state_s XXH_IPREF(XXH32_state_s) |
| 437 |
# define XXH32_state_t XXH_IPREF(XXH32_state_t) |
| 438 |
# define XXH64_state_s XXH_IPREF(XXH64_state_s) |
| 439 |
# define XXH64_state_t XXH_IPREF(XXH64_state_t) |
| 440 |
# define XXH3_state_s XXH_IPREF(XXH3_state_s) |
| 441 |
# define XXH3_state_t XXH_IPREF(XXH3_state_t) |
| 442 |
# define XXH128_hash_t XXH_IPREF(XXH128_hash_t) |
| 443 |
|
| 444 |
# undef XXHASH_H_5627135585666179 |
| 445 |
# undef XXHASH_H_STATIC_13879238742 |
| 446 |
#endif |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
#ifndef XXHASH_H_5627135585666179 |
| 452 |
# define XXHASH_H_5627135585666179 1 |
| 453 |
|
| 454 |
|
| 455 |
# if !defined(XXH_INLINE_ALL) && !defined(XXH_PRIVATE_API) |
| 456 |
# if defined(_WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT)) |
| 457 |
# ifdef XXH_EXPORT |
| 458 |
# define XXH_PUBLIC_API __declspec(dllexport) |
| 459 |
# elif XXH_IMPORT |
| 460 |
# define XXH_PUBLIC_API __declspec(dllimport) |
| 461 |
# endif |
| 462 |
# else |
| 463 |
# define XXH_PUBLIC_API |
| 464 |
# endif |
| 465 |
# endif |
| 466 |
|
| 467 |
# ifdef XXH_NAMESPACE |
| 468 |
# define XXH_versionNumber XXH_IPREF(XXH_versionNumber) |
| 469 |
|
| 470 |
# define XXH32 XXH_IPREF(XXH32) |
| 471 |
# define XXH32_createState XXH_IPREF(XXH32_createState) |
| 472 |
# define XXH32_freeState XXH_IPREF(XXH32_freeState) |
| 473 |
# define XXH32_reset XXH_IPREF(XXH32_reset) |
| 474 |
# define XXH32_update XXH_IPREF(XXH32_update) |
| 475 |
# define XXH32_digest XXH_IPREF(XXH32_digest) |
| 476 |
# define XXH32_copyState XXH_IPREF(XXH32_copyState) |
| 477 |
# define XXH32_canonicalFromHash XXH_IPREF(XXH32_canonicalFromHash) |
| 478 |
# define XXH32_hashFromCanonical XXH_IPREF(XXH32_hashFromCanonical) |
| 479 |
|
| 480 |
# define XXH64 XXH_IPREF(XXH64) |
| 481 |
# define XXH64_createState XXH_IPREF(XXH64_createState) |
| 482 |
# define XXH64_freeState XXH_IPREF(XXH64_freeState) |
| 483 |
# define XXH64_reset XXH_IPREF(XXH64_reset) |
| 484 |
# define XXH64_update XXH_IPREF(XXH64_update) |
| 485 |
# define XXH64_digest XXH_IPREF(XXH64_digest) |
| 486 |
# define XXH64_copyState XXH_IPREF(XXH64_copyState) |
| 487 |
# define XXH64_canonicalFromHash XXH_IPREF(XXH64_canonicalFromHash) |
| 488 |
# define XXH64_hashFromCanonical XXH_IPREF(XXH64_hashFromCanonical) |
| 489 |
|
| 490 |
# define XXH3_64bits XXH_IPREF(XXH3_64bits) |
| 491 |
# define XXH3_64bits_withSecret XXH_IPREF(XXH3_64bits_withSecret) |
| 492 |
# define XXH3_64bits_withSeed XXH_IPREF(XXH3_64bits_withSeed) |
| 493 |
# define XXH3_64bits_withSecretandSeed XXH_IPREF(XXH3_64bits_withSecretandSeed) |
| 494 |
# define XXH3_createState XXH_IPREF(XXH3_createState) |
| 495 |
# define XXH3_freeState XXH_IPREF(XXH3_freeState) |
| 496 |
# define XXH3_copyState XXH_IPREF(XXH3_copyState) |
| 497 |
# define XXH3_64bits_reset XXH_IPREF(XXH3_64bits_reset) |
| 498 |
# define XXH3_64bits_reset_withSeed XXH_IPREF(XXH3_64bits_reset_withSeed) |
| 499 |
# define XXH3_64bits_reset_withSecret XXH_IPREF(XXH3_64bits_reset_withSecret) |
| 500 |
# define XXH3_64bits_reset_withSecretandSeed XXH_IPREF(XXH3_64bits_reset_withSecretandSeed) |
| 501 |
# define XXH3_64bits_update XXH_IPREF(XXH3_64bits_update) |
| 502 |
# define XXH3_64bits_digest XXH_IPREF(XXH3_64bits_digest) |
| 503 |
# define XXH3_generateSecret XXH_IPREF(XXH3_generateSecret) |
| 504 |
# define XXH3_generateSecret_fromSeed XXH_IPREF(XXH3_generateSecret_fromSeed) |
| 505 |
|
| 506 |
# define XXH128 XXH_IPREF(XXH128) |
| 507 |
# define XXH3_128bits XXH_IPREF(XXH3_128bits) |
| 508 |
# define XXH3_128bits_withSeed XXH_IPREF(XXH3_128bits_withSeed) |
| 509 |
# define XXH3_128bits_withSecret XXH_IPREF(XXH3_128bits_withSecret) |
| 510 |
# define XXH3_128bits_withSecretandSeed XXH_IPREF(XXH3_128bits_withSecretandSeed) |
| 511 |
# define XXH3_128bits_reset XXH_IPREF(XXH3_128bits_reset) |
| 512 |
# define XXH3_128bits_reset_withSeed XXH_IPREF(XXH3_128bits_reset_withSeed) |
| 513 |
# define XXH3_128bits_reset_withSecret XXH_IPREF(XXH3_128bits_reset_withSecret) |
| 514 |
# define XXH3_128bits_reset_withSecretandSeed XXH_IPREF(XXH3_128bits_reset_withSecretandSeed) |
| 515 |
# define XXH3_128bits_update XXH_IPREF(XXH3_128bits_update) |
| 516 |
# define XXH3_128bits_digest XXH_IPREF(XXH3_128bits_digest) |
| 517 |
# define XXH128_isEqual XXH_IPREF(XXH128_isEqual) |
| 518 |
# define XXH128_cmp XXH_IPREF(XXH128_cmp) |
| 519 |
# define XXH128_canonicalFromHash XXH_IPREF(XXH128_canonicalFromHash) |
| 520 |
# define XXH128_hashFromCanonical XXH_IPREF(XXH128_hashFromCanonical) |
| 521 |
# endif |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
# if !defined(XXH_INLINE_ALL) && !defined(XXH_PRIVATE_API) |
| 529 |
# if defined(_WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT)) |
| 530 |
# ifdef XXH_EXPORT |
| 531 |
# define XXH_PUBLIC_API __declspec(dllexport) |
| 532 |
# elif XXH_IMPORT |
| 533 |
# define XXH_PUBLIC_API __declspec(dllimport) |
| 534 |
# endif |
| 535 |
# else |
| 536 |
# define XXH_PUBLIC_API |
| 537 |
# endif |
| 538 |
# endif |
| 539 |
|
| 540 |
# if defined(__GNUC__) |
| 541 |
# define XXH_CONSTF __attribute__((__const__)) |
| 542 |
# define XXH_PUREF __attribute__((__pure__)) |
| 543 |
# define XXH_MALLOCF __attribute__((__malloc__)) |
| 544 |
# else |
| 545 |
# define XXH_CONSTF |
| 546 |
# define XXH_PUREF |
| 547 |
# define XXH_MALLOCF |
| 548 |
# endif |
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
# define XXH_VERSION_MAJOR 0 |
| 554 |
# define XXH_VERSION_MINOR 8 |
| 555 |
# define XXH_VERSION_RELEASE 3 |
| 556 |
|
| 557 |
# define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR * 100 * 100 + XXH_VERSION_MINOR * 100 + XXH_VERSION_RELEASE) |
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber(void); |
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
# include <stddef.h> |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
typedef enum { |
| 577 |
XXH_OK = 0, |
| 578 |
XXH_ERROR |
| 579 |
} XXH_errorcode; |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
# if defined(XXH_DOXYGEN) |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
typedef uint32_t XXH32_hash_t; |
| 591 |
|
| 592 |
# elif !defined(__VMS) && \ |
| 593 |
(defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) )) |
| 594 |
# ifdef _AIX |
| 595 |
# include <inttypes.h> |
| 596 |
# else |
| 597 |
# include <stdint.h> |
| 598 |
# endif |
| 599 |
typedef uint32_t XXH32_hash_t; |
| 600 |
|
| 601 |
# else |
| 602 |
# include <limits.h> |
| 603 |
# if UINT_MAX == 0xFFFFFFFFUL |
| 604 |
typedef unsigned int XXH32_hash_t; |
| 605 |
# elif ULONG_MAX == 0xFFFFFFFFUL |
| 606 |
typedef unsigned long XXH32_hash_t; |
| 607 |
# else |
| 608 |
# error "unsupported platform: need a 32-bit type" |
| 609 |
# endif |
| 610 |
# endif |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32(const void *input, size_t length, XXH32_hash_t seed); |
| 646 |
|
| 647 |
# ifndef XXH_NO_STREAM |
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
typedef struct XXH32_state_s XXH32_state_t; |
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
XXH_PUBLIC_API XXH_MALLOCF XXH32_state_t *XXH32_createState(void); |
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t *statePtr); |
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t *dst_state, const XXH32_state_t *src_state); |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t *statePtr, XXH32_hash_t seed); |
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t *statePtr, const void *input, size_t length); |
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_digest(const XXH32_state_t *statePtr); |
| 749 |
# endif |
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
typedef struct { |
| 757 |
unsigned char digest[4]; |
| 758 |
} XXH32_canonical_t; |
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t *dst, XXH32_hash_t hash); |
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t *src); |
| 786 |
|
| 787 |
|
| 788 |
# ifdef __has_attribute |
| 789 |
# define XXH_HAS_ATTRIBUTE(x) __has_attribute(x) |
| 790 |
# else |
| 791 |
# define XXH_HAS_ATTRIBUTE(x) 0 |
| 792 |
# endif |
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) && defined(__has_c_attribute) |
| 798 |
# define XXH_HAS_C_ATTRIBUTE(x) __has_c_attribute(x) |
| 799 |
# else |
| 800 |
# define XXH_HAS_C_ATTRIBUTE(x) 0 |
| 801 |
# endif |
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
# if defined(__cplusplus) && defined(__has_cpp_attribute) |
| 806 |
# define XXH_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) |
| 807 |
# else |
| 808 |
# define XXH_HAS_CPP_ATTRIBUTE(x) 0 |
| 809 |
# endif |
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
# if XXH_HAS_C_ATTRIBUTE(fallthrough) || XXH_HAS_CPP_ATTRIBUTE(fallthrough) |
| 820 |
# define XXH_FALLTHROUGH [[fallthrough]] |
| 821 |
# elif XXH_HAS_ATTRIBUTE(__fallthrough__) |
| 822 |
# define XXH_FALLTHROUGH __attribute__((__fallthrough__)) |
| 823 |
# else |
| 824 |
# define XXH_FALLTHROUGH |
| 825 |
# endif |
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
# if XXH_HAS_ATTRIBUTE(noescape) |
| 835 |
# define XXH_NOESCAPE __attribute__((__noescape__)) |
| 836 |
# else |
| 837 |
# define XXH_NOESCAPE |
| 838 |
# endif |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
# ifndef XXH_NO_LONG_LONG |
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
# if defined(XXH_DOXYGEN) |
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
typedef uint64_t XXH64_hash_t; |
| 858 |
# elif !defined(__VMS) && \ |
| 859 |
(defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) )) |
| 860 |
# ifdef _AIX |
| 861 |
# include <inttypes.h> |
| 862 |
# else |
| 863 |
# include <stdint.h> |
| 864 |
# endif |
| 865 |
typedef uint64_t XXH64_hash_t; |
| 866 |
# else |
| 867 |
# include <limits.h> |
| 868 |
# if defined(__LP64__) && ULONG_MAX == 0xFFFFFFFFFFFFFFFFULL |
| 869 |
|
| 870 |
typedef unsigned long XXH64_hash_t; |
| 871 |
# else |
| 872 |
|
| 873 |
typedef unsigned long long XXH64_hash_t; |
| 874 |
# endif |
| 875 |
# endif |
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH64(XXH_NOESCAPE const void *input, size_t length, XXH64_hash_t seed); |
| 908 |
|
| 909 |
|
| 910 |
# ifndef XXH_NO_STREAM |
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
typedef struct XXH64_state_s XXH64_state_t; |
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
XXH_PUBLIC_API XXH_MALLOCF XXH64_state_t *XXH64_createState(void); |
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t *statePtr); |
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
XXH_PUBLIC_API void XXH64_copyState(XXH_NOESCAPE XXH64_state_t *dst_state, const XXH64_state_t *src_state); |
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH_NOESCAPE XXH64_state_t *statePtr, XXH64_hash_t seed); |
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
XXH_PUBLIC_API XXH_errorcode |
| 994 |
XXH64_update(XXH_NOESCAPE XXH64_state_t *statePtr, XXH_NOESCAPE const void *input, size_t length); |
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH64_digest(XXH_NOESCAPE const XXH64_state_t *statePtr); |
| 1013 |
# endif |
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
typedef struct { |
| 1020 |
unsigned char digest[sizeof(XXH64_hash_t)]; |
| 1021 |
} XXH64_canonical_t; |
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH_NOESCAPE XXH64_canonical_t *dst, XXH64_hash_t hash); |
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_canonical_t *src); |
| 1049 |
|
| 1050 |
# ifndef XXH_NO_XXH3 |
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
# define XXH_SCALAR 0 |
| 1114 |
# define XXH_SSE2 1 |
| 1115 |
# define XXH_AVX2 2 |
| 1116 |
# define XXH_AVX512 3 |
| 1117 |
# define XXH_NEON 4 |
| 1118 |
# define XXH_VSX 5 |
| 1119 |
# define XXH_SVE 6 |
| 1120 |
# define XXH_LSX 7 |
| 1121 |
# define XXH_LASX 8 |
| 1122 |
# define XXH_RVV 9 |
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits(XXH_NOESCAPE const void *input, size_t length); |
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
XXH_PUBLIC_API XXH_PUREF XXH64_hash_t |
| 1177 |
XXH3_64bits_withSeed(XXH_NOESCAPE const void *input, size_t length, XXH64_hash_t seed); |
| 1178 |
|
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
# define XXH3_SECRET_SIZE_MIN 136 |
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
|
| 1220 |
XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits_withSecret( |
| 1221 |
XXH_NOESCAPE const void *data, |
| 1222 |
size_t len, |
| 1223 |
XXH_NOESCAPE const void *secret, |
| 1224 |
size_t secretSize); |
| 1225 |
|
| 1226 |
|
| 1227 |
# ifndef XXH_NO_STREAM |
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
typedef struct XXH3_state_s XXH3_state_t; |
| 1242 |
XXH_PUBLIC_API XXH_MALLOCF XXH3_state_t *XXH3_createState(void); |
| 1243 |
XXH_PUBLIC_API XXH_errorcode XXH3_freeState(XXH3_state_t *statePtr); |
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
XXH_PUBLIC_API void XXH3_copyState(XXH_NOESCAPE XXH3_state_t *dst_state, XXH_NOESCAPE const XXH3_state_t *src_state); |
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset(XXH_NOESCAPE XXH3_state_t *statePtr); |
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
|
| 1295 |
|
| 1296 |
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t *statePtr, XXH64_hash_t seed); |
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret( |
| 1323 |
XXH_NOESCAPE XXH3_state_t *statePtr, |
| 1324 |
XXH_NOESCAPE const void *secret, |
| 1325 |
size_t secretSize); |
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
XXH_PUBLIC_API XXH_errorcode |
| 1349 |
XXH3_64bits_update(XXH_NOESCAPE XXH3_state_t *statePtr, XXH_NOESCAPE const void *input, size_t length); |
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits_digest(XXH_NOESCAPE const XXH3_state_t *statePtr); |
| 1368 |
# endif |
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
typedef struct { |
| 1384 |
XXH64_hash_t low64; |
| 1385 |
XXH64_hash_t high64; |
| 1386 |
} XXH128_hash_t; |
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits(XXH_NOESCAPE const void *data, size_t len); |
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
XXH_PUBLIC_API XXH_PUREF XXH128_hash_t |
| 1427 |
XXH3_128bits_withSeed(XXH_NOESCAPE const void *data, size_t len, XXH64_hash_t seed); |
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_withSecret( |
| 1456 |
XXH_NOESCAPE const void *data, |
| 1457 |
size_t len, |
| 1458 |
XXH_NOESCAPE const void *secret, |
| 1459 |
size_t secretSize); |
| 1460 |
|
| 1461 |
|
| 1462 |
# ifndef XXH_NO_STREAM |
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset(XXH_NOESCAPE XXH3_state_t *statePtr); |
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t *statePtr, XXH64_hash_t seed); |
| 1515 |
|
| 1516 |
|
| 1517 |
|
| 1518 |
|
| 1519 |
|
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecret( |
| 1538 |
XXH_NOESCAPE XXH3_state_t *statePtr, |
| 1539 |
XXH_NOESCAPE const void *secret, |
| 1540 |
size_t secretSize); |
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
XXH_PUBLIC_API XXH_errorcode |
| 1564 |
XXH3_128bits_update(XXH_NOESCAPE XXH3_state_t *statePtr, XXH_NOESCAPE const void *input, size_t length); |
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_digest(XXH_NOESCAPE const XXH3_state_t *statePtr); |
| 1582 |
# endif |
| 1583 |
|
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
XXH_PUBLIC_API XXH_PUREF int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2); |
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
|
| 1608 |
|
| 1609 |
|
| 1610 |
|
| 1611 |
XXH_PUBLIC_API XXH_PUREF int XXH128_cmp(XXH_NOESCAPE const void *h128_1, XXH_NOESCAPE const void *h128_2); |
| 1612 |
|
| 1613 |
|
| 1614 |
typedef struct { |
| 1615 |
unsigned char digest[sizeof(XXH128_hash_t)]; |
| 1616 |
} XXH128_canonical_t; |
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
XXH_PUBLIC_API void XXH128_canonicalFromHash(XXH_NOESCAPE XXH128_canonical_t *dst, XXH128_hash_t hash); |
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128_hashFromCanonical(XXH_NOESCAPE const XXH128_canonical_t *src); |
| 1642 |
|
| 1643 |
# endif |
| 1644 |
# endif |
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
#endif |
| 1650 |
|
| 1651 |
#if defined(XXH_STATIC_LINKING_ONLY) && !defined(XXHASH_H_STATIC_13879238742) |
| 1652 |
# define XXHASH_H_STATIC_13879238742 |
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
struct XXH32_state_s { |
| 1680 |
XXH32_hash_t total_len_32; |
| 1681 |
XXH32_hash_t large_len; |
| 1682 |
XXH32_hash_t acc[4]; |
| 1683 |
unsigned char buffer[16]; |
| 1684 |
XXH32_hash_t bufferedSize; |
| 1685 |
XXH32_hash_t reserved; |
| 1686 |
}; |
| 1687 |
|
| 1688 |
# ifndef XXH_NO_LONG_LONG |
| 1689 |
|
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
struct XXH64_state_s { |
| 1703 |
XXH64_hash_t total_len; |
| 1704 |
XXH64_hash_t acc[4]; |
| 1705 |
unsigned char buffer[32]; |
| 1706 |
XXH32_hash_t bufferedSize; |
| 1707 |
XXH32_hash_t reserved32; |
| 1708 |
XXH64_hash_t reserved64; |
| 1709 |
}; |
| 1710 |
|
| 1711 |
# ifndef XXH_NO_XXH3 |
| 1712 |
|
| 1713 |
# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) |
| 1714 |
# define XXH_ALIGN(n) _Alignas(n) |
| 1715 |
# elif defined(__cplusplus) && (__cplusplus >= 201103L) |
| 1716 |
|
| 1717 |
# define XXH_ALIGN(n) alignas(n) |
| 1718 |
# elif defined(__GNUC__) |
| 1719 |
# define XXH_ALIGN(n) __attribute__((aligned(n))) |
| 1720 |
# elif defined(_MSC_VER) |
| 1721 |
# define XXH_ALIGN(n) __declspec(align(n)) |
| 1722 |
# else |
| 1723 |
# define XXH_ALIGN(n) |
| 1724 |
# endif |
| 1725 |
|
| 1726 |
|
| 1727 |
# if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) \ |
| 1728 |
&& !(defined(__cplusplus) && (__cplusplus >= 201103L)) \ |
| 1729 |
&& defined(__GNUC__) |
| 1730 |
# define XXH_ALIGN_MEMBER(align, type) type XXH_ALIGN(align) |
| 1731 |
# else |
| 1732 |
# define XXH_ALIGN_MEMBER(align, type) XXH_ALIGN(align) type |
| 1733 |
# endif |
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
# define XXH3_INTERNALBUFFER_SIZE 256 |
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
|
| 1749 |
|
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
|
| 1754 |
# define XXH3_SECRET_DEFAULT_SIZE 192 |
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
struct XXH3_state_s { |
| 1779 |
XXH_ALIGN_MEMBER(64, XXH64_hash_t acc[8]); |
| 1780 |
|
| 1781 |
XXH_ALIGN_MEMBER(64, unsigned char customSecret[XXH3_SECRET_DEFAULT_SIZE]); |
| 1782 |
|
| 1783 |
XXH_ALIGN_MEMBER(64, unsigned char buffer[XXH3_INTERNALBUFFER_SIZE]); |
| 1784 |
|
| 1785 |
XXH32_hash_t bufferedSize; |
| 1786 |
|
| 1787 |
XXH32_hash_t useSeed; |
| 1788 |
|
| 1789 |
size_t nbStripesSoFar; |
| 1790 |
|
| 1791 |
XXH64_hash_t totalLen; |
| 1792 |
|
| 1793 |
size_t nbStripesPerBlock; |
| 1794 |
|
| 1795 |
size_t secretLimit; |
| 1796 |
|
| 1797 |
XXH64_hash_t seed; |
| 1798 |
|
| 1799 |
XXH64_hash_t reserved64; |
| 1800 |
|
| 1801 |
const unsigned char *extSecret; |
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
}; |
| 1806 |
|
| 1807 |
# undef XXH_ALIGN_MEMBER |
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
| 1819 |
|
| 1820 |
# define XXH3_INITSTATE(XXH3_state_ptr) \ |
| 1821 |
do { \ |
| 1822 |
XXH3_state_t *tmp_xxh3_state_ptr = (XXH3_state_ptr); \ |
| 1823 |
tmp_xxh3_state_ptr->seed = 0; \ |
| 1824 |
tmp_xxh3_state_ptr->extSecret = NULL; \ |
| 1825 |
} while (0) |
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
|
| 1841 |
|
| 1842 |
|
| 1843 |
XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128(XXH_NOESCAPE const void *data, size_t len, XXH64_hash_t seed); |
| 1844 |
|
| 1845 |
|
| 1846 |
|
| 1847 |
|
| 1848 |
|
| 1849 |
|
| 1850 |
|
| 1851 |
|
| 1852 |
|
| 1853 |
|
| 1854 |
|
| 1855 |
|
| 1856 |
|
| 1857 |
|
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
|
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
|
| 1878 |
|
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
|
| 1883 |
|
| 1884 |
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
|
| 1889 |
|
| 1890 |
|
| 1891 |
|
| 1892 |
|
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
|
| 1898 |
|
| 1899 |
|
| 1900 |
|
| 1901 |
|
| 1902 |
|
| 1903 |
|
| 1904 |
|
| 1905 |
|
| 1906 |
XXH_PUBLIC_API XXH_errorcode XXH3_generateSecret( |
| 1907 |
XXH_NOESCAPE void *secretBuffer, |
| 1908 |
size_t secretSize, |
| 1909 |
XXH_NOESCAPE const void *customSeed, |
| 1910 |
size_t customSeedSize); |
| 1911 |
|
| 1912 |
|
| 1913 |
|
| 1914 |
|
| 1915 |
|
| 1916 |
|
| 1917 |
|
| 1918 |
|
| 1919 |
|
| 1920 |
|
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
|
| 1944 |
|
| 1945 |
|
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
|
| 1950 |
XXH_PUBLIC_API void XXH3_generateSecret_fromSeed(XXH_NOESCAPE void *secretBuffer, XXH64_hash_t seed); |
| 1951 |
|
| 1952 |
|
| 1953 |
|
| 1954 |
|
| 1955 |
# define XXH3_MIDSIZE_MAX 240 |
| 1956 |
|
| 1957 |
|
| 1958 |
|
| 1959 |
|
| 1960 |
|
| 1961 |
|
| 1962 |
|
| 1963 |
|
| 1964 |
|
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
|
| 1979 |
|
| 1980 |
|
| 1981 |
|
| 1982 |
|
| 1983 |
|
| 1984 |
|
| 1985 |
|
| 1986 |
|
| 1987 |
|
| 1988 |
|
| 1989 |
|
| 1990 |
|
| 1991 |
XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits_withSecretandSeed( |
| 1992 |
XXH_NOESCAPE const void *data, |
| 1993 |
size_t len, |
| 1994 |
XXH_NOESCAPE const void *secret, |
| 1995 |
size_t secretSize, |
| 1996 |
XXH64_hash_t seed); |
| 1997 |
|
| 1998 |
|
| 1999 |
|
| 2000 |
|
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
|
| 2006 |
|
| 2007 |
|
| 2008 |
|
| 2009 |
|
| 2010 |
|
| 2011 |
|
| 2012 |
XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_withSecretandSeed( |
| 2013 |
XXH_NOESCAPE const void *input, |
| 2014 |
size_t length, |
| 2015 |
XXH_NOESCAPE const void *secret, |
| 2016 |
size_t secretSize, |
| 2017 |
XXH64_hash_t seed64); |
| 2018 |
|
| 2019 |
# ifndef XXH_NO_STREAM |
| 2020 |
|
| 2021 |
|
| 2022 |
|
| 2023 |
|
| 2024 |
|
| 2025 |
|
| 2026 |
|
| 2027 |
|
| 2028 |
|
| 2029 |
|
| 2030 |
|
| 2031 |
|
| 2032 |
|
| 2033 |
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecretandSeed( |
| 2034 |
XXH_NOESCAPE XXH3_state_t *statePtr, |
| 2035 |
XXH_NOESCAPE const void *secret, |
| 2036 |
size_t secretSize, |
| 2037 |
XXH64_hash_t seed64); |
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
|
| 2042 |
|
| 2043 |
|
| 2044 |
|
| 2045 |
|
| 2046 |
|
| 2047 |
|
| 2048 |
|
| 2049 |
|
| 2050 |
|
| 2051 |
|
| 2052 |
|
| 2053 |
|
| 2054 |
|
| 2055 |
|
| 2056 |
|
| 2057 |
|
| 2058 |
|
| 2059 |
|
| 2060 |
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecretandSeed( |
| 2061 |
XXH_NOESCAPE XXH3_state_t *statePtr, |
| 2062 |
XXH_NOESCAPE const void *secret, |
| 2063 |
size_t secretSize, |
| 2064 |
XXH64_hash_t seed64); |
| 2065 |
|
| 2066 |
# endif |
| 2067 |
|
| 2068 |
# endif |
| 2069 |
# endif |
| 2070 |
# if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) |
| 2071 |
# define XXH_IMPLEMENTATION |
| 2072 |
# endif |
| 2073 |
|
| 2074 |
#endif |
| 2075 |
|
| 2076 |
|
| 2077 |
|
| 2078 |
|
| 2079 |
|
| 2080 |
|
| 2081 |
|
| 2082 |
|
| 2083 |
|
| 2084 |
|
| 2085 |
|
| 2086 |
|
| 2087 |
|
| 2088 |
|
| 2089 |
|
| 2090 |
|
| 2091 |
|
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
|
| 2097 |
|
| 2098 |
|
| 2099 |
|
| 2100 |
|
| 2101 |
|
| 2102 |
#if (defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) || defined(XXH_IMPLEMENTATION)) && \ |
| 2103 |
!defined(XXH_IMPLEM_13a8737387) |
| 2104 |
# define XXH_IMPLEM_13a8737387 |
| 2105 |
|
| 2106 |
|
| 2107 |
|
| 2108 |
|
| 2109 |
|
| 2110 |
|
| 2111 |
|
| 2112 |
|
| 2113 |
|
| 2114 |
|
| 2115 |
|
| 2116 |
# ifdef XXH_DOXYGEN |
| 2117 |
|
| 2118 |
|
| 2119 |
|
| 2120 |
|
| 2121 |
|
| 2122 |
# define XXH_NO_LONG_LONG |
| 2123 |
# undef XXH_NO_LONG_LONG |
| 2124 |
|
| 2125 |
|
| 2126 |
|
| 2127 |
|
| 2128 |
|
| 2129 |
|
| 2130 |
|
| 2131 |
|
| 2132 |
|
| 2133 |
|
| 2134 |
|
| 2135 |
|
| 2136 |
|
| 2137 |
|
| 2138 |
|
| 2139 |
|
| 2140 |
|
| 2141 |
|
| 2142 |
|
| 2143 |
|
| 2144 |
|
| 2145 |
|
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
|
| 2150 |
|
| 2151 |
|
| 2152 |
|
| 2153 |
|
| 2154 |
|
| 2155 |
|
| 2156 |
|
| 2157 |
|
| 2158 |
|
| 2159 |
|
| 2160 |
|
| 2161 |
|
| 2162 |
|
| 2163 |
|
| 2164 |
|
| 2165 |
|
| 2166 |
|
| 2167 |
|
| 2168 |
|
| 2169 |
|
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
# define XXH_FORCE_MEMORY_ACCESS 0 |
| 2175 |
|
| 2176 |
|
| 2177 |
|
| 2178 |
|
| 2179 |
|
| 2180 |
|
| 2181 |
|
| 2182 |
|
| 2183 |
|
| 2184 |
|
| 2185 |
|
| 2186 |
|
| 2187 |
|
| 2188 |
|
| 2189 |
|
| 2190 |
|
| 2191 |
|
| 2192 |
|
| 2193 |
|
| 2194 |
|
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
|
| 2199 |
|
| 2200 |
|
| 2201 |
|
| 2202 |
# define XXH_SIZE_OPT 0 |
| 2203 |
|
| 2204 |
|
| 2205 |
|
| 2206 |
|
| 2207 |
|
| 2208 |
|
| 2209 |
|
| 2210 |
|
| 2211 |
|
| 2212 |
|
| 2213 |
|
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
|
| 2218 |
|
| 2219 |
|
| 2220 |
|
| 2221 |
|
| 2222 |
|
| 2223 |
|
| 2224 |
|
| 2225 |
|
| 2226 |
|
| 2227 |
|
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
|
| 2232 |
# define XXH_FORCE_ALIGN_CHECK 0 |
| 2233 |
|
| 2234 |
|
| 2235 |
|
| 2236 |
|
| 2237 |
|
| 2238 |
|
| 2239 |
|
| 2240 |
|
| 2241 |
|
| 2242 |
|
| 2243 |
|
| 2244 |
|
| 2245 |
|
| 2246 |
|
| 2247 |
|
| 2248 |
|
| 2249 |
|
| 2250 |
|
| 2251 |
|
| 2252 |
|
| 2253 |
|
| 2254 |
# define XXH_NO_INLINE_HINTS 0 |
| 2255 |
|
| 2256 |
|
| 2257 |
|
| 2258 |
|
| 2259 |
|
| 2260 |
|
| 2261 |
|
| 2262 |
|
| 2263 |
|
| 2264 |
|
| 2265 |
|
| 2266 |
|
| 2267 |
|
| 2268 |
|
| 2269 |
|
| 2270 |
|
| 2271 |
# define XXH3_INLINE_SECRET 0 |
| 2272 |
|
| 2273 |
|
| 2274 |
|
| 2275 |
|
| 2276 |
|
| 2277 |
|
| 2278 |
|
| 2279 |
|
| 2280 |
|
| 2281 |
|
| 2282 |
|
| 2283 |
# define XXH32_ENDJMP 0 |
| 2284 |
|
| 2285 |
|
| 2286 |
|
| 2287 |
|
| 2288 |
|
| 2289 |
|
| 2290 |
|
| 2291 |
|
| 2292 |
# define XXH_OLD_NAMES |
| 2293 |
# undef XXH_OLD_NAMES |
| 2294 |
|
| 2295 |
|
| 2296 |
|
| 2297 |
|
| 2298 |
|
| 2299 |
|
| 2300 |
|
| 2301 |
|
| 2302 |
|
| 2303 |
# define XXH_NO_STREAM |
| 2304 |
# undef XXH_NO_STREAM |
| 2305 |
# endif |
| 2306 |
|
| 2307 |
|
| 2308 |
|
| 2309 |
|
| 2310 |
# ifndef XXH_FORCE_MEMORY_ACCESS |
| 2311 |
|
| 2312 |
|
| 2313 |
|
| 2314 |
# if defined(__GNUC__) && !(defined(__ARM_ARCH) && __ARM_ARCH < 7 && defined(__ARM_FEATURE_UNALIGNED)) |
| 2315 |
# define XXH_FORCE_MEMORY_ACCESS 1 |
| 2316 |
# endif |
| 2317 |
# endif |
| 2318 |
|
| 2319 |
# ifndef XXH_SIZE_OPT |
| 2320 |
|
| 2321 |
# if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE_SIZE__) |
| 2322 |
# define XXH_SIZE_OPT 1 |
| 2323 |
# else |
| 2324 |
# define XXH_SIZE_OPT 0 |
| 2325 |
# endif |
| 2326 |
# endif |
| 2327 |
|
| 2328 |
# ifndef XXH_FORCE_ALIGN_CHECK |
| 2329 |
|
| 2330 |
# if XXH_SIZE_OPT >= 1 || defined(__i386) || defined(__x86_64__) || defined(__aarch64__) || \ |
| 2331 |
defined(__ARM_FEATURE_UNALIGNED) || defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64) || \ |
| 2332 |
defined(_M_ARM) |
| 2333 |
# define XXH_FORCE_ALIGN_CHECK 0 |
| 2334 |
# else |
| 2335 |
# define XXH_FORCE_ALIGN_CHECK 1 |
| 2336 |
# endif |
| 2337 |
# endif |
| 2338 |
|
| 2339 |
# ifndef XXH_NO_INLINE_HINTS |
| 2340 |
# if XXH_SIZE_OPT >= 1 || defined(__NO_INLINE__) |
| 2341 |
# define XXH_NO_INLINE_HINTS 1 |
| 2342 |
# else |
| 2343 |
# define XXH_NO_INLINE_HINTS 0 |
| 2344 |
# endif |
| 2345 |
# endif |
| 2346 |
|
| 2347 |
# ifndef XXH3_INLINE_SECRET |
| 2348 |
# if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12) || !defined(XXH_INLINE_ALL) |
| 2349 |
# define XXH3_INLINE_SECRET 0 |
| 2350 |
# else |
| 2351 |
# define XXH3_INLINE_SECRET 1 |
| 2352 |
# endif |
| 2353 |
# endif |
| 2354 |
|
| 2355 |
# ifndef XXH32_ENDJMP |
| 2356 |
|
| 2357 |
# define XXH32_ENDJMP 0 |
| 2358 |
# endif |
| 2359 |
|
| 2360 |
|
| 2361 |
|
| 2362 |
|
| 2363 |
|
| 2364 |
|
| 2365 |
|
| 2366 |
|
| 2367 |
|
| 2368 |
# if defined(XXH_NO_STREAM) |
| 2369 |
|
| 2370 |
# elif defined(XXH_NO_STDLIB) |
| 2371 |
|
| 2372 |
|
| 2373 |
|
| 2374 |
|
| 2375 |
|
| 2376 |
|
| 2377 |
|
| 2378 |
|
| 2379 |
|
| 2380 |
|
| 2381 |
static XXH_CONSTF void *XXH_malloc(size_t s) { |
| 2382 |
(void)s; |
| 2383 |
return NULL; |
| 2384 |
} |
| 2385 |
static void XXH_free(void *p) { |
| 2386 |
(void)p; |
| 2387 |
} |
| 2388 |
|
| 2389 |
# else |
| 2390 |
|
| 2391 |
|
| 2392 |
|
| 2393 |
|
| 2394 |
|
| 2395 |
# include <stdlib.h> |
| 2396 |
|
| 2397 |
|
| 2398 |
|
| 2399 |
|
| 2400 |
|
| 2401 |
|
| 2402 |
|
| 2403 |
|
| 2404 |
|
| 2405 |
|
| 2406 |
#include <aws/common/allocator.h> |
| 2407 |
|
| 2408 |
static struct aws_allocator *s_xxh_allocator = NULL; |
| 2409 |
|
| 2410 |
XXH_PUBLIC_API void XXH_set_allocator(struct aws_allocator *allocator) { |
| 2411 |
s_xxh_allocator = allocator; |
| 2412 |
} |
| 2413 |
|
| 2414 |
|
| 2415 |
|
| 2416 |
|
| 2417 |
|
| 2418 |
static XXH_MALLOCF void *XXH_malloc(size_t s) { |
| 2419 |
if (AWS_UNLIKELY(s_xxh_allocator)) { |
| 2420 |
return malloc(s); |
| 2421 |
} else { |
| 2422 |
return aws_mem_calloc(s_xxh_allocator, 1, s); |
| 2423 |
} |
| 2424 |
} |
| 2425 |
|
| 2426 |
|
| 2427 |
|
| 2428 |
|
| 2429 |
|
| 2430 |
static void XXH_free(void *p) { |
| 2431 |
if (AWS_UNLIKELY(s_xxh_allocator)) { |
| 2432 |
free(p); |
| 2433 |
} else { |
| 2434 |
aws_mem_release(s_xxh_allocator, p); |
| 2435 |
} |
| 2436 |
} |
| 2437 |
|
| 2438 |
|
| 2439 |
|
| 2440 |
# endif |
| 2441 |
|
| 2442 |
# ifndef XXH_memcpy |
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
|
| 2447 |
# include <string.h> |
| 2448 |
# define XXH_memcpy memcpy |
| 2449 |
# endif |
| 2450 |
|
| 2451 |
# ifndef XXH_memset |
| 2452 |
|
| 2453 |
|
| 2454 |
|
| 2455 |
|
| 2456 |
# include <string.h> |
| 2457 |
# define XXH_memset memset |
| 2458 |
# endif |
| 2459 |
|
| 2460 |
# ifndef XXH_memcmp |
| 2461 |
|
| 2462 |
|
| 2463 |
|
| 2464 |
|
| 2465 |
|
| 2466 |
# include <string.h> |
| 2467 |
# define XXH_memcmp memcmp |
| 2468 |
# endif |
| 2469 |
|
| 2470 |
# include <limits.h> |
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 2474 |
|
| 2475 |
# ifdef _MSC_VER |
| 2476 |
# pragma warning(disable : 4127) |
| 2477 |
# endif |
| 2478 |
|
| 2479 |
# if XXH_NO_INLINE_HINTS |
| 2480 |
# if defined(__GNUC__) || defined(__clang__) |
| 2481 |
# define XXH_FORCE_INLINE static __attribute__((__unused__)) |
| 2482 |
# else |
| 2483 |
# define XXH_FORCE_INLINE static |
| 2484 |
# endif |
| 2485 |
# define XXH_NO_INLINE static |
| 2486 |
|
| 2487 |
# elif defined(__GNUC__) || defined(__clang__) |
| 2488 |
# define XXH_FORCE_INLINE static __inline__ __attribute__((__always_inline__, __unused__)) |
| 2489 |
# define XXH_NO_INLINE static __attribute__((__noinline__)) |
| 2490 |
# elif defined(_MSC_VER) |
| 2491 |
# define XXH_FORCE_INLINE static __forceinline |
| 2492 |
# define XXH_NO_INLINE static __declspec(noinline) |
| 2493 |
# elif defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) |
| 2494 |
# define XXH_FORCE_INLINE static inline |
| 2495 |
# define XXH_NO_INLINE static |
| 2496 |
# else |
| 2497 |
# define XXH_FORCE_INLINE static |
| 2498 |
# define XXH_NO_INLINE static |
| 2499 |
# endif |
| 2500 |
|
| 2501 |
# if defined(XXH_INLINE_ALL) |
| 2502 |
# define XXH_STATIC XXH_FORCE_INLINE |
| 2503 |
# else |
| 2504 |
# define XXH_STATIC static |
| 2505 |
# endif |
| 2506 |
|
| 2507 |
# if XXH3_INLINE_SECRET |
| 2508 |
# define XXH3_WITH_SECRET_INLINE XXH_FORCE_INLINE |
| 2509 |
# else |
| 2510 |
# define XXH3_WITH_SECRET_INLINE XXH_NO_INLINE |
| 2511 |
# endif |
| 2512 |
|
| 2513 |
# if ((defined(sun) || defined(__sun)) && __cplusplus) |
| 2514 |
|
| 2515 |
# define XXH_RESTRICT |
| 2516 |
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
| 2517 |
# define XXH_RESTRICT restrict |
| 2518 |
# elif (defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))) || (defined(__clang__)) || \ |
| 2519 |
(defined(_MSC_VER) && (_MSC_VER >= 1400)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1300)) |
| 2520 |
|
| 2521 |
|
| 2522 |
|
| 2523 |
|
| 2524 |
# define XXH_RESTRICT __restrict |
| 2525 |
# else |
| 2526 |
# define XXH_RESTRICT |
| 2527 |
# endif |
| 2528 |
|
| 2529 |
|
| 2530 |
|
| 2531 |
|
| 2532 |
|
| 2533 |
|
| 2534 |
|
| 2535 |
|
| 2536 |
|
| 2537 |
|
| 2538 |
|
| 2539 |
|
| 2540 |
# ifndef XXH_DEBUGLEVEL |
| 2541 |
# ifdef DEBUGLEVEL |
| 2542 |
# define XXH_DEBUGLEVEL DEBUGLEVEL |
| 2543 |
# else |
| 2544 |
# define XXH_DEBUGLEVEL 0 |
| 2545 |
# endif |
| 2546 |
# endif |
| 2547 |
|
| 2548 |
# if (XXH_DEBUGLEVEL >= 1) |
| 2549 |
# include <assert.h> |
| 2550 |
# define XXH_ASSERT(c) assert(c) |
| 2551 |
# else |
| 2552 |
# if defined(__INTEL_COMPILER) |
| 2553 |
# define XXH_ASSERT(c) XXH_ASSUME((unsigned char)(c)) |
| 2554 |
# else |
| 2555 |
# define XXH_ASSERT(c) XXH_ASSUME(c) |
| 2556 |
# endif |
| 2557 |
# endif |
| 2558 |
|
| 2559 |
|
| 2560 |
# ifndef XXH_STATIC_ASSERT |
| 2561 |
# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) |
| 2562 |
# define XXH_STATIC_ASSERT_WITH_MESSAGE(c, m) \ |
| 2563 |
do { \ |
| 2564 |
_Static_assert((c), m); \ |
| 2565 |
} while (0) |
| 2566 |
# elif defined(__cplusplus) && (__cplusplus >= 201103L) |
| 2567 |
# define XXH_STATIC_ASSERT_WITH_MESSAGE(c, m) \ |
| 2568 |
do { \ |
| 2569 |
static_assert((c), m); \ |
| 2570 |
} while (0) |
| 2571 |
# else |
| 2572 |
# define XXH_STATIC_ASSERT_WITH_MESSAGE(c, m) \ |
| 2573 |
do { \ |
| 2574 |
struct xxh_sa { \ |
| 2575 |
char x[(c) ? 1 : -1]; \ |
| 2576 |
}; \ |
| 2577 |
} while (0) |
| 2578 |
# endif |
| 2579 |
# define XXH_STATIC_ASSERT(c) XXH_STATIC_ASSERT_WITH_MESSAGE((c), #c) |
| 2580 |
# endif |
| 2581 |
|
| 2582 |
|
| 2583 |
|
| 2584 |
|
| 2585 |
|
| 2586 |
|
| 2587 |
|
| 2588 |
|
| 2589 |
|
| 2590 |
|
| 2591 |
|
| 2592 |
|
| 2593 |
|
| 2594 |
|
| 2595 |
|
| 2596 |
|
| 2597 |
|
| 2598 |
# if defined(__GNUC__) || defined(__clang__) |
| 2599 |
# define XXH_COMPILER_GUARD(var) __asm__("" : "+r"(var)) |
| 2600 |
# else |
| 2601 |
# define XXH_COMPILER_GUARD(var) ((void)0) |
| 2602 |
# endif |
| 2603 |
|
| 2604 |
|
| 2605 |
|
| 2606 |
# if defined(__clang__) && defined(__ARM_ARCH) && !defined(__wasm__) |
| 2607 |
# define XXH_COMPILER_GUARD_CLANG_NEON(var) __asm__("" : "+w"(var)) |
| 2608 |
# else |
| 2609 |
# define XXH_COMPILER_GUARD_CLANG_NEON(var) ((void)0) |
| 2610 |
# endif |
| 2611 |
|
| 2612 |
|
| 2613 |
|
| 2614 |
|
| 2615 |
# if !defined(__VMS) && \ |
| 2616 |
(defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) )) |
| 2617 |
# ifdef _AIX |
| 2618 |
# include <inttypes.h> |
| 2619 |
# else |
| 2620 |
# include <stdint.h> |
| 2621 |
# endif |
| 2622 |
typedef uint8_t xxh_u8; |
| 2623 |
# else |
| 2624 |
typedef unsigned char xxh_u8; |
| 2625 |
# endif |
| 2626 |
typedef XXH32_hash_t xxh_u32; |
| 2627 |
|
| 2628 |
# ifdef XXH_OLD_NAMES |
| 2629 |
# warning \ |
| 2630 |
"XXH_OLD_NAMES is planned to be removed starting v0.9. If the program depends on it, consider moving away from it by employing newer type names directly" |
| 2631 |
# define BYTE xxh_u8 |
| 2632 |
# define U8 xxh_u8 |
| 2633 |
# define U32 xxh_u32 |
| 2634 |
# endif |
| 2635 |
|
| 2636 |
|
| 2637 |
|
| 2638 |
|
| 2639 |
|
| 2640 |
|
| 2641 |
|
| 2642 |
|
| 2643 |
|
| 2644 |
|
| 2645 |
|
| 2646 |
|
| 2647 |
|
| 2648 |
|
| 2649 |
|
| 2650 |
|
| 2651 |
|
| 2652 |
|
| 2653 |
|
| 2654 |
|
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
|
| 2663 |
|
| 2664 |
|
| 2665 |
|
| 2666 |
|
| 2667 |
|
| 2668 |
|
| 2669 |
|
| 2670 |
|
| 2671 |
|
| 2672 |
|
| 2673 |
|
| 2674 |
|
| 2675 |
|
| 2676 |
|
| 2677 |
|
| 2678 |
|
| 2679 |
|
| 2680 |
|
| 2681 |
|
| 2682 |
|
| 2683 |
|
| 2684 |
|
| 2685 |
|
| 2686 |
|
| 2687 |
|
| 2688 |
# if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS == 3)) |
| 2689 |
|
| 2690 |
|
| 2691 |
|
| 2692 |
|
| 2693 |
# elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS == 2)) |
| 2694 |
|
| 2695 |
|
| 2696 |
|
| 2697 |
|
| 2698 |
|
| 2699 |
static xxh_u32 XXH_read32(const void *memPtr) { |
| 2700 |
return *(const xxh_u32 *)memPtr; |
| 2701 |
} |
| 2702 |
|
| 2703 |
# elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS == 1)) |
| 2704 |
|
| 2705 |
|
| 2706 |
|
| 2707 |
|
| 2708 |
|
| 2709 |
|
| 2710 |
|
| 2711 |
|
| 2712 |
# ifdef XXH_OLD_NAMES |
| 2713 |
typedef union { |
| 2714 |
xxh_u32 u32; |
| 2715 |
} __attribute__((__packed__)) unalign; |
| 2716 |
# endif |
| 2717 |
static xxh_u32 XXH_read32(const void *ptr) { |
| 2718 |
typedef __attribute__((__aligned__(1))) __attribute__((__may_alias__)) xxh_u32 xxh_unalign32; |
| 2719 |
return *((const xxh_unalign32 *)ptr); |
| 2720 |
} |
| 2721 |
|
| 2722 |
# else |
| 2723 |
|
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
|
| 2728 |
static xxh_u32 XXH_read32(const void *memPtr) { |
| 2729 |
xxh_u32 val; |
| 2730 |
XXH_memcpy(&val, memPtr, sizeof(val)); |
| 2731 |
return val; |
| 2732 |
} |
| 2733 |
|
| 2734 |
# endif |
| 2735 |
|
| 2736 |
|
| 2737 |
|
| 2738 |
|
| 2739 |
|
| 2740 |
|
| 2741 |
|
| 2742 |
|
| 2743 |
|
| 2744 |
|
| 2745 |
|
| 2746 |
|
| 2747 |
|
| 2748 |
|
| 2749 |
|
| 2750 |
|
| 2751 |
|
| 2752 |
|
| 2753 |
|
| 2754 |
# ifndef XXH_CPU_LITTLE_ENDIAN |
| 2755 |
|
| 2756 |
|
| 2757 |
|
| 2758 |
|
| 2759 |
# if defined(_WIN32) \ |
| 2760 |
|| defined(__LITTLE_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) |
| 2761 |
# define XXH_CPU_LITTLE_ENDIAN 1 |
| 2762 |
# elif defined(__BIG_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) |
| 2763 |
# define XXH_CPU_LITTLE_ENDIAN 0 |
| 2764 |
# else |
| 2765 |
|
| 2766 |
|
| 2767 |
|
| 2768 |
|
| 2769 |
|
| 2770 |
|
| 2771 |
static int XXH_isLittleEndian(void) { |
| 2772 |
|
| 2773 |
|
| 2774 |
|
| 2775 |
|
| 2776 |
const union { |
| 2777 |
xxh_u32 u; |
| 2778 |
xxh_u8 c[4]; |
| 2779 |
} one = {1}; |
| 2780 |
return one.c[0]; |
| 2781 |
} |
| 2782 |
# define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian() |
| 2783 |
# endif |
| 2784 |
# endif |
| 2785 |
|
| 2786 |
|
| 2787 |
|
| 2788 |
|
| 2789 |
# define XXH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) |
| 2790 |
|
| 2791 |
# ifdef __has_builtin |
| 2792 |
# define XXH_HAS_BUILTIN(x) __has_builtin(x) |
| 2793 |
# else |
| 2794 |
# define XXH_HAS_BUILTIN(x) 0 |
| 2795 |
# endif |
| 2796 |
|
| 2797 |
|
| 2798 |
|
| 2799 |
|
| 2800 |
|
| 2801 |
|
| 2802 |
|
| 2803 |
|
| 2804 |
|
| 2805 |
|
| 2806 |
|
| 2807 |
|
| 2808 |
|
| 2809 |
|
| 2810 |
|
| 2811 |
|
| 2812 |
|
| 2813 |
|
| 2814 |
|
| 2815 |
|
| 2816 |
|
| 2817 |
|
| 2818 |
|
| 2819 |
|
| 2820 |
|
| 2821 |
|
| 2822 |
|
| 2823 |
|
| 2824 |
# if XXH_HAS_BUILTIN(__builtin_unreachable) |
| 2825 |
# define XXH_UNREACHABLE() __builtin_unreachable() |
| 2826 |
|
| 2827 |
# elif defined(_MSC_VER) |
| 2828 |
# define XXH_UNREACHABLE() __assume(0) |
| 2829 |
|
| 2830 |
# else |
| 2831 |
# define XXH_UNREACHABLE() |
| 2832 |
# endif |
| 2833 |
|
| 2834 |
# if XXH_HAS_BUILTIN(__builtin_assume) |
| 2835 |
# define XXH_ASSUME(c) __builtin_assume(c) |
| 2836 |
# else |
| 2837 |
# define XXH_ASSUME(c) \ |
| 2838 |
if (!(c)) { \ |
| 2839 |
XXH_UNREACHABLE(); \ |
| 2840 |
} |
| 2841 |
# endif |
| 2842 |
|
| 2843 |
|
| 2844 |
|
| 2845 |
|
| 2846 |
|
| 2847 |
|
| 2848 |
|
| 2849 |
|
| 2850 |
|
| 2851 |
|
| 2852 |
|
| 2853 |
|
| 2854 |
|
| 2855 |
|
| 2856 |
# if !defined(NO_CLANG_BUILTIN) && XXH_HAS_BUILTIN(__builtin_rotateleft32) && XXH_HAS_BUILTIN(__builtin_rotateleft64) |
| 2857 |
# define XXH_rotl32 __builtin_rotateleft32 |
| 2858 |
# define XXH_rotl64 __builtin_rotateleft64 |
| 2859 |
# elif XXH_HAS_BUILTIN(__builtin_stdc_rotate_left) |
| 2860 |
# define XXH_rotl32 __builtin_stdc_rotate_left |
| 2861 |
# define XXH_rotl64 __builtin_stdc_rotate_left |
| 2862 |
|
| 2863 |
# elif defined(_MSC_VER) |
| 2864 |
# define XXH_rotl32(x, r) _rotl(x, r) |
| 2865 |
# define XXH_rotl64(x, r) _rotl64(x, r) |
| 2866 |
# else |
| 2867 |
# define XXH_rotl32(x, r) (((x) << (r)) | ((x) >> (32 - (r)))) |
| 2868 |
# define XXH_rotl64(x, r) (((x) << (r)) | ((x) >> (64 - (r)))) |
| 2869 |
# endif |
| 2870 |
|
| 2871 |
|
| 2872 |
|
| 2873 |
|
| 2874 |
|
| 2875 |
|
| 2876 |
|
| 2877 |
|
| 2878 |
|
| 2879 |
# if defined(_MSC_VER) |
| 2880 |
# define XXH_swap32 _byteswap_ulong |
| 2881 |
# elif XXH_GCC_VERSION >= 403 |
| 2882 |
# define XXH_swap32 __builtin_bswap32 |
| 2883 |
# else |
| 2884 |
static xxh_u32 XXH_swap32(xxh_u32 x) { |
| 2885 |
return ((x << 24) & 0xff000000) | ((x << 8) & 0x00ff0000) | ((x >> 8) & 0x0000ff00) | ((x >> 24) & 0x000000ff); |
| 2886 |
} |
| 2887 |
# endif |
| 2888 |
|
| 2889 |
|
| 2890 |
|
| 2891 |
|
| 2892 |
|
| 2893 |
|
| 2894 |
|
| 2895 |
|
| 2896 |
|
| 2897 |
typedef enum { |
| 2898 |
XXH_aligned, |
| 2899 |
XXH_unaligned |
| 2900 |
} XXH_alignment; |
| 2901 |
|
| 2902 |
|
| 2903 |
|
| 2904 |
|
| 2905 |
|
| 2906 |
|
| 2907 |
# if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS == 3)) |
| 2908 |
|
| 2909 |
XXH_FORCE_INLINE xxh_u32 XXH_readLE32(const void *memPtr) { |
| 2910 |
const xxh_u8 *bytePtr = (const xxh_u8 *)memPtr; |
| 2911 |
return bytePtr[0] | ((xxh_u32)bytePtr[1] << 8) | ((xxh_u32)bytePtr[2] << 16) | ((xxh_u32)bytePtr[3] << 24); |
| 2912 |
} |
| 2913 |
|
| 2914 |
XXH_FORCE_INLINE xxh_u32 XXH_readBE32(const void *memPtr) { |
| 2915 |
const xxh_u8 *bytePtr = (const xxh_u8 *)memPtr; |
| 2916 |
return bytePtr[3] | ((xxh_u32)bytePtr[2] << 8) | ((xxh_u32)bytePtr[1] << 16) | ((xxh_u32)bytePtr[0] << 24); |
| 2917 |
} |
| 2918 |
|
| 2919 |
# else |
| 2920 |
XXH_FORCE_INLINE xxh_u32 XXH_readLE32(const void *ptr) { |
| 2921 |
return XXH_CPU_LITTLE_ENDIAN ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr)); |
| 2922 |
} |
| 2923 |
|
| 2924 |
static xxh_u32 XXH_readBE32(const void *ptr) { |
| 2925 |
return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr); |
| 2926 |
} |
| 2927 |
# endif |
| 2928 |
|
| 2929 |
XXH_FORCE_INLINE xxh_u32 XXH_readLE32_align(const void *ptr, XXH_alignment align) { |
| 2930 |
if (align == XXH_unaligned) { |
| 2931 |
return XXH_readLE32(ptr); |
| 2932 |
} else { |
| 2933 |
return XXH_CPU_LITTLE_ENDIAN ? *(const xxh_u32 *)ptr : XXH_swap32(*(const xxh_u32 *)ptr); |
| 2934 |
} |
| 2935 |
} |
| 2936 |
|
| 2937 |
|
| 2938 |
|
| 2939 |
|
| 2940 |
|
| 2941 |
XXH_PUBLIC_API unsigned XXH_versionNumber(void) { |
| 2942 |
return XXH_VERSION_NUMBER; |
| 2943 |
} |
| 2944 |
|
| 2945 |
|
| 2946 |
|
| 2947 |
|
| 2948 |
|
| 2949 |
|
| 2950 |
|
| 2951 |
|
| 2952 |
|
| 2953 |
|
| 2954 |
|
| 2955 |
|
| 2956 |
|
| 2957 |
# define XXH_PRIME32_1 0x9E3779B1U |
| 2958 |
# define XXH_PRIME32_2 0x85EBCA77U |
| 2959 |
# define XXH_PRIME32_3 0xC2B2AE3DU |
| 2960 |
# define XXH_PRIME32_4 0x27D4EB2FU |
| 2961 |
# define XXH_PRIME32_5 0x165667B1U |
| 2962 |
|
| 2963 |
# ifdef XXH_OLD_NAMES |
| 2964 |
# define PRIME32_1 XXH_PRIME32_1 |
| 2965 |
# define PRIME32_2 XXH_PRIME32_2 |
| 2966 |
# define PRIME32_3 XXH_PRIME32_3 |
| 2967 |
# define PRIME32_4 XXH_PRIME32_4 |
| 2968 |
# define PRIME32_5 XXH_PRIME32_5 |
| 2969 |
# endif |
| 2970 |
|
| 2971 |
|
| 2972 |
|
| 2973 |
|
| 2974 |
|
| 2975 |
|
| 2976 |
|
| 2977 |
|
| 2978 |
|
| 2979 |
|
| 2980 |
|
| 2981 |
|
| 2982 |
static xxh_u32 XXH32_round(xxh_u32 acc, xxh_u32 input) { |
| 2983 |
acc += input * XXH_PRIME32_2; |
| 2984 |
acc = XXH_rotl32(acc, 13); |
| 2985 |
acc *= XXH_PRIME32_1; |
| 2986 |
# if (defined(__SSE4_1__) || defined(__aarch64__) || defined(__wasm_simd128__)) && !defined(XXH_ENABLE_AUTOVECTORIZE) |
| 2987 |
|
| 2988 |
|
| 2989 |
|
| 2990 |
|
| 2991 |
|
| 2992 |
|
| 2993 |
|
| 2994 |
|
| 2995 |
|
| 2996 |
|
| 2997 |
|
| 2998 |
|
| 2999 |
|
| 3000 |
|
| 3001 |
|
| 3002 |
|
| 3003 |
|
| 3004 |
|
| 3005 |
|
| 3006 |
|
| 3007 |
|
| 3008 |
|
| 3009 |
|
| 3010 |
|
| 3011 |
|
| 3012 |
|
| 3013 |
|
| 3014 |
|
| 3015 |
|
| 3016 |
|
| 3017 |
|
| 3018 |
|
| 3019 |
|
| 3020 |
|
| 3021 |
|
| 3022 |
|
| 3023 |
XXH_COMPILER_GUARD(acc); |
| 3024 |
# endif |
| 3025 |
return acc; |
| 3026 |
} |
| 3027 |
|
| 3028 |
|
| 3029 |
|
| 3030 |
|
| 3031 |
|
| 3032 |
|
| 3033 |
|
| 3034 |
|
| 3035 |
|
| 3036 |
|
| 3037 |
|
| 3038 |
static xxh_u32 XXH32_avalanche(xxh_u32 hash) { |
| 3039 |
hash ^= hash >> 15; |
| 3040 |
hash *= XXH_PRIME32_2; |
| 3041 |
hash ^= hash >> 13; |
| 3042 |
hash *= XXH_PRIME32_3; |
| 3043 |
hash ^= hash >> 16; |
| 3044 |
return hash; |
| 3045 |
} |
| 3046 |
|
| 3047 |
# define XXH_get32bits(p) XXH_readLE32_align(p, align) |
| 3048 |
|
| 3049 |
|
| 3050 |
|
| 3051 |
|
| 3052 |
|
| 3053 |
XXH_FORCE_INLINE void XXH32_initAccs(xxh_u32 *acc, xxh_u32 seed) { |
| 3054 |
XXH_ASSERT(acc != NULL); |
| 3055 |
acc[0] = seed + XXH_PRIME32_1 + XXH_PRIME32_2; |
| 3056 |
acc[1] = seed + XXH_PRIME32_2; |
| 3057 |
acc[2] = seed + 0; |
| 3058 |
acc[3] = seed - XXH_PRIME32_1; |
| 3059 |
} |
| 3060 |
|
| 3061 |
|
| 3062 |
|
| 3063 |
|
| 3064 |
|
| 3065 |
|
| 3066 |
|
| 3067 |
XXH_FORCE_INLINE const xxh_u8 *XXH32_consumeLong( |
| 3068 |
xxh_u32 *XXH_RESTRICT acc, |
| 3069 |
xxh_u8 const *XXH_RESTRICT input, |
| 3070 |
size_t len, |
| 3071 |
XXH_alignment align) { |
| 3072 |
const xxh_u8 *const bEnd = input + len; |
| 3073 |
const xxh_u8 *const limit = bEnd - 15; |
| 3074 |
XXH_ASSERT(acc != NULL); |
| 3075 |
XXH_ASSERT(input != NULL); |
| 3076 |
XXH_ASSERT(len >= 16); |
| 3077 |
do { |
| 3078 |
acc[0] = XXH32_round(acc[0], XXH_get32bits(input)); |
| 3079 |
input += 4; |
| 3080 |
acc[1] = XXH32_round(acc[1], XXH_get32bits(input)); |
| 3081 |
input += 4; |
| 3082 |
acc[2] = XXH32_round(acc[2], XXH_get32bits(input)); |
| 3083 |
input += 4; |
| 3084 |
acc[3] = XXH32_round(acc[3], XXH_get32bits(input)); |
| 3085 |
input += 4; |
| 3086 |
} while (input < limit); |
| 3087 |
|
| 3088 |
return input; |
| 3089 |
} |
| 3090 |
|
| 3091 |
|
| 3092 |
|
| 3093 |
|
| 3094 |
|
| 3095 |
XXH_FORCE_INLINE XXH_PUREF xxh_u32 XXH32_mergeAccs(const xxh_u32 *acc) { |
| 3096 |
XXH_ASSERT(acc != NULL); |
| 3097 |
return XXH_rotl32(acc[0], 1) + XXH_rotl32(acc[1], 7) + XXH_rotl32(acc[2], 12) + XXH_rotl32(acc[3], 18); |
| 3098 |
} |
| 3099 |
|
| 3100 |
|
| 3101 |
|
| 3102 |
|
| 3103 |
|
| 3104 |
|
| 3105 |
|
| 3106 |
|
| 3107 |
|
| 3108 |
|
| 3109 |
|
| 3110 |
|
| 3111 |
|
| 3112 |
|
| 3113 |
|
| 3114 |
|
| 3115 |
static XXH_PUREF xxh_u32 XXH32_finalize(xxh_u32 hash, const xxh_u8 *ptr, size_t len, XXH_alignment align) { |
| 3116 |
# define XXH_PROCESS1 \ |
| 3117 |
do { \ |
| 3118 |
hash += (*ptr++) * XXH_PRIME32_5; \ |
| 3119 |
hash = XXH_rotl32(hash, 11) * XXH_PRIME32_1; \ |
| 3120 |
} while (0) |
| 3121 |
|
| 3122 |
# define XXH_PROCESS4 \ |
| 3123 |
do { \ |
| 3124 |
hash += XXH_get32bits(ptr) * XXH_PRIME32_3; \ |
| 3125 |
ptr += 4; \ |
| 3126 |
hash = XXH_rotl32(hash, 17) * XXH_PRIME32_4; \ |
| 3127 |
} while (0) |
| 3128 |
|
| 3129 |
if (ptr == NULL) |
| 3130 |
XXH_ASSERT(len == 0); |
| 3131 |
|
| 3132 |
|
| 3133 |
if (!XXH32_ENDJMP) { |
| 3134 |
len &= 15; |
| 3135 |
while (len >= 4) { |
| 3136 |
XXH_PROCESS4; |
| 3137 |
len -= 4; |
| 3138 |
} |
| 3139 |
while (len > 0) { |
| 3140 |
XXH_PROCESS1; |
| 3141 |
--len; |
| 3142 |
} |
| 3143 |
return XXH32_avalanche(hash); |
| 3144 |
} else { |
| 3145 |
switch (len & 15) { |
| 3146 |
case 12: |
| 3147 |
XXH_PROCESS4; |
| 3148 |
XXH_FALLTHROUGH; |
| 3149 |
case 8: |
| 3150 |
XXH_PROCESS4; |
| 3151 |
XXH_FALLTHROUGH; |
| 3152 |
case 4: |
| 3153 |
XXH_PROCESS4; |
| 3154 |
return XXH32_avalanche(hash); |
| 3155 |
|
| 3156 |
case 13: |
| 3157 |
XXH_PROCESS4; |
| 3158 |
XXH_FALLTHROUGH; |
| 3159 |
case 9: |
| 3160 |
XXH_PROCESS4; |
| 3161 |
XXH_FALLTHROUGH; |
| 3162 |
case 5: |
| 3163 |
XXH_PROCESS4; |
| 3164 |
XXH_PROCESS1; |
| 3165 |
return XXH32_avalanche(hash); |
| 3166 |
|
| 3167 |
case 14: |
| 3168 |
XXH_PROCESS4; |
| 3169 |
XXH_FALLTHROUGH; |
| 3170 |
case 10: |
| 3171 |
XXH_PROCESS4; |
| 3172 |
XXH_FALLTHROUGH; |
| 3173 |
case 6: |
| 3174 |
XXH_PROCESS4; |
| 3175 |
XXH_PROCESS1; |
| 3176 |
XXH_PROCESS1; |
| 3177 |
return XXH32_avalanche(hash); |
| 3178 |
|
| 3179 |
case 15: |
| 3180 |
XXH_PROCESS4; |
| 3181 |
XXH_FALLTHROUGH; |
| 3182 |
case 11: |
| 3183 |
XXH_PROCESS4; |
| 3184 |
XXH_FALLTHROUGH; |
| 3185 |
case 7: |
| 3186 |
XXH_PROCESS4; |
| 3187 |
XXH_FALLTHROUGH; |
| 3188 |
case 3: |
| 3189 |
XXH_PROCESS1; |
| 3190 |
XXH_FALLTHROUGH; |
| 3191 |
case 2: |
| 3192 |
XXH_PROCESS1; |
| 3193 |
XXH_FALLTHROUGH; |
| 3194 |
case 1: |
| 3195 |
XXH_PROCESS1; |
| 3196 |
XXH_FALLTHROUGH; |
| 3197 |
case 0: |
| 3198 |
return XXH32_avalanche(hash); |
| 3199 |
} |
| 3200 |
XXH_ASSERT(0); |
| 3201 |
return hash; |
| 3202 |
} |
| 3203 |
} |
| 3204 |
|
| 3205 |
# ifdef XXH_OLD_NAMES |
| 3206 |
# define PROCESS1 XXH_PROCESS1 |
| 3207 |
# define PROCESS4 XXH_PROCESS4 |
| 3208 |
# else |
| 3209 |
# undef XXH_PROCESS1 |
| 3210 |
# undef XXH_PROCESS4 |
| 3211 |
# endif |
| 3212 |
|
| 3213 |
|
| 3214 |
|
| 3215 |
|
| 3216 |
|
| 3217 |
|
| 3218 |
|
| 3219 |
|
| 3220 |
|
| 3221 |
XXH_FORCE_INLINE XXH_PUREF xxh_u32 |
| 3222 |
XXH32_endian_align(const xxh_u8 *input, size_t len, xxh_u32 seed, XXH_alignment align) { |
| 3223 |
xxh_u32 h32; |
| 3224 |
|
| 3225 |
if (input == NULL) |
| 3226 |
XXH_ASSERT(len == 0); |
| 3227 |
|
| 3228 |
if (len >= 16) { |
| 3229 |
xxh_u32 acc[4]; |
| 3230 |
XXH32_initAccs(acc, seed); |
| 3231 |
|
| 3232 |
input = XXH32_consumeLong(acc, input, len, align); |
| 3233 |
|
| 3234 |
h32 = XXH32_mergeAccs(acc); |
| 3235 |
} else { |
| 3236 |
h32 = seed + XXH_PRIME32_5; |
| 3237 |
} |
| 3238 |
|
| 3239 |
h32 += (xxh_u32)len; |
| 3240 |
|
| 3241 |
return XXH32_finalize(h32, input, len & 15, align); |
| 3242 |
} |
| 3243 |
|
| 3244 |
|
| 3245 |
XXH_PUBLIC_API XXH32_hash_t XXH32(const void *input, size_t len, XXH32_hash_t seed) { |
| 3246 |
# if !defined(XXH_NO_STREAM) && XXH_SIZE_OPT >= 2 |
| 3247 |
|
| 3248 |
XXH32_state_t state; |
| 3249 |
XXH32_reset(&state, seed); |
| 3250 |
XXH32_update(&state, (const xxh_u8 *)input, len); |
| 3251 |
return XXH32_digest(&state); |
| 3252 |
# else |
| 3253 |
if (XXH_FORCE_ALIGN_CHECK) { |
| 3254 |
if ((((size_t)input) & 3) == 0) { |
| 3255 |
return XXH32_endian_align((const xxh_u8 *)input, len, seed, XXH_aligned); |
| 3256 |
} |
| 3257 |
} |
| 3258 |
|
| 3259 |
return XXH32_endian_align((const xxh_u8 *)input, len, seed, XXH_unaligned); |
| 3260 |
# endif |
| 3261 |
} |
| 3262 |
|
| 3263 |
|
| 3264 |
# ifndef XXH_NO_STREAM |
| 3265 |
|
| 3266 |
XXH_PUBLIC_API XXH32_state_t *XXH32_createState(void) { |
| 3267 |
return (XXH32_state_t *)XXH_malloc(sizeof(XXH32_state_t)); |
| 3268 |
} |
| 3269 |
|
| 3270 |
XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t *statePtr) { |
| 3271 |
XXH_free(statePtr); |
| 3272 |
return XXH_OK; |
| 3273 |
} |
| 3274 |
|
| 3275 |
|
| 3276 |
XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t *dstState, const XXH32_state_t *srcState) { |
| 3277 |
XXH_memcpy(dstState, srcState, sizeof(*dstState)); |
| 3278 |
} |
| 3279 |
|
| 3280 |
|
| 3281 |
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t *statePtr, XXH32_hash_t seed) { |
| 3282 |
XXH_ASSERT(statePtr != NULL); |
| 3283 |
XXH_memset(statePtr, 0, sizeof(*statePtr)); |
| 3284 |
XXH32_initAccs(statePtr->acc, seed); |
| 3285 |
return XXH_OK; |
| 3286 |
} |
| 3287 |
|
| 3288 |
|
| 3289 |
XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t *state, const void *input, size_t len) { |
| 3290 |
if (input == NULL) { |
| 3291 |
XXH_ASSERT(len == 0); |
| 3292 |
return XXH_OK; |
| 3293 |
} |
| 3294 |
|
| 3295 |
state->total_len_32 += (XXH32_hash_t)len; |
| 3296 |
state->large_len |= (XXH32_hash_t)((len >= 16) | (state->total_len_32 >= 16)); |
| 3297 |
|
| 3298 |
XXH_ASSERT(state->bufferedSize < sizeof(state->buffer)); |
| 3299 |
if (len < sizeof(state->buffer) - state->bufferedSize) { |
| 3300 |
XXH_memcpy(state->buffer + state->bufferedSize, input, len); |
| 3301 |
state->bufferedSize += (XXH32_hash_t)len; |
| 3302 |
return XXH_OK; |
| 3303 |
} |
| 3304 |
|
| 3305 |
{ |
| 3306 |
const xxh_u8 *xinput = (const xxh_u8 *)input; |
| 3307 |
const xxh_u8 *const bEnd = xinput + len; |
| 3308 |
|
| 3309 |
if (state->bufferedSize) { |
| 3310 |
XXH_memcpy(state->buffer + state->bufferedSize, xinput, sizeof(state->buffer) - state->bufferedSize); |
| 3311 |
xinput += sizeof(state->buffer) - state->bufferedSize; |
| 3312 |
|
| 3313 |
(void)XXH32_consumeLong(state->acc, state->buffer, sizeof(state->buffer), XXH_aligned); |
| 3314 |
state->bufferedSize = 0; |
| 3315 |
} |
| 3316 |
|
| 3317 |
XXH_ASSERT(xinput <= bEnd); |
| 3318 |
if ((size_t)(bEnd - xinput) >= sizeof(state->buffer)) { |
| 3319 |
|
| 3320 |
xinput = XXH32_consumeLong(state->acc, xinput, (size_t)(bEnd - xinput), XXH_unaligned); |
| 3321 |
} |
| 3322 |
|
| 3323 |
if (xinput < bEnd) { |
| 3324 |
|
| 3325 |
XXH_memcpy(state->buffer, xinput, (size_t)(bEnd - xinput)); |
| 3326 |
state->bufferedSize = (unsigned)(bEnd - xinput); |
| 3327 |
} |
| 3328 |
} |
| 3329 |
|
| 3330 |
return XXH_OK; |
| 3331 |
} |
| 3332 |
|
| 3333 |
|
| 3334 |
XXH_PUBLIC_API XXH32_hash_t XXH32_digest(const XXH32_state_t *state) { |
| 3335 |
xxh_u32 h32; |
| 3336 |
|
| 3337 |
if (state->large_len) { |
| 3338 |
h32 = XXH32_mergeAccs(state->acc); |
| 3339 |
} else { |
| 3340 |
h32 = state->acc[2] + XXH_PRIME32_5; |
| 3341 |
} |
| 3342 |
|
| 3343 |
h32 += state->total_len_32; |
| 3344 |
|
| 3345 |
return XXH32_finalize(h32, state->buffer, state->bufferedSize, XXH_aligned); |
| 3346 |
} |
| 3347 |
# endif |
| 3348 |
|
| 3349 |
|
| 3350 |
|
| 3351 |
|
| 3352 |
XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t *dst, XXH32_hash_t hash) { |
| 3353 |
XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t)); |
| 3354 |
if (XXH_CPU_LITTLE_ENDIAN) |
| 3355 |
hash = XXH_swap32(hash); |
| 3356 |
XXH_memcpy(dst, &hash, sizeof(*dst)); |
| 3357 |
} |
| 3358 |
|
| 3359 |
XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t *src) { |
| 3360 |
return XXH_readBE32(src); |
| 3361 |
} |
| 3362 |
|
| 3363 |
# ifndef XXH_NO_LONG_LONG |
| 3364 |
|
| 3365 |
|
| 3366 |
|
| 3367 |
|
| 3368 |
|
| 3369 |
|
| 3370 |
|
| 3371 |
|
| 3372 |
|
| 3373 |
|
| 3374 |
|
| 3375 |
typedef XXH64_hash_t xxh_u64; |
| 3376 |
|
| 3377 |
# ifdef XXH_OLD_NAMES |
| 3378 |
# define U64 xxh_u64 |
| 3379 |
# endif |
| 3380 |
|
| 3381 |
# if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS == 3)) |
| 3382 |
|
| 3383 |
|
| 3384 |
|
| 3385 |
|
| 3386 |
# elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS == 2)) |
| 3387 |
|
| 3388 |
|
| 3389 |
static xxh_u64 XXH_read64(const void *memPtr) { |
| 3390 |
return *(const xxh_u64 *)memPtr; |
| 3391 |
} |
| 3392 |
|
| 3393 |
# elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS == 1)) |
| 3394 |
|
| 3395 |
|
| 3396 |
|
| 3397 |
|
| 3398 |
|
| 3399 |
|
| 3400 |
|
| 3401 |
|
| 3402 |
# ifdef XXH_OLD_NAMES |
| 3403 |
typedef union { |
| 3404 |
xxh_u32 u32; |
| 3405 |
xxh_u64 u64; |
| 3406 |
} __attribute__((__packed__)) unalign64; |
| 3407 |
# endif |
| 3408 |
static xxh_u64 XXH_read64(const void *ptr) { |
| 3409 |
typedef __attribute__((__aligned__(1))) __attribute__((__may_alias__)) xxh_u64 xxh_unalign64; |
| 3410 |
return *((const xxh_unalign64 *)ptr); |
| 3411 |
} |
| 3412 |
|
| 3413 |
# else |
| 3414 |
|
| 3415 |
|
| 3416 |
|
| 3417 |
|
| 3418 |
|
| 3419 |
static xxh_u64 XXH_read64(const void *memPtr) { |
| 3420 |
xxh_u64 val; |
| 3421 |
XXH_memcpy(&val, memPtr, sizeof(val)); |
| 3422 |
return val; |
| 3423 |
} |
| 3424 |
|
| 3425 |
# endif |
| 3426 |
|
| 3427 |
# if defined(_MSC_VER) |
| 3428 |
# define XXH_swap64 _byteswap_uint64 |
| 3429 |
# elif XXH_GCC_VERSION >= 403 |
| 3430 |
# define XXH_swap64 __builtin_bswap64 |
| 3431 |
# else |
| 3432 |
static xxh_u64 XXH_swap64(xxh_u64 x) { |
| 3433 |
return ((x << 56) & 0xff00000000000000ULL) | ((x << 40) & 0x00ff000000000000ULL) | |
| 3434 |
((x << 24) & 0x0000ff0000000000ULL) | ((x << 8) & 0x000000ff00000000ULL) | |
| 3435 |
((x >> 8) & 0x00000000ff000000ULL) | ((x >> 24) & 0x0000000000ff0000ULL) | |
| 3436 |
((x >> 40) & 0x000000000000ff00ULL) | ((x >> 56) & 0x00000000000000ffULL); |
| 3437 |
} |
| 3438 |
# endif |
| 3439 |
|
| 3440 |
|
| 3441 |
# if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS == 3)) |
| 3442 |
|
| 3443 |
XXH_FORCE_INLINE xxh_u64 XXH_readLE64(const void *memPtr) { |
| 3444 |
const xxh_u8 *bytePtr = (const xxh_u8 *)memPtr; |
| 3445 |
return bytePtr[0] | ((xxh_u64)bytePtr[1] << 8) | ((xxh_u64)bytePtr[2] << 16) | ((xxh_u64)bytePtr[3] << 24) | |
| 3446 |
((xxh_u64)bytePtr[4] << 32) | ((xxh_u64)bytePtr[5] << 40) | ((xxh_u64)bytePtr[6] << 48) | |
| 3447 |
((xxh_u64)bytePtr[7] << 56); |
| 3448 |
} |
| 3449 |
|
| 3450 |
XXH_FORCE_INLINE xxh_u64 XXH_readBE64(const void *memPtr) { |
| 3451 |
const xxh_u8 *bytePtr = (const xxh_u8 *)memPtr; |
| 3452 |
return bytePtr[7] | ((xxh_u64)bytePtr[6] << 8) | ((xxh_u64)bytePtr[5] << 16) | ((xxh_u64)bytePtr[4] << 24) | |
| 3453 |
((xxh_u64)bytePtr[3] << 32) | ((xxh_u64)bytePtr[2] << 40) | ((xxh_u64)bytePtr[1] << 48) | |
| 3454 |
((xxh_u64)bytePtr[0] << 56); |
| 3455 |
} |
| 3456 |
|
| 3457 |
# else |
| 3458 |
XXH_FORCE_INLINE xxh_u64 XXH_readLE64(const void *ptr) { |
| 3459 |
return XXH_CPU_LITTLE_ENDIAN ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr)); |
| 3460 |
} |
| 3461 |
|
| 3462 |
static xxh_u64 XXH_readBE64(const void *ptr) { |
| 3463 |
return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64(XXH_read64(ptr)) : XXH_read64(ptr); |
| 3464 |
} |
| 3465 |
# endif |
| 3466 |
|
| 3467 |
XXH_FORCE_INLINE xxh_u64 XXH_readLE64_align(const void *ptr, XXH_alignment align) { |
| 3468 |
if (align == XXH_unaligned) |
| 3469 |
return XXH_readLE64(ptr); |
| 3470 |
else |
| 3471 |
return XXH_CPU_LITTLE_ENDIAN ? *(const xxh_u64 *)ptr : XXH_swap64(*(const xxh_u64 *)ptr); |
| 3472 |
} |
| 3473 |
|
| 3474 |
|
| 3475 |
|
| 3476 |
|
| 3477 |
|
| 3478 |
|
| 3479 |
|
| 3480 |
|
| 3481 |
|
| 3482 |
|
| 3483 |
|
| 3484 |
# define XXH_PRIME64_1 \ |
| 3485 |
0x9E3779B185EBCA87ULL |
| 3486 |
# define XXH_PRIME64_2 \ |
| 3487 |
0xC2B2AE3D27D4EB4FULL |
| 3488 |
# define XXH_PRIME64_3 \ |
| 3489 |
0x165667B19E3779F9ULL |
| 3490 |
# define XXH_PRIME64_4 \ |
| 3491 |
0x85EBCA77C2B2AE63ULL |
| 3492 |
# define XXH_PRIME64_5 \ |
| 3493 |
0x27D4EB2F165667C5ULL |
| 3494 |
|
| 3495 |
# ifdef XXH_OLD_NAMES |
| 3496 |
# define PRIME64_1 XXH_PRIME64_1 |
| 3497 |
# define PRIME64_2 XXH_PRIME64_2 |
| 3498 |
# define PRIME64_3 XXH_PRIME64_3 |
| 3499 |
# define PRIME64_4 XXH_PRIME64_4 |
| 3500 |
# define PRIME64_5 XXH_PRIME64_5 |
| 3501 |
# endif |
| 3502 |
|
| 3503 |
|
| 3504 |
static xxh_u64 XXH64_round(xxh_u64 acc, xxh_u64 input) { |
| 3505 |
acc += input * XXH_PRIME64_2; |
| 3506 |
acc = XXH_rotl64(acc, 31); |
| 3507 |
acc *= XXH_PRIME64_1; |
| 3508 |
# if (defined(__AVX512F__)) && !defined(XXH_ENABLE_AUTOVECTORIZE) |
| 3509 |
|
| 3510 |
|
| 3511 |
|
| 3512 |
|
| 3513 |
|
| 3514 |
|
| 3515 |
|
| 3516 |
|
| 3517 |
|
| 3518 |
|
| 3519 |
|
| 3520 |
|
| 3521 |
|
| 3522 |
|
| 3523 |
XXH_COMPILER_GUARD(acc); |
| 3524 |
# endif |
| 3525 |
return acc; |
| 3526 |
} |
| 3527 |
|
| 3528 |
static xxh_u64 XXH64_mergeRound(xxh_u64 acc, xxh_u64 val) { |
| 3529 |
val = XXH64_round(0, val); |
| 3530 |
acc ^= val; |
| 3531 |
acc = acc * XXH_PRIME64_1 + XXH_PRIME64_4; |
| 3532 |
return acc; |
| 3533 |
} |
| 3534 |
|
| 3535 |
|
| 3536 |
static xxh_u64 XXH64_avalanche(xxh_u64 hash) { |
| 3537 |
hash ^= hash >> 33; |
| 3538 |
hash *= XXH_PRIME64_2; |
| 3539 |
hash ^= hash >> 29; |
| 3540 |
hash *= XXH_PRIME64_3; |
| 3541 |
hash ^= hash >> 32; |
| 3542 |
return hash; |
| 3543 |
} |
| 3544 |
|
| 3545 |
# define XXH_get64bits(p) XXH_readLE64_align(p, align) |
| 3546 |
|
| 3547 |
|
| 3548 |
|
| 3549 |
|
| 3550 |
|
| 3551 |
XXH_FORCE_INLINE void XXH64_initAccs(xxh_u64 *acc, xxh_u64 seed) { |
| 3552 |
XXH_ASSERT(acc != NULL); |
| 3553 |
acc[0] = seed + XXH_PRIME64_1 + XXH_PRIME64_2; |
| 3554 |
acc[1] = seed + XXH_PRIME64_2; |
| 3555 |
acc[2] = seed + 0; |
| 3556 |
acc[3] = seed - XXH_PRIME64_1; |
| 3557 |
} |
| 3558 |
|
| 3559 |
|
| 3560 |
|
| 3561 |
|
| 3562 |
|
| 3563 |
|
| 3564 |
|
| 3565 |
XXH_FORCE_INLINE const xxh_u8 *XXH64_consumeLong( |
| 3566 |
xxh_u64 *XXH_RESTRICT acc, |
| 3567 |
xxh_u8 const *XXH_RESTRICT input, |
| 3568 |
size_t len, |
| 3569 |
XXH_alignment align) { |
| 3570 |
const xxh_u8 *const bEnd = input + len; |
| 3571 |
const xxh_u8 *const limit = bEnd - 31; |
| 3572 |
XXH_ASSERT(acc != NULL); |
| 3573 |
XXH_ASSERT(input != NULL); |
| 3574 |
XXH_ASSERT(len >= 32); |
| 3575 |
do { |
| 3576 |
|
| 3577 |
if (sizeof(void *) < sizeof(xxh_u64)) { |
| 3578 |
size_t i; |
| 3579 |
for (i = 0; i < 4; i++) { |
| 3580 |
acc[i] = XXH64_round(acc[i], XXH_get64bits(input)); |
| 3581 |
input += 8; |
| 3582 |
} |
| 3583 |
} else { |
| 3584 |
acc[0] = XXH64_round(acc[0], XXH_get64bits(input)); |
| 3585 |
input += 8; |
| 3586 |
acc[1] = XXH64_round(acc[1], XXH_get64bits(input)); |
| 3587 |
input += 8; |
| 3588 |
acc[2] = XXH64_round(acc[2], XXH_get64bits(input)); |
| 3589 |
input += 8; |
| 3590 |
acc[3] = XXH64_round(acc[3], XXH_get64bits(input)); |
| 3591 |
input += 8; |
| 3592 |
} |
| 3593 |
} while (input < limit); |
| 3594 |
|
| 3595 |
return input; |
| 3596 |
} |
| 3597 |
|
| 3598 |
|
| 3599 |
|
| 3600 |
|
| 3601 |
|
| 3602 |
XXH_FORCE_INLINE XXH_PUREF xxh_u64 XXH64_mergeAccs(const xxh_u64 *acc) { |
| 3603 |
XXH_ASSERT(acc != NULL); |
| 3604 |
{ |
| 3605 |
xxh_u64 h64 = XXH_rotl64(acc[0], 1) + XXH_rotl64(acc[1], 7) + XXH_rotl64(acc[2], 12) + XXH_rotl64(acc[3], 18); |
| 3606 |
|
| 3607 |
if (sizeof(void *) < sizeof(xxh_u64)) { |
| 3608 |
size_t i; |
| 3609 |
for (i = 0; i < 4; i++) { |
| 3610 |
h64 = XXH64_mergeRound(h64, acc[i]); |
| 3611 |
} |
| 3612 |
} else { |
| 3613 |
h64 = XXH64_mergeRound(h64, acc[0]); |
| 3614 |
h64 = XXH64_mergeRound(h64, acc[1]); |
| 3615 |
h64 = XXH64_mergeRound(h64, acc[2]); |
| 3616 |
h64 = XXH64_mergeRound(h64, acc[3]); |
| 3617 |
} |
| 3618 |
return h64; |
| 3619 |
} |
| 3620 |
} |
| 3621 |
|
| 3622 |
|
| 3623 |
|
| 3624 |
|
| 3625 |
|
| 3626 |
|
| 3627 |
|
| 3628 |
|
| 3629 |
|
| 3630 |
|
| 3631 |
|
| 3632 |
|
| 3633 |
|
| 3634 |
|
| 3635 |
|
| 3636 |
|
| 3637 |
XXH_STATIC XXH_PUREF xxh_u64 XXH64_finalize(xxh_u64 hash, const xxh_u8 *ptr, size_t len, XXH_alignment align) { |
| 3638 |
if (ptr == NULL) |
| 3639 |
XXH_ASSERT(len == 0); |
| 3640 |
len &= 31; |
| 3641 |
while (len >= 8) { |
| 3642 |
xxh_u64 const k1 = XXH64_round(0, XXH_get64bits(ptr)); |
| 3643 |
ptr += 8; |
| 3644 |
hash ^= k1; |
| 3645 |
hash = XXH_rotl64(hash, 27) * XXH_PRIME64_1 + XXH_PRIME64_4; |
| 3646 |
len -= 8; |
| 3647 |
} |
| 3648 |
if (len >= 4) { |
| 3649 |
hash ^= (xxh_u64)(XXH_get32bits(ptr)) * XXH_PRIME64_1; |
| 3650 |
ptr += 4; |
| 3651 |
hash = XXH_rotl64(hash, 23) * XXH_PRIME64_2 + XXH_PRIME64_3; |
| 3652 |
len -= 4; |
| 3653 |
} |
| 3654 |
while (len > 0) { |
| 3655 |
hash ^= (*ptr++) * XXH_PRIME64_5; |
| 3656 |
hash = XXH_rotl64(hash, 11) * XXH_PRIME64_1; |
| 3657 |
--len; |
| 3658 |
} |
| 3659 |
return XXH64_avalanche(hash); |
| 3660 |
} |
| 3661 |
|
| 3662 |
# ifdef XXH_OLD_NAMES |
| 3663 |
# define PROCESS1_64 XXH_PROCESS1_64 |
| 3664 |
# define PROCESS4_64 XXH_PROCESS4_64 |
| 3665 |
# define PROCESS8_64 XXH_PROCESS8_64 |
| 3666 |
# else |
| 3667 |
# undef XXH_PROCESS1_64 |
| 3668 |
# undef XXH_PROCESS4_64 |
| 3669 |
# undef XXH_PROCESS8_64 |
| 3670 |
# endif |
| 3671 |
|
| 3672 |
|
| 3673 |
|
| 3674 |
|
| 3675 |
|
| 3676 |
|
| 3677 |
|
| 3678 |
|
| 3679 |
|
| 3680 |
XXH_FORCE_INLINE XXH_PUREF xxh_u64 |
| 3681 |
XXH64_endian_align(const xxh_u8 *input, size_t len, xxh_u64 seed, XXH_alignment align) { |
| 3682 |
xxh_u64 h64; |
| 3683 |
if (input == NULL) |
| 3684 |
XXH_ASSERT(len == 0); |
| 3685 |
|
| 3686 |
if (len >= 32) { |
| 3687 |
xxh_u64 acc[4]; |
| 3688 |
XXH64_initAccs(acc, seed); |
| 3689 |
|
| 3690 |
input = XXH64_consumeLong(acc, input, len, align); |
| 3691 |
|
| 3692 |
h64 = XXH64_mergeAccs(acc); |
| 3693 |
} else { |
| 3694 |
h64 = seed + XXH_PRIME64_5; |
| 3695 |
} |
| 3696 |
|
| 3697 |
h64 += (xxh_u64)len; |
| 3698 |
|
| 3699 |
return XXH64_finalize(h64, input, len, align); |
| 3700 |
} |
| 3701 |
|
| 3702 |
|
| 3703 |
XXH_PUBLIC_API XXH64_hash_t XXH64(XXH_NOESCAPE const void *input, size_t len, XXH64_hash_t seed) { |
| 3704 |
# if !defined(XXH_NO_STREAM) && XXH_SIZE_OPT >= 2 |
| 3705 |
|
| 3706 |
XXH64_state_t state; |
| 3707 |
XXH64_reset(&state, seed); |
| 3708 |
XXH64_update(&state, (const xxh_u8 *)input, len); |
| 3709 |
return XXH64_digest(&state); |
| 3710 |
# else |
| 3711 |
if (XXH_FORCE_ALIGN_CHECK) { |
| 3712 |
if ((((size_t)input) & 7) == 0) { |
| 3713 |
return XXH64_endian_align((const xxh_u8 *)input, len, seed, XXH_aligned); |
| 3714 |
} |
| 3715 |
} |
| 3716 |
|
| 3717 |
return XXH64_endian_align((const xxh_u8 *)input, len, seed, XXH_unaligned); |
| 3718 |
|
| 3719 |
# endif |
| 3720 |
} |
| 3721 |
|
| 3722 |
|
| 3723 |
# ifndef XXH_NO_STREAM |
| 3724 |
|
| 3725 |
XXH_PUBLIC_API XXH64_state_t *XXH64_createState(void) { |
| 3726 |
return (XXH64_state_t *)XXH_malloc(sizeof(XXH64_state_t)); |
| 3727 |
} |
| 3728 |
|
| 3729 |
XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t *statePtr) { |
| 3730 |
XXH_free(statePtr); |
| 3731 |
return XXH_OK; |
| 3732 |
} |
| 3733 |
|
| 3734 |
|
| 3735 |
XXH_PUBLIC_API void XXH64_copyState(XXH_NOESCAPE XXH64_state_t *dstState, const XXH64_state_t *srcState) { |
| 3736 |
XXH_memcpy(dstState, srcState, sizeof(*dstState)); |
| 3737 |
} |
| 3738 |
|
| 3739 |
|
| 3740 |
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH_NOESCAPE XXH64_state_t *statePtr, XXH64_hash_t seed) { |
| 3741 |
XXH_ASSERT(statePtr != NULL); |
| 3742 |
XXH_memset(statePtr, 0, sizeof(*statePtr)); |
| 3743 |
XXH64_initAccs(statePtr->acc, seed); |
| 3744 |
return XXH_OK; |
| 3745 |
} |
| 3746 |
|
| 3747 |
|
| 3748 |
XXH_PUBLIC_API XXH_errorcode |
| 3749 |
XXH64_update(XXH_NOESCAPE XXH64_state_t *state, XXH_NOESCAPE const void *input, size_t len) { |
| 3750 |
if (input == NULL) { |
| 3751 |
XXH_ASSERT(len == 0); |
| 3752 |
return XXH_OK; |
| 3753 |
} |
| 3754 |
|
| 3755 |
state->total_len += len; |
| 3756 |
|
| 3757 |
XXH_ASSERT(state->bufferedSize <= sizeof(state->buffer)); |
| 3758 |
if (len < sizeof(state->buffer) - state->bufferedSize) { |
| 3759 |
XXH_memcpy(state->buffer + state->bufferedSize, input, len); |
| 3760 |
state->bufferedSize += (XXH32_hash_t)len; |
| 3761 |
return XXH_OK; |
| 3762 |
} |
| 3763 |
|
| 3764 |
{ |
| 3765 |
const xxh_u8 *xinput = (const xxh_u8 *)input; |
| 3766 |
const xxh_u8 *const bEnd = xinput + len; |
| 3767 |
|
| 3768 |
if (state->bufferedSize) { |
| 3769 |
XXH_memcpy(state->buffer + state->bufferedSize, xinput, sizeof(state->buffer) - state->bufferedSize); |
| 3770 |
xinput += sizeof(state->buffer) - state->bufferedSize; |
| 3771 |
|
| 3772 |
(void)XXH64_consumeLong(state->acc, state->buffer, sizeof(state->buffer), XXH_aligned); |
| 3773 |
state->bufferedSize = 0; |
| 3774 |
} |
| 3775 |
|
| 3776 |
XXH_ASSERT(xinput <= bEnd); |
| 3777 |
if ((size_t)(bEnd - xinput) >= sizeof(state->buffer)) { |
| 3778 |
|
| 3779 |
xinput = XXH64_consumeLong(state->acc, xinput, (size_t)(bEnd - xinput), XXH_unaligned); |
| 3780 |
} |
| 3781 |
|
| 3782 |
if (xinput < bEnd) { |
| 3783 |
|
| 3784 |
XXH_memcpy(state->buffer, xinput, (size_t)(bEnd - xinput)); |
| 3785 |
state->bufferedSize = (unsigned)(bEnd - xinput); |
| 3786 |
} |
| 3787 |
} |
| 3788 |
|
| 3789 |
return XXH_OK; |
| 3790 |
} |
| 3791 |
|
| 3792 |
|
| 3793 |
XXH_PUBLIC_API XXH64_hash_t XXH64_digest(XXH_NOESCAPE const XXH64_state_t *state) { |
| 3794 |
xxh_u64 h64; |
| 3795 |
|
| 3796 |
if (state->total_len >= 32) { |
| 3797 |
h64 = XXH64_mergeAccs(state->acc); |
| 3798 |
} else { |
| 3799 |
h64 = state->acc[2] + XXH_PRIME64_5; |
| 3800 |
} |
| 3801 |
|
| 3802 |
h64 += (xxh_u64)state->total_len; |
| 3803 |
|
| 3804 |
return XXH64_finalize(h64, state->buffer, (size_t)state->total_len, XXH_aligned); |
| 3805 |
} |
| 3806 |
# endif |
| 3807 |
|
| 3808 |
|
| 3809 |
|
| 3810 |
|
| 3811 |
XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH_NOESCAPE XXH64_canonical_t *dst, XXH64_hash_t hash) { |
| 3812 |
XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t)); |
| 3813 |
if (XXH_CPU_LITTLE_ENDIAN) |
| 3814 |
hash = XXH_swap64(hash); |
| 3815 |
XXH_memcpy(dst, &hash, sizeof(*dst)); |
| 3816 |
} |
| 3817 |
|
| 3818 |
|
| 3819 |
XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_canonical_t *src) { |
| 3820 |
return XXH_readBE64(src); |
| 3821 |
} |
| 3822 |
|
| 3823 |
# ifndef XXH_NO_XXH3 |
| 3824 |
|
| 3825 |
|
| 3826 |
|
| 3827 |
|
| 3828 |
|
| 3829 |
|
| 3830 |
|
| 3831 |
|
| 3832 |
|
| 3833 |
|
| 3834 |
|
| 3835 |
|
| 3836 |
|
| 3837 |
|
| 3838 |
# if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || \ |
| 3839 |
defined(__clang__) |
| 3840 |
# define XXH_likely(x) __builtin_expect(x, 1) |
| 3841 |
# define XXH_unlikely(x) __builtin_expect(x, 0) |
| 3842 |
# else |
| 3843 |
# define XXH_likely(x) (x) |
| 3844 |
# define XXH_unlikely(x) (x) |
| 3845 |
# endif |
| 3846 |
|
| 3847 |
# ifndef XXH_HAS_INCLUDE |
| 3848 |
# ifdef __has_include |
| 3849 |
|
| 3850 |
|
| 3851 |
|
| 3852 |
|
| 3853 |
# define XXH_HAS_INCLUDE __has_include |
| 3854 |
# else |
| 3855 |
# define XXH_HAS_INCLUDE(x) 0 |
| 3856 |
# endif |
| 3857 |
# endif |
| 3858 |
|
| 3859 |
# if defined(__GNUC__) || defined(__clang__) |
| 3860 |
# if defined(__ARM_FEATURE_SVE) |
| 3861 |
# include <arm_sve.h> |
| 3862 |
# endif |
| 3863 |
# if defined(__ARM_NEON__) || defined(__ARM_NEON) || (defined(_M_ARM) && _M_ARM >= 7) || \ |
| 3864 |
defined(_M_ARM64) || defined(_M_ARM64EC) || \ |
| 3865 |
(defined(__wasm_simd128__) && XXH_HAS_INCLUDE(<arm_neon.h>)) |
| 3866 |
# define inline __inline__ |
| 3867 |
# include <arm_neon.h> |
| 3868 |
# undef inline |
| 3869 |
# elif defined(__AVX2__) |
| 3870 |
# include <immintrin.h> |
| 3871 |
# elif defined(__SSE2__) |
| 3872 |
# include <emmintrin.h> |
| 3873 |
# elif defined(__loongarch_asx) |
| 3874 |
# include <lasxintrin.h> |
| 3875 |
# include <lsxintrin.h> |
| 3876 |
# elif defined(__loongarch_sx) |
| 3877 |
# include <lsxintrin.h> |
| 3878 |
# elif defined(__riscv_vector) |
| 3879 |
# include <riscv_vector.h> |
| 3880 |
# endif |
| 3881 |
# endif |
| 3882 |
|
| 3883 |
# if defined(_MSC_VER) |
| 3884 |
# include <intrin.h> |
| 3885 |
# endif |
| 3886 |
|
| 3887 |
|
| 3888 |
|
| 3889 |
|
| 3890 |
|
| 3891 |
|
| 3892 |
|
| 3893 |
|
| 3894 |
|
| 3895 |
|
| 3896 |
|
| 3897 |
|
| 3898 |
|
| 3899 |
|
| 3900 |
|
| 3901 |
|
| 3902 |
|
| 3903 |
|
| 3904 |
|
| 3905 |
|
| 3906 |
|
| 3907 |
|
| 3908 |
|
| 3909 |
|
| 3910 |
|
| 3911 |
|
| 3912 |
|
| 3913 |
|
| 3914 |
|
| 3915 |
|
| 3916 |
|
| 3917 |
|
| 3918 |
|
| 3919 |
|
| 3920 |
|
| 3921 |
|
| 3922 |
|
| 3923 |
|
| 3924 |
|
| 3925 |
|
| 3926 |
|
| 3927 |
|
| 3928 |
|
| 3929 |
|
| 3930 |
|
| 3931 |
|
| 3932 |
|
| 3933 |
|
| 3934 |
|
| 3935 |
|
| 3936 |
|
| 3937 |
|
| 3938 |
|
| 3939 |
|
| 3940 |
|
| 3941 |
|
| 3942 |
|
| 3943 |
|
| 3944 |
|
| 3945 |
|
| 3946 |
|
| 3947 |
|
| 3948 |
|
| 3949 |
|
| 3950 |
|
| 3951 |
|
| 3952 |
|
| 3953 |
|
| 3954 |
|
| 3955 |
|
| 3956 |
# if defined(__thumb__) && !defined(__thumb2__) && defined(__ARM_ARCH_ISA_ARM) |
| 3957 |
# warning "XXH3 is highly inefficient without ARM or Thumb-2." |
| 3958 |
# endif |
| 3959 |
|
| 3960 |
|
| 3961 |
|
| 3962 |
|
| 3963 |
|
| 3964 |
# ifdef XXH_DOXYGEN |
| 3965 |
|
| 3966 |
|
| 3967 |
|
| 3968 |
|
| 3969 |
|
| 3970 |
|
| 3971 |
|
| 3972 |
|
| 3973 |
|
| 3974 |
|
| 3975 |
# define XXH_VECTOR XXH_SCALAR |
| 3976 |
|
| 3977 |
|
| 3978 |
|
| 3979 |
|
| 3980 |
|
| 3981 |
|
| 3982 |
|
| 3983 |
|
| 3984 |
|
| 3985 |
# define XXH_ACC_ALIGN 8 |
| 3986 |
# endif |
| 3987 |
|
| 3988 |
|
| 3989 |
# ifndef XXH_DOXYGEN |
| 3990 |
# endif |
| 3991 |
|
| 3992 |
# ifndef XXH_VECTOR |
| 3993 |
# if ( \ |
| 3994 |
defined(__ARM_NEON__) || defined(__ARM_NEON) \ |
| 3995 |
|| defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) \ |
| 3996 |
|| (defined(__wasm_simd128__) && XXH_HAS_INCLUDE(<arm_neon.h>)) \ |
| 3997 |
) && \ |
| 3998 |
(defined(_WIN32) || defined(__LITTLE_ENDIAN__) \ |
| 3999 |
|| (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) |
| 4000 |
# define XXH_VECTOR XXH_NEON |
| 4001 |
# elif defined(__ARM_FEATURE_SVE) |
| 4002 |
# define XXH_VECTOR XXH_SVE |
| 4003 |
# elif defined(__AVX512F__) |
| 4004 |
# define XXH_VECTOR XXH_AVX512 |
| 4005 |
# elif defined(__AVX2__) |
| 4006 |
# define XXH_VECTOR XXH_AVX2 |
| 4007 |
# elif defined(__SSE2__) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP == 2)) |
| 4008 |
# define XXH_VECTOR XXH_SSE2 |
| 4009 |
# elif (defined(__PPC64__) && defined(__POWER8_VECTOR__)) || \ |
| 4010 |
(defined(__s390x__) && defined(__VEC__)) && defined(__GNUC__) |
| 4011 |
# define XXH_VECTOR XXH_VSX |
| 4012 |
# elif defined(__loongarch_asx) |
| 4013 |
# define XXH_VECTOR XXH_LASX |
| 4014 |
# elif defined(__loongarch_sx) |
| 4015 |
# define XXH_VECTOR XXH_LSX |
| 4016 |
# elif defined(__riscv_vector) |
| 4017 |
# define XXH_VECTOR XXH_RVV |
| 4018 |
# else |
| 4019 |
# define XXH_VECTOR XXH_SCALAR |
| 4020 |
# endif |
| 4021 |
# endif |
| 4022 |
|
| 4023 |
|
| 4024 |
# if (XXH_VECTOR == XXH_SVE) && !defined(__ARM_FEATURE_SVE) |
| 4025 |
# ifdef _MSC_VER |
| 4026 |
# pragma warning(once : 4606) |
| 4027 |
# else |
| 4028 |
# warning "__ARM_FEATURE_SVE isn't supported. Use SCALAR instead." |
| 4029 |
# endif |
| 4030 |
# undef XXH_VECTOR |
| 4031 |
# define XXH_VECTOR XXH_SCALAR |
| 4032 |
# endif |
| 4033 |
|
| 4034 |
|
| 4035 |
|
| 4036 |
|
| 4037 |
|
| 4038 |
# ifndef XXH_ACC_ALIGN |
| 4039 |
# if defined(XXH_X86DISPATCH) |
| 4040 |
# define XXH_ACC_ALIGN 64 |
| 4041 |
# elif XXH_VECTOR == XXH_SCALAR |
| 4042 |
# define XXH_ACC_ALIGN 8 |
| 4043 |
# elif XXH_VECTOR == XXH_SSE2 |
| 4044 |
# define XXH_ACC_ALIGN 16 |
| 4045 |
# elif XXH_VECTOR == XXH_AVX2 |
| 4046 |
# define XXH_ACC_ALIGN 32 |
| 4047 |
# elif XXH_VECTOR == XXH_NEON |
| 4048 |
# define XXH_ACC_ALIGN 16 |
| 4049 |
# elif XXH_VECTOR == XXH_VSX |
| 4050 |
# define XXH_ACC_ALIGN 16 |
| 4051 |
# elif XXH_VECTOR == XXH_AVX512 |
| 4052 |
# define XXH_ACC_ALIGN 64 |
| 4053 |
# elif XXH_VECTOR == XXH_SVE |
| 4054 |
# define XXH_ACC_ALIGN 64 |
| 4055 |
# elif XXH_VECTOR == XXH_LASX |
| 4056 |
# define XXH_ACC_ALIGN 64 |
| 4057 |
# elif XXH_VECTOR == XXH_LSX |
| 4058 |
# define XXH_ACC_ALIGN 64 |
| 4059 |
# elif XXH_VECTOR == XXH_RVV |
| 4060 |
# define XXH_ACC_ALIGN 64 |
| 4061 |
# endif |
| 4062 |
# endif |
| 4063 |
|
| 4064 |
# if defined(XXH_X86DISPATCH) || XXH_VECTOR == XXH_SSE2 || XXH_VECTOR == XXH_AVX2 || XXH_VECTOR == XXH_AVX512 |
| 4065 |
# define XXH_SEC_ALIGN XXH_ACC_ALIGN |
| 4066 |
# elif XXH_VECTOR == XXH_SVE |
| 4067 |
# define XXH_SEC_ALIGN XXH_ACC_ALIGN |
| 4068 |
# elif XXH_VECTOR == XXH_RVV |
| 4069 |
# define XXH_SEC_ALIGN XXH_ACC_ALIGN |
| 4070 |
# else |
| 4071 |
# define XXH_SEC_ALIGN 8 |
| 4072 |
# endif |
| 4073 |
|
| 4074 |
# if defined(__GNUC__) || defined(__clang__) |
| 4075 |
# define XXH_ALIASING __attribute__((__may_alias__)) |
| 4076 |
# else |
| 4077 |
# define XXH_ALIASING |
| 4078 |
# endif |
| 4079 |
|
| 4080 |
|
| 4081 |
|
| 4082 |
|
| 4083 |
|
| 4084 |
|
| 4085 |
|
| 4086 |
|
| 4087 |
|
| 4088 |
|
| 4089 |
|
| 4090 |
|
| 4091 |
|
| 4092 |
|
| 4093 |
|
| 4094 |
|
| 4095 |
|
| 4096 |
|
| 4097 |
|
| 4098 |
|
| 4099 |
|
| 4100 |
|
| 4101 |
# if XXH_VECTOR == XXH_AVX2 \ |
| 4102 |
&& defined(__GNUC__) && !defined(__clang__) \ |
| 4103 |
&& defined(__OPTIMIZE__) && XXH_SIZE_OPT <= 0 |
| 4104 |
# pragma GCC push_options |
| 4105 |
# pragma GCC optimize("-O2") |
| 4106 |
# endif |
| 4107 |
|
| 4108 |
# if XXH_VECTOR == XXH_NEON |
| 4109 |
|
| 4110 |
|
| 4111 |
|
| 4112 |
|
| 4113 |
|
| 4114 |
|
| 4115 |
|
| 4116 |
|
| 4117 |
typedef uint64x2_t xxh_aliasing_uint64x2_t XXH_ALIASING; |
| 4118 |
|
| 4119 |
|
| 4120 |
|
| 4121 |
|
| 4122 |
|
| 4123 |
|
| 4124 |
|
| 4125 |
|
| 4126 |
|
| 4127 |
|
| 4128 |
|
| 4129 |
|
| 4130 |
|
| 4131 |
|
| 4132 |
# if defined(__aarch64__) && defined(__GNUC__) && !defined(__clang__) |
| 4133 |
XXH_FORCE_INLINE uint64x2_t XXH_vld1q_u64(void const *ptr) |
| 4134 |
{ |
| 4135 |
return *(xxh_aliasing_uint64x2_t const *)ptr; |
| 4136 |
} |
| 4137 |
# else |
| 4138 |
XXH_FORCE_INLINE uint64x2_t XXH_vld1q_u64(void const *ptr) { |
| 4139 |
return vreinterpretq_u64_u8(vld1q_u8((uint8_t const *)ptr)); |
| 4140 |
} |
| 4141 |
# endif |
| 4142 |
|
| 4143 |
|
| 4144 |
|
| 4145 |
|
| 4146 |
|
| 4147 |
|
| 4148 |
|
| 4149 |
|
| 4150 |
|
| 4151 |
# if defined(__aarch64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 11 |
| 4152 |
XXH_FORCE_INLINE uint64x2_t XXH_vmlal_low_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) { |
| 4153 |
|
| 4154 |
__asm__("umlal %0.2d, %1.2s, %2.2s" : "+w"(acc) : "w"(lhs), "w"(rhs)); |
| 4155 |
return acc; |
| 4156 |
} |
| 4157 |
XXH_FORCE_INLINE uint64x2_t XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) { |
| 4158 |
|
| 4159 |
return vmlal_high_u32(acc, lhs, rhs); |
| 4160 |
} |
| 4161 |
# else |
| 4162 |
|
| 4163 |
XXH_FORCE_INLINE uint64x2_t XXH_vmlal_low_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) { |
| 4164 |
return vmlal_u32(acc, vget_low_u32(lhs), vget_low_u32(rhs)); |
| 4165 |
} |
| 4166 |
|
| 4167 |
|
| 4168 |
XXH_FORCE_INLINE uint64x2_t XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) { |
| 4169 |
return vmlal_u32(acc, vget_high_u32(lhs), vget_high_u32(rhs)); |
| 4170 |
} |
| 4171 |
# endif |
| 4172 |
|
| 4173 |
|
| 4174 |
|
| 4175 |
|
| 4176 |
|
| 4177 |
|
| 4178 |
|
| 4179 |
|
| 4180 |
|
| 4181 |
|
| 4182 |
|
| 4183 |
|
| 4184 |
|
| 4185 |
|
| 4186 |
|
| 4187 |
|
| 4188 |
|
| 4189 |
|
| 4190 |
|
| 4191 |
|
| 4192 |
|
| 4193 |
|
| 4194 |
|
| 4195 |
|
| 4196 |
|
| 4197 |
|
| 4198 |
|
| 4199 |
|
| 4200 |
|
| 4201 |
|
| 4202 |
|
| 4203 |
|
| 4204 |
|
| 4205 |
|
| 4206 |
|
| 4207 |
|
| 4208 |
|
| 4209 |
|
| 4210 |
|
| 4211 |
# ifndef XXH3_NEON_LANES |
| 4212 |
# if (defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || defined(_M_ARM64EC)) && \ |
| 4213 |
!defined(__APPLE__) && XXH_SIZE_OPT <= 0 |
| 4214 |
# define XXH3_NEON_LANES 6 |
| 4215 |
# else |
| 4216 |
# define XXH3_NEON_LANES XXH_ACC_NB |
| 4217 |
# endif |
| 4218 |
# endif |
| 4219 |
# endif |
| 4220 |
|
| 4221 |
|
| 4222 |
|
| 4223 |
|
| 4224 |
|
| 4225 |
|
| 4226 |
|
| 4227 |
|
| 4228 |
|
| 4229 |
# if XXH_VECTOR == XXH_VSX |
| 4230 |
|
| 4231 |
|
| 4232 |
|
| 4233 |
|
| 4234 |
|
| 4235 |
|
| 4236 |
|
| 4237 |
|
| 4238 |
# pragma push_macro("bool") |
| 4239 |
# pragma push_macro("vector") |
| 4240 |
# pragma push_macro("pixel") |
| 4241 |
|
| 4242 |
# undef bool |
| 4243 |
# undef vector |
| 4244 |
# undef pixel |
| 4245 |
|
| 4246 |
# if defined(__s390x__) |
| 4247 |
# include <s390intrin.h> |
| 4248 |
# else |
| 4249 |
# include <altivec.h> |
| 4250 |
# endif |
| 4251 |
|
| 4252 |
|
| 4253 |
# pragma pop_macro("pixel") |
| 4254 |
# pragma pop_macro("vector") |
| 4255 |
# pragma pop_macro("bool") |
| 4256 |
|
| 4257 |
typedef __vector unsigned long long xxh_u64x2; |
| 4258 |
typedef __vector unsigned char xxh_u8x16; |
| 4259 |
typedef __vector unsigned xxh_u32x4; |
| 4260 |
|
| 4261 |
|
| 4262 |
|
| 4263 |
|
| 4264 |
typedef xxh_u64x2 xxh_aliasing_u64x2 XXH_ALIASING; |
| 4265 |
|
| 4266 |
# ifndef XXH_VSX_BE |
| 4267 |
# if defined(__BIG_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) |
| 4268 |
# define XXH_VSX_BE 1 |
| 4269 |
# elif defined(__VEC_ELEMENT_REG_ORDER__) && __VEC_ELEMENT_REG_ORDER__ == __ORDER_BIG_ENDIAN__ |
| 4270 |
# warning "-maltivec=be is not recommended. Please use native endianness." |
| 4271 |
# define XXH_VSX_BE 1 |
| 4272 |
# else |
| 4273 |
# define XXH_VSX_BE 0 |
| 4274 |
# endif |
| 4275 |
# endif |
| 4276 |
|
| 4277 |
# if XXH_VSX_BE |
| 4278 |
# if defined(__POWER9_VECTOR__) || (defined(__clang__) && defined(__s390x__)) |
| 4279 |
# define XXH_vec_revb vec_revb |
| 4280 |
# else |
| 4281 |
|
| 4282 |
|
| 4283 |
|
| 4284 |
XXH_FORCE_INLINE xxh_u64x2 XXH_vec_revb(xxh_u64x2 val) { |
| 4285 |
xxh_u8x16 const vByteSwap = { |
| 4286 |
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08}; |
| 4287 |
return vec_perm(val, val, vByteSwap); |
| 4288 |
} |
| 4289 |
# endif |
| 4290 |
# endif |
| 4291 |
|
| 4292 |
|
| 4293 |
|
| 4294 |
|
| 4295 |
XXH_FORCE_INLINE xxh_u64x2 XXH_vec_loadu(const void *ptr) { |
| 4296 |
xxh_u64x2 ret; |
| 4297 |
XXH_memcpy(&ret, ptr, sizeof(xxh_u64x2)); |
| 4298 |
# if XXH_VSX_BE |
| 4299 |
ret = XXH_vec_revb(ret); |
| 4300 |
# endif |
| 4301 |
return ret; |
| 4302 |
} |
| 4303 |
|
| 4304 |
|
| 4305 |
|
| 4306 |
|
| 4307 |
|
| 4308 |
|
| 4309 |
|
| 4310 |
# if defined(__s390x__) |
| 4311 |
|
| 4312 |
# define XXH_vec_mulo vec_mulo |
| 4313 |
# define XXH_vec_mule vec_mule |
| 4314 |
# elif defined(__clang__) && XXH_HAS_BUILTIN(__builtin_altivec_vmuleuw) && !defined(__ibmxl__) |
| 4315 |
|
| 4316 |
|
| 4317 |
# define XXH_vec_mulo __builtin_altivec_vmulouw |
| 4318 |
# define XXH_vec_mule __builtin_altivec_vmuleuw |
| 4319 |
# else |
| 4320 |
|
| 4321 |
|
| 4322 |
XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mulo(xxh_u32x4 a, xxh_u32x4 b) { |
| 4323 |
xxh_u64x2 result; |
| 4324 |
__asm__("vmulouw %0, %1, %2" : "=v"(result) : "v"(a), "v"(b)); |
| 4325 |
return result; |
| 4326 |
} |
| 4327 |
XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b) { |
| 4328 |
xxh_u64x2 result; |
| 4329 |
__asm__("vmuleuw %0, %1, %2" : "=v"(result) : "v"(a), "v"(b)); |
| 4330 |
return result; |
| 4331 |
} |
| 4332 |
# endif |
| 4333 |
# endif |
| 4334 |
|
| 4335 |
# if XXH_VECTOR == XXH_SVE |
| 4336 |
# define ACCRND(acc, offset) \ |
| 4337 |
do { \ |
| 4338 |
svuint64_t input_vec = svld1_u64(mask, xinput + offset); \ |
| 4339 |
svuint64_t secret_vec = svld1_u64(mask, xsecret + offset); \ |
| 4340 |
svuint64_t mixed = sveor_u64_x(mask, secret_vec, input_vec); \ |
| 4341 |
svuint64_t swapped = svtbl_u64(input_vec, kSwap); \ |
| 4342 |
svuint64_t mixed_lo = svextw_u64_x(mask, mixed); \ |
| 4343 |
svuint64_t mixed_hi = svlsr_n_u64_x(mask, mixed, 32); \ |
| 4344 |
svuint64_t mul = svmad_u64_x(mask, mixed_lo, mixed_hi, swapped); \ |
| 4345 |
acc = svadd_u64_x(mask, acc, mul); \ |
| 4346 |
} while (0) |
| 4347 |
# endif |
| 4348 |
|
| 4349 |
|
| 4350 |
|
| 4351 |
# if defined(XXH_NO_PREFETCH) |
| 4352 |
# define XXH_PREFETCH(ptr) (void)(ptr) |
| 4353 |
# else |
| 4354 |
# if XXH_SIZE_OPT >= 1 |
| 4355 |
# define XXH_PREFETCH(ptr) (void)(ptr) |
| 4356 |
# elif defined(_MSC_VER) && \ |
| 4357 |
(defined(_M_X64) || defined(_M_IX86)) |
| 4358 |
# include <mmintrin.h> |
| 4359 |
# define XXH_PREFETCH(ptr) _mm_prefetch((const char *)(ptr), _MM_HINT_T0) |
| 4360 |
# elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) |
| 4361 |
# define XXH_PREFETCH(ptr) __builtin_prefetch((ptr), 0 , 3 ) |
| 4362 |
# else |
| 4363 |
# define XXH_PREFETCH(ptr) (void)(ptr) |
| 4364 |
# endif |
| 4365 |
# endif |
| 4366 |
|
| 4367 |
|
| 4368 |
|
| 4369 |
|
| 4370 |
|
| 4371 |
# define XXH_SECRET_DEFAULT_SIZE 192 |
| 4372 |
|
| 4373 |
# if (XXH_SECRET_DEFAULT_SIZE < XXH3_SECRET_SIZE_MIN) |
| 4374 |
# error "default keyset is not large enough" |
| 4375 |
# endif |
| 4376 |
|
| 4377 |
|
| 4378 |
|
| 4379 |
|
| 4380 |
|
| 4381 |
XXH_ALIGN(64) |
| 4382 |
static const xxh_u8 XXH3_kSecret[XXH_SECRET_DEFAULT_SIZE] = { |
| 4383 |
0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c, 0xde, 0xd4, |
| 4384 |
0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f, 0xcb, 0x79, 0xe6, 0x4e, |
| 4385 |
0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21, 0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, |
| 4386 |
0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c, 0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, |
| 4387 |
0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3, 0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, |
| 4388 |
0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8, 0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, |
| 4389 |
0xc7, 0x0b, 0x4f, 0x1d, 0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, |
| 4390 |
0x73, 0x64, 0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb, |
| 4391 |
0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e, 0x2b, 0x16, |
| 4392 |
0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce, 0x45, 0xcb, 0x3a, 0x8f, |
| 4393 |
0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e, |
| 4394 |
}; |
| 4395 |
|
| 4396 |
static const xxh_u64 PRIME_MX1 = |
| 4397 |
0x165667919E3779F9ULL; |
| 4398 |
static const xxh_u64 PRIME_MX2 = |
| 4399 |
0x9FB21C651E98DF25ULL; |
| 4400 |
|
| 4401 |
# ifdef XXH_OLD_NAMES |
| 4402 |
# define kSecret XXH3_kSecret |
| 4403 |
# endif |
| 4404 |
|
| 4405 |
# ifdef XXH_DOXYGEN |
| 4406 |
|
| 4407 |
|
| 4408 |
|
| 4409 |
|
| 4410 |
|
| 4411 |
|
| 4412 |
|
| 4413 |
|
| 4414 |
|
| 4415 |
|
| 4416 |
|
| 4417 |
|
| 4418 |
|
| 4419 |
|
| 4420 |
|
| 4421 |
|
| 4422 |
XXH_FORCE_INLINE xxh_u64 XXH_mult32to64(xxh_u64 x, xxh_u64 y) { |
| 4423 |
return (x & 0xFFFFFFFF) * (y & 0xFFFFFFFF); |
| 4424 |
} |
| 4425 |
# elif defined(_MSC_VER) && defined(_M_IX86) |
| 4426 |
# define XXH_mult32to64(x, y) __emulu((unsigned)(x), (unsigned)(y)) |
| 4427 |
# else |
| 4428 |
|
| 4429 |
|
| 4430 |
|
| 4431 |
|
| 4432 |
|
| 4433 |
|
| 4434 |
|
| 4435 |
# define XXH_mult32to64(x, y) ((xxh_u64)(xxh_u32)(x) * (xxh_u64)(xxh_u32)(y)) |
| 4436 |
# endif |
| 4437 |
|
| 4438 |
|
| 4439 |
|
| 4440 |
|
| 4441 |
|
| 4442 |
|
| 4443 |
|
| 4444 |
|
| 4445 |
|
| 4446 |
|
| 4447 |
static XXH128_hash_t XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs) { |
| 4448 |
|
| 4449 |
|
| 4450 |
|
| 4451 |
|
| 4452 |
|
| 4453 |
|
| 4454 |
|
| 4455 |
|
| 4456 |
|
| 4457 |
|
| 4458 |
|
| 4459 |
|
| 4460 |
|
| 4461 |
|
| 4462 |
|
| 4463 |
# if (defined(__GNUC__) || defined(__clang__)) && !defined(__wasm__) && defined(__SIZEOF_INT128__) || \ |
| 4464 |
(defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 128) |
| 4465 |
|
| 4466 |
__uint128_t const product = (__uint128_t)lhs * (__uint128_t)rhs; |
| 4467 |
XXH128_hash_t r128; |
| 4468 |
r128.low64 = (xxh_u64)(product); |
| 4469 |
r128.high64 = (xxh_u64)(product >> 64); |
| 4470 |
return r128; |
| 4471 |
|
| 4472 |
|
| 4473 |
|
| 4474 |
|
| 4475 |
|
| 4476 |
|
| 4477 |
|
| 4478 |
|
| 4479 |
# elif (defined(_M_X64) || defined(_M_IA64)) && !defined(_M_ARM64EC) |
| 4480 |
|
| 4481 |
# ifndef _MSC_VER |
| 4482 |
# pragma intrinsic(_umul128) |
| 4483 |
# endif |
| 4484 |
xxh_u64 product_high; |
| 4485 |
xxh_u64 const product_low = _umul128(lhs, rhs, &product_high); |
| 4486 |
XXH128_hash_t r128; |
| 4487 |
r128.low64 = product_low; |
| 4488 |
r128.high64 = product_high; |
| 4489 |
return r128; |
| 4490 |
|
| 4491 |
|
| 4492 |
|
| 4493 |
|
| 4494 |
|
| 4495 |
|
| 4496 |
# elif defined(_M_ARM64) || defined(_M_ARM64EC) |
| 4497 |
|
| 4498 |
# ifndef _MSC_VER |
| 4499 |
# pragma intrinsic(__umulh) |
| 4500 |
# endif |
| 4501 |
XXH128_hash_t r128; |
| 4502 |
r128.low64 = lhs * rhs; |
| 4503 |
r128.high64 = __umulh(lhs, rhs); |
| 4504 |
return r128; |
| 4505 |
|
| 4506 |
# else |
| 4507 |
|
| 4508 |
|
| 4509 |
|
| 4510 |
|
| 4511 |
|
| 4512 |
|
| 4513 |
|
| 4514 |
|
| 4515 |
|
| 4516 |
|
| 4517 |
|
| 4518 |
|
| 4519 |
|
| 4520 |
|
| 4521 |
|
| 4522 |
|
| 4523 |
|
| 4524 |
|
| 4525 |
|
| 4526 |
|
| 4527 |
|
| 4528 |
|
| 4529 |
|
| 4530 |
|
| 4531 |
|
| 4532 |
|
| 4533 |
|
| 4534 |
|
| 4535 |
|
| 4536 |
|
| 4537 |
|
| 4538 |
|
| 4539 |
|
| 4540 |
|
| 4541 |
|
| 4542 |
|
| 4543 |
|
| 4544 |
|
| 4545 |
|
| 4546 |
|
| 4547 |
|
| 4548 |
|
| 4549 |
|
| 4550 |
|
| 4551 |
xxh_u64 const lo_lo = XXH_mult32to64(lhs & 0xFFFFFFFF, rhs & 0xFFFFFFFF); |
| 4552 |
xxh_u64 const hi_lo = XXH_mult32to64(lhs >> 32, rhs & 0xFFFFFFFF); |
| 4553 |
xxh_u64 const lo_hi = XXH_mult32to64(lhs & 0xFFFFFFFF, rhs >> 32); |
| 4554 |
xxh_u64 const hi_hi = XXH_mult32to64(lhs >> 32, rhs >> 32); |
| 4555 |
|
| 4556 |
|
| 4557 |
xxh_u64 const cross = (lo_lo >> 32) + (hi_lo & 0xFFFFFFFF) + lo_hi; |
| 4558 |
xxh_u64 const upper = (hi_lo >> 32) + (cross >> 32) + hi_hi; |
| 4559 |
xxh_u64 const lower = (cross << 32) | (lo_lo & 0xFFFFFFFF); |
| 4560 |
|
| 4561 |
XXH128_hash_t r128; |
| 4562 |
r128.low64 = lower; |
| 4563 |
r128.high64 = upper; |
| 4564 |
return r128; |
| 4565 |
# endif |
| 4566 |
} |
| 4567 |
|
| 4568 |
|
| 4569 |
|
| 4570 |
|
| 4571 |
|
| 4572 |
|
| 4573 |
|
| 4574 |
|
| 4575 |
|
| 4576 |
|
| 4577 |
|
| 4578 |
static xxh_u64 XXH3_mul128_fold64(xxh_u64 lhs, xxh_u64 rhs) { |
| 4579 |
XXH128_hash_t product = XXH_mult64to128(lhs, rhs); |
| 4580 |
return product.low64 ^ product.high64; |
| 4581 |
} |
| 4582 |
|
| 4583 |
|
| 4584 |
XXH_FORCE_INLINE XXH_CONSTF xxh_u64 XXH_xorshift64(xxh_u64 v64, int shift) { |
| 4585 |
XXH_ASSERT(0 <= shift && shift < 64); |
| 4586 |
return v64 ^ (v64 >> shift); |
| 4587 |
} |
| 4588 |
|
| 4589 |
|
| 4590 |
|
| 4591 |
|
| 4592 |
|
| 4593 |
static XXH64_hash_t XXH3_avalanche(xxh_u64 h64) { |
| 4594 |
h64 = XXH_xorshift64(h64, 37); |
| 4595 |
h64 *= PRIME_MX1; |
| 4596 |
h64 = XXH_xorshift64(h64, 32); |
| 4597 |
return h64; |
| 4598 |
} |
| 4599 |
|
| 4600 |
|
| 4601 |
|
| 4602 |
|
| 4603 |
|
| 4604 |
|
| 4605 |
static XXH64_hash_t XXH3_rrmxmx(xxh_u64 h64, xxh_u64 len) { |
| 4606 |
|
| 4607 |
h64 ^= XXH_rotl64(h64, 49) ^ XXH_rotl64(h64, 24); |
| 4608 |
h64 *= PRIME_MX2; |
| 4609 |
h64 ^= (h64 >> 35) + len; |
| 4610 |
h64 *= PRIME_MX2; |
| 4611 |
return XXH_xorshift64(h64, 28); |
| 4612 |
} |
| 4613 |
|
| 4614 |
|
| 4615 |
|
| 4616 |
|
| 4617 |
|
| 4618 |
|
| 4619 |
|
| 4620 |
|
| 4621 |
|
| 4622 |
|
| 4623 |
|
| 4624 |
|
| 4625 |
|
| 4626 |
|
| 4627 |
|
| 4628 |
|
| 4629 |
|
| 4630 |
|
| 4631 |
|
| 4632 |
|
| 4633 |
|
| 4634 |
|
| 4635 |
|
| 4636 |
|
| 4637 |
|
| 4638 |
|
| 4639 |
|
| 4640 |
|
| 4641 |
|
| 4642 |
|
| 4643 |
|
| 4644 |
|
| 4645 |
|
| 4646 |
|
| 4647 |
XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t |
| 4648 |
XXH3_len_1to3_64b(const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) { |
| 4649 |
XXH_ASSERT(input != NULL); |
| 4650 |
XXH_ASSERT(1 <= len && len <= 3); |
| 4651 |
XXH_ASSERT(secret != NULL); |
| 4652 |
|
| 4653 |
|
| 4654 |
|
| 4655 |
|
| 4656 |
|
| 4657 |
{ |
| 4658 |
xxh_u8 const c1 = input[0]; |
| 4659 |
xxh_u8 const c2 = input[len >> 1]; |
| 4660 |
xxh_u8 const c3 = input[len - 1]; |
| 4661 |
xxh_u32 const combined = ((xxh_u32)c1 << 16) | ((xxh_u32)c2 << 24) | ((xxh_u32)c3 << 0) | ((xxh_u32)len << 8); |
| 4662 |
xxh_u64 const bitflip = (XXH_readLE32(secret) ^ XXH_readLE32(secret + 4)) + seed; |
| 4663 |
xxh_u64 const keyed = (xxh_u64)combined ^ bitflip; |
| 4664 |
return XXH64_avalanche(keyed); |
| 4665 |
} |
| 4666 |
} |
| 4667 |
|
| 4668 |
XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t |
| 4669 |
XXH3_len_4to8_64b(const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) { |
| 4670 |
XXH_ASSERT(input != NULL); |
| 4671 |
XXH_ASSERT(secret != NULL); |
| 4672 |
XXH_ASSERT(4 <= len && len <= 8); |
| 4673 |
seed ^= (xxh_u64)XXH_swap32((xxh_u32)seed) << 32; |
| 4674 |
{ |
| 4675 |
xxh_u32 const input1 = XXH_readLE32(input); |
| 4676 |
xxh_u32 const input2 = XXH_readLE32(input + len - 4); |
| 4677 |
xxh_u64 const bitflip = (XXH_readLE64(secret + 8) ^ XXH_readLE64(secret + 16)) - seed; |
| 4678 |
xxh_u64 const input64 = input2 + (((xxh_u64)input1) << 32); |
| 4679 |
xxh_u64 const keyed = input64 ^ bitflip; |
| 4680 |
return XXH3_rrmxmx(keyed, len); |
| 4681 |
} |
| 4682 |
} |
| 4683 |
|
| 4684 |
XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t |
| 4685 |
XXH3_len_9to16_64b(const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) { |
| 4686 |
XXH_ASSERT(input != NULL); |
| 4687 |
XXH_ASSERT(secret != NULL); |
| 4688 |
XXH_ASSERT(9 <= len && len <= 16); |
| 4689 |
{ |
| 4690 |
xxh_u64 const bitflip1 = (XXH_readLE64(secret + 24) ^ XXH_readLE64(secret + 32)) + seed; |
| 4691 |
xxh_u64 const bitflip2 = (XXH_readLE64(secret + 40) ^ XXH_readLE64(secret + 48)) - seed; |
| 4692 |
xxh_u64 const input_lo = XXH_readLE64(input) ^ bitflip1; |
| 4693 |
xxh_u64 const input_hi = XXH_readLE64(input + len - 8) ^ bitflip2; |
| 4694 |
xxh_u64 const acc = len + XXH_swap64(input_lo) + input_hi + XXH3_mul128_fold64(input_lo, input_hi); |
| 4695 |
return XXH3_avalanche(acc); |
| 4696 |
} |
| 4697 |
} |
| 4698 |
|
| 4699 |
XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t |
| 4700 |
XXH3_len_0to16_64b(const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) { |
| 4701 |
XXH_ASSERT(len <= 16); |
| 4702 |
{ |
| 4703 |
if (XXH_likely(len > 8)) |
| 4704 |
return XXH3_len_9to16_64b(input, len, secret, seed); |
| 4705 |
if (XXH_likely(len >= 4)) |
| 4706 |
return XXH3_len_4to8_64b(input, len, secret, seed); |
| 4707 |
if (len) |
| 4708 |
return XXH3_len_1to3_64b(input, len, secret, seed); |
| 4709 |
return XXH64_avalanche(seed ^ (XXH_readLE64(secret + 56) ^ XXH_readLE64(secret + 64))); |
| 4710 |
} |
| 4711 |
} |
| 4712 |
|
| 4713 |
|
| 4714 |
|
| 4715 |
|
| 4716 |
|
| 4717 |
|
| 4718 |
|
| 4719 |
|
| 4720 |
|
| 4721 |
|
| 4722 |
|
| 4723 |
|
| 4724 |
|
| 4725 |
|
| 4726 |
|
| 4727 |
|
| 4728 |
|
| 4729 |
|
| 4730 |
|
| 4731 |
|
| 4732 |
|
| 4733 |
|
| 4734 |
|
| 4735 |
|
| 4736 |
|
| 4737 |
|
| 4738 |
|
| 4739 |
XXH_FORCE_INLINE xxh_u64 |
| 4740 |
XXH3_mix16B(const xxh_u8 *XXH_RESTRICT input, const xxh_u8 *XXH_RESTRICT secret, xxh_u64 seed64) { |
| 4741 |
# if defined(__GNUC__) && !defined(__clang__) \ |
| 4742 |
&& defined(__i386__) && defined(__SSE2__) \ |
| 4743 |
&& !defined(XXH_ENABLE_AUTOVECTORIZE) |
| 4744 |
|
| 4745 |
|
| 4746 |
|
| 4747 |
|
| 4748 |
|
| 4749 |
|
| 4750 |
|
| 4751 |
|
| 4752 |
|
| 4753 |
|
| 4754 |
|
| 4755 |
|
| 4756 |
|
| 4757 |
|
| 4758 |
|
| 4759 |
XXH_COMPILER_GUARD(seed64); |
| 4760 |
# endif |
| 4761 |
{ |
| 4762 |
xxh_u64 const input_lo = XXH_readLE64(input); |
| 4763 |
xxh_u64 const input_hi = XXH_readLE64(input + 8); |
| 4764 |
return XXH3_mul128_fold64( |
| 4765 |
input_lo ^ (XXH_readLE64(secret) + seed64), input_hi ^ (XXH_readLE64(secret + 8) - seed64)); |
| 4766 |
} |
| 4767 |
} |
| 4768 |
|
| 4769 |
|
| 4770 |
XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t XXH3_len_17to128_64b( |
| 4771 |
const xxh_u8 *XXH_RESTRICT input, |
| 4772 |
size_t len, |
| 4773 |
const xxh_u8 *XXH_RESTRICT secret, |
| 4774 |
size_t secretSize, |
| 4775 |
XXH64_hash_t seed) { |
| 4776 |
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); |
| 4777 |
(void)secretSize; |
| 4778 |
XXH_ASSERT(16 < len && len <= 128); |
| 4779 |
|
| 4780 |
{ |
| 4781 |
xxh_u64 acc = len * XXH_PRIME64_1; |
| 4782 |
# if XXH_SIZE_OPT >= 1 |
| 4783 |
|
| 4784 |
unsigned int i = (unsigned int)(len - 1) / 32; |
| 4785 |
do { |
| 4786 |
acc += XXH3_mix16B(input + 16 * i, secret + 32 * i, seed); |
| 4787 |
acc += XXH3_mix16B(input + len - 16 * (i + 1), secret + 32 * i + 16, seed); |
| 4788 |
} while (i-- != 0); |
| 4789 |
# else |
| 4790 |
if (len > 32) { |
| 4791 |
if (len > 64) { |
| 4792 |
if (len > 96) { |
| 4793 |
acc += XXH3_mix16B(input + 48, secret + 96, seed); |
| 4794 |
acc += XXH3_mix16B(input + len - 64, secret + 112, seed); |
| 4795 |
} |
| 4796 |
acc += XXH3_mix16B(input + 32, secret + 64, seed); |
| 4797 |
acc += XXH3_mix16B(input + len - 48, secret + 80, seed); |
| 4798 |
} |
| 4799 |
acc += XXH3_mix16B(input + 16, secret + 32, seed); |
| 4800 |
acc += XXH3_mix16B(input + len - 32, secret + 48, seed); |
| 4801 |
} |
| 4802 |
acc += XXH3_mix16B(input + 0, secret + 0, seed); |
| 4803 |
acc += XXH3_mix16B(input + len - 16, secret + 16, seed); |
| 4804 |
# endif |
| 4805 |
return XXH3_avalanche(acc); |
| 4806 |
} |
| 4807 |
} |
| 4808 |
|
| 4809 |
XXH_NO_INLINE XXH_PUREF XXH64_hash_t XXH3_len_129to240_64b( |
| 4810 |
const xxh_u8 *XXH_RESTRICT input, |
| 4811 |
size_t len, |
| 4812 |
const xxh_u8 *XXH_RESTRICT secret, |
| 4813 |
size_t secretSize, |
| 4814 |
XXH64_hash_t seed) { |
| 4815 |
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); |
| 4816 |
(void)secretSize; |
| 4817 |
XXH_ASSERT(128 < len && len <= XXH3_MIDSIZE_MAX); |
| 4818 |
|
| 4819 |
# define XXH3_MIDSIZE_STARTOFFSET 3 |
| 4820 |
# define XXH3_MIDSIZE_LASTOFFSET 17 |
| 4821 |
|
| 4822 |
{ |
| 4823 |
xxh_u64 acc = len * XXH_PRIME64_1; |
| 4824 |
xxh_u64 acc_end; |
| 4825 |
unsigned int const nbRounds = (unsigned int)len / 16; |
| 4826 |
unsigned int i; |
| 4827 |
XXH_ASSERT(128 < len && len <= XXH3_MIDSIZE_MAX); |
| 4828 |
for (i = 0; i < 8; i++) { |
| 4829 |
acc += XXH3_mix16B(input + (16 * i), secret + (16 * i), seed); |
| 4830 |
} |
| 4831 |
|
| 4832 |
acc_end = XXH3_mix16B(input + len - 16, secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET, seed); |
| 4833 |
XXH_ASSERT(nbRounds >= 8); |
| 4834 |
acc = XXH3_avalanche(acc); |
| 4835 |
# if defined(__clang__) \ |
| 4836 |
&& (defined(__ARM_NEON) || defined(__ARM_NEON__)) \ |
| 4837 |
&& !defined(XXH_ENABLE_AUTOVECTORIZE) |
| 4838 |
|
| 4839 |
|
| 4840 |
|
| 4841 |
|
| 4842 |
|
| 4843 |
|
| 4844 |
|
| 4845 |
|
| 4846 |
|
| 4847 |
|
| 4848 |
|
| 4849 |
|
| 4850 |
|
| 4851 |
|
| 4852 |
|
| 4853 |
|
| 4854 |
|
| 4855 |
|
| 4856 |
|
| 4857 |
|
| 4858 |
# pragma clang loop vectorize(disable) |
| 4859 |
# endif |
| 4860 |
for (i = 8; i < nbRounds; i++) { |
| 4861 |
|
| 4862 |
|
| 4863 |
|
| 4864 |
XXH_COMPILER_GUARD(acc); |
| 4865 |
acc_end += XXH3_mix16B(input + (16 * i), secret + (16 * (i - 8)) + XXH3_MIDSIZE_STARTOFFSET, seed); |
| 4866 |
} |
| 4867 |
return XXH3_avalanche(acc + acc_end); |
| 4868 |
} |
| 4869 |
} |
| 4870 |
|
| 4871 |
|
| 4872 |
|
| 4873 |
# define XXH_STRIPE_LEN 64 |
| 4874 |
# define XXH_SECRET_CONSUME_RATE 8 |
| 4875 |
# define XXH_ACC_NB (XXH_STRIPE_LEN / sizeof(xxh_u64)) |
| 4876 |
|
| 4877 |
# ifdef XXH_OLD_NAMES |
| 4878 |
# define STRIPE_LEN XXH_STRIPE_LEN |
| 4879 |
# define ACC_NB XXH_ACC_NB |
| 4880 |
# endif |
| 4881 |
|
| 4882 |
# ifndef XXH_PREFETCH_DIST |
| 4883 |
# ifdef __clang__ |
| 4884 |
# define XXH_PREFETCH_DIST 320 |
| 4885 |
# else |
| 4886 |
# if (XXH_VECTOR == XXH_AVX512) |
| 4887 |
# define XXH_PREFETCH_DIST 512 |
| 4888 |
# else |
| 4889 |
# define XXH_PREFETCH_DIST 384 |
| 4890 |
# endif |
| 4891 |
# endif |
| 4892 |
# endif |
| 4893 |
|
| 4894 |
|
| 4895 |
|
| 4896 |
|
| 4897 |
|
| 4898 |
|
| 4899 |
|
| 4900 |
|
| 4901 |
|
| 4902 |
|
| 4903 |
|
| 4904 |
# define XXH3_ACCUMULATE_TEMPLATE(name) \ |
| 4905 |
void XXH3_accumulate_##name( \ |
| 4906 |
xxh_u64 *XXH_RESTRICT acc, \ |
| 4907 |
const xxh_u8 *XXH_RESTRICT input, \ |
| 4908 |
const xxh_u8 *XXH_RESTRICT secret, \ |
| 4909 |
size_t nbStripes) { \ |
| 4910 |
size_t n; \ |
| 4911 |
for (n = 0; n < nbStripes; n++) { \ |
| 4912 |
const xxh_u8 *const in = input + n * XXH_STRIPE_LEN; \ |
| 4913 |
XXH_PREFETCH(in + XXH_PREFETCH_DIST); \ |
| 4914 |
XXH3_accumulate_512_##name(acc, in, secret + n * XXH_SECRET_CONSUME_RATE); \ |
| 4915 |
} \ |
| 4916 |
} |
| 4917 |
|
| 4918 |
XXH_FORCE_INLINE void XXH_writeLE64(void *dst, xxh_u64 v64) { |
| 4919 |
if (!XXH_CPU_LITTLE_ENDIAN) |
| 4920 |
v64 = XXH_swap64(v64); |
| 4921 |
XXH_memcpy(dst, &v64, sizeof(v64)); |
| 4922 |
} |
| 4923 |
|
| 4924 |
|
| 4925 |
|
| 4926 |
|
| 4927 |
|
| 4928 |
|
| 4929 |
# if !defined(__VMS) && \ |
| 4930 |
(defined(__cplusplus) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) )) |
| 4931 |
typedef int64_t xxh_i64; |
| 4932 |
# else |
| 4933 |
|
| 4934 |
typedef long long xxh_i64; |
| 4935 |
# endif |
| 4936 |
|
| 4937 |
|
| 4938 |
|
| 4939 |
|
| 4940 |
|
| 4941 |
|
| 4942 |
|
| 4943 |
|
| 4944 |
|
| 4945 |
|
| 4946 |
|
| 4947 |
|
| 4948 |
|
| 4949 |
|
| 4950 |
|
| 4951 |
|
| 4952 |
|
| 4953 |
|
| 4954 |
|
| 4955 |
|
| 4956 |
|
| 4957 |
|
| 4958 |
|
| 4959 |
|
| 4960 |
# if (XXH_VECTOR == XXH_AVX512) || (defined(XXH_DISPATCH_AVX512) && XXH_DISPATCH_AVX512 != 0) |
| 4961 |
|
| 4962 |
# ifndef XXH_TARGET_AVX512 |
| 4963 |
# define XXH_TARGET_AVX512 |
| 4964 |
# endif |
| 4965 |
|
| 4966 |
XXH_FORCE_INLINE XXH_TARGET_AVX512 void XXH3_accumulate_512_avx512( |
| 4967 |
void *XXH_RESTRICT acc, |
| 4968 |
const void *XXH_RESTRICT input, |
| 4969 |
const void *XXH_RESTRICT secret) { |
| 4970 |
__m512i *const xacc = (__m512i *)acc; |
| 4971 |
XXH_ASSERT((((size_t)acc) & 63) == 0); |
| 4972 |
XXH_STATIC_ASSERT(XXH_STRIPE_LEN == sizeof(__m512i)); |
| 4973 |
|
| 4974 |
{ |
| 4975 |
|
| 4976 |
__m512i const data_vec = _mm512_loadu_si512(input); |
| 4977 |
|
| 4978 |
__m512i const key_vec = _mm512_loadu_si512(secret); |
| 4979 |
|
| 4980 |
__m512i const data_key = _mm512_xor_si512(data_vec, key_vec); |
| 4981 |
|
| 4982 |
__m512i const data_key_lo = _mm512_srli_epi64(data_key, 32); |
| 4983 |
|
| 4984 |
__m512i const product = _mm512_mul_epu32(data_key, data_key_lo); |
| 4985 |
|
| 4986 |
__m512i const data_swap = _mm512_shuffle_epi32(data_vec, (_MM_PERM_ENUM)_MM_SHUFFLE(1, 0, 3, 2)); |
| 4987 |
__m512i const sum = _mm512_add_epi64(*xacc, data_swap); |
| 4988 |
|
| 4989 |
*xacc = _mm512_add_epi64(product, sum); |
| 4990 |
} |
| 4991 |
} |
| 4992 |
XXH_FORCE_INLINE XXH_TARGET_AVX512 XXH3_ACCUMULATE_TEMPLATE(avx512) |
| 4993 |
|
| 4994 |
|
| 4995 |
|
| 4996 |
|
| 4997 |
|
| 4998 |
|
| 4999 |
|
| 5000 |
|
| 5001 |
|
| 5002 |
|
| 5003 |
|
| 5004 |
|
| 5005 |
|
| 5006 |
|
| 5007 |
|
| 5008 |
|
| 5009 |
|
| 5010 |
|
| 5011 |
|
| 5012 |
|
| 5013 |
|
| 5014 |
|
| 5015 |
XXH_FORCE_INLINE XXH_TARGET_AVX512 |
| 5016 |
void XXH3_scrambleAcc_avx512(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 5017 |
XXH_ASSERT((((size_t)acc) & 63) == 0); |
| 5018 |
XXH_STATIC_ASSERT(XXH_STRIPE_LEN == sizeof(__m512i)); |
| 5019 |
{ |
| 5020 |
__m512i *const xacc = (__m512i *)acc; |
| 5021 |
const __m512i prime32 = _mm512_set1_epi32((int)XXH_PRIME32_1); |
| 5022 |
|
| 5023 |
|
| 5024 |
__m512i const acc_vec = *xacc; |
| 5025 |
__m512i const shifted = _mm512_srli_epi64(acc_vec, 47); |
| 5026 |
|
| 5027 |
__m512i const key_vec = _mm512_loadu_si512(secret); |
| 5028 |
__m512i const data_key = |
| 5029 |
_mm512_ternarylogic_epi32(key_vec, acc_vec, shifted, 0x96 ); |
| 5030 |
|
| 5031 |
|
| 5032 |
__m512i const data_key_hi = _mm512_srli_epi64(data_key, 32); |
| 5033 |
__m512i const prod_lo = _mm512_mul_epu32(data_key, prime32); |
| 5034 |
__m512i const prod_hi = _mm512_mul_epu32(data_key_hi, prime32); |
| 5035 |
*xacc = _mm512_add_epi64(prod_lo, _mm512_slli_epi64(prod_hi, 32)); |
| 5036 |
} |
| 5037 |
} |
| 5038 |
|
| 5039 |
XXH_FORCE_INLINE XXH_TARGET_AVX512 void XXH3_initCustomSecret_avx512(void *XXH_RESTRICT customSecret, xxh_u64 seed64) { |
| 5040 |
XXH_STATIC_ASSERT((XXH_SECRET_DEFAULT_SIZE & 63) == 0); |
| 5041 |
XXH_STATIC_ASSERT(XXH_SEC_ALIGN == 64); |
| 5042 |
XXH_ASSERT(((size_t)customSecret & 63) == 0); |
| 5043 |
(void)(&XXH_writeLE64); |
| 5044 |
{ |
| 5045 |
int const nbRounds = XXH_SECRET_DEFAULT_SIZE / sizeof(__m512i); |
| 5046 |
__m512i const seed_pos = _mm512_set1_epi64((xxh_i64)seed64); |
| 5047 |
__m512i const seed = _mm512_mask_sub_epi64(seed_pos, 0xAA, _mm512_set1_epi8(0), seed_pos); |
| 5048 |
|
| 5049 |
const __m512i *const src = (const __m512i *)((const void *)XXH3_kSecret); |
| 5050 |
__m512i *const dest = (__m512i *)customSecret; |
| 5051 |
int i; |
| 5052 |
XXH_ASSERT(((size_t)src & 63) == 0); |
| 5053 |
XXH_ASSERT(((size_t)dest & 63) == 0); |
| 5054 |
for (i = 0; i < nbRounds; ++i) { |
| 5055 |
dest[i] = _mm512_add_epi64(_mm512_load_si512(src + i), seed); |
| 5056 |
} |
| 5057 |
} |
| 5058 |
} |
| 5059 |
|
| 5060 |
# endif |
| 5061 |
|
| 5062 |
# if (XXH_VECTOR == XXH_AVX2) || (defined(XXH_DISPATCH_AVX2) && XXH_DISPATCH_AVX2 != 0) |
| 5063 |
|
| 5064 |
# ifndef XXH_TARGET_AVX2 |
| 5065 |
# define XXH_TARGET_AVX2 |
| 5066 |
# endif |
| 5067 |
|
| 5068 |
XXH_FORCE_INLINE XXH_TARGET_AVX2 void XXH3_accumulate_512_avx2( |
| 5069 |
void *XXH_RESTRICT acc, |
| 5070 |
const void *XXH_RESTRICT input, |
| 5071 |
const void *XXH_RESTRICT secret) { |
| 5072 |
XXH_ASSERT((((size_t)acc) & 31) == 0); |
| 5073 |
{ |
| 5074 |
__m256i *const xacc = (__m256i *)acc; |
| 5075 |
|
| 5076 |
|
| 5077 |
const __m256i *const xinput = (const __m256i *)input; |
| 5078 |
|
| 5079 |
|
| 5080 |
const __m256i *const xsecret = (const __m256i *)secret; |
| 5081 |
|
| 5082 |
size_t i; |
| 5083 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(__m256i); i++) { |
| 5084 |
|
| 5085 |
__m256i const data_vec = _mm256_loadu_si256(xinput + i); |
| 5086 |
|
| 5087 |
__m256i const key_vec = _mm256_loadu_si256(xsecret + i); |
| 5088 |
|
| 5089 |
__m256i const data_key = _mm256_xor_si256(data_vec, key_vec); |
| 5090 |
|
| 5091 |
__m256i const data_key_lo = _mm256_srli_epi64(data_key, 32); |
| 5092 |
|
| 5093 |
__m256i const product = _mm256_mul_epu32(data_key, data_key_lo); |
| 5094 |
|
| 5095 |
__m256i const data_swap = _mm256_shuffle_epi32(data_vec, _MM_SHUFFLE(1, 0, 3, 2)); |
| 5096 |
__m256i const sum = _mm256_add_epi64(xacc[i], data_swap); |
| 5097 |
|
| 5098 |
xacc[i] = _mm256_add_epi64(product, sum); |
| 5099 |
} |
| 5100 |
} |
| 5101 |
} |
| 5102 |
XXH_FORCE_INLINE XXH_TARGET_AVX2 XXH3_ACCUMULATE_TEMPLATE(avx2) |
| 5103 |
|
| 5104 |
XXH_FORCE_INLINE XXH_TARGET_AVX2 |
| 5105 |
void XXH3_scrambleAcc_avx2(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 5106 |
XXH_ASSERT((((size_t)acc) & 31) == 0); |
| 5107 |
{ |
| 5108 |
__m256i *const xacc = (__m256i *)acc; |
| 5109 |
|
| 5110 |
|
| 5111 |
const __m256i *const xsecret = (const __m256i *)secret; |
| 5112 |
const __m256i prime32 = _mm256_set1_epi32((int)XXH_PRIME32_1); |
| 5113 |
|
| 5114 |
size_t i; |
| 5115 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(__m256i); i++) { |
| 5116 |
|
| 5117 |
__m256i const acc_vec = xacc[i]; |
| 5118 |
__m256i const shifted = _mm256_srli_epi64(acc_vec, 47); |
| 5119 |
__m256i const data_vec = _mm256_xor_si256(acc_vec, shifted); |
| 5120 |
|
| 5121 |
__m256i const key_vec = _mm256_loadu_si256(xsecret + i); |
| 5122 |
__m256i const data_key = _mm256_xor_si256(data_vec, key_vec); |
| 5123 |
|
| 5124 |
|
| 5125 |
__m256i const data_key_hi = _mm256_srli_epi64(data_key, 32); |
| 5126 |
__m256i const prod_lo = _mm256_mul_epu32(data_key, prime32); |
| 5127 |
__m256i const prod_hi = _mm256_mul_epu32(data_key_hi, prime32); |
| 5128 |
xacc[i] = _mm256_add_epi64(prod_lo, _mm256_slli_epi64(prod_hi, 32)); |
| 5129 |
} |
| 5130 |
} |
| 5131 |
} |
| 5132 |
|
| 5133 |
XXH_FORCE_INLINE XXH_TARGET_AVX2 void XXH3_initCustomSecret_avx2(void *XXH_RESTRICT customSecret, xxh_u64 seed64) { |
| 5134 |
XXH_STATIC_ASSERT((XXH_SECRET_DEFAULT_SIZE & 31) == 0); |
| 5135 |
XXH_STATIC_ASSERT((XXH_SECRET_DEFAULT_SIZE / sizeof(__m256i)) == 6); |
| 5136 |
XXH_STATIC_ASSERT(XXH_SEC_ALIGN <= 64); |
| 5137 |
(void)(&XXH_writeLE64); |
| 5138 |
XXH_PREFETCH(customSecret); |
| 5139 |
{ |
| 5140 |
__m256i const seed = |
| 5141 |
_mm256_set_epi64x((xxh_i64)(0U - seed64), (xxh_i64)seed64, (xxh_i64)(0U - seed64), (xxh_i64)seed64); |
| 5142 |
|
| 5143 |
const __m256i *const src = (const __m256i *)((const void *)XXH3_kSecret); |
| 5144 |
__m256i *dest = (__m256i *)customSecret; |
| 5145 |
|
| 5146 |
# if defined(__GNUC__) || defined(__clang__) |
| 5147 |
|
| 5148 |
|
| 5149 |
|
| 5150 |
|
| 5151 |
|
| 5152 |
XXH_COMPILER_GUARD(dest); |
| 5153 |
# endif |
| 5154 |
XXH_ASSERT(((size_t)src & 31) == 0); |
| 5155 |
XXH_ASSERT(((size_t)dest & 31) == 0); |
| 5156 |
|
| 5157 |
|
| 5158 |
dest[0] = _mm256_add_epi64(_mm256_load_si256(src + 0), seed); |
| 5159 |
dest[1] = _mm256_add_epi64(_mm256_load_si256(src + 1), seed); |
| 5160 |
dest[2] = _mm256_add_epi64(_mm256_load_si256(src + 2), seed); |
| 5161 |
dest[3] = _mm256_add_epi64(_mm256_load_si256(src + 3), seed); |
| 5162 |
dest[4] = _mm256_add_epi64(_mm256_load_si256(src + 4), seed); |
| 5163 |
dest[5] = _mm256_add_epi64(_mm256_load_si256(src + 5), seed); |
| 5164 |
} |
| 5165 |
} |
| 5166 |
|
| 5167 |
# endif |
| 5168 |
|
| 5169 |
|
| 5170 |
# if (XXH_VECTOR == XXH_SSE2) || defined(XXH_X86DISPATCH) |
| 5171 |
|
| 5172 |
# ifndef XXH_TARGET_SSE2 |
| 5173 |
# define XXH_TARGET_SSE2 |
| 5174 |
# endif |
| 5175 |
|
| 5176 |
XXH_FORCE_INLINE XXH_TARGET_SSE2 void XXH3_accumulate_512_sse2( |
| 5177 |
void *XXH_RESTRICT acc, |
| 5178 |
const void *XXH_RESTRICT input, |
| 5179 |
const void *XXH_RESTRICT secret) { |
| 5180 |
|
| 5181 |
XXH_ASSERT((((size_t)acc) & 15) == 0); |
| 5182 |
{ |
| 5183 |
__m128i *const xacc = (__m128i *)acc; |
| 5184 |
|
| 5185 |
|
| 5186 |
const __m128i *const xinput = (const __m128i *)input; |
| 5187 |
|
| 5188 |
|
| 5189 |
const __m128i *const xsecret = (const __m128i *)secret; |
| 5190 |
|
| 5191 |
size_t i; |
| 5192 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(__m128i); i++) { |
| 5193 |
|
| 5194 |
__m128i const data_vec = _mm_loadu_si128(xinput + i); |
| 5195 |
|
| 5196 |
__m128i const key_vec = _mm_loadu_si128(xsecret + i); |
| 5197 |
|
| 5198 |
__m128i const data_key = _mm_xor_si128(data_vec, key_vec); |
| 5199 |
|
| 5200 |
__m128i const data_key_lo = _mm_shuffle_epi32(data_key, _MM_SHUFFLE(0, 3, 0, 1)); |
| 5201 |
|
| 5202 |
__m128i const product = _mm_mul_epu32(data_key, data_key_lo); |
| 5203 |
|
| 5204 |
__m128i const data_swap = _mm_shuffle_epi32(data_vec, _MM_SHUFFLE(1, 0, 3, 2)); |
| 5205 |
__m128i const sum = _mm_add_epi64(xacc[i], data_swap); |
| 5206 |
|
| 5207 |
xacc[i] = _mm_add_epi64(product, sum); |
| 5208 |
} |
| 5209 |
} |
| 5210 |
} |
| 5211 |
XXH_FORCE_INLINE XXH_TARGET_SSE2 XXH3_ACCUMULATE_TEMPLATE(sse2) |
| 5212 |
|
| 5213 |
XXH_FORCE_INLINE XXH_TARGET_SSE2 |
| 5214 |
void XXH3_scrambleAcc_sse2(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 5215 |
XXH_ASSERT((((size_t)acc) & 15) == 0); |
| 5216 |
{ |
| 5217 |
__m128i *const xacc = (__m128i *)acc; |
| 5218 |
|
| 5219 |
|
| 5220 |
const __m128i *const xsecret = (const __m128i *)secret; |
| 5221 |
const __m128i prime32 = _mm_set1_epi32((int)XXH_PRIME32_1); |
| 5222 |
|
| 5223 |
size_t i; |
| 5224 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(__m128i); i++) { |
| 5225 |
|
| 5226 |
__m128i const acc_vec = xacc[i]; |
| 5227 |
__m128i const shifted = _mm_srli_epi64(acc_vec, 47); |
| 5228 |
__m128i const data_vec = _mm_xor_si128(acc_vec, shifted); |
| 5229 |
|
| 5230 |
__m128i const key_vec = _mm_loadu_si128(xsecret + i); |
| 5231 |
__m128i const data_key = _mm_xor_si128(data_vec, key_vec); |
| 5232 |
|
| 5233 |
|
| 5234 |
__m128i const data_key_hi = _mm_shuffle_epi32(data_key, _MM_SHUFFLE(0, 3, 0, 1)); |
| 5235 |
__m128i const prod_lo = _mm_mul_epu32(data_key, prime32); |
| 5236 |
__m128i const prod_hi = _mm_mul_epu32(data_key_hi, prime32); |
| 5237 |
xacc[i] = _mm_add_epi64(prod_lo, _mm_slli_epi64(prod_hi, 32)); |
| 5238 |
} |
| 5239 |
} |
| 5240 |
} |
| 5241 |
|
| 5242 |
XXH_FORCE_INLINE XXH_TARGET_SSE2 void XXH3_initCustomSecret_sse2(void *XXH_RESTRICT customSecret, xxh_u64 seed64) { |
| 5243 |
XXH_STATIC_ASSERT((XXH_SECRET_DEFAULT_SIZE & 15) == 0); |
| 5244 |
(void)(&XXH_writeLE64); |
| 5245 |
{ |
| 5246 |
int const nbRounds = XXH_SECRET_DEFAULT_SIZE / sizeof(__m128i); |
| 5247 |
|
| 5248 |
# if defined(_MSC_VER) && defined(_M_IX86) && _MSC_VER <= 1900 |
| 5249 |
|
| 5250 |
|
| 5251 |
|
| 5252 |
xxh_u64 const seed64_unsigned = (xxh_u64)seed64; |
| 5253 |
xxh_u64 const neg_seed64 = (xxh_u64)(0ULL - seed64_unsigned); |
| 5254 |
__m128i const seed = _mm_set_epi32( |
| 5255 |
(int)(neg_seed64 >> 32), |
| 5256 |
(int)(neg_seed64), |
| 5257 |
(int)(seed64_unsigned >> 32), |
| 5258 |
(int)(seed64_unsigned) |
| 5259 |
); |
| 5260 |
# else |
| 5261 |
__m128i const seed = _mm_set_epi64x((xxh_i64)(0U - seed64), (xxh_i64)seed64); |
| 5262 |
# endif |
| 5263 |
int i; |
| 5264 |
|
| 5265 |
const void *const src16 = XXH3_kSecret; |
| 5266 |
__m128i *dst16 = (__m128i *)customSecret; |
| 5267 |
# if defined(__GNUC__) || defined(__clang__) |
| 5268 |
|
| 5269 |
|
| 5270 |
|
| 5271 |
|
| 5272 |
|
| 5273 |
XXH_COMPILER_GUARD(dst16); |
| 5274 |
# endif |
| 5275 |
XXH_ASSERT(((size_t)src16 & 15) == 0); |
| 5276 |
XXH_ASSERT(((size_t)dst16 & 15) == 0); |
| 5277 |
|
| 5278 |
for (i = 0; i < nbRounds; ++i) { |
| 5279 |
dst16[i] = _mm_add_epi64(_mm_load_si128((const __m128i *)src16 + i), seed); |
| 5280 |
} |
| 5281 |
} |
| 5282 |
} |
| 5283 |
|
| 5284 |
# endif |
| 5285 |
|
| 5286 |
# if (XXH_VECTOR == XXH_NEON) |
| 5287 |
|
| 5288 |
|
| 5289 |
XXH_FORCE_INLINE void XXH3_scalarRound( |
| 5290 |
void *XXH_RESTRICT acc, |
| 5291 |
void const *XXH_RESTRICT input, |
| 5292 |
void const *XXH_RESTRICT secret, |
| 5293 |
size_t lane); |
| 5294 |
|
| 5295 |
XXH_FORCE_INLINE void XXH3_scalarScrambleRound(void *XXH_RESTRICT acc, void const *XXH_RESTRICT secret, size_t lane); |
| 5296 |
|
| 5297 |
|
| 5298 |
|
| 5299 |
|
| 5300 |
|
| 5301 |
|
| 5302 |
|
| 5303 |
|
| 5304 |
|
| 5305 |
|
| 5306 |
|
| 5307 |
|
| 5308 |
|
| 5309 |
|
| 5310 |
|
| 5311 |
|
| 5312 |
|
| 5313 |
|
| 5314 |
|
| 5315 |
|
| 5316 |
|
| 5317 |
|
| 5318 |
|
| 5319 |
|
| 5320 |
|
| 5321 |
XXH_FORCE_INLINE void XXH3_accumulate_512_neon( |
| 5322 |
void *XXH_RESTRICT acc, |
| 5323 |
const void *XXH_RESTRICT input, |
| 5324 |
const void *XXH_RESTRICT secret) { |
| 5325 |
XXH_ASSERT((((size_t)acc) & 15) == 0); |
| 5326 |
XXH_STATIC_ASSERT(XXH3_NEON_LANES > 0 && XXH3_NEON_LANES <= XXH_ACC_NB && XXH3_NEON_LANES % 2 == 0); |
| 5327 |
{ |
| 5328 |
xxh_aliasing_uint64x2_t *const xacc = (xxh_aliasing_uint64x2_t *)acc; |
| 5329 |
|
| 5330 |
uint8_t const *xinput = (const uint8_t *)input; |
| 5331 |
uint8_t const *xsecret = (const uint8_t *)secret; |
| 5332 |
|
| 5333 |
size_t i; |
| 5334 |
# ifdef __wasm_simd128__ |
| 5335 |
|
| 5336 |
|
| 5337 |
|
| 5338 |
|
| 5339 |
|
| 5340 |
|
| 5341 |
|
| 5342 |
|
| 5343 |
|
| 5344 |
|
| 5345 |
|
| 5346 |
|
| 5347 |
|
| 5348 |
|
| 5349 |
|
| 5350 |
|
| 5351 |
|
| 5352 |
XXH_COMPILER_GUARD(xsecret); |
| 5353 |
# endif |
| 5354 |
|
| 5355 |
for (i = XXH3_NEON_LANES; i < XXH_ACC_NB; i++) { |
| 5356 |
XXH3_scalarRound(acc, input, secret, i); |
| 5357 |
} |
| 5358 |
i = 0; |
| 5359 |
|
| 5360 |
for (; i + 1 < XXH3_NEON_LANES / 2; i += 2) { |
| 5361 |
|
| 5362 |
uint64x2_t data_vec_1 = XXH_vld1q_u64(xinput + (i * 16)); |
| 5363 |
uint64x2_t data_vec_2 = XXH_vld1q_u64(xinput + ((i + 1) * 16)); |
| 5364 |
|
| 5365 |
uint64x2_t key_vec_1 = XXH_vld1q_u64(xsecret + (i * 16)); |
| 5366 |
uint64x2_t key_vec_2 = XXH_vld1q_u64(xsecret + ((i + 1) * 16)); |
| 5367 |
|
| 5368 |
uint64x2_t data_swap_1 = vextq_u64(data_vec_1, data_vec_1, 1); |
| 5369 |
uint64x2_t data_swap_2 = vextq_u64(data_vec_2, data_vec_2, 1); |
| 5370 |
|
| 5371 |
uint64x2_t data_key_1 = veorq_u64(data_vec_1, key_vec_1); |
| 5372 |
uint64x2_t data_key_2 = veorq_u64(data_vec_2, key_vec_2); |
| 5373 |
|
| 5374 |
|
| 5375 |
|
| 5376 |
|
| 5377 |
|
| 5378 |
|
| 5379 |
|
| 5380 |
|
| 5381 |
|
| 5382 |
|
| 5383 |
|
| 5384 |
|
| 5385 |
|
| 5386 |
|
| 5387 |
uint32x4x2_t unzipped = vuzpq_u32(vreinterpretq_u32_u64(data_key_1), vreinterpretq_u32_u64(data_key_2)); |
| 5388 |
|
| 5389 |
uint32x4_t data_key_lo = unzipped.val[0]; |
| 5390 |
|
| 5391 |
uint32x4_t data_key_hi = unzipped.val[1]; |
| 5392 |
|
| 5393 |
|
| 5394 |
|
| 5395 |
|
| 5396 |
|
| 5397 |
|
| 5398 |
|
| 5399 |
uint64x2_t sum_1 = XXH_vmlal_low_u32(data_swap_1, data_key_lo, data_key_hi); |
| 5400 |
uint64x2_t sum_2 = XXH_vmlal_high_u32(data_swap_2, data_key_lo, data_key_hi); |
| 5401 |
|
| 5402 |
|
| 5403 |
|
| 5404 |
|
| 5405 |
|
| 5406 |
|
| 5407 |
|
| 5408 |
|
| 5409 |
|
| 5410 |
|
| 5411 |
|
| 5412 |
|
| 5413 |
XXH_COMPILER_GUARD_CLANG_NEON(sum_1); |
| 5414 |
XXH_COMPILER_GUARD_CLANG_NEON(sum_2); |
| 5415 |
|
| 5416 |
xacc[i] = vaddq_u64(xacc[i], sum_1); |
| 5417 |
xacc[i + 1] = vaddq_u64(xacc[i + 1], sum_2); |
| 5418 |
} |
| 5419 |
|
| 5420 |
for (; i < XXH3_NEON_LANES / 2; i++) { |
| 5421 |
|
| 5422 |
uint64x2_t data_vec = XXH_vld1q_u64(xinput + (i * 16)); |
| 5423 |
|
| 5424 |
uint64x2_t key_vec = XXH_vld1q_u64(xsecret + (i * 16)); |
| 5425 |
|
| 5426 |
uint64x2_t data_swap = vextq_u64(data_vec, data_vec, 1); |
| 5427 |
|
| 5428 |
uint64x2_t data_key = veorq_u64(data_vec, key_vec); |
| 5429 |
|
| 5430 |
|
| 5431 |
uint32x2_t data_key_lo = vmovn_u64(data_key); |
| 5432 |
|
| 5433 |
uint32x2_t data_key_hi = vshrn_n_u64(data_key, 32); |
| 5434 |
|
| 5435 |
uint64x2_t sum = vmlal_u32(data_swap, data_key_lo, data_key_hi); |
| 5436 |
|
| 5437 |
XXH_COMPILER_GUARD_CLANG_NEON(sum); |
| 5438 |
|
| 5439 |
xacc[i] = vaddq_u64(xacc[i], sum); |
| 5440 |
} |
| 5441 |
} |
| 5442 |
} |
| 5443 |
XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(neon) |
| 5444 |
|
| 5445 |
XXH_FORCE_INLINE void XXH3_scrambleAcc_neon(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 5446 |
XXH_ASSERT((((size_t)acc) & 15) == 0); |
| 5447 |
|
| 5448 |
{ |
| 5449 |
xxh_aliasing_uint64x2_t *xacc = (xxh_aliasing_uint64x2_t *)acc; |
| 5450 |
uint8_t const *xsecret = (uint8_t const *)secret; |
| 5451 |
|
| 5452 |
size_t i; |
| 5453 |
|
| 5454 |
# ifndef __wasm_simd128__ |
| 5455 |
|
| 5456 |
uint32x2_t const kPrimeLo = vdup_n_u32(XXH_PRIME32_1); |
| 5457 |
|
| 5458 |
uint32x4_t const kPrimeHi = vreinterpretq_u32_u64(vdupq_n_u64((xxh_u64)XXH_PRIME32_1 << 32)); |
| 5459 |
# endif |
| 5460 |
|
| 5461 |
|
| 5462 |
for (i = XXH3_NEON_LANES; i < XXH_ACC_NB; i++) { |
| 5463 |
XXH3_scalarScrambleRound(acc, secret, i); |
| 5464 |
} |
| 5465 |
for (i = 0; i < XXH3_NEON_LANES / 2; i++) { |
| 5466 |
|
| 5467 |
uint64x2_t acc_vec = xacc[i]; |
| 5468 |
uint64x2_t shifted = vshrq_n_u64(acc_vec, 47); |
| 5469 |
uint64x2_t data_vec = veorq_u64(acc_vec, shifted); |
| 5470 |
|
| 5471 |
|
| 5472 |
uint64x2_t key_vec = XXH_vld1q_u64(xsecret + (i * 16)); |
| 5473 |
uint64x2_t data_key = veorq_u64(data_vec, key_vec); |
| 5474 |
|
| 5475 |
# ifdef __wasm_simd128__ |
| 5476 |
|
| 5477 |
xacc[i] = data_key * XXH_PRIME32_1; |
| 5478 |
# else |
| 5479 |
|
| 5480 |
|
| 5481 |
|
| 5482 |
|
| 5483 |
|
| 5484 |
|
| 5485 |
|
| 5486 |
|
| 5487 |
|
| 5488 |
|
| 5489 |
|
| 5490 |
uint32x4_t prod_hi = vmulq_u32(vreinterpretq_u32_u64(data_key), kPrimeHi); |
| 5491 |
|
| 5492 |
uint32x2_t data_key_lo = vmovn_u64(data_key); |
| 5493 |
|
| 5494 |
xacc[i] = vmlal_u32(vreinterpretq_u64_u32(prod_hi), data_key_lo, kPrimeLo); |
| 5495 |
# endif |
| 5496 |
} |
| 5497 |
} |
| 5498 |
} |
| 5499 |
# endif |
| 5500 |
|
| 5501 |
# if (XXH_VECTOR == XXH_VSX) |
| 5502 |
|
| 5503 |
XXH_FORCE_INLINE void XXH3_accumulate_512_vsx( |
| 5504 |
void *XXH_RESTRICT acc, |
| 5505 |
const void *XXH_RESTRICT input, |
| 5506 |
const void *XXH_RESTRICT secret) { |
| 5507 |
|
| 5508 |
xxh_aliasing_u64x2 *const xacc = (xxh_aliasing_u64x2 *)acc; |
| 5509 |
xxh_u8 const *const xinput = (xxh_u8 const *)input; |
| 5510 |
xxh_u8 const *const xsecret = (xxh_u8 const *)secret; |
| 5511 |
xxh_u64x2 const v32 = {32, 32}; |
| 5512 |
size_t i; |
| 5513 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(xxh_u64x2); i++) { |
| 5514 |
|
| 5515 |
xxh_u64x2 const data_vec = XXH_vec_loadu(xinput + 16 * i); |
| 5516 |
|
| 5517 |
xxh_u64x2 const key_vec = XXH_vec_loadu(xsecret + 16 * i); |
| 5518 |
xxh_u64x2 const data_key = data_vec ^ key_vec; |
| 5519 |
|
| 5520 |
xxh_u32x4 const shuffled = (xxh_u32x4)vec_rl(data_key, v32); |
| 5521 |
|
| 5522 |
xxh_u64x2 const product = XXH_vec_mulo((xxh_u32x4)data_key, shuffled); |
| 5523 |
|
| 5524 |
xxh_u64x2 acc_vec = xacc[i]; |
| 5525 |
acc_vec += product; |
| 5526 |
|
| 5527 |
|
| 5528 |
# ifdef __s390x__ |
| 5529 |
acc_vec += vec_permi(data_vec, data_vec, 2); |
| 5530 |
# else |
| 5531 |
acc_vec += vec_xxpermdi(data_vec, data_vec, 2); |
| 5532 |
# endif |
| 5533 |
xacc[i] = acc_vec; |
| 5534 |
} |
| 5535 |
} |
| 5536 |
XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(vsx) |
| 5537 |
|
| 5538 |
XXH_FORCE_INLINE void XXH3_scrambleAcc_vsx(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 5539 |
XXH_ASSERT((((size_t)acc) & 15) == 0); |
| 5540 |
|
| 5541 |
{ |
| 5542 |
xxh_aliasing_u64x2 *const xacc = (xxh_aliasing_u64x2 *)acc; |
| 5543 |
const xxh_u8 *const xsecret = (const xxh_u8 *)secret; |
| 5544 |
|
| 5545 |
xxh_u64x2 const v32 = {32, 32}; |
| 5546 |
xxh_u64x2 const v47 = {47, 47}; |
| 5547 |
xxh_u32x4 const prime = {XXH_PRIME32_1, XXH_PRIME32_1, XXH_PRIME32_1, XXH_PRIME32_1}; |
| 5548 |
size_t i; |
| 5549 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(xxh_u64x2); i++) { |
| 5550 |
|
| 5551 |
xxh_u64x2 const acc_vec = xacc[i]; |
| 5552 |
xxh_u64x2 const data_vec = acc_vec ^ (acc_vec >> v47); |
| 5553 |
|
| 5554 |
|
| 5555 |
xxh_u64x2 const key_vec = XXH_vec_loadu(xsecret + 16 * i); |
| 5556 |
xxh_u64x2 const data_key = data_vec ^ key_vec; |
| 5557 |
|
| 5558 |
|
| 5559 |
|
| 5560 |
xxh_u64x2 const prod_even = XXH_vec_mule((xxh_u32x4)data_key, prime); |
| 5561 |
|
| 5562 |
xxh_u64x2 const prod_odd = XXH_vec_mulo((xxh_u32x4)data_key, prime); |
| 5563 |
xacc[i] = prod_odd + (prod_even << v32); |
| 5564 |
} |
| 5565 |
} |
| 5566 |
} |
| 5567 |
|
| 5568 |
# endif |
| 5569 |
|
| 5570 |
# if (XXH_VECTOR == XXH_SVE) |
| 5571 |
|
| 5572 |
XXH_FORCE_INLINE void XXH3_accumulate_512_sve( |
| 5573 |
void *XXH_RESTRICT acc, |
| 5574 |
const void *XXH_RESTRICT input, |
| 5575 |
const void *XXH_RESTRICT secret) { |
| 5576 |
uint64_t *xacc = (uint64_t *)acc; |
| 5577 |
const uint64_t *xinput = (const uint64_t *)(const void *)input; |
| 5578 |
const uint64_t *xsecret = (const uint64_t *)(const void *)secret; |
| 5579 |
svuint64_t kSwap = sveor_n_u64_z(svptrue_b64(), svindex_u64(0, 1), 1); |
| 5580 |
uint64_t element_count = svcntd(); |
| 5581 |
if (element_count >= 8) { |
| 5582 |
svbool_t mask = svptrue_pat_b64(SV_VL8); |
| 5583 |
svuint64_t vacc = svld1_u64(mask, xacc); |
| 5584 |
ACCRND(vacc, 0); |
| 5585 |
svst1_u64(mask, xacc, vacc); |
| 5586 |
} else if (element_count == 2) { |
| 5587 |
svbool_t mask = svptrue_pat_b64(SV_VL2); |
| 5588 |
svuint64_t acc0 = svld1_u64(mask, xacc + 0); |
| 5589 |
svuint64_t acc1 = svld1_u64(mask, xacc + 2); |
| 5590 |
svuint64_t acc2 = svld1_u64(mask, xacc + 4); |
| 5591 |
svuint64_t acc3 = svld1_u64(mask, xacc + 6); |
| 5592 |
ACCRND(acc0, 0); |
| 5593 |
ACCRND(acc1, 2); |
| 5594 |
ACCRND(acc2, 4); |
| 5595 |
ACCRND(acc3, 6); |
| 5596 |
svst1_u64(mask, xacc + 0, acc0); |
| 5597 |
svst1_u64(mask, xacc + 2, acc1); |
| 5598 |
svst1_u64(mask, xacc + 4, acc2); |
| 5599 |
svst1_u64(mask, xacc + 6, acc3); |
| 5600 |
} else { |
| 5601 |
svbool_t mask = svptrue_pat_b64(SV_VL4); |
| 5602 |
svuint64_t acc0 = svld1_u64(mask, xacc + 0); |
| 5603 |
svuint64_t acc1 = svld1_u64(mask, xacc + 4); |
| 5604 |
ACCRND(acc0, 0); |
| 5605 |
ACCRND(acc1, 4); |
| 5606 |
svst1_u64(mask, xacc + 0, acc0); |
| 5607 |
svst1_u64(mask, xacc + 4, acc1); |
| 5608 |
} |
| 5609 |
} |
| 5610 |
|
| 5611 |
XXH_FORCE_INLINE void XXH3_accumulate_sve( |
| 5612 |
xxh_u64 *XXH_RESTRICT acc, |
| 5613 |
const xxh_u8 *XXH_RESTRICT input, |
| 5614 |
const xxh_u8 *XXH_RESTRICT secret, |
| 5615 |
size_t nbStripes) { |
| 5616 |
if (nbStripes != 0) { |
| 5617 |
uint64_t *xacc = (uint64_t *)acc; |
| 5618 |
const uint64_t *xinput = (const uint64_t *)(const void *)input; |
| 5619 |
const uint64_t *xsecret = (const uint64_t *)(const void *)secret; |
| 5620 |
svuint64_t kSwap = sveor_n_u64_z(svptrue_b64(), svindex_u64(0, 1), 1); |
| 5621 |
uint64_t element_count = svcntd(); |
| 5622 |
if (element_count >= 8) { |
| 5623 |
svbool_t mask = svptrue_pat_b64(SV_VL8); |
| 5624 |
svuint64_t vacc = svld1_u64(mask, xacc + 0); |
| 5625 |
do { |
| 5626 |
|
| 5627 |
svprfd(mask, xinput + 128, SV_PLDL1STRM); |
| 5628 |
ACCRND(vacc, 0); |
| 5629 |
xinput += 8; |
| 5630 |
xsecret += 1; |
| 5631 |
nbStripes--; |
| 5632 |
} while (nbStripes != 0); |
| 5633 |
|
| 5634 |
svst1_u64(mask, xacc + 0, vacc); |
| 5635 |
} else if (element_count == 2) { |
| 5636 |
svbool_t mask = svptrue_pat_b64(SV_VL2); |
| 5637 |
svuint64_t acc0 = svld1_u64(mask, xacc + 0); |
| 5638 |
svuint64_t acc1 = svld1_u64(mask, xacc + 2); |
| 5639 |
svuint64_t acc2 = svld1_u64(mask, xacc + 4); |
| 5640 |
svuint64_t acc3 = svld1_u64(mask, xacc + 6); |
| 5641 |
do { |
| 5642 |
svprfd(mask, xinput + 128, SV_PLDL1STRM); |
| 5643 |
ACCRND(acc0, 0); |
| 5644 |
ACCRND(acc1, 2); |
| 5645 |
ACCRND(acc2, 4); |
| 5646 |
ACCRND(acc3, 6); |
| 5647 |
xinput += 8; |
| 5648 |
xsecret += 1; |
| 5649 |
nbStripes--; |
| 5650 |
} while (nbStripes != 0); |
| 5651 |
|
| 5652 |
svst1_u64(mask, xacc + 0, acc0); |
| 5653 |
svst1_u64(mask, xacc + 2, acc1); |
| 5654 |
svst1_u64(mask, xacc + 4, acc2); |
| 5655 |
svst1_u64(mask, xacc + 6, acc3); |
| 5656 |
} else { |
| 5657 |
svbool_t mask = svptrue_pat_b64(SV_VL4); |
| 5658 |
svuint64_t acc0 = svld1_u64(mask, xacc + 0); |
| 5659 |
svuint64_t acc1 = svld1_u64(mask, xacc + 4); |
| 5660 |
do { |
| 5661 |
svprfd(mask, xinput + 128, SV_PLDL1STRM); |
| 5662 |
ACCRND(acc0, 0); |
| 5663 |
ACCRND(acc1, 4); |
| 5664 |
xinput += 8; |
| 5665 |
xsecret += 1; |
| 5666 |
nbStripes--; |
| 5667 |
} while (nbStripes != 0); |
| 5668 |
|
| 5669 |
svst1_u64(mask, xacc + 0, acc0); |
| 5670 |
svst1_u64(mask, xacc + 4, acc1); |
| 5671 |
} |
| 5672 |
} |
| 5673 |
} |
| 5674 |
|
| 5675 |
# endif |
| 5676 |
|
| 5677 |
# if (XXH_VECTOR == XXH_LSX) |
| 5678 |
# define _LSX_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) |
| 5679 |
|
| 5680 |
XXH_FORCE_INLINE void XXH3_accumulate_512_lsx( |
| 5681 |
void *XXH_RESTRICT acc, |
| 5682 |
const void *XXH_RESTRICT input, |
| 5683 |
const void *XXH_RESTRICT secret) { |
| 5684 |
XXH_ASSERT((((size_t)acc) & 15) == 0); |
| 5685 |
{ |
| 5686 |
__m128i *const xacc = (__m128i *)acc; |
| 5687 |
const __m128i *const xinput = (const __m128i *)input; |
| 5688 |
const __m128i *const xsecret = (const __m128i *)secret; |
| 5689 |
size_t i; |
| 5690 |
|
| 5691 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(__m128i); i++) { |
| 5692 |
|
| 5693 |
__m128i const data_vec = __lsx_vld(xinput + i, 0); |
| 5694 |
|
| 5695 |
__m128i const key_vec = __lsx_vld(xsecret + i, 0); |
| 5696 |
|
| 5697 |
__m128i const data_key = __lsx_vxor_v(data_vec, key_vec); |
| 5698 |
|
| 5699 |
__m128i const data_key_lo = __lsx_vsrli_d(data_key, 32); |
| 5700 |
|
| 5701 |
|
| 5702 |
__m128i const product = __lsx_vmulwev_d_wu(data_key, data_key_lo); |
| 5703 |
|
| 5704 |
__m128i const data_swap = __lsx_vshuf4i_w(data_vec, _LSX_SHUFFLE(1, 0, 3, 2)); |
| 5705 |
__m128i const sum = __lsx_vadd_d(xacc[i], data_swap); |
| 5706 |
|
| 5707 |
xacc[i] = __lsx_vadd_d(product, sum); |
| 5708 |
} |
| 5709 |
} |
| 5710 |
} |
| 5711 |
XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(lsx) |
| 5712 |
|
| 5713 |
XXH_FORCE_INLINE void XXH3_scrambleAcc_lsx(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 5714 |
XXH_ASSERT((((size_t)acc) & 15) == 0); |
| 5715 |
{ |
| 5716 |
__m128i *const xacc = (__m128i *)acc; |
| 5717 |
const __m128i *const xsecret = (const __m128i *)secret; |
| 5718 |
const __m128i prime32 = __lsx_vreplgr2vr_d(XXH_PRIME32_1); |
| 5719 |
size_t i; |
| 5720 |
|
| 5721 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(__m128i); i++) { |
| 5722 |
|
| 5723 |
__m128i const acc_vec = xacc[i]; |
| 5724 |
__m128i const shifted = __lsx_vsrli_d(acc_vec, 47); |
| 5725 |
__m128i const data_vec = __lsx_vxor_v(acc_vec, shifted); |
| 5726 |
|
| 5727 |
__m128i const key_vec = __lsx_vld(xsecret + i, 0); |
| 5728 |
__m128i const data_key = __lsx_vxor_v(data_vec, key_vec); |
| 5729 |
|
| 5730 |
|
| 5731 |
xacc[i] = __lsx_vmul_d(data_key, prime32); |
| 5732 |
} |
| 5733 |
} |
| 5734 |
} |
| 5735 |
|
| 5736 |
# endif |
| 5737 |
|
| 5738 |
# if (XXH_VECTOR == XXH_LASX) |
| 5739 |
# define _LASX_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) |
| 5740 |
|
| 5741 |
XXH_FORCE_INLINE void XXH3_accumulate_512_lasx( |
| 5742 |
void *XXH_RESTRICT acc, |
| 5743 |
const void *XXH_RESTRICT input, |
| 5744 |
const void *XXH_RESTRICT secret) { |
| 5745 |
XXH_ASSERT((((size_t)acc) & 31) == 0); |
| 5746 |
{ |
| 5747 |
size_t i; |
| 5748 |
__m256i *const xacc = (__m256i *)acc; |
| 5749 |
const __m256i *const xinput = (const __m256i *)input; |
| 5750 |
const __m256i *const xsecret = (const __m256i *)secret; |
| 5751 |
|
| 5752 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(__m256i); i++) { |
| 5753 |
|
| 5754 |
__m256i const data_vec = __lasx_xvld(xinput + i, 0); |
| 5755 |
|
| 5756 |
__m256i const key_vec = __lasx_xvld(xsecret + i, 0); |
| 5757 |
|
| 5758 |
__m256i const data_key = __lasx_xvxor_v(data_vec, key_vec); |
| 5759 |
|
| 5760 |
__m256i const data_key_lo = __lasx_xvsrli_d(data_key, 32); |
| 5761 |
|
| 5762 |
|
| 5763 |
__m256i const product = __lasx_xvmulwev_d_wu(data_key, data_key_lo); |
| 5764 |
|
| 5765 |
__m256i const data_swap = __lasx_xvshuf4i_w(data_vec, _LASX_SHUFFLE(1, 0, 3, 2)); |
| 5766 |
__m256i const sum = __lasx_xvadd_d(xacc[i], data_swap); |
| 5767 |
|
| 5768 |
xacc[i] = __lasx_xvadd_d(product, sum); |
| 5769 |
} |
| 5770 |
} |
| 5771 |
} |
| 5772 |
XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(lasx) |
| 5773 |
|
| 5774 |
XXH_FORCE_INLINE void XXH3_scrambleAcc_lasx(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 5775 |
XXH_ASSERT((((size_t)acc) & 31) == 0); |
| 5776 |
{ |
| 5777 |
__m256i *const xacc = (__m256i *)acc; |
| 5778 |
const __m256i *const xsecret = (const __m256i *)secret; |
| 5779 |
const __m256i prime32 = __lasx_xvreplgr2vr_d(XXH_PRIME32_1); |
| 5780 |
size_t i; |
| 5781 |
|
| 5782 |
for (i = 0; i < XXH_STRIPE_LEN / sizeof(__m256i); i++) { |
| 5783 |
|
| 5784 |
__m256i const acc_vec = xacc[i]; |
| 5785 |
__m256i const shifted = __lasx_xvsrli_d(acc_vec, 47); |
| 5786 |
__m256i const data_vec = __lasx_xvxor_v(acc_vec, shifted); |
| 5787 |
|
| 5788 |
__m256i const key_vec = __lasx_xvld(xsecret + i, 0); |
| 5789 |
__m256i const data_key = __lasx_xvxor_v(data_vec, key_vec); |
| 5790 |
|
| 5791 |
|
| 5792 |
xacc[i] = __lasx_xvmul_d(data_key, prime32); |
| 5793 |
} |
| 5794 |
} |
| 5795 |
} |
| 5796 |
|
| 5797 |
# endif |
| 5798 |
|
| 5799 |
# if (XXH_VECTOR == XXH_RVV) |
| 5800 |
# define XXH_CONCAT2(X, Y) X##Y |
| 5801 |
# define XXH_CONCAT(X, Y) XXH_CONCAT2(X, Y) |
| 5802 |
# if ( \ |
| 5803 |
(defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 13) || \ |
| 5804 |
(defined(__clang__) && __clang_major__ < 16)) |
| 5805 |
# define XXH_RVOP(op) op |
| 5806 |
# define XXH_RVCAST(op) XXH_CONCAT(vreinterpret_v_, op) |
| 5807 |
# else |
| 5808 |
# define XXH_RVOP(op) XXH_CONCAT(__riscv_, op) |
| 5809 |
# define XXH_RVCAST(op) XXH_CONCAT(__riscv_vreinterpret_v_, op) |
| 5810 |
# endif |
| 5811 |
XXH_FORCE_INLINE void XXH3_accumulate_512_rvv( |
| 5812 |
void *XXH_RESTRICT acc, |
| 5813 |
const void *XXH_RESTRICT input, |
| 5814 |
const void *XXH_RESTRICT secret) { |
| 5815 |
XXH_ASSERT((((size_t)acc) & 63) == 0); |
| 5816 |
{ |
| 5817 |
|
| 5818 |
|
| 5819 |
size_t vl = XXH_RVOP(vsetvl_e64m2)(8); |
| 5820 |
|
| 5821 |
uint64_t *xacc = (uint64_t *)acc; |
| 5822 |
const uint64_t *xinput = (const uint64_t *)input; |
| 5823 |
const uint64_t *xsecret = (const uint64_t *)secret; |
| 5824 |
static const uint64_t swap_mask[16] = {1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}; |
| 5825 |
vuint64m2_t xswap_mask = XXH_RVOP(vle64_v_u64m2)(swap_mask, vl); |
| 5826 |
|
| 5827 |
size_t i; |
| 5828 |
for (i = 0; i < XXH_STRIPE_LEN / 8; i += vl) { |
| 5829 |
|
| 5830 |
vuint64m2_t data_vec = XXH_RVCAST(u8m2_u64m2)(XXH_RVOP(vle8_v_u8m2)((const uint8_t *)(xinput + i), vl * 8)); |
| 5831 |
|
| 5832 |
vuint64m2_t key_vec = XXH_RVCAST(u8m2_u64m2)(XXH_RVOP(vle8_v_u8m2)((const uint8_t *)(xsecret + i), vl * 8)); |
| 5833 |
|
| 5834 |
vuint64m2_t acc_vec = XXH_RVOP(vle64_v_u64m2)(xacc + i, vl); |
| 5835 |
|
| 5836 |
vuint64m2_t data_key = XXH_RVOP(vxor_vv_u64m2)(data_vec, key_vec, vl); |
| 5837 |
|
| 5838 |
vuint64m2_t data_key_hi = XXH_RVOP(vsrl_vx_u64m2)(data_key, 32, vl); |
| 5839 |
|
| 5840 |
vuint64m2_t data_key_lo = XXH_RVOP(vand_vx_u64m2)(data_key, 0xffffffff, vl); |
| 5841 |
|
| 5842 |
vuint64m2_t data_swap = XXH_RVOP(vrgather_vv_u64m2)(data_vec, xswap_mask, vl); |
| 5843 |
|
| 5844 |
acc_vec = XXH_RVOP(vmacc_vv_u64m2)(acc_vec, data_key_lo, data_key_hi, vl); |
| 5845 |
|
| 5846 |
acc_vec = XXH_RVOP(vadd_vv_u64m2)(acc_vec, data_swap, vl); |
| 5847 |
|
| 5848 |
XXH_RVOP(vse64_v_u64m2)(xacc + i, acc_vec, vl); |
| 5849 |
} |
| 5850 |
} |
| 5851 |
} |
| 5852 |
|
| 5853 |
XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(rvv) |
| 5854 |
|
| 5855 |
XXH_FORCE_INLINE void XXH3_scrambleAcc_rvv(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 5856 |
XXH_ASSERT((((size_t)acc) & 15) == 0); |
| 5857 |
{ |
| 5858 |
size_t count = XXH_STRIPE_LEN / 8; |
| 5859 |
uint64_t *xacc = (uint64_t *)acc; |
| 5860 |
const uint8_t *xsecret = (const uint8_t *)secret; |
| 5861 |
size_t vl; |
| 5862 |
for (; count > 0; count -= vl, xacc += vl, xsecret += vl * 8) { |
| 5863 |
vl = XXH_RVOP(vsetvl_e64m2)(count); |
| 5864 |
{ |
| 5865 |
|
| 5866 |
vuint64m2_t key_vec = XXH_RVCAST(u8m2_u64m2)(XXH_RVOP(vle8_v_u8m2)(xsecret, vl * 8)); |
| 5867 |
|
| 5868 |
vuint64m2_t acc_vec = XXH_RVOP(vle64_v_u64m2)(xacc, vl); |
| 5869 |
|
| 5870 |
vuint64m2_t vsrl = XXH_RVOP(vsrl_vx_u64m2)(acc_vec, 47, vl); |
| 5871 |
acc_vec = XXH_RVOP(vxor_vv_u64m2)(acc_vec, vsrl, vl); |
| 5872 |
|
| 5873 |
acc_vec = XXH_RVOP(vxor_vv_u64m2)(acc_vec, key_vec, vl); |
| 5874 |
|
| 5875 |
acc_vec = XXH_RVOP(vmul_vx_u64m2)(acc_vec, XXH_PRIME32_1, vl); |
| 5876 |
|
| 5877 |
XXH_RVOP(vse64_v_u64m2)(xacc, acc_vec, vl); |
| 5878 |
} |
| 5879 |
} |
| 5880 |
} |
| 5881 |
} |
| 5882 |
|
| 5883 |
XXH_FORCE_INLINE void XXH3_initCustomSecret_rvv(void *XXH_RESTRICT customSecret, xxh_u64 seed64) { |
| 5884 |
XXH_STATIC_ASSERT(XXH_SEC_ALIGN >= 8); |
| 5885 |
XXH_ASSERT(((size_t)customSecret & 7) == 0); |
| 5886 |
(void)(&XXH_writeLE64); |
| 5887 |
{ |
| 5888 |
size_t count = XXH_SECRET_DEFAULT_SIZE / 8; |
| 5889 |
size_t vl; |
| 5890 |
size_t VLMAX = XXH_RVOP(vsetvlmax_e64m2)(); |
| 5891 |
int64_t *cSecret = (int64_t *)customSecret; |
| 5892 |
const int64_t *kSecret = (const int64_t *)(const void *)XXH3_kSecret; |
| 5893 |
|
| 5894 |
# if __riscv_v_intrinsic >= 1000000 |
| 5895 |
|
| 5896 |
vbool32_t mneg = XXH_RVCAST(u8m1_b32)(XXH_RVOP(vmv_v_x_u8m1)(0xaa, XXH_RVOP(vsetvlmax_e8m1)())); |
| 5897 |
# else |
| 5898 |
|
| 5899 |
size_t vlmax = XXH_RVOP(vsetvlmax_e8m1)(); |
| 5900 |
vbool32_t mneg = |
| 5901 |
XXH_RVOP(vmseq_vx_u8mf4_b32)(XXH_RVOP(vand_vx_u8mf4)(XXH_RVOP(vid_v_u8mf4)(vlmax), 1, vlmax), 1, vlmax); |
| 5902 |
# endif |
| 5903 |
vint64m2_t seed = XXH_RVOP(vmv_v_x_i64m2)((int64_t)seed64, VLMAX); |
| 5904 |
seed = XXH_RVOP(vneg_v_i64m2_mu)(mneg, seed, seed, VLMAX); |
| 5905 |
|
| 5906 |
for (; count > 0; count -= vl, cSecret += vl, kSecret += vl) { |
| 5907 |
|
| 5908 |
vl = XXH_RVOP(vsetvl_e64m2)(count < VLMAX ? count : VLMAX); |
| 5909 |
{ |
| 5910 |
vint64m2_t src = XXH_RVOP(vle64_v_i64m2)(kSecret, vl); |
| 5911 |
vint64m2_t res = XXH_RVOP(vadd_vv_i64m2)(src, seed, vl); |
| 5912 |
XXH_RVOP(vse64_v_i64m2)(cSecret, res, vl); |
| 5913 |
} |
| 5914 |
} |
| 5915 |
} |
| 5916 |
} |
| 5917 |
# endif |
| 5918 |
|
| 5919 |
|
| 5920 |
|
| 5921 |
# if defined(__aarch64__) && (defined(__GNUC__) || defined(__clang__)) |
| 5922 |
|
| 5923 |
|
| 5924 |
|
| 5925 |
|
| 5926 |
|
| 5927 |
|
| 5928 |
|
| 5929 |
|
| 5930 |
|
| 5931 |
|
| 5932 |
|
| 5933 |
|
| 5934 |
|
| 5935 |
|
| 5936 |
XXH_FORCE_INLINE xxh_u64 XXH_mult32to64_add64(xxh_u64 lhs, xxh_u64 rhs, xxh_u64 acc) { |
| 5937 |
xxh_u64 ret; |
| 5938 |
|
| 5939 |
__asm__("umaddl %x0, %w1, %w2, %x3" : "=r"(ret) : "r"(lhs), "r"(rhs), "r"(acc)); |
| 5940 |
return ret; |
| 5941 |
} |
| 5942 |
# else |
| 5943 |
XXH_FORCE_INLINE xxh_u64 XXH_mult32to64_add64(xxh_u64 lhs, xxh_u64 rhs, xxh_u64 acc) { |
| 5944 |
return XXH_mult32to64((xxh_u32)lhs, (xxh_u32)rhs) + acc; |
| 5945 |
} |
| 5946 |
# endif |
| 5947 |
|
| 5948 |
|
| 5949 |
|
| 5950 |
|
| 5951 |
|
| 5952 |
|
| 5953 |
|
| 5954 |
|
| 5955 |
XXH_FORCE_INLINE void XXH3_scalarRound( |
| 5956 |
void *XXH_RESTRICT acc, |
| 5957 |
void const *XXH_RESTRICT input, |
| 5958 |
void const *XXH_RESTRICT secret, |
| 5959 |
size_t lane) { |
| 5960 |
xxh_u64 *xacc = (xxh_u64 *)acc; |
| 5961 |
xxh_u8 const *xinput = (xxh_u8 const *)input; |
| 5962 |
xxh_u8 const *xsecret = (xxh_u8 const *)secret; |
| 5963 |
XXH_ASSERT(lane < XXH_ACC_NB); |
| 5964 |
XXH_ASSERT(((size_t)acc & (XXH_ACC_ALIGN - 1)) == 0); |
| 5965 |
{ |
| 5966 |
xxh_u64 const data_val = XXH_readLE64(xinput + lane * 8); |
| 5967 |
xxh_u64 const data_key = data_val ^ XXH_readLE64(xsecret + lane * 8); |
| 5968 |
xacc[lane ^ 1] += data_val; |
| 5969 |
xacc[lane] = XXH_mult32to64_add64(data_key , data_key >> 32, xacc[lane]); |
| 5970 |
} |
| 5971 |
} |
| 5972 |
|
| 5973 |
|
| 5974 |
|
| 5975 |
|
| 5976 |
|
| 5977 |
XXH_FORCE_INLINE void XXH3_accumulate_512_scalar( |
| 5978 |
void *XXH_RESTRICT acc, |
| 5979 |
const void *XXH_RESTRICT input, |
| 5980 |
const void *XXH_RESTRICT secret) { |
| 5981 |
size_t i; |
| 5982 |
|
| 5983 |
# if defined(__GNUC__) && !defined(__clang__) && (defined(__arm__) || defined(__thumb2__)) && \ |
| 5984 |
defined(__ARM_FEATURE_UNALIGNED) \ |
| 5985 |
&& XXH_SIZE_OPT <= 0 |
| 5986 |
# pragma GCC unroll 8 |
| 5987 |
# endif |
| 5988 |
for (i = 0; i < XXH_ACC_NB; i++) { |
| 5989 |
XXH3_scalarRound(acc, input, secret, i); |
| 5990 |
} |
| 5991 |
} |
| 5992 |
XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(scalar) |
| 5993 |
|
| 5994 |
|
| 5995 |
|
| 5996 |
|
| 5997 |
|
| 5998 |
|
| 5999 |
|
| 6000 |
|
| 6001 |
XXH_FORCE_INLINE |
| 6002 |
void XXH3_scalarScrambleRound(void *XXH_RESTRICT acc, void const *XXH_RESTRICT secret, size_t lane) { |
| 6003 |
xxh_u64 *const xacc = (xxh_u64 *)acc; |
| 6004 |
const xxh_u8 *const xsecret = (const xxh_u8 *)secret; |
| 6005 |
XXH_ASSERT((((size_t)acc) & (XXH_ACC_ALIGN - 1)) == 0); |
| 6006 |
XXH_ASSERT(lane < XXH_ACC_NB); |
| 6007 |
{ |
| 6008 |
xxh_u64 const key64 = XXH_readLE64(xsecret + lane * 8); |
| 6009 |
xxh_u64 acc64 = xacc[lane]; |
| 6010 |
acc64 = XXH_xorshift64(acc64, 47); |
| 6011 |
acc64 ^= key64; |
| 6012 |
acc64 *= XXH_PRIME32_1; |
| 6013 |
xacc[lane] = acc64; |
| 6014 |
} |
| 6015 |
} |
| 6016 |
|
| 6017 |
|
| 6018 |
|
| 6019 |
|
| 6020 |
|
| 6021 |
XXH_FORCE_INLINE void XXH3_scrambleAcc_scalar(void *XXH_RESTRICT acc, const void *XXH_RESTRICT secret) { |
| 6022 |
size_t i; |
| 6023 |
for (i = 0; i < XXH_ACC_NB; i++) { |
| 6024 |
XXH3_scalarScrambleRound(acc, secret, i); |
| 6025 |
} |
| 6026 |
} |
| 6027 |
|
| 6028 |
XXH_FORCE_INLINE void XXH3_initCustomSecret_scalar(void *XXH_RESTRICT customSecret, xxh_u64 seed64) { |
| 6029 |
|
| 6030 |
|
| 6031 |
|
| 6032 |
|
| 6033 |
|
| 6034 |
const xxh_u8 *kSecretPtr = XXH3_kSecret; |
| 6035 |
XXH_STATIC_ASSERT((XXH_SECRET_DEFAULT_SIZE & 15) == 0); |
| 6036 |
|
| 6037 |
# if defined(__GNUC__) && defined(__aarch64__) |
| 6038 |
|
| 6039 |
|
| 6040 |
|
| 6041 |
|
| 6042 |
|
| 6043 |
|
| 6044 |
|
| 6045 |
|
| 6046 |
|
| 6047 |
|
| 6048 |
|
| 6049 |
|
| 6050 |
|
| 6051 |
|
| 6052 |
|
| 6053 |
|
| 6054 |
|
| 6055 |
|
| 6056 |
|
| 6057 |
|
| 6058 |
|
| 6059 |
|
| 6060 |
|
| 6061 |
|
| 6062 |
|
| 6063 |
|
| 6064 |
|
| 6065 |
|
| 6066 |
|
| 6067 |
|
| 6068 |
|
| 6069 |
|
| 6070 |
XXH_COMPILER_GUARD(kSecretPtr); |
| 6071 |
# endif |
| 6072 |
{ |
| 6073 |
int const nbRounds = XXH_SECRET_DEFAULT_SIZE / 16; |
| 6074 |
int i; |
| 6075 |
for (i = 0; i < nbRounds; i++) { |
| 6076 |
|
| 6077 |
|
| 6078 |
|
| 6079 |
|
| 6080 |
|
| 6081 |
|
| 6082 |
xxh_u64 lo = XXH_readLE64(kSecretPtr + 16 * i) + seed64; |
| 6083 |
xxh_u64 hi = XXH_readLE64(kSecretPtr + 16 * i + 8) - seed64; |
| 6084 |
XXH_writeLE64((xxh_u8 *)customSecret + 16 * i, lo); |
| 6085 |
XXH_writeLE64((xxh_u8 *)customSecret + 16 * i + 8, hi); |
| 6086 |
} |
| 6087 |
} |
| 6088 |
} |
| 6089 |
|
| 6090 |
typedef void ( |
| 6091 |
*XXH3_f_accumulate)(xxh_u64 *XXH_RESTRICT, const xxh_u8 *XXH_RESTRICT, const xxh_u8 *XXH_RESTRICT, size_t); |
| 6092 |
typedef void (*XXH3_f_scrambleAcc)(void *XXH_RESTRICT, const void *); |
| 6093 |
typedef void (*XXH3_f_initCustomSecret)(void *XXH_RESTRICT, xxh_u64); |
| 6094 |
|
| 6095 |
# if (XXH_VECTOR == XXH_AVX512) |
| 6096 |
|
| 6097 |
# define XXH3_accumulate_512 XXH3_accumulate_512_avx512 |
| 6098 |
# define XXH3_accumulate XXH3_accumulate_avx512 |
| 6099 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_avx512 |
| 6100 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_avx512 |
| 6101 |
|
| 6102 |
# elif (XXH_VECTOR == XXH_AVX2) |
| 6103 |
|
| 6104 |
# define XXH3_accumulate_512 XXH3_accumulate_512_avx2 |
| 6105 |
# define XXH3_accumulate XXH3_accumulate_avx2 |
| 6106 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_avx2 |
| 6107 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_avx2 |
| 6108 |
|
| 6109 |
# elif (XXH_VECTOR == XXH_SSE2) |
| 6110 |
|
| 6111 |
# define XXH3_accumulate_512 XXH3_accumulate_512_sse2 |
| 6112 |
# define XXH3_accumulate XXH3_accumulate_sse2 |
| 6113 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_sse2 |
| 6114 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_sse2 |
| 6115 |
|
| 6116 |
# elif (XXH_VECTOR == XXH_NEON) |
| 6117 |
|
| 6118 |
# define XXH3_accumulate_512 XXH3_accumulate_512_neon |
| 6119 |
# define XXH3_accumulate XXH3_accumulate_neon |
| 6120 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_neon |
| 6121 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_scalar |
| 6122 |
|
| 6123 |
# elif (XXH_VECTOR == XXH_VSX) |
| 6124 |
|
| 6125 |
# define XXH3_accumulate_512 XXH3_accumulate_512_vsx |
| 6126 |
# define XXH3_accumulate XXH3_accumulate_vsx |
| 6127 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_vsx |
| 6128 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_scalar |
| 6129 |
|
| 6130 |
# elif (XXH_VECTOR == XXH_SVE) |
| 6131 |
# define XXH3_accumulate_512 XXH3_accumulate_512_sve |
| 6132 |
# define XXH3_accumulate XXH3_accumulate_sve |
| 6133 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_scalar |
| 6134 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_scalar |
| 6135 |
|
| 6136 |
# elif (XXH_VECTOR == XXH_LASX) |
| 6137 |
# define XXH3_accumulate_512 XXH3_accumulate_512_lasx |
| 6138 |
# define XXH3_accumulate XXH3_accumulate_lasx |
| 6139 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_lasx |
| 6140 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_scalar |
| 6141 |
|
| 6142 |
# elif (XXH_VECTOR == XXH_LSX) |
| 6143 |
# define XXH3_accumulate_512 XXH3_accumulate_512_lsx |
| 6144 |
# define XXH3_accumulate XXH3_accumulate_lsx |
| 6145 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_lsx |
| 6146 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_scalar |
| 6147 |
|
| 6148 |
# elif (XXH_VECTOR == XXH_RVV) |
| 6149 |
# define XXH3_accumulate_512 XXH3_accumulate_512_rvv |
| 6150 |
# define XXH3_accumulate XXH3_accumulate_rvv |
| 6151 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_rvv |
| 6152 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_rvv |
| 6153 |
|
| 6154 |
# else |
| 6155 |
|
| 6156 |
# define XXH3_accumulate_512 XXH3_accumulate_512_scalar |
| 6157 |
# define XXH3_accumulate XXH3_accumulate_scalar |
| 6158 |
# define XXH3_scrambleAcc XXH3_scrambleAcc_scalar |
| 6159 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_scalar |
| 6160 |
|
| 6161 |
# endif |
| 6162 |
|
| 6163 |
# if XXH_SIZE_OPT >= 1 |
| 6164 |
# undef XXH3_initCustomSecret |
| 6165 |
# define XXH3_initCustomSecret XXH3_initCustomSecret_scalar |
| 6166 |
# endif |
| 6167 |
|
| 6168 |
XXH_FORCE_INLINE void XXH3_hashLong_internal_loop( |
| 6169 |
xxh_u64 *XXH_RESTRICT acc, |
| 6170 |
const xxh_u8 *XXH_RESTRICT input, |
| 6171 |
size_t len, |
| 6172 |
const xxh_u8 *XXH_RESTRICT secret, |
| 6173 |
size_t secretSize, |
| 6174 |
XXH3_f_accumulate f_acc, |
| 6175 |
XXH3_f_scrambleAcc f_scramble) { |
| 6176 |
size_t const nbStripesPerBlock = (secretSize - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE; |
| 6177 |
size_t const block_len = XXH_STRIPE_LEN * nbStripesPerBlock; |
| 6178 |
size_t const nb_blocks = (len - 1) / block_len; |
| 6179 |
|
| 6180 |
size_t n; |
| 6181 |
|
| 6182 |
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); |
| 6183 |
|
| 6184 |
for (n = 0; n < nb_blocks; n++) { |
| 6185 |
f_acc(acc, input + n * block_len, secret, nbStripesPerBlock); |
| 6186 |
f_scramble(acc, secret + secretSize - XXH_STRIPE_LEN); |
| 6187 |
} |
| 6188 |
|
| 6189 |
|
| 6190 |
XXH_ASSERT(len > XXH_STRIPE_LEN); |
| 6191 |
{ |
| 6192 |
size_t const nbStripes = ((len - 1) - (block_len * nb_blocks)) / XXH_STRIPE_LEN; |
| 6193 |
XXH_ASSERT(nbStripes <= (secretSize / XXH_SECRET_CONSUME_RATE)); |
| 6194 |
f_acc(acc, input + nb_blocks * block_len, secret, nbStripes); |
| 6195 |
|
| 6196 |
|
| 6197 |
{ |
| 6198 |
const xxh_u8 *const p = input + len - XXH_STRIPE_LEN; |
| 6199 |
# define XXH_SECRET_LASTACC_START 7 |
| 6200 |
XXH3_accumulate_512(acc, p, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START); |
| 6201 |
} |
| 6202 |
} |
| 6203 |
} |
| 6204 |
|
| 6205 |
XXH_FORCE_INLINE xxh_u64 XXH3_mix2Accs(const xxh_u64 *XXH_RESTRICT acc, const xxh_u8 *XXH_RESTRICT secret) { |
| 6206 |
return XXH3_mul128_fold64(acc[0] ^ XXH_readLE64(secret), acc[1] ^ XXH_readLE64(secret + 8)); |
| 6207 |
} |
| 6208 |
|
| 6209 |
static XXH_PUREF XXH64_hash_t |
| 6210 |
XXH3_mergeAccs(const xxh_u64 *XXH_RESTRICT acc, const xxh_u8 *XXH_RESTRICT secret, xxh_u64 start) { |
| 6211 |
xxh_u64 result64 = start; |
| 6212 |
size_t i = 0; |
| 6213 |
|
| 6214 |
for (i = 0; i < 4; i++) { |
| 6215 |
result64 += XXH3_mix2Accs(acc + 2 * i, secret + 16 * i); |
| 6216 |
# if defined(__clang__) \ |
| 6217 |
&& (defined(__arm__) || defined(__thumb__)) \ |
| 6218 |
&& (defined(__ARM_NEON) || defined(__ARM_NEON__)) \ |
| 6219 |
&& !defined(XXH_ENABLE_AUTOVECTORIZE) |
| 6220 |
|
| 6221 |
|
| 6222 |
|
| 6223 |
|
| 6224 |
|
| 6225 |
|
| 6226 |
|
| 6227 |
|
| 6228 |
XXH_COMPILER_GUARD(result64); |
| 6229 |
# endif |
| 6230 |
} |
| 6231 |
|
| 6232 |
return XXH3_avalanche(result64); |
| 6233 |
} |
| 6234 |
|
| 6235 |
|
| 6236 |
# define XXH_SECRET_MERGEACCS_START 11 |
| 6237 |
|
| 6238 |
static XXH_PUREF XXH64_hash_t |
| 6239 |
XXH3_finalizeLong_64b(const xxh_u64 *XXH_RESTRICT acc, const xxh_u8 *XXH_RESTRICT secret, xxh_u64 len) { |
| 6240 |
return XXH3_mergeAccs(acc, secret + XXH_SECRET_MERGEACCS_START, len * XXH_PRIME64_1); |
| 6241 |
} |
| 6242 |
|
| 6243 |
# define XXH3_INIT_ACC \ |
| 6244 |
{XXH_PRIME32_3, \ |
| 6245 |
XXH_PRIME64_1, \ |
| 6246 |
XXH_PRIME64_2, \ |
| 6247 |
XXH_PRIME64_3, \ |
| 6248 |
XXH_PRIME64_4, \ |
| 6249 |
XXH_PRIME32_2, \ |
| 6250 |
XXH_PRIME64_5, \ |
| 6251 |
XXH_PRIME32_1} |
| 6252 |
|
| 6253 |
XXH_FORCE_INLINE XXH64_hash_t XXH3_hashLong_64b_internal( |
| 6254 |
const void *XXH_RESTRICT input, |
| 6255 |
size_t len, |
| 6256 |
const void *XXH_RESTRICT secret, |
| 6257 |
size_t secretSize, |
| 6258 |
XXH3_f_accumulate f_acc, |
| 6259 |
XXH3_f_scrambleAcc f_scramble) { |
| 6260 |
XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[XXH_ACC_NB] = XXH3_INIT_ACC; |
| 6261 |
|
| 6262 |
XXH3_hashLong_internal_loop(acc, (const xxh_u8 *)input, len, (const xxh_u8 *)secret, secretSize, f_acc, f_scramble); |
| 6263 |
|
| 6264 |
|
| 6265 |
XXH_STATIC_ASSERT(sizeof(acc) == 64); |
| 6266 |
XXH_ASSERT(secretSize >= sizeof(acc) + XXH_SECRET_MERGEACCS_START); |
| 6267 |
return XXH3_finalizeLong_64b(acc, (const xxh_u8 *)secret, (xxh_u64)len); |
| 6268 |
} |
| 6269 |
|
| 6270 |
|
| 6271 |
|
| 6272 |
|
| 6273 |
|
| 6274 |
|
| 6275 |
|
| 6276 |
|
| 6277 |
XXH3_WITH_SECRET_INLINE XXH64_hash_t XXH3_hashLong_64b_withSecret( |
| 6278 |
const void *XXH_RESTRICT input, |
| 6279 |
size_t len, |
| 6280 |
XXH64_hash_t seed64, |
| 6281 |
const xxh_u8 *XXH_RESTRICT secret, |
| 6282 |
size_t secretLen) { |
| 6283 |
(void)seed64; |
| 6284 |
return XXH3_hashLong_64b_internal(input, len, secret, secretLen, XXH3_accumulate, XXH3_scrambleAcc); |
| 6285 |
} |
| 6286 |
|
| 6287 |
|
| 6288 |
|
| 6289 |
|
| 6290 |
|
| 6291 |
|
| 6292 |
|
| 6293 |
XXH_NO_INLINE XXH_PUREF XXH64_hash_t XXH3_hashLong_64b_default( |
| 6294 |
const void *XXH_RESTRICT input, |
| 6295 |
size_t len, |
| 6296 |
XXH64_hash_t seed64, |
| 6297 |
const xxh_u8 *XXH_RESTRICT secret, |
| 6298 |
size_t secretLen) { |
| 6299 |
(void)seed64; |
| 6300 |
(void)secret; |
| 6301 |
(void)secretLen; |
| 6302 |
return XXH3_hashLong_64b_internal( |
| 6303 |
input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate, XXH3_scrambleAcc); |
| 6304 |
} |
| 6305 |
|
| 6306 |
|
| 6307 |
|
| 6308 |
|
| 6309 |
|
| 6310 |
|
| 6311 |
|
| 6312 |
|
| 6313 |
|
| 6314 |
|
| 6315 |
|
| 6316 |
|
| 6317 |
XXH_FORCE_INLINE XXH64_hash_t XXH3_hashLong_64b_withSeed_internal( |
| 6318 |
const void *input, |
| 6319 |
size_t len, |
| 6320 |
XXH64_hash_t seed, |
| 6321 |
XXH3_f_accumulate f_acc, |
| 6322 |
XXH3_f_scrambleAcc f_scramble, |
| 6323 |
XXH3_f_initCustomSecret f_initSec) { |
| 6324 |
# if XXH_SIZE_OPT <= 0 |
| 6325 |
if (seed == 0) |
| 6326 |
return XXH3_hashLong_64b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), f_acc, f_scramble); |
| 6327 |
# endif |
| 6328 |
{ |
| 6329 |
XXH_ALIGN(XXH_SEC_ALIGN) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE]; |
| 6330 |
f_initSec(secret, seed); |
| 6331 |
return XXH3_hashLong_64b_internal(input, len, secret, sizeof(secret), f_acc, f_scramble); |
| 6332 |
} |
| 6333 |
} |
| 6334 |
|
| 6335 |
|
| 6336 |
|
| 6337 |
|
| 6338 |
XXH_NO_INLINE XXH64_hash_t XXH3_hashLong_64b_withSeed( |
| 6339 |
const void *XXH_RESTRICT input, |
| 6340 |
size_t len, |
| 6341 |
XXH64_hash_t seed, |
| 6342 |
const xxh_u8 *XXH_RESTRICT secret, |
| 6343 |
size_t secretLen) { |
| 6344 |
(void)secret; |
| 6345 |
(void)secretLen; |
| 6346 |
return XXH3_hashLong_64b_withSeed_internal( |
| 6347 |
input, len, seed, XXH3_accumulate, XXH3_scrambleAcc, XXH3_initCustomSecret); |
| 6348 |
} |
| 6349 |
|
| 6350 |
typedef XXH64_hash_t ( |
| 6351 |
*XXH3_hashLong64_f)(const void *XXH_RESTRICT, size_t, XXH64_hash_t, const xxh_u8 *XXH_RESTRICT, size_t); |
| 6352 |
|
| 6353 |
XXH_FORCE_INLINE XXH64_hash_t XXH3_64bits_internal( |
| 6354 |
const void *XXH_RESTRICT input, |
| 6355 |
size_t len, |
| 6356 |
XXH64_hash_t seed64, |
| 6357 |
const void *XXH_RESTRICT secret, |
| 6358 |
size_t secretLen, |
| 6359 |
XXH3_hashLong64_f f_hashLong) { |
| 6360 |
XXH_ASSERT(secretLen >= XXH3_SECRET_SIZE_MIN); |
| 6361 |
|
| 6362 |
|
| 6363 |
|
| 6364 |
|
| 6365 |
|
| 6366 |
|
| 6367 |
|
| 6368 |
if (len <= 16) |
| 6369 |
return XXH3_len_0to16_64b((const xxh_u8 *)input, len, (const xxh_u8 *)secret, seed64); |
| 6370 |
if (len <= 128) |
| 6371 |
return XXH3_len_17to128_64b((const xxh_u8 *)input, len, (const xxh_u8 *)secret, secretLen, seed64); |
| 6372 |
if (len <= XXH3_MIDSIZE_MAX) |
| 6373 |
return XXH3_len_129to240_64b((const xxh_u8 *)input, len, (const xxh_u8 *)secret, secretLen, seed64); |
| 6374 |
return f_hashLong(input, len, seed64, (const xxh_u8 *)secret, secretLen); |
| 6375 |
} |
| 6376 |
|
| 6377 |
|
| 6378 |
|
| 6379 |
|
| 6380 |
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(XXH_NOESCAPE const void *input, size_t length) { |
| 6381 |
return XXH3_64bits_internal(input, length, 0, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_64b_default); |
| 6382 |
} |
| 6383 |
|
| 6384 |
|
| 6385 |
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecret( |
| 6386 |
XXH_NOESCAPE const void *input, |
| 6387 |
size_t length, |
| 6388 |
XXH_NOESCAPE const void *secret, |
| 6389 |
size_t secretSize) { |
| 6390 |
return XXH3_64bits_internal(input, length, 0, secret, secretSize, XXH3_hashLong_64b_withSecret); |
| 6391 |
} |
| 6392 |
|
| 6393 |
|
| 6394 |
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(XXH_NOESCAPE const void *input, size_t length, XXH64_hash_t seed) { |
| 6395 |
return XXH3_64bits_internal(input, length, seed, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_64b_withSeed); |
| 6396 |
} |
| 6397 |
|
| 6398 |
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecretandSeed( |
| 6399 |
XXH_NOESCAPE const void *input, |
| 6400 |
size_t length, |
| 6401 |
XXH_NOESCAPE const void *secret, |
| 6402 |
size_t secretSize, |
| 6403 |
XXH64_hash_t seed) { |
| 6404 |
if (length <= XXH3_MIDSIZE_MAX) |
| 6405 |
return XXH3_64bits_internal(input, length, seed, XXH3_kSecret, sizeof(XXH3_kSecret), NULL); |
| 6406 |
return XXH3_hashLong_64b_withSecret(input, length, seed, (const xxh_u8 *)secret, secretSize); |
| 6407 |
} |
| 6408 |
|
| 6409 |
|
| 6410 |
# ifndef XXH_NO_STREAM |
| 6411 |
|
| 6412 |
|
| 6413 |
|
| 6414 |
|
| 6415 |
|
| 6416 |
|
| 6417 |
|
| 6418 |
|
| 6419 |
|
| 6420 |
|
| 6421 |
|
| 6422 |
|
| 6423 |
|
| 6424 |
|
| 6425 |
|
| 6426 |
|
| 6427 |
|
| 6428 |
|
| 6429 |
|
| 6430 |
|
| 6431 |
|
| 6432 |
|
| 6433 |
|
| 6434 |
static XXH_MALLOCF void *XXH_alignedMalloc(size_t s, size_t align) { |
| 6435 |
XXH_ASSERT(align <= 128 && align >= 8); |
| 6436 |
XXH_ASSERT((align & (align - 1)) == 0); |
| 6437 |
XXH_ASSERT(s != 0 && s < (s + align)); |
| 6438 |
{ |
| 6439 |
xxh_u8 *base = (xxh_u8 *)XXH_malloc(s + align); |
| 6440 |
if (base != NULL) { |
| 6441 |
|
| 6442 |
|
| 6443 |
|
| 6444 |
|
| 6445 |
|
| 6446 |
|
| 6447 |
size_t offset = align - ((size_t)base & (align - 1)); |
| 6448 |
|
| 6449 |
xxh_u8 *ptr = base + offset; |
| 6450 |
|
| 6451 |
XXH_ASSERT((size_t)ptr % align == 0); |
| 6452 |
|
| 6453 |
|
| 6454 |
ptr[-1] = (xxh_u8)offset; |
| 6455 |
return ptr; |
| 6456 |
} |
| 6457 |
return NULL; |
| 6458 |
} |
| 6459 |
} |
| 6460 |
|
| 6461 |
|
| 6462 |
|
| 6463 |
|
| 6464 |
static void XXH_alignedFree(void *p) { |
| 6465 |
if (p != NULL) { |
| 6466 |
xxh_u8 *ptr = (xxh_u8 *)p; |
| 6467 |
|
| 6468 |
xxh_u8 offset = ptr[-1]; |
| 6469 |
|
| 6470 |
xxh_u8 *base = ptr - offset; |
| 6471 |
XXH_free(base); |
| 6472 |
} |
| 6473 |
} |
| 6474 |
|
| 6475 |
|
| 6476 |
|
| 6477 |
|
| 6478 |
|
| 6479 |
|
| 6480 |
|
| 6481 |
|
| 6482 |
|
| 6483 |
|
| 6484 |
|
| 6485 |
XXH_PUBLIC_API XXH3_state_t *XXH3_createState(void) { |
| 6486 |
XXH3_state_t *const state = (XXH3_state_t *)XXH_alignedMalloc(sizeof(XXH3_state_t), 64); |
| 6487 |
if (state == NULL) |
| 6488 |
return NULL; |
| 6489 |
XXH3_INITSTATE(state); |
| 6490 |
return state; |
| 6491 |
} |
| 6492 |
|
| 6493 |
|
| 6494 |
|
| 6495 |
|
| 6496 |
|
| 6497 |
|
| 6498 |
|
| 6499 |
|
| 6500 |
|
| 6501 |
|
| 6502 |
|
| 6503 |
|
| 6504 |
|
| 6505 |
XXH_PUBLIC_API XXH_errorcode XXH3_freeState(XXH3_state_t *statePtr) { |
| 6506 |
XXH_alignedFree(statePtr); |
| 6507 |
return XXH_OK; |
| 6508 |
} |
| 6509 |
|
| 6510 |
|
| 6511 |
XXH_PUBLIC_API void XXH3_copyState(XXH_NOESCAPE XXH3_state_t *dst_state, XXH_NOESCAPE const XXH3_state_t *src_state) { |
| 6512 |
XXH_memcpy(dst_state, src_state, sizeof(*dst_state)); |
| 6513 |
} |
| 6514 |
|
| 6515 |
static void XXH3_reset_internal(XXH3_state_t *statePtr, XXH64_hash_t seed, const void *secret, size_t secretSize) { |
| 6516 |
size_t const initStart = offsetof(XXH3_state_t, bufferedSize); |
| 6517 |
size_t const initLength = offsetof(XXH3_state_t, nbStripesPerBlock) - initStart; |
| 6518 |
XXH_ASSERT(offsetof(XXH3_state_t, nbStripesPerBlock) > initStart); |
| 6519 |
XXH_ASSERT(statePtr != NULL); |
| 6520 |
|
| 6521 |
XXH_memset((char *)statePtr + initStart, 0, initLength); |
| 6522 |
statePtr->acc[0] = XXH_PRIME32_3; |
| 6523 |
statePtr->acc[1] = XXH_PRIME64_1; |
| 6524 |
statePtr->acc[2] = XXH_PRIME64_2; |
| 6525 |
statePtr->acc[3] = XXH_PRIME64_3; |
| 6526 |
statePtr->acc[4] = XXH_PRIME64_4; |
| 6527 |
statePtr->acc[5] = XXH_PRIME32_2; |
| 6528 |
statePtr->acc[6] = XXH_PRIME64_5; |
| 6529 |
statePtr->acc[7] = XXH_PRIME32_1; |
| 6530 |
statePtr->seed = seed; |
| 6531 |
statePtr->useSeed = (seed != 0); |
| 6532 |
statePtr->extSecret = (const unsigned char *)secret; |
| 6533 |
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); |
| 6534 |
statePtr->secretLimit = secretSize - XXH_STRIPE_LEN; |
| 6535 |
statePtr->nbStripesPerBlock = statePtr->secretLimit / XXH_SECRET_CONSUME_RATE; |
| 6536 |
} |
| 6537 |
|
| 6538 |
|
| 6539 |
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset(XXH_NOESCAPE XXH3_state_t *statePtr) { |
| 6540 |
if (statePtr == NULL) |
| 6541 |
return XXH_ERROR; |
| 6542 |
XXH3_reset_internal(statePtr, 0, XXH3_kSecret, XXH_SECRET_DEFAULT_SIZE); |
| 6543 |
return XXH_OK; |
| 6544 |
} |
| 6545 |
|
| 6546 |
|
| 6547 |
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret( |
| 6548 |
XXH_NOESCAPE XXH3_state_t *statePtr, |
| 6549 |
XXH_NOESCAPE const void *secret, |
| 6550 |
size_t secretSize) { |
| 6551 |
if (statePtr == NULL) |
| 6552 |
return XXH_ERROR; |
| 6553 |
XXH3_reset_internal(statePtr, 0, secret, secretSize); |
| 6554 |
if (secret == NULL) |
| 6555 |
return XXH_ERROR; |
| 6556 |
if (secretSize < XXH3_SECRET_SIZE_MIN) |
| 6557 |
return XXH_ERROR; |
| 6558 |
return XXH_OK; |
| 6559 |
} |
| 6560 |
|
| 6561 |
|
| 6562 |
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t *statePtr, XXH64_hash_t seed) { |
| 6563 |
if (statePtr == NULL) |
| 6564 |
return XXH_ERROR; |
| 6565 |
if (seed == 0) |
| 6566 |
return XXH3_64bits_reset(statePtr); |
| 6567 |
if ((seed != statePtr->seed) || (statePtr->extSecret != NULL)) |
| 6568 |
XXH3_initCustomSecret(statePtr->customSecret, seed); |
| 6569 |
XXH3_reset_internal(statePtr, seed, NULL, XXH_SECRET_DEFAULT_SIZE); |
| 6570 |
return XXH_OK; |
| 6571 |
} |
| 6572 |
|
| 6573 |
|
| 6574 |
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecretandSeed( |
| 6575 |
XXH_NOESCAPE XXH3_state_t *statePtr, |
| 6576 |
XXH_NOESCAPE const void *secret, |
| 6577 |
size_t secretSize, |
| 6578 |
XXH64_hash_t seed64) { |
| 6579 |
if (statePtr == NULL) |
| 6580 |
return XXH_ERROR; |
| 6581 |
if (secret == NULL) |
| 6582 |
return XXH_ERROR; |
| 6583 |
if (secretSize < XXH3_SECRET_SIZE_MIN) |
| 6584 |
return XXH_ERROR; |
| 6585 |
XXH3_reset_internal(statePtr, seed64, secret, secretSize); |
| 6586 |
statePtr->useSeed = 1; |
| 6587 |
return XXH_OK; |
| 6588 |
} |
| 6589 |
|
| 6590 |
|
| 6591 |
|
| 6592 |
|
| 6593 |
|
| 6594 |
|
| 6595 |
|
| 6596 |
|
| 6597 |
|
| 6598 |
|
| 6599 |
|
| 6600 |
|
| 6601 |
|
| 6602 |
|
| 6603 |
|
| 6604 |
|
| 6605 |
|
| 6606 |
|
| 6607 |
XXH_FORCE_INLINE const xxh_u8 *XXH3_consumeStripes( |
| 6608 |
xxh_u64 *XXH_RESTRICT acc, |
| 6609 |
size_t *XXH_RESTRICT nbStripesSoFarPtr, |
| 6610 |
size_t nbStripesPerBlock, |
| 6611 |
const xxh_u8 *XXH_RESTRICT input, |
| 6612 |
size_t nbStripes, |
| 6613 |
const xxh_u8 *XXH_RESTRICT secret, |
| 6614 |
size_t secretLimit, |
| 6615 |
XXH3_f_accumulate f_acc, |
| 6616 |
XXH3_f_scrambleAcc f_scramble) { |
| 6617 |
const xxh_u8 *initialSecret = secret + *nbStripesSoFarPtr * XXH_SECRET_CONSUME_RATE; |
| 6618 |
|
| 6619 |
if (nbStripes >= (nbStripesPerBlock - *nbStripesSoFarPtr)) { |
| 6620 |
|
| 6621 |
size_t nbStripesThisIter = nbStripesPerBlock - *nbStripesSoFarPtr; |
| 6622 |
|
| 6623 |
do { |
| 6624 |
|
| 6625 |
f_acc(acc, input, initialSecret, nbStripesThisIter); |
| 6626 |
f_scramble(acc, secret + secretLimit); |
| 6627 |
input += nbStripesThisIter * XXH_STRIPE_LEN; |
| 6628 |
nbStripes -= nbStripesThisIter; |
| 6629 |
|
| 6630 |
nbStripesThisIter = nbStripesPerBlock; |
| 6631 |
initialSecret = secret; |
| 6632 |
} while (nbStripes >= nbStripesPerBlock); |
| 6633 |
*nbStripesSoFarPtr = 0; |
| 6634 |
} |
| 6635 |
|
| 6636 |
if (nbStripes > 0) { |
| 6637 |
f_acc(acc, input, initialSecret, nbStripes); |
| 6638 |
input += nbStripes * XXH_STRIPE_LEN; |
| 6639 |
*nbStripesSoFarPtr += nbStripes; |
| 6640 |
} |
| 6641 |
|
| 6642 |
return input; |
| 6643 |
} |
| 6644 |
|
| 6645 |
# ifndef XXH3_STREAM_USE_STACK |
| 6646 |
# if XXH_SIZE_OPT <= 0 && !defined(__clang__) |
| 6647 |
# define XXH3_STREAM_USE_STACK 1 |
| 6648 |
# endif |
| 6649 |
# endif |
| 6650 |
|
| 6651 |
|
| 6652 |
|
| 6653 |
|
| 6654 |
XXH_FORCE_INLINE XXH_errorcode XXH3_update( |
| 6655 |
XXH3_state_t *XXH_RESTRICT const state, |
| 6656 |
const xxh_u8 *XXH_RESTRICT input, |
| 6657 |
size_t len, |
| 6658 |
XXH3_f_accumulate f_acc, |
| 6659 |
XXH3_f_scrambleAcc f_scramble) { |
| 6660 |
if (input == NULL) { |
| 6661 |
XXH_ASSERT(len == 0); |
| 6662 |
return XXH_OK; |
| 6663 |
} |
| 6664 |
|
| 6665 |
XXH_ASSERT(state != NULL); |
| 6666 |
state->totalLen += len; |
| 6667 |
|
| 6668 |
|
| 6669 |
XXH_ASSERT(state->bufferedSize <= XXH3_INTERNALBUFFER_SIZE); |
| 6670 |
if (len <= XXH3_INTERNALBUFFER_SIZE - state->bufferedSize) { |
| 6671 |
XXH_memcpy(state->buffer + state->bufferedSize, input, len); |
| 6672 |
state->bufferedSize += (XXH32_hash_t)len; |
| 6673 |
return XXH_OK; |
| 6674 |
} |
| 6675 |
|
| 6676 |
{ |
| 6677 |
const xxh_u8 *const bEnd = input + len; |
| 6678 |
const unsigned char *const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret; |
| 6679 |
# if defined(XXH3_STREAM_USE_STACK) && XXH3_STREAM_USE_STACK >= 1 |
| 6680 |
|
| 6681 |
|
| 6682 |
|
| 6683 |
|
| 6684 |
XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[8]; |
| 6685 |
XXH_memcpy(acc, state->acc, sizeof(acc)); |
| 6686 |
# else |
| 6687 |
xxh_u64 *XXH_RESTRICT const acc = state->acc; |
| 6688 |
# endif |
| 6689 |
|
| 6690 |
|
| 6691 |
# define XXH3_INTERNALBUFFER_STRIPES (XXH3_INTERNALBUFFER_SIZE / XXH_STRIPE_LEN) |
| 6692 |
XXH_STATIC_ASSERT(XXH3_INTERNALBUFFER_SIZE % XXH_STRIPE_LEN == 0); |
| 6693 |
|
| 6694 |
|
| 6695 |
|
| 6696 |
|
| 6697 |
|
| 6698 |
if (state->bufferedSize) { |
| 6699 |
size_t const loadSize = XXH3_INTERNALBUFFER_SIZE - state->bufferedSize; |
| 6700 |
XXH_memcpy(state->buffer + state->bufferedSize, input, loadSize); |
| 6701 |
input += loadSize; |
| 6702 |
XXH3_consumeStripes( |
| 6703 |
acc, |
| 6704 |
&state->nbStripesSoFar, |
| 6705 |
state->nbStripesPerBlock, |
| 6706 |
state->buffer, |
| 6707 |
XXH3_INTERNALBUFFER_STRIPES, |
| 6708 |
secret, |
| 6709 |
state->secretLimit, |
| 6710 |
f_acc, |
| 6711 |
f_scramble); |
| 6712 |
state->bufferedSize = 0; |
| 6713 |
} |
| 6714 |
XXH_ASSERT(input < bEnd); |
| 6715 |
if (bEnd - input > XXH3_INTERNALBUFFER_SIZE) { |
| 6716 |
size_t nbStripes = (size_t)(bEnd - 1 - input) / XXH_STRIPE_LEN; |
| 6717 |
input = XXH3_consumeStripes( |
| 6718 |
acc, |
| 6719 |
&state->nbStripesSoFar, |
| 6720 |
state->nbStripesPerBlock, |
| 6721 |
input, |
| 6722 |
nbStripes, |
| 6723 |
secret, |
| 6724 |
state->secretLimit, |
| 6725 |
f_acc, |
| 6726 |
f_scramble); |
| 6727 |
XXH_memcpy(state->buffer + sizeof(state->buffer) - XXH_STRIPE_LEN, input - XXH_STRIPE_LEN, XXH_STRIPE_LEN); |
| 6728 |
} |
| 6729 |
|
| 6730 |
XXH_ASSERT(input < bEnd); |
| 6731 |
XXH_ASSERT(bEnd - input <= XXH3_INTERNALBUFFER_SIZE); |
| 6732 |
XXH_ASSERT(state->bufferedSize == 0); |
| 6733 |
XXH_memcpy(state->buffer, input, (size_t)(bEnd - input)); |
| 6734 |
state->bufferedSize = (XXH32_hash_t)(bEnd - input); |
| 6735 |
# if defined(XXH3_STREAM_USE_STACK) && XXH3_STREAM_USE_STACK >= 1 |
| 6736 |
|
| 6737 |
XXH_memcpy(state->acc, acc, sizeof(acc)); |
| 6738 |
# endif |
| 6739 |
} |
| 6740 |
|
| 6741 |
return XXH_OK; |
| 6742 |
} |
| 6743 |
|
| 6744 |
|
| 6745 |
|
| 6746 |
|
| 6747 |
XXH_NO_INLINE XXH_errorcode |
| 6748 |
XXH3_update_regular(XXH_NOESCAPE XXH3_state_t *state, XXH_NOESCAPE const void *input, size_t len) { |
| 6749 |
return XXH3_update(state, (const xxh_u8 *)input, len, XXH3_accumulate, XXH3_scrambleAcc); |
| 6750 |
} |
| 6751 |
|
| 6752 |
|
| 6753 |
XXH_PUBLIC_API XXH_errorcode |
| 6754 |
XXH3_64bits_update(XXH_NOESCAPE XXH3_state_t *state, XXH_NOESCAPE const void *input, size_t len) { |
| 6755 |
return XXH3_update_regular(state, input, len); |
| 6756 |
} |
| 6757 |
|
| 6758 |
XXH_FORCE_INLINE void XXH3_digest_long(XXH64_hash_t *acc, const XXH3_state_t *state, const unsigned char *secret) { |
| 6759 |
xxh_u8 lastStripe[XXH_STRIPE_LEN]; |
| 6760 |
const xxh_u8 *lastStripePtr; |
| 6761 |
|
| 6762 |
|
| 6763 |
|
| 6764 |
|
| 6765 |
|
| 6766 |
XXH_memcpy(acc, state->acc, sizeof(state->acc)); |
| 6767 |
if (state->bufferedSize >= XXH_STRIPE_LEN) { |
| 6768 |
|
| 6769 |
size_t const nbStripes = (state->bufferedSize - 1) / XXH_STRIPE_LEN; |
| 6770 |
size_t nbStripesSoFar = state->nbStripesSoFar; |
| 6771 |
XXH3_consumeStripes( |
| 6772 |
acc, |
| 6773 |
&nbStripesSoFar, |
| 6774 |
state->nbStripesPerBlock, |
| 6775 |
state->buffer, |
| 6776 |
nbStripes, |
| 6777 |
secret, |
| 6778 |
state->secretLimit, |
| 6779 |
XXH3_accumulate, |
| 6780 |
XXH3_scrambleAcc); |
| 6781 |
lastStripePtr = state->buffer + state->bufferedSize - XXH_STRIPE_LEN; |
| 6782 |
} else { |
| 6783 |
|
| 6784 |
size_t const catchupSize = XXH_STRIPE_LEN - state->bufferedSize; |
| 6785 |
XXH_ASSERT(state->bufferedSize > 0); |
| 6786 |
XXH_memcpy(lastStripe, state->buffer + sizeof(state->buffer) - catchupSize, catchupSize); |
| 6787 |
XXH_memcpy(lastStripe + catchupSize, state->buffer, state->bufferedSize); |
| 6788 |
lastStripePtr = lastStripe; |
| 6789 |
} |
| 6790 |
|
| 6791 |
XXH3_accumulate_512(acc, lastStripePtr, secret + state->secretLimit - XXH_SECRET_LASTACC_START); |
| 6792 |
} |
| 6793 |
|
| 6794 |
|
| 6795 |
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest(XXH_NOESCAPE const XXH3_state_t *state) { |
| 6796 |
const unsigned char *const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret; |
| 6797 |
if (state->totalLen > XXH3_MIDSIZE_MAX) { |
| 6798 |
XXH_ALIGN(XXH_ACC_ALIGN) XXH64_hash_t acc[XXH_ACC_NB]; |
| 6799 |
XXH3_digest_long(acc, state, secret); |
| 6800 |
return XXH3_finalizeLong_64b(acc, secret, (xxh_u64)state->totalLen); |
| 6801 |
} |
| 6802 |
|
| 6803 |
if (state->useSeed) |
| 6804 |
return XXH3_64bits_withSeed(state->buffer, (size_t)state->totalLen, state->seed); |
| 6805 |
return XXH3_64bits_withSecret( |
| 6806 |
state->buffer, (size_t)(state->totalLen), secret, state->secretLimit + XXH_STRIPE_LEN); |
| 6807 |
} |
| 6808 |
# endif |
| 6809 |
|
| 6810 |
|
| 6811 |
|
| 6812 |
|
| 6813 |
|
| 6814 |
|
| 6815 |
|
| 6816 |
|
| 6817 |
|
| 6818 |
|
| 6819 |
|
| 6820 |
|
| 6821 |
|
| 6822 |
|
| 6823 |
|
| 6824 |
|
| 6825 |
|
| 6826 |
|
| 6827 |
XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t |
| 6828 |
XXH3_len_1to3_128b(const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) { |
| 6829 |
|
| 6830 |
XXH_ASSERT(input != NULL); |
| 6831 |
XXH_ASSERT(1 <= len && len <= 3); |
| 6832 |
XXH_ASSERT(secret != NULL); |
| 6833 |
|
| 6834 |
|
| 6835 |
|
| 6836 |
|
| 6837 |
|
| 6838 |
{ |
| 6839 |
xxh_u8 const c1 = input[0]; |
| 6840 |
xxh_u8 const c2 = input[len >> 1]; |
| 6841 |
xxh_u8 const c3 = input[len - 1]; |
| 6842 |
xxh_u32 const combinedl = ((xxh_u32)c1 << 16) | ((xxh_u32)c2 << 24) | ((xxh_u32)c3 << 0) | ((xxh_u32)len << 8); |
| 6843 |
xxh_u32 const combinedh = XXH_rotl32(XXH_swap32(combinedl), 13); |
| 6844 |
xxh_u64 const bitflipl = (XXH_readLE32(secret) ^ XXH_readLE32(secret + 4)) + seed; |
| 6845 |
xxh_u64 const bitfliph = (XXH_readLE32(secret + 8) ^ XXH_readLE32(secret + 12)) - seed; |
| 6846 |
xxh_u64 const keyed_lo = (xxh_u64)combinedl ^ bitflipl; |
| 6847 |
xxh_u64 const keyed_hi = (xxh_u64)combinedh ^ bitfliph; |
| 6848 |
XXH128_hash_t h128; |
| 6849 |
h128.low64 = XXH64_avalanche(keyed_lo); |
| 6850 |
h128.high64 = XXH64_avalanche(keyed_hi); |
| 6851 |
return h128; |
| 6852 |
} |
| 6853 |
} |
| 6854 |
|
| 6855 |
XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t |
| 6856 |
XXH3_len_4to8_128b(const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) { |
| 6857 |
XXH_ASSERT(input != NULL); |
| 6858 |
XXH_ASSERT(secret != NULL); |
| 6859 |
XXH_ASSERT(4 <= len && len <= 8); |
| 6860 |
seed ^= (xxh_u64)XXH_swap32((xxh_u32)seed) << 32; |
| 6861 |
{ |
| 6862 |
xxh_u32 const input_lo = XXH_readLE32(input); |
| 6863 |
xxh_u32 const input_hi = XXH_readLE32(input + len - 4); |
| 6864 |
xxh_u64 const input_64 = input_lo + ((xxh_u64)input_hi << 32); |
| 6865 |
xxh_u64 const bitflip = (XXH_readLE64(secret + 16) ^ XXH_readLE64(secret + 24)) + seed; |
| 6866 |
xxh_u64 const keyed = input_64 ^ bitflip; |
| 6867 |
|
| 6868 |
|
| 6869 |
XXH128_hash_t m128 = XXH_mult64to128(keyed, XXH_PRIME64_1 + (len << 2)); |
| 6870 |
|
| 6871 |
m128.high64 += (m128.low64 << 1); |
| 6872 |
m128.low64 ^= (m128.high64 >> 3); |
| 6873 |
|
| 6874 |
m128.low64 = XXH_xorshift64(m128.low64, 35); |
| 6875 |
m128.low64 *= PRIME_MX2; |
| 6876 |
m128.low64 = XXH_xorshift64(m128.low64, 28); |
| 6877 |
m128.high64 = XXH3_avalanche(m128.high64); |
| 6878 |
return m128; |
| 6879 |
} |
| 6880 |
} |
| 6881 |
|
| 6882 |
XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t |
| 6883 |
XXH3_len_9to16_128b(const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) { |
| 6884 |
XXH_ASSERT(input != NULL); |
| 6885 |
XXH_ASSERT(secret != NULL); |
| 6886 |
XXH_ASSERT(9 <= len && len <= 16); |
| 6887 |
{ |
| 6888 |
xxh_u64 const bitflipl = (XXH_readLE64(secret + 32) ^ XXH_readLE64(secret + 40)) - seed; |
| 6889 |
xxh_u64 const bitfliph = (XXH_readLE64(secret + 48) ^ XXH_readLE64(secret + 56)) + seed; |
| 6890 |
xxh_u64 const input_lo = XXH_readLE64(input); |
| 6891 |
xxh_u64 input_hi = XXH_readLE64(input + len - 8); |
| 6892 |
XXH128_hash_t m128 = XXH_mult64to128(input_lo ^ input_hi ^ bitflipl, XXH_PRIME64_1); |
| 6893 |
|
| 6894 |
|
| 6895 |
|
| 6896 |
|
| 6897 |
m128.low64 += (xxh_u64)(len - 1) << 54; |
| 6898 |
input_hi ^= bitfliph; |
| 6899 |
|
| 6900 |
|
| 6901 |
|
| 6902 |
|
| 6903 |
|
| 6904 |
|
| 6905 |
|
| 6906 |
if (sizeof(void *) < sizeof(xxh_u64)) { |
| 6907 |
|
| 6908 |
|
| 6909 |
|
| 6910 |
|
| 6911 |
|
| 6912 |
|
| 6913 |
m128.high64 += (input_hi & 0xFFFFFFFF00000000ULL) + XXH_mult32to64((xxh_u32)input_hi, XXH_PRIME32_2); |
| 6914 |
} else { |
| 6915 |
|
| 6916 |
|
| 6917 |
|
| 6918 |
|
| 6919 |
|
| 6920 |
|
| 6921 |
|
| 6922 |
|
| 6923 |
|
| 6924 |
|
| 6925 |
|
| 6926 |
|
| 6927 |
|
| 6928 |
|
| 6929 |
|
| 6930 |
|
| 6931 |
|
| 6932 |
|
| 6933 |
|
| 6934 |
|
| 6935 |
|
| 6936 |
|
| 6937 |
|
| 6938 |
|
| 6939 |
m128.high64 += input_hi + XXH_mult32to64((xxh_u32)input_hi, XXH_PRIME32_2 - 1); |
| 6940 |
} |
| 6941 |
|
| 6942 |
m128.low64 ^= XXH_swap64(m128.high64); |
| 6943 |
|
| 6944 |
{ |
| 6945 |
XXH128_hash_t h128 = XXH_mult64to128(m128.low64, XXH_PRIME64_2); |
| 6946 |
h128.high64 += m128.high64 * XXH_PRIME64_2; |
| 6947 |
|
| 6948 |
h128.low64 = XXH3_avalanche(h128.low64); |
| 6949 |
h128.high64 = XXH3_avalanche(h128.high64); |
| 6950 |
return h128; |
| 6951 |
} |
| 6952 |
} |
| 6953 |
} |
| 6954 |
|
| 6955 |
|
| 6956 |
|
| 6957 |
|
| 6958 |
XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t |
| 6959 |
XXH3_len_0to16_128b(const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) { |
| 6960 |
XXH_ASSERT(len <= 16); |
| 6961 |
{ |
| 6962 |
if (len > 8) |
| 6963 |
return XXH3_len_9to16_128b(input, len, secret, seed); |
| 6964 |
if (len >= 4) |
| 6965 |
return XXH3_len_4to8_128b(input, len, secret, seed); |
| 6966 |
if (len) |
| 6967 |
return XXH3_len_1to3_128b(input, len, secret, seed); |
| 6968 |
{ |
| 6969 |
XXH128_hash_t h128; |
| 6970 |
xxh_u64 const bitflipl = XXH_readLE64(secret + 64) ^ XXH_readLE64(secret + 72); |
| 6971 |
xxh_u64 const bitfliph = XXH_readLE64(secret + 80) ^ XXH_readLE64(secret + 88); |
| 6972 |
h128.low64 = XXH64_avalanche(seed ^ bitflipl); |
| 6973 |
h128.high64 = XXH64_avalanche(seed ^ bitfliph); |
| 6974 |
return h128; |
| 6975 |
} |
| 6976 |
} |
| 6977 |
} |
| 6978 |
|
| 6979 |
|
| 6980 |
|
| 6981 |
|
| 6982 |
XXH_FORCE_INLINE XXH128_hash_t XXH128_mix32B( |
| 6983 |
XXH128_hash_t acc, |
| 6984 |
const xxh_u8 *input_1, |
| 6985 |
const xxh_u8 *input_2, |
| 6986 |
const xxh_u8 *secret, |
| 6987 |
XXH64_hash_t seed) { |
| 6988 |
acc.low64 += XXH3_mix16B(input_1, secret + 0, seed); |
| 6989 |
acc.low64 ^= XXH_readLE64(input_2) + XXH_readLE64(input_2 + 8); |
| 6990 |
acc.high64 += XXH3_mix16B(input_2, secret + 16, seed); |
| 6991 |
acc.high64 ^= XXH_readLE64(input_1) + XXH_readLE64(input_1 + 8); |
| 6992 |
return acc; |
| 6993 |
} |
| 6994 |
|
| 6995 |
XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t XXH3_len_17to128_128b( |
| 6996 |
const xxh_u8 *XXH_RESTRICT input, |
| 6997 |
size_t len, |
| 6998 |
const xxh_u8 *XXH_RESTRICT secret, |
| 6999 |
size_t secretSize, |
| 7000 |
XXH64_hash_t seed) { |
| 7001 |
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); |
| 7002 |
(void)secretSize; |
| 7003 |
XXH_ASSERT(16 < len && len <= 128); |
| 7004 |
|
| 7005 |
{ |
| 7006 |
XXH128_hash_t acc; |
| 7007 |
acc.low64 = len * XXH_PRIME64_1; |
| 7008 |
acc.high64 = 0; |
| 7009 |
|
| 7010 |
# if XXH_SIZE_OPT >= 1 |
| 7011 |
{ |
| 7012 |
|
| 7013 |
unsigned int i = (unsigned int)(len - 1) / 32; |
| 7014 |
do { |
| 7015 |
acc = XXH128_mix32B(acc, input + 16 * i, input + len - 16 * (i + 1), secret + 32 * i, seed); |
| 7016 |
} while (i-- != 0); |
| 7017 |
} |
| 7018 |
# else |
| 7019 |
if (len > 32) { |
| 7020 |
if (len > 64) { |
| 7021 |
if (len > 96) { |
| 7022 |
acc = XXH128_mix32B(acc, input + 48, input + len - 64, secret + 96, seed); |
| 7023 |
} |
| 7024 |
acc = XXH128_mix32B(acc, input + 32, input + len - 48, secret + 64, seed); |
| 7025 |
} |
| 7026 |
acc = XXH128_mix32B(acc, input + 16, input + len - 32, secret + 32, seed); |
| 7027 |
} |
| 7028 |
acc = XXH128_mix32B(acc, input, input + len - 16, secret, seed); |
| 7029 |
# endif |
| 7030 |
{ |
| 7031 |
XXH128_hash_t h128; |
| 7032 |
h128.low64 = acc.low64 + acc.high64; |
| 7033 |
h128.high64 = (acc.low64 * XXH_PRIME64_1) + (acc.high64 * XXH_PRIME64_4) + ((len - seed) * XXH_PRIME64_2); |
| 7034 |
h128.low64 = XXH3_avalanche(h128.low64); |
| 7035 |
h128.high64 = (XXH64_hash_t)0 - XXH3_avalanche(h128.high64); |
| 7036 |
return h128; |
| 7037 |
} |
| 7038 |
} |
| 7039 |
} |
| 7040 |
|
| 7041 |
XXH_NO_INLINE XXH_PUREF XXH128_hash_t XXH3_len_129to240_128b( |
| 7042 |
const xxh_u8 *XXH_RESTRICT input, |
| 7043 |
size_t len, |
| 7044 |
const xxh_u8 *XXH_RESTRICT secret, |
| 7045 |
size_t secretSize, |
| 7046 |
XXH64_hash_t seed) { |
| 7047 |
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); |
| 7048 |
(void)secretSize; |
| 7049 |
XXH_ASSERT(128 < len && len <= XXH3_MIDSIZE_MAX); |
| 7050 |
|
| 7051 |
{ |
| 7052 |
XXH128_hash_t acc; |
| 7053 |
unsigned i; |
| 7054 |
acc.low64 = len * XXH_PRIME64_1; |
| 7055 |
acc.high64 = 0; |
| 7056 |
|
| 7057 |
|
| 7058 |
|
| 7059 |
|
| 7060 |
|
| 7061 |
|
| 7062 |
for (i = 32; i < 160; i += 32) { |
| 7063 |
acc = XXH128_mix32B(acc, input + i - 32, input + i - 16, secret + i - 32, seed); |
| 7064 |
} |
| 7065 |
acc.low64 = XXH3_avalanche(acc.low64); |
| 7066 |
acc.high64 = XXH3_avalanche(acc.high64); |
| 7067 |
|
| 7068 |
|
| 7069 |
|
| 7070 |
|
| 7071 |
|
| 7072 |
for (i = 160; i <= len; i += 32) { |
| 7073 |
acc = XXH128_mix32B(acc, input + i - 32, input + i - 16, secret + XXH3_MIDSIZE_STARTOFFSET + i - 160, seed); |
| 7074 |
} |
| 7075 |
|
| 7076 |
acc = XXH128_mix32B( |
| 7077 |
acc, |
| 7078 |
input + len - 16, |
| 7079 |
input + len - 32, |
| 7080 |
secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET - 16, |
| 7081 |
(XXH64_hash_t)0 - seed); |
| 7082 |
|
| 7083 |
{ |
| 7084 |
XXH128_hash_t h128; |
| 7085 |
h128.low64 = acc.low64 + acc.high64; |
| 7086 |
h128.high64 = (acc.low64 * XXH_PRIME64_1) + (acc.high64 * XXH_PRIME64_4) + ((len - seed) * XXH_PRIME64_2); |
| 7087 |
h128.low64 = XXH3_avalanche(h128.low64); |
| 7088 |
h128.high64 = (XXH64_hash_t)0 - XXH3_avalanche(h128.high64); |
| 7089 |
return h128; |
| 7090 |
} |
| 7091 |
} |
| 7092 |
} |
| 7093 |
|
| 7094 |
static XXH_PUREF XXH128_hash_t XXH3_finalizeLong_128b( |
| 7095 |
const xxh_u64 *XXH_RESTRICT acc, |
| 7096 |
const xxh_u8 *XXH_RESTRICT secret, |
| 7097 |
size_t secretSize, |
| 7098 |
xxh_u64 len) { |
| 7099 |
XXH128_hash_t h128; |
| 7100 |
h128.low64 = XXH3_finalizeLong_64b(acc, secret, len); |
| 7101 |
h128.high64 = |
| 7102 |
XXH3_mergeAccs(acc, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_MERGEACCS_START, ~(len * XXH_PRIME64_2)); |
| 7103 |
return h128; |
| 7104 |
} |
| 7105 |
|
| 7106 |
XXH_FORCE_INLINE XXH128_hash_t XXH3_hashLong_128b_internal( |
| 7107 |
const void *XXH_RESTRICT input, |
| 7108 |
size_t len, |
| 7109 |
const xxh_u8 *XXH_RESTRICT secret, |
| 7110 |
size_t secretSize, |
| 7111 |
XXH3_f_accumulate f_acc, |
| 7112 |
XXH3_f_scrambleAcc f_scramble) { |
| 7113 |
XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[XXH_ACC_NB] = XXH3_INIT_ACC; |
| 7114 |
|
| 7115 |
XXH3_hashLong_internal_loop(acc, (const xxh_u8 *)input, len, secret, secretSize, f_acc, f_scramble); |
| 7116 |
|
| 7117 |
|
| 7118 |
XXH_STATIC_ASSERT(sizeof(acc) == 64); |
| 7119 |
XXH_ASSERT(secretSize >= sizeof(acc) + XXH_SECRET_MERGEACCS_START); |
| 7120 |
return XXH3_finalizeLong_128b(acc, secret, secretSize, (xxh_u64)len); |
| 7121 |
} |
| 7122 |
|
| 7123 |
|
| 7124 |
|
| 7125 |
|
| 7126 |
XXH_NO_INLINE XXH_PUREF XXH128_hash_t XXH3_hashLong_128b_default( |
| 7127 |
const void *XXH_RESTRICT input, |
| 7128 |
size_t len, |
| 7129 |
XXH64_hash_t seed64, |
| 7130 |
const void *XXH_RESTRICT secret, |
| 7131 |
size_t secretLen) { |
| 7132 |
(void)seed64; |
| 7133 |
(void)secret; |
| 7134 |
(void)secretLen; |
| 7135 |
return XXH3_hashLong_128b_internal( |
| 7136 |
input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate, XXH3_scrambleAcc); |
| 7137 |
} |
| 7138 |
|
| 7139 |
|
| 7140 |
|
| 7141 |
|
| 7142 |
|
| 7143 |
|
| 7144 |
|
| 7145 |
|
| 7146 |
XXH3_WITH_SECRET_INLINE XXH128_hash_t XXH3_hashLong_128b_withSecret( |
| 7147 |
const void *XXH_RESTRICT input, |
| 7148 |
size_t len, |
| 7149 |
XXH64_hash_t seed64, |
| 7150 |
const void *XXH_RESTRICT secret, |
| 7151 |
size_t secretLen) { |
| 7152 |
(void)seed64; |
| 7153 |
return XXH3_hashLong_128b_internal( |
| 7154 |
input, len, (const xxh_u8 *)secret, secretLen, XXH3_accumulate, XXH3_scrambleAcc); |
| 7155 |
} |
| 7156 |
|
| 7157 |
XXH_FORCE_INLINE XXH128_hash_t XXH3_hashLong_128b_withSeed_internal( |
| 7158 |
const void *XXH_RESTRICT input, |
| 7159 |
size_t len, |
| 7160 |
XXH64_hash_t seed64, |
| 7161 |
XXH3_f_accumulate f_acc, |
| 7162 |
XXH3_f_scrambleAcc f_scramble, |
| 7163 |
XXH3_f_initCustomSecret f_initSec) { |
| 7164 |
if (seed64 == 0) |
| 7165 |
return XXH3_hashLong_128b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), f_acc, f_scramble); |
| 7166 |
{ |
| 7167 |
XXH_ALIGN(XXH_SEC_ALIGN) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE]; |
| 7168 |
f_initSec(secret, seed64); |
| 7169 |
return XXH3_hashLong_128b_internal(input, len, (const xxh_u8 *)secret, sizeof(secret), f_acc, f_scramble); |
| 7170 |
} |
| 7171 |
} |
| 7172 |
|
| 7173 |
|
| 7174 |
|
| 7175 |
|
| 7176 |
XXH_NO_INLINE XXH128_hash_t XXH3_hashLong_128b_withSeed( |
| 7177 |
const void *input, |
| 7178 |
size_t len, |
| 7179 |
XXH64_hash_t seed64, |
| 7180 |
const void *XXH_RESTRICT secret, |
| 7181 |
size_t secretLen) { |
| 7182 |
(void)secret; |
| 7183 |
(void)secretLen; |
| 7184 |
return XXH3_hashLong_128b_withSeed_internal( |
| 7185 |
input, len, seed64, XXH3_accumulate, XXH3_scrambleAcc, XXH3_initCustomSecret); |
| 7186 |
} |
| 7187 |
|
| 7188 |
typedef XXH128_hash_t ( |
| 7189 |
*XXH3_hashLong128_f)(const void *XXH_RESTRICT, size_t, XXH64_hash_t, const void *XXH_RESTRICT, size_t); |
| 7190 |
|
| 7191 |
XXH_FORCE_INLINE XXH128_hash_t XXH3_128bits_internal( |
| 7192 |
const void *input, |
| 7193 |
size_t len, |
| 7194 |
XXH64_hash_t seed64, |
| 7195 |
const void *XXH_RESTRICT secret, |
| 7196 |
size_t secretLen, |
| 7197 |
XXH3_hashLong128_f f_hl128) { |
| 7198 |
XXH_ASSERT(secretLen >= XXH3_SECRET_SIZE_MIN); |
| 7199 |
|
| 7200 |
|
| 7201 |
|
| 7202 |
|
| 7203 |
|
| 7204 |
|
| 7205 |
if (len <= 16) |
| 7206 |
return XXH3_len_0to16_128b((const xxh_u8 *)input, len, (const xxh_u8 *)secret, seed64); |
| 7207 |
if (len <= 128) |
| 7208 |
return XXH3_len_17to128_128b((const xxh_u8 *)input, len, (const xxh_u8 *)secret, secretLen, seed64); |
| 7209 |
if (len <= XXH3_MIDSIZE_MAX) |
| 7210 |
return XXH3_len_129to240_128b((const xxh_u8 *)input, len, (const xxh_u8 *)secret, secretLen, seed64); |
| 7211 |
return f_hl128(input, len, seed64, secret, secretLen); |
| 7212 |
} |
| 7213 |
|
| 7214 |
|
| 7215 |
|
| 7216 |
|
| 7217 |
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits(XXH_NOESCAPE const void *input, size_t len) { |
| 7218 |
return XXH3_128bits_internal(input, len, 0, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_128b_default); |
| 7219 |
} |
| 7220 |
|
| 7221 |
|
| 7222 |
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSecret( |
| 7223 |
XXH_NOESCAPE const void *input, |
| 7224 |
size_t len, |
| 7225 |
XXH_NOESCAPE const void *secret, |
| 7226 |
size_t secretSize) { |
| 7227 |
return XXH3_128bits_internal(input, len, 0, (const xxh_u8 *)secret, secretSize, XXH3_hashLong_128b_withSecret); |
| 7228 |
} |
| 7229 |
|
| 7230 |
|
| 7231 |
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSeed(XXH_NOESCAPE const void *input, size_t len, XXH64_hash_t seed) { |
| 7232 |
return XXH3_128bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_128b_withSeed); |
| 7233 |
} |
| 7234 |
|
| 7235 |
|
| 7236 |
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSecretandSeed( |
| 7237 |
XXH_NOESCAPE const void *input, |
| 7238 |
size_t len, |
| 7239 |
XXH_NOESCAPE const void *secret, |
| 7240 |
size_t secretSize, |
| 7241 |
XXH64_hash_t seed) { |
| 7242 |
if (len <= XXH3_MIDSIZE_MAX) |
| 7243 |
return XXH3_128bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), NULL); |
| 7244 |
return XXH3_hashLong_128b_withSecret(input, len, seed, secret, secretSize); |
| 7245 |
} |
| 7246 |
|
| 7247 |
|
| 7248 |
XXH_PUBLIC_API XXH128_hash_t XXH128(XXH_NOESCAPE const void *input, size_t len, XXH64_hash_t seed) { |
| 7249 |
return XXH3_128bits_withSeed(input, len, seed); |
| 7250 |
} |
| 7251 |
|
| 7252 |
|
| 7253 |
# ifndef XXH_NO_STREAM |
| 7254 |
|
| 7255 |
|
| 7256 |
|
| 7257 |
|
| 7258 |
|
| 7259 |
|
| 7260 |
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset(XXH_NOESCAPE XXH3_state_t *statePtr) { |
| 7261 |
return XXH3_64bits_reset(statePtr); |
| 7262 |
} |
| 7263 |
|
| 7264 |
|
| 7265 |
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecret( |
| 7266 |
XXH_NOESCAPE XXH3_state_t *statePtr, |
| 7267 |
XXH_NOESCAPE const void *secret, |
| 7268 |
size_t secretSize) { |
| 7269 |
return XXH3_64bits_reset_withSecret(statePtr, secret, secretSize); |
| 7270 |
} |
| 7271 |
|
| 7272 |
|
| 7273 |
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t *statePtr, XXH64_hash_t seed) { |
| 7274 |
return XXH3_64bits_reset_withSeed(statePtr, seed); |
| 7275 |
} |
| 7276 |
|
| 7277 |
|
| 7278 |
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecretandSeed( |
| 7279 |
XXH_NOESCAPE XXH3_state_t *statePtr, |
| 7280 |
XXH_NOESCAPE const void *secret, |
| 7281 |
size_t secretSize, |
| 7282 |
XXH64_hash_t seed) { |
| 7283 |
return XXH3_64bits_reset_withSecretandSeed(statePtr, secret, secretSize, seed); |
| 7284 |
} |
| 7285 |
|
| 7286 |
|
| 7287 |
XXH_PUBLIC_API XXH_errorcode |
| 7288 |
XXH3_128bits_update(XXH_NOESCAPE XXH3_state_t *state, XXH_NOESCAPE const void *input, size_t len) { |
| 7289 |
return XXH3_update_regular(state, input, len); |
| 7290 |
} |
| 7291 |
|
| 7292 |
|
| 7293 |
XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest(XXH_NOESCAPE const XXH3_state_t *state) { |
| 7294 |
const unsigned char *const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret; |
| 7295 |
if (state->totalLen > XXH3_MIDSIZE_MAX) { |
| 7296 |
XXH_ALIGN(XXH_ACC_ALIGN) XXH64_hash_t acc[XXH_ACC_NB]; |
| 7297 |
XXH3_digest_long(acc, state, secret); |
| 7298 |
XXH_ASSERT(state->secretLimit + XXH_STRIPE_LEN >= sizeof(acc) + XXH_SECRET_MERGEACCS_START); |
| 7299 |
return XXH3_finalizeLong_128b(acc, secret, state->secretLimit + XXH_STRIPE_LEN, (xxh_u64)state->totalLen); |
| 7300 |
} |
| 7301 |
|
| 7302 |
if (state->useSeed) |
| 7303 |
return XXH3_128bits_withSeed(state->buffer, (size_t)state->totalLen, state->seed); |
| 7304 |
return XXH3_128bits_withSecret( |
| 7305 |
state->buffer, (size_t)(state->totalLen), secret, state->secretLimit + XXH_STRIPE_LEN); |
| 7306 |
} |
| 7307 |
# endif |
| 7308 |
|
| 7309 |
|
| 7310 |
|
| 7311 |
|
| 7312 |
XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2) { |
| 7313 |
|
| 7314 |
return !(XXH_memcmp(&h1, &h2, sizeof(h1))); |
| 7315 |
} |
| 7316 |
|
| 7317 |
|
| 7318 |
|
| 7319 |
|
| 7320 |
|
| 7321 |
|
| 7322 |
XXH_PUBLIC_API int XXH128_cmp(XXH_NOESCAPE const void *h128_1, XXH_NOESCAPE const void *h128_2) { |
| 7323 |
XXH128_hash_t const h1 = *(const XXH128_hash_t *)h128_1; |
| 7324 |
XXH128_hash_t const h2 = *(const XXH128_hash_t *)h128_2; |
| 7325 |
int const hcmp = (h1.high64 > h2.high64) - (h2.high64 > h1.high64); |
| 7326 |
|
| 7327 |
if (hcmp) |
| 7328 |
return hcmp; |
| 7329 |
return (h1.low64 > h2.low64) - (h2.low64 > h1.low64); |
| 7330 |
} |
| 7331 |
|
| 7332 |
|
| 7333 |
|
| 7334 |
XXH_PUBLIC_API void XXH128_canonicalFromHash(XXH_NOESCAPE XXH128_canonical_t *dst, XXH128_hash_t hash) { |
| 7335 |
XXH_STATIC_ASSERT(sizeof(XXH128_canonical_t) == sizeof(XXH128_hash_t)); |
| 7336 |
if (XXH_CPU_LITTLE_ENDIAN) { |
| 7337 |
hash.high64 = XXH_swap64(hash.high64); |
| 7338 |
hash.low64 = XXH_swap64(hash.low64); |
| 7339 |
} |
| 7340 |
XXH_memcpy(dst, &hash.high64, sizeof(hash.high64)); |
| 7341 |
XXH_memcpy((char *)dst + sizeof(hash.high64), &hash.low64, sizeof(hash.low64)); |
| 7342 |
} |
| 7343 |
|
| 7344 |
|
| 7345 |
XXH_PUBLIC_API XXH128_hash_t XXH128_hashFromCanonical(XXH_NOESCAPE const XXH128_canonical_t *src) { |
| 7346 |
XXH128_hash_t h; |
| 7347 |
h.high64 = XXH_readBE64(src); |
| 7348 |
h.low64 = XXH_readBE64(src->digest + 8); |
| 7349 |
return h; |
| 7350 |
} |
| 7351 |
|
| 7352 |
|
| 7353 |
|
| 7354 |
|
| 7355 |
|
| 7356 |
# define XXH_MIN(x, y) (((x) > (y)) ? (y) : (x)) |
| 7357 |
|
| 7358 |
XXH_FORCE_INLINE void XXH3_combine16(void *dst, XXH128_hash_t h128) { |
| 7359 |
XXH_writeLE64(dst, XXH_readLE64(dst) ^ h128.low64); |
| 7360 |
XXH_writeLE64((char *)dst + 8, XXH_readLE64((char *)dst + 8) ^ h128.high64); |
| 7361 |
} |
| 7362 |
|
| 7363 |
|
| 7364 |
XXH_PUBLIC_API XXH_errorcode XXH3_generateSecret( |
| 7365 |
XXH_NOESCAPE void *secretBuffer, |
| 7366 |
size_t secretSize, |
| 7367 |
XXH_NOESCAPE const void *customSeed, |
| 7368 |
size_t customSeedSize) { |
| 7369 |
# if (XXH_DEBUGLEVEL >= 1) |
| 7370 |
XXH_ASSERT(secretBuffer != NULL); |
| 7371 |
XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); |
| 7372 |
# else |
| 7373 |
|
| 7374 |
if (secretBuffer == NULL) |
| 7375 |
return XXH_ERROR; |
| 7376 |
if (secretSize < XXH3_SECRET_SIZE_MIN) |
| 7377 |
return XXH_ERROR; |
| 7378 |
# endif |
| 7379 |
|
| 7380 |
if (customSeedSize == 0) { |
| 7381 |
customSeed = XXH3_kSecret; |
| 7382 |
customSeedSize = XXH_SECRET_DEFAULT_SIZE; |
| 7383 |
} |
| 7384 |
# if (XXH_DEBUGLEVEL >= 1) |
| 7385 |
XXH_ASSERT(customSeed != NULL); |
| 7386 |
# else |
| 7387 |
if (customSeed == NULL) |
| 7388 |
return XXH_ERROR; |
| 7389 |
# endif |
| 7390 |
|
| 7391 |
|
| 7392 |
{ |
| 7393 |
size_t pos = 0; |
| 7394 |
while (pos < secretSize) { |
| 7395 |
size_t const toCopy = XXH_MIN((secretSize - pos), customSeedSize); |
| 7396 |
XXH_memcpy((char *)secretBuffer + pos, customSeed, toCopy); |
| 7397 |
pos += toCopy; |
| 7398 |
} |
| 7399 |
} |
| 7400 |
|
| 7401 |
{ |
| 7402 |
size_t const nbSeg16 = secretSize / 16; |
| 7403 |
size_t n; |
| 7404 |
XXH128_canonical_t scrambler; |
| 7405 |
XXH128_canonicalFromHash(&scrambler, XXH128(customSeed, customSeedSize, 0)); |
| 7406 |
for (n = 0; n < nbSeg16; n++) { |
| 7407 |
XXH128_hash_t const h128 = XXH128(&scrambler, sizeof(scrambler), n); |
| 7408 |
XXH3_combine16((char *)secretBuffer + n * 16, h128); |
| 7409 |
} |
| 7410 |
|
| 7411 |
XXH3_combine16((char *)secretBuffer + secretSize - 16, XXH128_hashFromCanonical(&scrambler)); |
| 7412 |
} |
| 7413 |
return XXH_OK; |
| 7414 |
} |
| 7415 |
|
| 7416 |
|
| 7417 |
XXH_PUBLIC_API void XXH3_generateSecret_fromSeed(XXH_NOESCAPE void *secretBuffer, XXH64_hash_t seed) { |
| 7418 |
XXH_ALIGN(XXH_SEC_ALIGN) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE]; |
| 7419 |
XXH3_initCustomSecret(secret, seed); |
| 7420 |
XXH_ASSERT(secretBuffer != NULL); |
| 7421 |
XXH_memcpy(secretBuffer, secret, XXH_SECRET_DEFAULT_SIZE); |
| 7422 |
} |
| 7423 |
|
| 7424 |
|
| 7425 |
# if XXH_VECTOR == XXH_AVX2 \ |
| 7426 |
&& defined(__GNUC__) && !defined(__clang__) \ |
| 7427 |
&& defined(__OPTIMIZE__) && XXH_SIZE_OPT <= 0 |
| 7428 |
# pragma GCC pop_options |
| 7429 |
# endif |
| 7430 |
|
| 7431 |
# endif |
| 7432 |
|
| 7433 |
# endif |
| 7434 |
|
| 7435 |
|
| 7436 |
|
| 7437 |
|
| 7438 |
#endif |
| 7439 |
|
| 7440 |
#if defined(__cplusplus) && !defined(XXH_NO_EXTERNC_GUARD) |
| 7441 |
} |
| 7442 |
#endif |