digest-xxhash 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac9bf248e60109b08aa07caf6981909f861a420ce307e5ada2983f2be1cbe68e
4
- data.tar.gz: 3fd2fb64a02ae986f2592f8f98a2d074949f063f31d947f9d039e1503b7428c7
3
+ metadata.gz: 919358191e0f1f26b79b95bc7253d80ec46b26aabcaa729c0b82fd69d7ffd2ff
4
+ data.tar.gz: 5111f27d4afb62092f5643e7f85fa07e6b46a20863f7682c2993902fd22b31a6
5
5
  SHA512:
6
- metadata.gz: d3d55d75fe83b85e7833d082876d3241702c3640b52e889c73b3e1bbae5d2fe68c0d769892efb318d187bbcf7ac2518e34b04a9c98b32a51a4f333bd4aca2b8f
7
- data.tar.gz: 5d2802ba4f69c2da468880b65b63bb23f67ff1db093af5aeb4a710cf6d695937cef67135389c99a14699d0be0f0c60ba2abeee0557f228268771079d108fbc89
6
+ metadata.gz: 5ddde4f920bd2ea2a62f131650bf58b884c5006568887ca6c5c35c38ca1a73c4bd566198a7366c72e0576d02f850728715f47623afa2052b54636734462f0c32
7
+ data.tar.gz: 3fd5a9ce98fba62c9e8c246a64fd64c49b7692cf4c7056b7ff9894cf21015acce1723a792d5cef4f09da2b6e5bbea24a77f4c8cd6b0bf486db19587c40077e5e
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2021 konsolebox
1
+ Copyright (c) 2022 konsolebox
2
2
 
3
3
  MIT License
4
4
 
@@ -547,6 +547,7 @@ typedef uint32_t XXH32_hash_t;
547
547
  */
548
548
  XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32 (const void* input, size_t length, XXH32_hash_t seed);
549
549
 
550
+ #ifndef XXH_NO_STREAM
550
551
  /*!
551
552
  * Streaming functions generate the xxHash value from an incremental input.
552
553
  * This method is slower than single-call functions, due to state management.
@@ -655,6 +656,7 @@ XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void*
655
656
  * @return The calculated xxHash32 value from that state.
656
657
  */
657
658
  XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr);
659
+ #endif /* !XXH_NO_STREAM */
658
660
 
659
661
  /******* Canonical representation *******/
660
662
 
@@ -814,6 +816,7 @@ typedef uint64_t XXH64_hash_t;
814
816
  XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH64(const void* input, size_t length, XXH64_hash_t seed);
815
817
 
816
818
  /******* Streaming *******/
819
+ #ifndef XXH_NO_STREAM
817
820
  /*!
818
821
  * @brief The opaque state struct for the XXH64 streaming API.
819
822
  *
@@ -827,7 +830,7 @@ XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dst_state, const XXH64_state_
827
830
  XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, XXH64_hash_t seed);
828
831
  XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length);
829
832
  XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr);
830
-
833
+ #endif /* !XXH_NO_STREAM */
831
834
  /******* Canonical representation *******/
832
835
  typedef struct { unsigned char digest[sizeof(XXH64_hash_t)]; } XXH64_canonical_t;
833
836
  XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash);
