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 -# if defined(__GNUC__) +# if defined(CRYPTOPP_GCC_COMPATIBLE) # include # endif -#endif +# include +#endif // XOP #if (CRYPTOPP_SSE41_AVAILABLE) # include 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 -# if defined(__GNUC__) +# if defined(CRYPTOPP_GCC_COMPATIBLE) # include # endif -#endif +# include +#endif // XOP #if (CRYPTOPP_SSE41_AVAILABLE) # include 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 -# if defined(__GNUC__) +# if defined(CRYPTOPP_GCC_COMPATIBLE) # include # endif -#endif +# include +#endif // XOP #if (CRYPTOPP_ARM_NEON_HEADER) # include 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 -# if defined(__GNUC__) +# if defined(CRYPTOPP_GCC_COMPATIBLE) # include # endif -#endif +# include +#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 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 -# if defined(__GNUC__) +# if defined(CRYPTOPP_GCC_COMPATIBLE) # include # endif -#endif +# include +#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 -# if defined(__GNUC__) +# if defined(CRYPTOPP_GCC_COMPATIBLE) # include # endif -#endif +# include +#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 #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 #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 #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 #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 #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 #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 #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 #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 +# if defined(CRYPTOPP_GCC_COMPATIBLE) +# include +# endif # include -#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 -# if defined(__GNUC__) +# if defined(CRYPTOPP_GCC_COMPATIBLE) # include # endif -#endif +# include +#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 -# if defined(__GNUC__) +# if defined(CRYPTOPP_GCC_COMPATIBLE) # include # endif -#endif +# include +#endif // XOP #if (CRYPTOPP_ARM_NEON_HEADER) # include "adv_simd.h"