From 4322f15012e9ac46421467cf5b71cc55bd411788 Mon Sep 17 00:00:00 2001 From: Scr3amer Date: Sat, 2 Sep 2023 09:22:20 -0400 Subject: [PATCH] Do not redefine _mm_roti_epi64 if xop target feature is enabled. (#1305) Undefine compiler macro if present and XOP not enable to avoid preprocessor warnings due to macro redefinition --- .../crypto_generichash/blake2b/ref/blake2b-compress-sse41.h | 3 +++ .../crypto_generichash/blake2b/ref/blake2b-compress-ssse3.h | 2 ++ src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.h b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.h index ac78e5bb..c4c93f77 100644 --- a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.h +++ b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.h @@ -5,6 +5,8 @@ #define LOADU(p) _mm_loadu_si128((const __m128i *) (const void *) (p)) #define STOREU(p, r) _mm_storeu_si128((__m128i *) (void *) (p), r) +#if !(defined(_mm_roti_epi64) && defined(__XOP__)) +#undef _mm_roti_epi64 #define _mm_roti_epi64(x, c) \ (-(c) == 32) \ ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2, 3, 0, 1)) \ @@ -17,6 +19,7 @@ _mm_add_epi64((x), (x))) \ : _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ _mm_slli_epi64((x), 64 - (-(c)))) +#endif #define G1(row1l, row2l, row3l, row4l, row1h, row2h, row3h, row4h, b0, b1) \ row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \ diff --git a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.h b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.h index 9a7164fe..127c0f7e 100644 --- a/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.h +++ b/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.h @@ -5,6 +5,7 @@ #define LOADU(p) _mm_loadu_si128((const __m128i *) (const void *) (p)) #define STOREU(p, r) _mm_storeu_si128((__m128i *) (void *) (p), r) +#if !(defined(_mm_roti_epi64) && defined(__XOP__)) #define _mm_roti_epi64(x, c) \ (-(c) == 32) \ ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2, 3, 0, 1)) \ @@ -17,6 +18,7 @@ _mm_add_epi64((x), (x))) \ : _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ _mm_slli_epi64((x), 64 - (-(c)))) +#endif #define G1(row1l, row2l, row3l, row4l, row1h, row2h, row3h, row4h, b0, b1) \ row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \ diff --git a/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h b/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h index 98a47b93..5134b67c 100644 --- a/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h +++ b/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h @@ -8,6 +8,9 @@ (_mm_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9)) #define r24 \ (_mm_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10)) + +#if !(defined(_mm_roti_epi64) && defined(__XOP__)) +#undef _mm_roti_epi64 #define _mm_roti_epi64(x, c) \ (-(c) == 32) \ ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2, 3, 0, 1)) \ @@ -20,6 +23,7 @@ _mm_add_epi64((x), (x))) \ : _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ _mm_slli_epi64((x), 64 - (-(c)))) +#endif static inline __m128i fBlaMka(__m128i x, __m128i y)