@@ -949,6 +952,7 @@ XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits_withSecret(const void* data, s
949
952
 
950
953
 
951
954
  /******* Streaming *******/
955
+ #ifndef XXH_NO_STREAM
952
956
  /*
953
957
  * Streaming requires state maintenance.
954
958
  * This operation costs memory and CPU.
@@ -991,6 +995,7 @@ XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret(XXH3_state_t* statePtr
991
995
 
992
996
  XXH_PUBLIC_API XXH_errorcode XXH3_64bits_update (XXH3_state_t* statePtr, const void* input, size_t length);
993
997
  XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* statePtr);
998
+ #endif /* !XXH_NO_STREAM */
994
999
 
995
1000
  /* note : canonical representation of XXH3 is the same as XXH64
996
1001
  * since they both produce XXH64_hash_t values */
@@ -1035,6 +1040,7 @@ XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_withSeed(const void* data, s
1035
1040
  XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize);
1036
1041
 
1037
1042
  /******* Streaming *******/
1043
+ #ifndef XXH_NO_STREAM
1038
1044
  /*
1039
1045
  * Streaming requires state maintenance.
1040
1046
  * This operation costs memory and CPU.
@@ -1053,6 +1059,7 @@ XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecret(XXH3_state_t* statePt
1053
1059
 
1054
1060
  XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update (XXH3_state_t* statePtr, const void* input, size_t length);
1055
1061
  XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* statePtr);
1062
+ #endif /* !XXH_NO_STREAM */
1056
1063
 
1057
1064
  /* Following helper functions make it possible to compare XXH128_hast_t values.
1058
1065
  * Since XXH128_hash_t is a structure, this capability is not offered by the language.
@@ -1398,6 +1405,7 @@ XXH_PUBLIC_API XXH_PUREF XXH128_hash_t
1398
1405
  XXH3_128bits_withSecretandSeed(const void* input, size_t length,
1399
1406
  const void* secret, size_t secretSize,
1400
1407
  XXH64_hash_t seed64);
1408
+ #ifndef XXH_NO_STREAM
1401
1409
  /*! @copydoc XXH3_64bits_withSecretandSeed() */
1402
1410
  XXH_PUBLIC_API XXH_errorcode
1403
1411
  XXH3_64bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
@@ -1408,7 +1416,7 @@ XXH_PUBLIC_API XXH_errorcode
1408
1416
  XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1409
1417
  const void* secret, size_t secretSize,
1410
1418
  XXH64_hash_t seed64);
1411
-
1419
+ #endif /* !XXH_NO_STREAM */
1412
1420
 
1413
1421
  #endif /* !XXH_NO_XXH3 */
1414
1422
  #endif /* XXH_NO_LONG_LONG */
@@ -1520,6 +1528,34 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1520
1528
  */
1521
1529
  # define XXH_FORCE_MEMORY_ACCESS 0
1522
1530
 
1531
+ /*!
1532
+ * @def XXH_SIZE_OPT
1533
+ * @brief Controls how much xxHash optimizes for size.
1534
+ *
1535
+ * xxHash, when compiled, tends to result in a rather large binary size. This
1536
+ * is mostly due to heavy usage to forced inlining and constant folding of the
1537
+ * @ref XXH3_family to increase performance.
1538
+ *
1539
+ * However, some developers prefer size over speed. This option can
1540
+ * significantly reduce the size of the generated code. When using the `-Os`
1541
+ * or `-Oz` options on GCC or Clang, this is defined to 1 by default,
1542
+ * otherwise it is defined to 0.
1543
+ *
1544
+ * Most of these size optimizations can be controlled manually.
1545
+ *
1546
+ * This is a number from 0-2.
1547
+ * - `XXH_SIZE_OPT` == 0: Default. xxHash makes no size optimizations. Speed
1548
+ * comes first.
1549
+ * - `XXH_SIZE_OPT` == 1: Default for `-Os` and `-Oz`. xxHash is more
1550
+ * conservative and disables hacks that increase code size. It implies the
1551
+ * options @ref XXH_NO_INLINE_HINTS == 1, @ref XXH_FORCE_ALIGN_CHECK == 0,
1552
+ * and @ref XXH3_NEON_LANES == 8 if they are not already defined.
1553
+ * - `XXH_SIZE_OPT` == 2: xxHash tries to make itself as small as possible.
1554
+ * Performance may cry. For example, the single shot functions just use the
1555
+ * streaming API.
1556
+ */
1557
+ # define XXH_SIZE_OPT 0
1558
+
1523
1559
  /*!
1524
1560
  * @def XXH_FORCE_ALIGN_CHECK
1525
1561
  * @brief If defined to non-zero, adds a special path for aligned inputs (XXH32()
@@ -1541,9 +1577,11 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1541
1577
  *
1542
1578
  * In these cases, the alignment check can be removed by setting this macro to 0.
1543
1579
  * Then the code will always use unaligned memory access.
1544
- * Align check is automatically disabled on x86, x64 & arm64,
1580
+ * Align check is automatically disabled on x86, x64, ARM64, and some ARM chips
1545
1581
  * which are platforms known to offer good unaligned memory accesses performance.
1546
1582
  *
1583
+ * It is also disabled by default when @ref XXH_SIZE_OPT >= 1.
1584
+ *
1547
1585
  * This option does not affect XXH3 (only XXH32 and XXH64).
1548
1586
  */
