diff options
| author | Jeffrey Walton <noloader@gmail.com> | 2017-08-17 12:33:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-17 12:33:43 -0400 |
| commit | e2c377effd9a4eca0291c217e9c3256b033511dc (patch) | |
| tree | a33fa7d52e14b923a034bafb9a05172a983a0e7c /config.h | |
| parent | 74d21068a16c2b3e879336ae7eed180d4466e8b5 (diff) | |
| download | cryptopp-git-e2c377effd9a4eca0291c217e9c3256b033511dc.tar.gz | |
Split source files to support Base Implementation + SIMD implementation (GH #461)
Split source files to support Base Implementation + SIMD implementation
Diffstat (limited to 'config.h')
| -rw-r--r-- | config.h | 223 |
1 files changed, 133 insertions, 90 deletions
@@ -80,8 +80,15 @@ // #endif
// File system code to write to GZIP archive.
+// http://www.gzip.org/format.txt
#if !defined(GZIP_OS_CODE)
-# define GZIP_OS_CODE 0
+# if defined(__macintosh__)
+# define GZIP_OS_CODE 7
+# elif defined(__unix__) || defined(__linux__)
+# define GZIP_OS_CODE 3
+# else
+# define GZIP_OS_CODE 0
+# endif
#endif
// Try this if your CPU has 256K internal cache or a slow multiply instruction
@@ -386,7 +393,62 @@ NAMESPACE_END #define CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE
#endif
-// Apple's Clang prior to 5.0 cannot handle SSE2 (and Apple does not use LLVM Clang numbering...)
+// ***************** Platform and CPU features ********************
+
+// Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
+// Detect via __ILP32__ (http://wiki.debian.org/X32Port). However, __ILP32__ shows up in more places than
+// the System V ABI specs calls out, like on some Solaris installations and just about any 32-bit system with Clang.
+#if (defined(__ILP32__) || defined(_ILP32)) && defined(__x86_64__)
+ #define CRYPTOPP_BOOL_X32 1
+#else
+ #define CRYPTOPP_BOOL_X32 0
+#endif
+
+// see http://predef.sourceforge.net/prearch.html
+#if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32
+ #define CRYPTOPP_BOOL_X86 1
+#else
+ #define CRYPTOPP_BOOL_X86 0
+#endif
+
+#if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32
+ #define CRYPTOPP_BOOL_X64 1
+#else
+ #define CRYPTOPP_BOOL_X64 0
+#endif
+
+// Undo the ASM and Intrinsic related defines due to X32.
+#if CRYPTOPP_BOOL_X32
+# undef CRYPTOPP_BOOL_X64
+# undef CRYPTOPP_X64_ASM_AVAILABLE
+# undef CRYPTOPP_X64_MASM_AVAILABLE
+#endif
+
+#if defined(__arm__) || defined(__aarch32__) || defined(_M_ARM)
+ #define CRYPTOPP_BOOL_ARM32 1
+#else
+ #define CRYPTOPP_BOOL_ARM32 0
+#endif
+
+// 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(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
+ #define CRYPTOPP_BOOL_ARM64 1
+#else
+ #define CRYPTOPP_BOOL_ARM64 0
+#endif
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+# define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY 1
+#else
+# define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY 1
+#endif
+
+// ***************** IA32 CPU features ********************
+
+#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
+
+// Apple Clang prior to 5.0 cannot handle SSE2
#if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000)
# define CRYPTOPP_DISABLE_ASM
#endif
@@ -403,63 +465,80 @@ NAMESPACE_END #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
#define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 1
- #else
- #define CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE 0
#endif
- #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || (defined(__SSE3__) && defined(__SSSE3__)))
+ #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || defined(__SSSE3__))
#define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 1
- #else
- #define CRYPTOPP_BOOL_SSSE3_ASM_AVAILABLE 0
#endif
#endif
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
- #define CRYPTOPP_X64_MASM_AVAILABLE
+ #define CRYPTOPP_X64_MASM_AVAILABLE 1
#endif
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
- #define CRYPTOPP_X64_ASM_AVAILABLE
+ #define CRYPTOPP_X64_ASM_AVAILABLE 1
#endif
-#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(_MSC_VER) || defined(__SSE2__)) && !defined(_M_ARM)
- #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
-#else
- #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 0
+#if !defined(CRYPTOPP_DISABLE_ASM) && (defined(_MSC_VER) || defined(__SSE2__))
+ #define CRYPTOPP_SSE2_AVAILABLE 1
#endif
-#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SSSE3) && !defined(_M_ARM) && (_MSC_VER >= 1500 || (defined(__SSSE3__) && defined(__SSSE3__)))
- #define CRYPTOPP_BOOL_SSSE3_INTRINSICS_AVAILABLE 1
-#else
- #define CRYPTOPP_BOOL_SSSE3_INTRINSICS_AVAILABLE 0
+#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SSSE3)
+# if defined(__SSSE3__) || (_MSC_VER >= 1500) || (CRYPTOPP_GCC_VERSION >= 40300)
+ #define CRYPTOPP_SSSE3_AVAILABLE 1
+# endif
#endif
// Intrinsics availible in GCC 4.3 (http://gcc.gnu.org/gcc-4.3/changes.html) and
// MSVC 2008 (http://msdn.microsoft.com/en-us/library/bb892950%28v=vs.90%29.aspx)
// SunCC could generate SSE4 at 12.1, but the intrinsics are missing until 12.4.
-#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SSE4) && !defined(_M_ARM) && ((_MSC_VER >= 1500) || (defined(__SSE4_1__) && defined(__SSE4_2__)))
- #define CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE 1
-#else
- #define CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE 0
+#if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
+ (defined(__SSE4_1__) || (CRYPTOPP_MSC_VERSION >= 1500) || \
+ (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || \
+ (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000))
+ #define CRYPTOPP_SSE41_AVAILABLE 1
#endif
-// Don't disgorge AES-NI from CLMUL. There will be two to four subtle breaks
-#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_AESNI) && !defined(_M_ARM) && (_MSC_FULL_VER >= 150030729 || __INTEL_COMPILER >= 1110 || (defined(__AES__) && defined(__PCLMUL__)))
- #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 1
-#else
- #define CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE 0
+#if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
+ (defined(__SSE4_2__) || (CRYPTOPP_MSC_VERSION >= 1500) || \
+ (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || \
+ (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000))
+ #define CRYPTOPP_SSE42_AVAILABLE 1
#endif
-#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SHA) && !defined(_M_ARM) && ((_MSC_VER >= 1900) || defined(__SHA__))
- #define CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE 1
-#else
- #define CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE 0
+#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_CLMUL) && \
+ (defined(__PCLMUL__) || (_MSC_FULL_VER >= 150030729) || \
+ (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1110) || \
+ (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300))
+ #define CRYPTOPP_CLMUL_AVAILABLE 1
+#endif
+
+#if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
+ (defined(__AES__) || (_MSC_FULL_VER >= 150030729) || \
+ (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1110) || \
+ (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300))
+ #define CRYPTOPP_AESNI_AVAILABLE 1
#endif
+#if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_SHA) && \
+ (defined(__SHA__) || (CRYPTOPP_MSC_VERSION >= 1900) || \
+ (CRYPTOPP_GCC_VERSION >= 40900) || (__INTEL_COMPILER >= 1300) || \
+ (CRYPTOPP_LLVM_CLANG_VERSION >= 30400) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50100))
+ #define CRYPTOPP_SHANI_AVAILABLE 1
+#endif
+
+#endif // X86, X32, X64
+
+// ***************** ARM CPU features ********************
+
+#if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
+
// Requires ARMv7 and ACLE 1.0. Testing shows ARMv7 is really ARMv7a under most toolchains.
-#if !defined(CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
-# if defined(__ARM_NEON__) || defined(__ARM_NEON) || defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM)
-# define CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE 1
+#if !defined(CRYPTOPP_ARM_NEON_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
+# if defined(__ARM_NEON__) || defined(__ARM_FEATURE_NEON) || (CRYPTOPP_MSC_VERSION >= 1700) || \
+ (CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30500)
+# define CRYPTOPP_ARM_NEON_AVAILABLE 1
# endif
#endif
@@ -467,21 +546,21 @@ NAMESPACE_END // LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
// 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)
-# if defined(__ARM_FEATURE_CRC32)
-# define CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE 1
+#if !defined(CRYPTOPP_ARM_CRC32_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__apple_build_version__)
+# if defined(__ARM_FEATURE_CRC32) || (CRYPTOPP_MSC_VERSION >= 1910) || \
+ defined(__aarch32__) || defined(__aarch64__)
+# define CRYPTOPP_ARM_CRC32_AVAILABLE 1
# endif
#endif
-// Requires ARMv8, ACLE 2.0 and Aarch64. GCC requires 4.8 and above.
-// LLVM Clang requires 3.5. Apple Clang does not support it at the moment.
+// Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
+// LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
// 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_PMULL_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
-# if defined(__ARM_FEATURE_CRYPTO) && !defined(__apple_build_version__)
-# if defined(__arm64__) || defined(__aarch64__)
-# define CRYPTOPP_BOOL_ARM_PMULL_AVAILABLE 1
-# endif
+#if !defined(CRYPTOPP_ARM_PMULL_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__apple_build_version__)
+# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_MSC_VERSION >= 1910) || \
+ defined(__aarch32__) || defined(__aarch64__)
+# define CRYPTOPP_ARM_PMULL_AVAILABLE 1
# endif
#endif
@@ -489,13 +568,20 @@ NAMESPACE_END // LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
// 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)
-# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_MSC_VERSION >= 1910)
-# define CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE 1
+#if !defined(CRYPTOPP_ARM_CRYPTO_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
+# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_MSC_VERSION >= 1910) || \
+ defined(__aarch32__) || defined(__aarch64__)
+# define CRYPTOPP_ARM_AES_AVAILABLE 1
+# define CRYPTOPP_ARM_SHA_AVAILABLE 1
+# define CRYPTOPP_ARM_CRYPTO_AVAILABLE 1
# endif
#endif
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
+#endif // ARM32, ARM64
+
+// ***************** Miscellaneous ********************
+
+#if CRYPTOPP_SSE2_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || CRYPTOPP_ARM_NEON_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
#define CRYPTOPP_BOOL_ALIGN16 1
#else
#define CRYPTOPP_BOOL_ALIGN16 0
@@ -536,49 +622,6 @@ NAMESPACE_END # define CRYPTOPP_CONSTANT(x) enum {x};
#endif
-// Linux provides X32, which is 32-bit integers, longs and pointers on x86_64 using the full x86_64 register set.
-// Detect via __ILP32__ (http://wiki.debian.org/X32Port). However, __ILP32__ shows up in more places than
-// the System V ABI specs calls out, like on some Solaris installations and just about any 32-bit system with Clang.
-#if (defined(__ILP32__) || defined(_ILP32)) && defined(__x86_64__)
- #define CRYPTOPP_BOOL_X32 1
-#else
- #define CRYPTOPP_BOOL_X32 0
-#endif
-
-// see http://predef.sourceforge.net/prearch.html
-#if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32
- #define CRYPTOPP_BOOL_X86 1
-#else
- #define CRYPTOPP_BOOL_X86 0
-#endif
-
-#if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32
- #define CRYPTOPP_BOOL_X64 1
-#else
- #define CRYPTOPP_BOOL_X64 0
-#endif
-
-// Undo the ASM and Intrinsic related defines due to X32.
-#if CRYPTOPP_BOOL_X32
-# undef CRYPTOPP_BOOL_X64
-# undef CRYPTOPP_X64_ASM_AVAILABLE
-# undef CRYPTOPP_X64_MASM_AVAILABLE
-#endif
-
-#if defined(__arm__) || defined(__aarch32__) || defined(_M_ARM)
- #define CRYPTOPP_BOOL_ARM32 1
-#else
- #define CRYPTOPP_BOOL_ARM32 0
-#endif
-
-// 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(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
- #define CRYPTOPP_BOOL_ARM64 1
-#else
- #define CRYPTOPP_BOOL_ARM64 0
-#endif
-
// ***************** Initialization and Constructor priorities ********************
// CRYPTOPP_INIT_PRIORITY attempts to manage initialization of C++ static objects.
|
