summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2023-04-15 18:21:03 -0400
committerJeffrey Walton <noloader@gmail.com>2023-04-15 18:21:03 -0400
commitddb8f36e8894a3bce7daeca0815fb0137de73388 (patch)
tree2db9cb4c53c63323da064f21461b63dbcd982013
parentf5f63850f9a5521e45de3cc45be61309a2e71ab2 (diff)
downloadcryptopp-git-ddb8f36e8894a3bce7daeca0815fb0137de73388.tar.gz
Fix use of <x86intrin.h> for MSVC (GH #1198)
It seems Microsoft now defines GCC defines, like __BMI__
-rw-r--r--blake2b_simd.cpp6
-rw-r--r--blake2s_simd.cpp6
-rw-r--r--chacha_simd.cpp6
-rw-r--r--cham_simd.cpp6
-rw-r--r--config_ver.h6
-rw-r--r--keccak_simd.cpp6
-rw-r--r--lea_simd.cpp6
-rw-r--r--lsh256_avx.cpp3
-rw-r--r--lsh256_sse.cpp3
-rw-r--r--lsh512_avx.cpp3
-rw-r--r--lsh512_sse.cpp3
-rw-r--r--misc.h6
-rw-r--r--simon128_simd.cpp6
-rw-r--r--speck128_simd.cpp6
14 files changed, 38 insertions, 34 deletions
diff --git a/blake2b_simd.cpp b/blake2b_simd.cpp
index f408b8fa..7e3a5832 100644
--- a/blake2b_simd.cpp
+++ b/blake2b_simd.cpp
@@ -33,11 +33,11 @@
#endif
#if defined(__XOP__)
-# include <ammintrin.h>
-# if defined(__GNUC__)
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
# endif
-#endif
+# include <ammintrin.h>
+#endif // XOP
#if (CRYPTOPP_SSE41_AVAILABLE)
# include <emmintrin.h>
diff --git a/blake2s_simd.cpp b/blake2s_simd.cpp
index 4d00f609..a25cc1cd 100644
--- a/blake2s_simd.cpp
+++ b/blake2s_simd.cpp
@@ -43,11 +43,11 @@
#endif
#if defined(__XOP__)
-# include <ammintrin.h>
-# if defined(__GNUC__)
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
# endif
-#endif
+# include <ammintrin.h>
+#endif // XOP
#if (CRYPTOPP_SSE41_AVAILABLE)
# include <emmintrin.h>
diff --git a/chacha_simd.cpp b/chacha_simd.cpp
index 4e5a3cc3..556070e5 100644
--- a/chacha_simd.cpp
+++ b/chacha_simd.cpp
@@ -45,11 +45,11 @@
#endif
#if defined(__XOP__)
-# include <ammintrin.h>
-# if defined(__GNUC__)
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
# endif
-#endif
+# include <ammintrin.h>
+#endif // XOP
#if (CRYPTOPP_ARM_NEON_HEADER)
# include <arm_neon.h>
diff --git a/cham_simd.cpp b/cham_simd.cpp
index b848ba10..8048fd3d 100644
--- a/cham_simd.cpp
+++ b/cham_simd.cpp
@@ -23,11 +23,11 @@
#endif
#if defined(__XOP__)
-# include <ammintrin.h>
-# if defined(__GNUC__)
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
# endif
-#endif
+# include <ammintrin.h>
+#endif // XOP
// Clang intrinsic casts, http://bugs.llvm.org/show_bug.cgi?id=20670
#define DOUBLE_CAST(x) ((double*)(void*)(x))
diff --git a/config_ver.h b/config_ver.h
index c28abb86..a771de44 100644
--- a/config_ver.h
+++ b/config_ver.h
@@ -87,4 +87,10 @@
# define CRYPTOPP_MSC_VERSION (_MSC_VER)
#endif
+// To control <x86intrin.h> include. May need a guard, like GCC 4.5 and above
+// Also see https://stackoverflow.com/a/42493893 and https://github.com/weidai11/cryptopp/issues/1198
+#if defined(CRYPTOPP_GCC_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) || defined(CRYPTOPP_LLVM_CLANG_VERSION)
+# define CRYPTOPP_GCC_COMPATIBLE 1
+#endif
+
#endif // CRYPTOPP_CONFIG_VERSION_H
diff --git a/keccak_simd.cpp b/keccak_simd.cpp
index 5a534a99..b2cf62ee 100644
--- a/keccak_simd.cpp
+++ b/keccak_simd.cpp
@@ -27,11 +27,11 @@
#endif
#if defined(__XOP__)
-# include <ammintrin.h>
-# if defined(__GNUC__)
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
# endif
-#endif
+# include <ammintrin.h>
+#endif // XOP
// Squash MS LNK4221 and libtool warnings
extern const char KECCAK_SIMD_FNAME[] = __FILE__;
diff --git a/lea_simd.cpp b/lea_simd.cpp
index 7ea9cfa5..a016cb38 100644
--- a/lea_simd.cpp
+++ b/lea_simd.cpp
@@ -23,11 +23,11 @@
#endif
#if defined(__XOP__)
-# include <ammintrin.h>
-# if defined(__GNUC__)
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
# endif
-#endif
+# include <ammintrin.h>
+#endif // XOP
#if (CRYPTOPP_ARM_NEON_HEADER)
# include "adv_simd.h"
diff --git a/lsh256_avx.cpp b/lsh256_avx.cpp
index 88df6a17..f4ac6b57 100644
--- a/lsh256_avx.cpp
+++ b/lsh256_avx.cpp
@@ -25,8 +25,7 @@ extern const char LSH256_AVX_FNAME[] = __FILE__;
# include <immintrin.h>
#endif
-// GCC at 4.5. Clang is unknown. Also see https://stackoverflow.com/a/42493893.
-#if (CRYPTOPP_GCC_VERSION >= 40500)
+#if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
#endif
diff --git a/lsh256_sse.cpp b/lsh256_sse.cpp
index fe96b789..cec70b77 100644
--- a/lsh256_sse.cpp
+++ b/lsh256_sse.cpp
@@ -30,8 +30,7 @@ extern const char LSH256_SSE_FNAME[] = __FILE__;
# include <ammintrin.h>
#endif
-// GCC at 4.5. Clang is unknown. Also see https://stackoverflow.com/a/42493893.
-#if (CRYPTOPP_GCC_VERSION >= 40500)
+#if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
#endif
diff --git a/lsh512_avx.cpp b/lsh512_avx.cpp
index afb3ba24..56fed7c8 100644
--- a/lsh512_avx.cpp
+++ b/lsh512_avx.cpp
@@ -25,8 +25,7 @@ extern const char LSH512_AVX_FNAME[] = __FILE__;
# include <immintrin.h>
#endif
-// GCC at 4.5. Clang is unknown. Also see https://stackoverflow.com/a/42493893.
-#if (CRYPTOPP_GCC_VERSION >= 40500)
+#if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
#endif
diff --git a/lsh512_sse.cpp b/lsh512_sse.cpp
index cc08ccef..96cffd45 100644
--- a/lsh512_sse.cpp
+++ b/lsh512_sse.cpp
@@ -29,8 +29,7 @@ extern const char LSH512_SSE_FNAME[] = __FILE__;
# include <ammintrin.h>
#endif
-// GCC at 4.5. Clang is unknown. Also see https://stackoverflow.com/a/42493893.
-#if (CRYPTOPP_GCC_VERSION >= 40500)
+#if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
#endif
diff --git a/misc.h b/misc.h
index f81e81f4..be9fcf38 100644
--- a/misc.h
+++ b/misc.h
@@ -80,9 +80,11 @@
#endif
#if defined(__BMI__)
-# include <x86intrin.h>
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
+# include <x86intrin.h>
+# endif
# include <immintrin.h>
-#endif // GCC and BMI
+#endif // BMI
// More LLVM bullshit. Apple Clang 6.0 does not define them.
// Later version of Clang defines them and results in warnings.
diff --git a/simon128_simd.cpp b/simon128_simd.cpp
index 5a0aaddf..4503dd90 100644
--- a/simon128_simd.cpp
+++ b/simon128_simd.cpp
@@ -23,11 +23,11 @@
#endif
#if defined(__XOP__)
-# include <ammintrin.h>
-# if defined(__GNUC__)
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
# endif
-#endif
+# include <ammintrin.h>
+#endif // XOP
#if (CRYPTOPP_ARM_NEON_HEADER)
# include "adv_simd.h"
diff --git a/speck128_simd.cpp b/speck128_simd.cpp
index a17ce38d..0130aca8 100644
--- a/speck128_simd.cpp
+++ b/speck128_simd.cpp
@@ -23,11 +23,11 @@
#endif
#if defined(__XOP__)
-# include <ammintrin.h>
-# if defined(__GNUC__)
+# if defined(CRYPTOPP_GCC_COMPATIBLE)
# include <x86intrin.h>
# endif
-#endif
+# include <ammintrin.h>
+#endif // XOP
#if (CRYPTOPP_ARM_NEON_HEADER)
# include "adv_simd.h"