1549
1587
  # define XXH_FORCE_ALIGN_CHECK 0
@@ -1565,8 +1603,8 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1565
1603
  * XXH_NO_INLINE_HINTS marks all internal functions as static, giving the
1566
1604
  * compiler full control on whether to inline or not.
1567
1605
  *
1568
- * When not optimizing (-O0), optimizing for size (-Os, -Oz), or using
1569
- * -fno-inline with GCC or Clang, this will automatically be defined.
1606
+ * When not optimizing (-O0), using `-fno-inline` with GCC or Clang, or if
1607
+ * @ref XXH_SIZE_OPT >= 1, this will automatically be defined.
1570
1608
  */
1571
1609
  # define XXH_NO_INLINE_HINTS 0
1572
1610
 
@@ -1591,6 +1629,17 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1591
1629
  */
1592
1630
  # define XXH_OLD_NAMES
1593
1631
  # undef XXH_OLD_NAMES /* don't actually use, it is ugly. */
1632
+
1633
+ /*!
1634
+ * @def XXH_NO_STREAM
1635
+ * @brief Disables the streaming API.
1636
+ *
1637
+ * When xxHash is not inlined and the streaming functions are not used, disabling
1638
+ * the streaming functions can improve code size significantly, especially with
1639
+ * the @ref XXH3_family which tends to make constant folded copies of itself.
1640
+ */
1641
+ # define XXH_NO_STREAM
1642
+ # undef XXH_NO_STREAM /* don't actually */
1594
1643
  #endif /* XXH_DOXYGEN */
1595
1644
  /*!
1596
1645
  * @}
@@ -1605,9 +1654,19 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1605
1654
  # endif
1606
1655
  #endif
1607
1656
 
1657
+ #ifndef XXH_SIZE_OPT
1658
+ /* default to 1 for -Os or -Oz */
1659
+ # if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE_SIZE__)
1660
+ # define XXH_SIZE_OPT 1
1661
+ # else
1662
+ # define XXH_SIZE_OPT 0
1663
+ # endif
1664
+ #endif
1665
+
1608
1666
  #ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */
1609
- /* don't check on x86, aarch64, or arm when unaligned access is available */
1610
- # if defined(__i386) || defined(__x86_64__) || defined(__aarch64__) || defined(__ARM_FEATURE_UNALIGNED) \
1667
+ /* don't check on sizeopt, x86, aarch64, or arm when unaligned access is available */
1668
+ # if XXH_SIZE_OPT >= 1 || \
1669
+ defined(__i386) || defined(__x86_64__) || defined(__aarch64__) || defined(__ARM_FEATURE_UNALIGNED) \
1611
1670
  || defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64) || defined(_M_ARM) /* visual */
1612
1671
  # define XXH_FORCE_ALIGN_CHECK 0
1613
1672
  # else
@@ -1616,8 +1675,7 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1616
1675
  #endif
1617
1676
 
1618
1677
  #ifndef XXH_NO_INLINE_HINTS
1619
- # if defined(__OPTIMIZE_SIZE__) /* -Os, -Oz */ \
1620
- || defined(__NO_INLINE__) /* -O0, -fno-inline */
1678
+ # if XXH_SIZE_OPT >= 1 || defined(__NO_INLINE__) /* -O0, -fno-inline */
1621
1679
  # define XXH_NO_INLINE_HINTS 1
1622
1680
  # else
1623
1681
  # define XXH_NO_INLINE_HINTS 0
@@ -1638,7 +1696,9 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr,
1638
1696
  /* *************************************
1639
1697
  * Includes & Memory related functions
1640
1698
  ***************************************/
