aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-10-21 00:06:52 +0300
committerLasse Collin <lasse.collin@tukaani.org>2024-01-11 14:29:42 +0200
commite3833e297dfb5021a197bda34ba2a795e30aaf8a (patch)
treeef443223ecd826402e5714472a5afdbfbdc9282a /src/liblzma/check
parentliblzma: Simplify existing cases with lzma_attr_no_sanitize_address. (diff)
downloadxz-e3833e297dfb5021a197bda34ba2a795e30aaf8a.tar.xz
liblzma: crc_clmul.c: Add crc_attr_target macro.
This reduces the number of the complex #if directives.
Diffstat (limited to 'src/liblzma/check')
-rw-r--r--src/liblzma/check/crc_clmul.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/liblzma/check/crc_clmul.c b/src/liblzma/check/crc_clmul.c
index b855e443..381948a9 100644
--- a/src/liblzma/check/crc_clmul.c
+++ b/src/liblzma/check/crc_clmul.c
@@ -31,6 +31,19 @@
#include <immintrin.h>
+// EDG-based compilers (Intel's classic compiler and compiler for E2K) can
+// define __GNUC__ but the attribute must not be used with them.
+// The new Clang-based ICX needs the attribute.
+//
+// NOTE: Build systems check for this too, keep them in sync with this.
+#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)
+# define crc_attr_target \
+ __attribute__((__target__("ssse3,sse4.1,pclmul")))
+#else
+# define crc_attr_target
+#endif
+
+
#define MASK_L(in, mask, r) r = _mm_shuffle_epi8(in, mask)
#define MASK_H(in, mask, r) \
@@ -41,9 +54,7 @@
MASK_H(in, mask, high)
-#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)
-__attribute__((__target__("ssse3,sse4.1,pclmul")))
-#endif
+crc_attr_target
crc_attr_no_sanitize_address
static crc_always_inline void
crc_simd_body(const uint8_t *buf, const size_t size, __m128i *v0, __m128i *v1,
@@ -216,14 +227,7 @@ calc_hi(uint64_t p, uint64_t a, int n)
#ifdef HAVE_CHECK_CRC32
-// EDG-based compilers (Intel's classic compiler and compiler for E2K) can
-// define __GNUC__ but the attribute must not be used with them.
-// The new Clang-based ICX needs the attribute.
-//
-// NOTE: Build systems check for this too, keep them in sync with this.
-#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)
-__attribute__((__target__("ssse3,sse4.1,pclmul")))
-#endif
+crc_attr_target
crc_attr_no_sanitize_address
extern uint32_t
lzma_crc32_clmul(const uint8_t *buf, size_t size, uint32_t crc)
@@ -312,9 +316,7 @@ calc_hi(uint64_t poly, uint64_t a)
# pragma optimize("g", off)
#endif
-#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)
-__attribute__((__target__("ssse3,sse4.1,pclmul")))
-#endif
+crc_attr_target
crc_attr_no_sanitize_address
extern uint64_t
lzma_crc64_clmul(const uint8_t *buf, size_t size, uint64_t crc)