From 3f6d499c1900608aba1a1872f3bfde7c3b60ece5 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 1 Aug 2016 13:41:42 -0400 Subject: [PATCH] Fix missing arm_acle.h under GCC 4.8. Rearrange some defines to better account for ARM and MIPS --- config.h | 4 +-- config.recommend | 4 +-- cpu.h | 64 +++++++++++++++++++++++------------------------- 3 files changed, 35 insertions(+), 37 deletions(-) diff --git a/config.h b/config.h index 73af8e27..accbe06f 100644 --- a/config.h +++ b/config.h @@ -492,7 +492,7 @@ NAMESPACE_END # endif #endif -// Requires ARMv8 and ACLE 2.0. +// Requires ARMv8 and ACLE 2.0. For GCC, requires 4.8 and above. // Microsoft plans to support ARM-64, but its not clear how to detect it. // TODO: Add MSC_VER and ARM-64 platform define when available #if !defined(CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) @@ -501,7 +501,7 @@ NAMESPACE_END # endif #endif -// Requires ARMv8 and ACLE 2.0. +// Requires ARMv8 and ACLE 2.0. For GCC, requires 4.8 and above. // Microsoft plans to support ARM-64, but its not clear how to detect it. // TODO: Add MSC_VER and ARM-64 platform define when available #if !defined(CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) diff --git a/config.recommend b/config.recommend index 19c32822..815cd184 100644 --- a/config.recommend +++ b/config.recommend @@ -492,7 +492,7 @@ NAMESPACE_END # endif #endif -// Requires ARMv8 and ACLE 2.0. +// Requires ARMv8 and ACLE 2.0. For GCC, requires 4.8 and above. // Microsoft plans to support ARM-64, but its not clear how to detect it. // TODO: Add MSC_VER and ARM-64 platform define when available #if !defined(CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) @@ -501,7 +501,7 @@ NAMESPACE_END # endif #endif -// Requires ARMv8 and ACLE 2.0. +// Requires ARMv8 and ACLE 2.0. For GCC, requires 4.8 and above. // Microsoft plans to support ARM-64, but its not clear how to detect it. // TODO: Add MSC_VER and ARM-64 platform define when available #if !defined(CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) diff --git a/cpu.h b/cpu.h index 7e7cca43..8398e37d 100644 --- a/cpu.h +++ b/cpu.h @@ -10,22 +10,47 @@ #include "config.h" #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64) -# if defined(_MSC_VER) || defined(__BORLANDC__) -# define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY -# else -# define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY +# if __GNUC__ +# include # endif # if CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE # include # endif # if (CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) -# include -# if (defined(__ARM_ACLE) || defined(__GNUC__)) && !defined(__APPLE__) +# if (defined(__ARM_ACLE)) # include # endif # endif #endif // ARM-32 or ARM-64 +// Applies to both X86/X32/X64 and ARM32/ARM64. And we've got MIPS devices on the way. +#if defined(_MSC_VER) || defined(__BORLANDC__) +# define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY +#else +# define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY +#endif + +// Applies to both X86/X32/X64 and ARM32/ARM64 +#if defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER) + #define NEW_LINE "\n" + #define INTEL_PREFIX ".intel_syntax;" + #define INTEL_NOPREFIX ".intel_syntax;" + #define ATT_PREFIX ".att_syntax;" + #define ATT_NOPREFIX ".att_syntax;" +#elif defined(__GNUC__) + #define NEW_LINE + #define INTEL_PREFIX ".intel_syntax prefix;" + #define INTEL_NOPREFIX ".intel_syntax noprefix;" + #define ATT_PREFIX ".att_syntax prefix;" + #define ATT_NOPREFIX ".att_syntax noprefix;" +#else + #define NEW_LINE + #define INTEL_PREFIX + #define INTEL_NOPREFIX + #define ATT_PREFIX + #define ATT_NOPREFIX +#endif + #ifdef CRYPTOPP_GENERATE_X64_MASM #define CRYPTOPP_X86_ASM_AVAILABLE @@ -39,12 +64,6 @@ # include # endif -// #if defined(CRYPTOPP_GCC_VERSION) && (CRYPTOPP_GCC_VERSION < 50000) -// typedef int __v4si __attribute__ ((__vector_size__ (16))); -// typedef long long __v2di __attribute__ ((__vector_size__ (16))); -// typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__)); -// #endif - #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE // GCC 5.3/i686 fails to declare __m128 in the headers we use when compiling with -std=c++11 or -std=c++14. @@ -650,27 +669,6 @@ inline int GetCacheLineSize() #endif // X86/X32/X64 -// Applies to both X86/X32/X64 and ARM32/ARM64 -#if defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER) - #define NEW_LINE "\n" - #define INTEL_PREFIX ".intel_syntax;" - #define INTEL_NOPREFIX ".intel_syntax;" - #define ATT_PREFIX ".att_syntax;" - #define ATT_NOPREFIX ".att_syntax;" -#elif defined(__GNUC__) - #define NEW_LINE - #define INTEL_PREFIX ".intel_syntax prefix;" - #define INTEL_NOPREFIX ".intel_syntax noprefix;" - #define ATT_PREFIX ".att_syntax prefix;" - #define ATT_NOPREFIX ".att_syntax noprefix;" -#else - #define NEW_LINE - #define INTEL_PREFIX - #define INTEL_NOPREFIX - #define ATT_PREFIX - #define ATT_NOPREFIX -#endif - NAMESPACE_END #endif // CRYPTOPP_CPU_H