1641
- #if defined(XXH_NO_STDLIB)
1699
+ #if defined(XXH_NO_STREAM)
1700
+ /* nothing */
1701
+ #elif defined(XXH_NO_STDLIB)
1642
1702
 
1643
1703
  /* When requesting to disable any mention of stdlib,
1644
1704
  * the library loses the ability to invoked malloc / free.
@@ -2322,7 +2382,7 @@ XXH32_endian_align(const xxh_u8* input, size_t len, xxh_u32 seed, XXH_alignment
2322
2382
  /*! @ingroup XXH32_family */
2323
2383
  XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t len, XXH32_hash_t seed)
2324
2384
  {
2325
- #if 0
2385
+ #if !defined(XXH_NO_STREAM) && XXH_SIZE_OPT >= 2
2326
2386
  /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
2327
2387
  XXH32_state_t state;
2328
2388
  XXH32_reset(&state, seed);
@@ -2341,6 +2401,7 @@ XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t len, XXH32_hash_t s
2341
2401
 
2342
2402
 
2343
2403
  /******* Hash streaming *******/
2404
+ #ifndef XXH_NO_STREAM
2344
2405
  /*! @ingroup XXH32_family */
2345
2406
  XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void)
2346
2407
  {
@@ -2445,7 +2506,7 @@ XXH_PUBLIC_API XXH32_hash_t XXH32_digest(const XXH32_state_t* state)
2445
2506
 
2446
2507
  return XXH32_finalize(h32, (const xxh_u8*)state->mem32, state->memsize, XXH_aligned);
2447
2508
  }
2448
-
2509
+ #endif /* !XXH_NO_STREAM */
2449
2510
 
2450
2511
  /******* Canonical representation *******/
2451
2512
 
@@ -2764,7 +2825,7 @@ XXH64_endian_align(const xxh_u8* input, size_t len, xxh_u64 seed, XXH_alignment
2764
2825
  /*! @ingroup XXH64_family */
2765
2826
  XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t len, XXH64_hash_t seed)
2766
2827
  {
2767
- #if 0
2828
+ #if !defined(XXH_NO_STREAM) && XXH_SIZE_OPT >= 2
2768
2829
  /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
2769
2830
  XXH64_state_t state;
2770
2831
  XXH64_reset(&state, seed);
@@ -2782,7 +2843,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t len, XXH64_hash_t s
2782
2843
  }
2783
2844
 
2784
2845
  /******* Hash Streaming *******/
2785
-
2846
+ #ifndef XXH_NO_STREAM
2786
2847
  /*! @ingroup XXH64_family*/
2787
2848
  XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void)
2788
2849
  {
@@ -2884,7 +2945,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_digest(const XXH64_state_t* state)
2884
2945
 
2885
2946
  return XXH64_finalize(h64, (const xxh_u8*)state->mem64, (size_t)state->total_len, XXH_aligned);
2886
2947
  }
2887
-
2948
+ #endif /* !XXH_NO_STREAM */
2888
2949
 
2889
2950
  /******* Canonical representation *******/
2890
2951
 
@@ -3163,7 +3224,7 @@ enum XXH_VECTOR_TYPE /* fake enum */ {
3163
3224
  */
3164
3225
  #if XXH_VECTOR == XXH_AVX2 /* AVX2 */ \
3165
3226
  && defined(__GNUC__) && !defined(__clang__) /* GCC, not Clang */ \
3166
- && defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) /* respect -O0 and -Os */
3227
+ && defined(__OPTIMIZE__) && XXH_SIZE_OPT <= 0 /* respect -O0 and -Os */
3167
3228
  # pragma GCC push_options
3168
3229
  # pragma GCC optimize("-O2")
3169
3230
  #endif
@@ -3333,7 +3394,7 @@ XXH_FORCE_INLINE uint64x2_t XXH_vld1q_u64(void const* ptr)
3333
3394
  */
3334
3395
  # ifndef XXH3_NEON_LANES
3335
3396
  # if (defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || defined(_M_ARM64EC)) \
