@@ -1627,6 +1627,23 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
1627
1627
*/
1628
1628
# define XXH_NO_INLINE_HINTS 0
1629
1629
1630
+ /* !
1631
+ * @def XXH3_INLINE_SECRET
1632
+ * @brief Determines whether to inline the XXH3 withSecret code.
1633
+ *
1634
+ * When the secret size is known, the compiler can improve the performance
1635
+ * of XXH3_64bits_withSecret() and XXH3_128bits_withSecret().
1636
+ *
1637
+ * However, if the secret size is not known, it doesn't have any benefit. This
1638
+ * happens when xxHash is compiled into a global symbol. Therefore, if
1639
+ * @ref XXH_INLINE_ALL is *not* defined, this will be defined to 0.
1640
+ *
1641
+ * Additionally, this defaults to 0 on GCC 12+, which has an issue with function pointers
1642
+ * that are *sometimes* force inline on -Og, and it is impossible to automatically
1643
+ * detect this optimization level.
1644
+ */
1645
+ # define XXH3_INLINE_SECRET 0
1646
+
1630
1647
/* !
1631
1648
* @def XXH32_ENDJMP
1632
1649
* @brief Whether to use a jump for `XXH32_finalize`.
@@ -1701,6 +1718,15 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
1701
1718
# endif
1702
1719
#endif
1703
1720
1721
+ #ifndef XXH3_INLINE_SECRET
1722
+ # if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12) \
1723
+ || !defined(XXH_INLINE_ALL)
1724
+ # define XXH3_INLINE_SECRET 0
1725
+ # else
1726
+ # define XXH3_INLINE_SECRET 1
1727
+ # endif
1728
+ #endif
1729
+
1704
1730
#ifndef XXH32_ENDJMP
1705
1731
/* generally preferable for performance */
1706
1732
# define XXH32_ENDJMP 0
@@ -1797,6 +1823,11 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
1797
1823
# define XXH_NO_INLINE static
1798
1824
#endif
1799
1825
1826
+ #if XXH3_INLINE_SECRET
1827
+ # define XXH3_WITH_SECRET_INLINE XXH_FORCE_INLINE
1828
+ #else
1829
+ # define XXH3_WITH_SECRET_INLINE XXH_NO_INLINE
1830
+ #endif
1800
1831
1801
1832
1802
1833
/* *************************************
@@ -5149,12 +5180,7 @@ XXH3_hashLong_64b_internal(const void* XXH_RESTRICT input, size_t len,
5149
5180
* When the secret size is unknown, or on GCC 12 where the mix of NO_INLINE and FORCE_INLINE
5150
5181
* breaks -Og, this is XXH_NO_INLINE.
5151
5182
*/
5152
- #if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12) || !defined(XXH_INLINE_ALL)
5153
- XXH_NO_INLINE
5154
- #else
5155
- XXH_FORCE_INLINE
5156
- #endif
5157
- XXH64_hash_t
5183
+ XXH3_WITH_SECRET_INLINE XXH64_hash_t
5158
5184
XXH3_hashLong_64b_withSecret (const void * XXH_RESTRICT input, size_t len,
5159
5185
XXH64_hash_t seed64, const xxh_u8* XXH_RESTRICT secret, size_t secretLen)
5160
5186
{
@@ -5977,12 +6003,7 @@ XXH3_hashLong_128b_default(const void* XXH_RESTRICT input, size_t len,
5977
6003
* When the secret size is unknown, or on GCC 12 where the mix of NO_INLINE and FORCE_INLINE
5978
6004
* breaks -Og, this is XXH_NO_INLINE.
5979
6005
*/
5980
- #if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12) || !defined(XXH_INLINE_ALL)
5981
- XXH_NO_INLINE
5982
- #else
5983
- XXH_FORCE_INLINE
5984
- #endif
5985
- XXH128_hash_t
6006
+ XXH3_WITH_SECRET_INLINE XXH128_hash_t
5986
6007
XXH3_hashLong_128b_withSecret (const void * XXH_RESTRICT input, size_t len,
5987
6008
XXH64_hash_t seed64,
5988
6009
const void * XXH_RESTRICT secret, size_t secretLen)
0 commit comments