3336
- && !defined(__OPTIMIZE_SIZE__)
3397
+ && XXH_SIZE_OPT <= 0
3337
3398
  # define XXH3_NEON_LANES 6
3338
3399
  # else
3339
3400
  # define XXH3_NEON_LANES XXH_ACC_NB
@@ -3350,23 +3411,33 @@ XXH_FORCE_INLINE uint64x2_t XXH_vld1q_u64(void const* ptr)
3350
3411
  * inconsistent intrinsics, spotty coverage, and multiple endiannesses.
3351
3412
  */
3352
3413
  #if XXH_VECTOR == XXH_VSX
3414
+ /* Annoyingly, these headers _may_ define three macros: `bool`, `vector`,
3415
+ * and `pixel`. This is a problem for obvious reasons.
3416
+ *
3417
+ * These keywords are unnecessary; the spec literally says they are
3418
+ * equivalent to `__bool`, `__vector`, and `__pixel` and may be undef'd
3419
+ * after including the header.
3420
+ *
3421
+ * We use pragma push_macro/pop_macro to keep the namespace clean. */
3422
+ # pragma push_macro("bool")
3423
+ # pragma push_macro("vector")
3424
+ # pragma push_macro("pixel")
3425
+ /* silence potential macro redefined warnings */
3426
+ # undef bool
3427
+ # undef vector
3428
+ # undef pixel
3429
+
3353
3430
  # if defined(__s390x__)
3354
3431
  # include <s390intrin.h>
3355
3432
  # else
3356
- /* gcc's altivec.h can have the unwanted consequence to unconditionally
3357
- * #define bool, vector, and pixel keywords,
3358
- * with bad consequences for programs already using these keywords for other purposes.
3359
- * The paragraph defining these macros is skipped when __APPLE_ALTIVEC__ is defined.
3360
- * __APPLE_ALTIVEC__ is _generally_ defined automatically by the compiler,
3361
- * but it seems that, in some cases, it isn't.
3362
- * Force the build macro to be defined, so that keywords are not altered.
3363
- */
3364
- # if defined(__GNUC__) && !defined(__APPLE_ALTIVEC__)
3365
- # define __APPLE_ALTIVEC__
3366
- # endif
3367
3433
  # include <altivec.h>
3368
3434
  # endif
3369
3435
 
3436
+ /* Restore the original macro values, if applicable. */
3437
+ # pragma pop_macro("pixel")
3438
+ # pragma pop_macro("vector")
3439
+ # pragma pop_macro("bool")
3440
+
3370
3441
  typedef __vector unsigned long long xxh_u64x2;
3371
3442
  typedef __vector unsigned char xxh_u8x16;
3372
3443
  typedef __vector unsigned xxh_u32x4;
@@ -3450,7 +3521,9 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b)
3450
3521
  #if defined(XXH_NO_PREFETCH)
3451
3522
  # define XXH_PREFETCH(ptr) (void)(ptr) /* disabled */
3452
3523
  #else
3453
- # if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) /* _mm_prefetch() not defined outside of x86/x64 */
3524
+ # if XXH_SIZE_OPT >= 1
3525
+ # define XXH_PREFETCH(ptr) (void)(ptr)
3526
+ # elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) /* _mm_prefetch() not defined outside of x86/x64 */
3454
3527
  # include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
3455
3528
  # define XXH_PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
3456
3529
  # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
@@ -3879,6 +3952,14 @@ XXH3_len_17to128_64b(const xxh_u8* XXH_RESTRICT input, size_t len,
3879
3952
  XXH_ASSERT(16 < len && len <= 128);
3880
3953
 
3881
3954
  { xxh_u64 acc = len * XXH_PRIME64_1;
3955
+ #if XXH_SIZE_OPT >= 1
3956
+ /* Smaller and cleaner, but slightly slower. */
3957
+ size_t i = (len - 1) / 32;
3958
+ do {
3959
+ acc += XXH3_mix16B(input+16 * i, secret+32*i, seed);
3960
+ acc += XXH3_mix16B(input+len-16*(i+1), secret+32*i+16, seed);
3961
+ } while (i-- != 0);
3962
+ #else
3882
3963
  if (len > 32) {
3883
3964
  if (len > 64) {
3884
3965
  if (len > 96) {
@@ -3893,7 +3974,7 @@ XXH3_len_17to128_64b(const xxh_u8* XXH_RESTRICT input, size_t len,
3893
3974
  }
3894
3975
  acc += XXH3_mix16B(input+0, secret+0, seed);
3895
3976
  acc += XXH3_mix16B(input+len-16, secret+16, seed);
3896
-
3977
+ #endif
3897
3978
  return XXH3_avalanche(acc);
3898
3979
  }
3899
3980
  }
@@ -4566,7 +4647,7 @@ XXH3_accumulate_512_scalar(void* XXH_RESTRICT acc,
4566
4647
  #if defined(__GNUC__) && !defined(__clang__) \
4567
4648
  && (defined(__arm__) || defined(__thumb2__)) \
4568
4649
  && defined(__ARM_FEATURE_UNALIGNED) /* no unaligned access just wastes bytes */ \
4569
- && !defined(__OPTIMIZE_SIZE__)
4650
+ && XXH_SIZE_OPT <= 0
4570
4651
  # pragma GCC unroll 8
4571
4652
  #endif
4572
4653
  for (i=0; i < XXH_ACC_NB; i++) {
@@ -4725,7 +4806,10 @@ typedef void (*XXH3_f_initCustomSecret)(void* XXH_RESTRICT, xxh_u64);
4725
4806
 
4726
4807
  #endif
4727
4808
 
4728
-
4809
+ #if XXH_SIZE_OPT >= 1 /* don't do SIMD for initialization */
4810
+ # undef XXH3_initCustomSecret
4811
+ # define XXH3_initCustomSecret XXH3_initCustomSecret_scalar
4812
+ #endif
4729
4813
 
4730
4814
  #ifndef XXH_PREFETCH_DIST
4731
4815
  # ifdef __clang__
@@ -4895,10 +4979,12 @@ XXH3_hashLong_64b_withSeed_internal(const void* input, size_t len,
4895
4979
  XXH3_f_scrambleAcc f_scramble,
4896
4980
  XXH3_f_initCustomSecret f_initSec)
4897
4981
  {
4982
+ #if XXH_SIZE_OPT <= 0
4898
4983
  if (seed == 0)
4899
4984
  return XXH3_hashLong_64b_internal(input, len,
4900
4985
  XXH3_kSecret, sizeof(XXH3_kSecret),
4901
4986
  f_acc512, f_scramble);
4987
+ #endif
4902
4988
  { XXH_ALIGN(XXH_SEC_ALIGN) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE];
4903
4989
  f_initSec(secret, seed);
4904
4990
  return XXH3_hashLong_64b_internal(input, len, secret, sizeof(secret),
@@ -4977,7 +5063,7 @@ XXH3_64bits_withSecretandSeed(const void* input, size_t length, const void* secr
4977
5063
 
4978
5064
 
4979
5065
  /* === XXH3 streaming === */
4980
-
5066
+ #ifndef XXH_NO_STREAM
4981
5067
  /*
4982
5068
  * Malloc's a pointer that is always aligned to align.
4983
5069
  *
@@ -5165,7 +5251,7 @@ XXH3_consumeStripes(xxh_u64* XXH_RESTRICT acc,
5165
5251
  }
5166
5252
 
5167
5253
  #ifndef XXH3_STREAM_USE_STACK
5168
- # ifndef __clang__ /* clang doesn't need additional stack space */
5254
+ # if XXH_SIZE_OPT <= 0 && !defined(__clang__) /* clang doesn't need additional stack space */
5169
5255
  # define XXH3_STREAM_USE_STACK 1
5170
5256
  # endif
5171
5257
  #endif
@@ -5347,7 +5433,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* state)
5347
5433
  return XXH3_64bits_withSecret(state->buffer, (size_t)(state->totalLen),
5348
5434
  secret, state->secretLimit + XXH_STRIPE_LEN);
5349
5435
  }
5350
-
5436
+ #endif /* !XXH_NO_STREAM */
5351
5437
 
5352
5438
 
5353
5439
  /* ==========================================
@@ -5540,6 +5626,16 @@ XXH3_len_17to128_128b(const xxh_u8* XXH_RESTRICT input, size_t len,
5540
5626
  { XXH128_hash_t acc;
5541
5627
  acc.low64 = len * XXH_PRIME64_1;
5542
5628
  acc.high64 = 0;
5629
+
5630
+ #if XXH_SIZE_OPT >= 1
5631
+ {
5632
+ /* Smaller, but slightly slower. */
5633
+ size_t i = (len - 1) / 32;
5634
+ do {
5635
+ acc = XXH128_mix32B(acc, input+16*i, input+len-16*(i+1), secret+32*i, seed);
5636
+ } while (i-- != 0);
5637
+ }
5638
+ #else
5543
5639
  if (len > 32) {
5544
5640
  if (len > 64) {
5545
5641
  if (len > 96) {
@@ -5550,6 +5646,7 @@ XXH3_len_17to128_128b(const xxh_u8* XXH_RESTRICT input, size_t len,
5550
5646
  acc = XXH128_mix32B(acc, input+16, input+len-32, secret+32, seed);
5551
5647
  }
5552
5648
  acc = XXH128_mix32B(acc, input, input+len-16, secret, seed);
5649
+ #endif
5553
5650
  { XXH128_hash_t h128;
5554
5651
  h128.low64 = acc.low64 + acc.high64;
5555
5652
  h128.high64 = (acc.low64 * XXH_PRIME64_1)
@@ -5764,7 +5861,7 @@ XXH128(const void* input, size_t len, XXH64_hash_t seed)
5764
5861
 
5765
5862
 
5766
5863
  /* === XXH3 128-bit streaming === */
5767
-
5864
+ #ifndef XXH_NO_STREAM
5768
5865
  /*
5769
5866
  * All initialization and update functions are identical to 64-bit streaming variant.
5770
5867
  * The only difference is the finalization routine.
@@ -5831,7 +5928,7 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* state)
5831
5928
  return XXH3_128bits_withSecret(state->buffer, (size_t)(state->totalLen),
5832
5929
  secret, state->secretLimit + XXH_STRIPE_LEN);
5833
5930
  }
5834
-
5931
+ #endif /* !XXH_NO_STREAM */
5835
5932
  /* 128-bit utility functions */
5836
5933
 
5837
5934
  #include <string.h> /* memcmp, memcpy */
@@ -5958,7 +6055,7 @@ XXH3_generateSecret_fromSeed(void* secretBuffer, XXH64_hash_t seed)
5958
6055
  /* Pop our optimization override from above */
5959
6056
  #if XXH_VECTOR == XXH_AVX2 /* AVX2 */ \
5960
6057
  && defined(__GNUC__) && !defined(__clang__) /* GCC, not Clang */ \
5961
- && defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) /* respect -O0 and -Os */
6058
+ && defined(__OPTIMIZE__) && XXH_SIZE_OPT <= 0 /* respect -O0 and -Os */
5962
6059
  # pragma GCC pop_options
5963
6060
  #endif
5964
6061
 
@@ -2,6 +2,6 @@ require 'digest'
2
2
 
3
3
  module Digest
4
4
  class XXHash < Digest::Class
5
- VERSION = "0.2.3"
5
+ VERSION = "0.2.4"
6
6
  end
7
7
  end
@@ -35,8 +35,7 @@ class AltInstallTask < Rake::TaskLib
35
35
 
36
36
  def define
37
37
  [:install, :"install:local"].each do |name|
38
- Rake::Task[name].clear if Rake::Task.task_defined?(name)
39
- task(name => :build){ |task| execute_task(task) }
38
+ task(name).clear.enhance([:build]){ |task| execute_task(task) }
40
39
  .singleton_class.prepend(TaskComment)
41
40
  end
42
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digest-xxhash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - konsolebox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-29 00:00:00.000000000 Z
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake