Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:55

0001 // config_asm.h - written and placed in public domain by Jeffrey Walton

0002 //                the bits that make up this source file are from the

0003 //                library's monolithic config.h.

0004 
0005 /// \file config_asm.h

0006 /// \brief Library configuration file

0007 /// \details <tt>config_asm.h</tt> provides defines for instruction set

0008 ///  architectures

0009 ///  and inline assembly.

0010 /// \details <tt>config.h</tt> was split into components in May 2019 to better

0011 ///  integrate with Autoconf and its feature tests. The splitting occurred so

0012 ///  users could continue to include <tt>config.h</tt> while allowing Autoconf

0013 ///  to write new <tt>config_asm.h</tt> and new <tt>config_cxx.h</tt> using

0014 ///  its feature tests.

0015 /// \note You should include <tt>config.h</tt> rather than <tt>config_asm.h</tt>

0016 ///  directly.

0017 /// \sa <A HREF="https://github.com/weidai11/cryptopp/issues/835">Issue 835,

0018 ///  Make config.h more autoconf friendly</A>,

0019 ///  <A HREF="https://www.cryptopp.com/wiki/Configure.sh">Configure.sh script</A>

0020 ///  on the Crypto++ wiki

0021 /// \since Crypto++ 8.3

0022 
0023 #ifndef CRYPTOPP_CONFIG_ASM_H
0024 #define CRYPTOPP_CONFIG_ASM_H
0025 
0026 #include "config_os.h"
0027 #include "config_cpu.h"
0028 #include "config_ver.h"
0029 
0030 // Define this to disable ASM, intrinsics and built-ins. The library will be

0031 // compiled using C++ only. The library code will not include SSE2 (and

0032 // above), NEON, Aarch32, Aarch64, or Altivec (and above). Note the compiler

0033 // may use higher ISAs depending on compiler options, but the library will not

0034 // explicitly use the ISAs. When disabling ASM, it is best to do it from

0035 // config.h to ensure the library and all programs share the setting.

0036 // #define CRYPTOPP_DISABLE_ASM 1

0037 
0038 // https://github.com/weidai11/cryptopp/issues/719

0039 #if defined(__native_client__)
0040 # undef CRYPTOPP_DISABLE_ASM
0041 # define CRYPTOPP_DISABLE_ASM 1
0042 #endif
0043 
0044 // Some Clang and SunCC cannot handle mixed asm with positional arguments,

0045 // where the body is Intel style with no prefix and the templates are

0046 // AT&T style. Define this if the Makefile misdetects the configuration.

0047 // Also see https://bugs.llvm.org/show_bug.cgi?id=39895 .

0048 // #define CRYPTOPP_DISABLE_MIXED_ASM 1

0049 
0050 #if defined(__clang__) || (defined(__APPLE__) && defined(__GNUC__)) || defined(__SUNPRO_CC)
0051 # undef CRYPTOPP_DISABLE_MIXED_ASM
0052 # define CRYPTOPP_DISABLE_MIXED_ASM 1
0053 #endif
0054 
0055 // Define this if you need to disable Android advanced ISAs.

0056 // The problem is, Android-mk does not allow us to specify an

0057 // ISA option, like -maes or -march=armv8-a+crypto for AES.

0058 // Lack of an option results in a compile failure. To avoid

0059 // the compile failure, set this define. Also see

0060 // https://github.com/weidai11/cryptopp/issues/1015

0061 // CRYPTOPP_DISABLE_ANDROID_ADVANCED_ISA 1

0062 
0063 // ***************** IA32 CPU features ********************

0064 
0065 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
0066 
0067 // Apple Clang prior to 5.0 cannot handle SSE2

0068 #if defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION < 50000)
0069 # define CRYPTOPP_DISABLE_ASM 1
0070 #endif
0071 
0072 // Sun Studio 12.1 provides GCC inline assembly

0073 // http://blogs.oracle.com/x86be/entry/gcc_style_asm_inlining_support

0074 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5100)
0075 # define CRYPTOPP_DISABLE_ASM 1
0076 #endif
0077 
0078 // Guard everything in CRYPTOPP_DISABLE_ASM

0079 #if !defined(CRYPTOPP_DISABLE_ASM)
0080 
0081 #if (defined(_MSC_VER) && defined(_M_IX86)) || ((defined(__GNUC__) && (defined(__i386__)) || defined(__x86_64__)))
0082     // C++Builder 2010 does not allow "call label" where label is defined within inline assembly

0083     #define CRYPTOPP_X86_ASM_AVAILABLE 1
0084 
0085     #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(_MSC_VER) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__))
0086         #define CRYPTOPP_SSE2_ASM_AVAILABLE 1
0087     #endif
0088 
0089     #if !defined(CRYPTOPP_DISABLE_SSSE3) && (_MSC_VER >= 1500 || CRYPTOPP_GCC_VERSION >= 40300 || defined(__SSSE3__))
0090         #define CRYPTOPP_SSSE3_ASM_AVAILABLE 1
0091     #endif
0092 #endif
0093 
0094 #if defined(_MSC_VER) && defined(_M_X64)
0095     #define CRYPTOPP_X64_MASM_AVAILABLE 1
0096 #endif
0097 
0098 #if defined(__GNUC__) && defined(__x86_64__)
0099     #define CRYPTOPP_X64_ASM_AVAILABLE 1
0100 #endif
0101 
0102 // 32-bit SunCC does not enable SSE2 by default.

0103 #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSC_VERSION) || CRYPTOPP_GCC_VERSION >= 30300 || defined(__SSE2__) || (__SUNPRO_CC >= 0x5100))
0104     #define CRYPTOPP_SSE2_INTRIN_AVAILABLE 1
0105 #endif
0106 
0107 #if !defined(CRYPTOPP_DISABLE_SSSE3)
0108 # if defined(__SSSE3__) || (CRYPTOPP_MSC_VERSION >= 1500) || \
0109     (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || (__SUNPRO_CC >= 0x5110) || \
0110     (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000)
0111     #define CRYPTOPP_SSSE3_AVAILABLE 1
0112 # endif
0113 #endif
0114 
0115 // Intrinsics available in GCC 4.3 (http://gcc.gnu.org/gcc-4.3/changes.html) and

0116 // MSVC 2008 (http://msdn.microsoft.com/en-us/library/bb892950%28v=vs.90%29.aspx)

0117 // SunCC could generate SSE4 at 12.1, but the intrinsics are missing until 12.4.

0118 #if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
0119     (defined(__SSE4_1__) || (CRYPTOPP_MSC_VERSION >= 1500) || \
0120     (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || (__SUNPRO_CC >= 0x5110) || \
0121     (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000))
0122     #define CRYPTOPP_SSE41_AVAILABLE 1
0123 #endif
0124 
0125 #if !defined(CRYPTOPP_DISABLE_SSE4) && defined(CRYPTOPP_SSSE3_AVAILABLE) && \
0126     (defined(__SSE4_2__) || (CRYPTOPP_MSC_VERSION >= 1500) || (__SUNPRO_CC >= 0x5110) || \
0127     (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1000) || \
0128     (CRYPTOPP_LLVM_CLANG_VERSION >= 20300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000))
0129     #define CRYPTOPP_SSE42_AVAILABLE 1
0130 #endif
0131 
0132 // Couple to CRYPTOPP_DISABLE_AESNI, but use CRYPTOPP_CLMUL_AVAILABLE so we can selectively

0133 //  disable for misbehaving platforms and compilers, like Solaris or some Clang.

0134 #if defined(CRYPTOPP_DISABLE_AESNI)
0135     #define CRYPTOPP_DISABLE_CLMUL 1
0136 #endif
0137 
0138 // Requires Sun Studio 12.3 (SunCC 0x5120) in theory.

0139 #if !defined(CRYPTOPP_DISABLE_CLMUL) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
0140     (defined(__PCLMUL__) || (_MSC_FULL_VER >= 150030729) || (__SUNPRO_CC >= 0x5120) || \
0141     (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1110) || \
0142     (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300))
0143     #define CRYPTOPP_CLMUL_AVAILABLE 1
0144 #endif
0145 
0146 // Requires Sun Studio 12.3 (SunCC 0x5120)

0147 #if !defined(CRYPTOPP_DISABLE_AESNI) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
0148     (defined(__AES__) || (_MSC_FULL_VER >= 150030729) || (__SUNPRO_CC >= 0x5120) || \
0149     (CRYPTOPP_GCC_VERSION >= 40300) || (__INTEL_COMPILER >= 1110) || \
0150     (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300))
0151     #define CRYPTOPP_AESNI_AVAILABLE 1
0152 #endif
0153 
0154 // Requires Binutils 2.24

0155 #if !defined(CRYPTOPP_DISABLE_AVX) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
0156     (defined(__AVX2__) || (CRYPTOPP_MSC_VERSION >= 1800) || (__SUNPRO_CC >= 0x5130) || \
0157     (CRYPTOPP_GCC_VERSION >= 40700) || (__INTEL_COMPILER >= 1400) || \
0158     (CRYPTOPP_LLVM_CLANG_VERSION >= 30100) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40600))
0159 #define CRYPTOPP_AVX_AVAILABLE 1
0160 #endif
0161 
0162 // Requires Binutils 2.24

0163 #if !defined(CRYPTOPP_DISABLE_AVX2) && defined(CRYPTOPP_AVX_AVAILABLE) && \
0164     (defined(__AVX2__) || (CRYPTOPP_MSC_VERSION >= 1800) || (__SUNPRO_CC >= 0x5130) || \
0165     (CRYPTOPP_GCC_VERSION >= 40900) || (__INTEL_COMPILER >= 1400) || \
0166     (CRYPTOPP_LLVM_CLANG_VERSION >= 30100) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40600))
0167 #define CRYPTOPP_AVX2_AVAILABLE 1
0168 #endif
0169 
0170 // Guessing at SHA for SunCC. Its not in Sun Studio 12.6. Also see

0171 // http://stackoverflow.com/questions/45872180/which-xarch-for-sha-extensions-on-solaris

0172 // Guessing for Intel ICPC. A slide deck says SHA support is in version 16.0-beta

0173 // https://www.alcf.anl.gov/files/ken_intel_compiler_optimization.pdf

0174 #if !defined(CRYPTOPP_DISABLE_SHANI) && defined(CRYPTOPP_SSE42_AVAILABLE) && \
0175     (defined(__SHA__) || (CRYPTOPP_MSC_VERSION >= 1900) || (__SUNPRO_CC >= 0x5160) || \
0176     (CRYPTOPP_GCC_VERSION >= 40900) || (__INTEL_COMPILER >= 1600) || \
0177     (CRYPTOPP_LLVM_CLANG_VERSION >= 30400) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50100))
0178     #define CRYPTOPP_SHANI_AVAILABLE 1
0179 #endif
0180 
0181 // RDRAND uses byte codes. All we need is x86 ASM for it.

0182 // However tie it to AES-NI since SecureKey was available with it.

0183 #if !defined(CRYPTOPP_DISABLE_RDRAND) && defined(CRYPTOPP_AESNI_AVAILABLE)
0184     #define CRYPTOPP_RDRAND_AVAILABLE 1
0185 #endif
0186 
0187 // RDSEED uses byte codes. All we need is x86 ASM for it.

0188 // However tie it to AES-NI since SecureKey was available with it.

0189 #if !defined(CRYPTOPP_DISABLE_RDSEED) && defined(CRYPTOPP_AESNI_AVAILABLE)
0190     #define CRYPTOPP_RDSEED_AVAILABLE 1
0191 #endif
0192 
0193 // PadlockRNG uses byte codes. All we need is x86 ASM for it.

0194 #if !defined(CRYPTOPP_DISABLE_PADLOCK) && \
0195     !(defined(__ANDROID__) || defined(ANDROID) || defined(__APPLE__)) && \
0196     defined(CRYPTOPP_X86_ASM_AVAILABLE)
0197     #define CRYPTOPP_PADLOCK_AVAILABLE 1
0198     #define CRYPTOPP_PADLOCK_RNG_AVAILABLE 1
0199     #define CRYPTOPP_PADLOCK_ACE_AVAILABLE 1
0200     #define CRYPTOPP_PADLOCK_ACE2_AVAILABLE 1
0201     #define CRYPTOPP_PADLOCK_PHE_AVAILABLE 1
0202     #define CRYPTOPP_PADLOCK_PMM_AVAILABLE 1
0203 #endif
0204 
0205 // Fixup for SunCC 12.1-12.4. Bad code generation in AES_Encrypt and friends.

0206 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5130)
0207 # undef CRYPTOPP_AESNI_AVAILABLE
0208 #endif
0209 
0210 // Fixup for SunCC 12.1-12.6. Compiler crash on GCM_Reduce_CLMUL.

0211 // http://github.com/weidai11/cryptopp/issues/226

0212 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5150)
0213 # undef CRYPTOPP_CLMUL_AVAILABLE
0214 #endif
0215 
0216 // Clang intrinsic casts, http://bugs.llvm.org/show_bug.cgi?id=20670

0217 #define M128_CAST(x) ((__m128i *)(void *)(x))
0218 #define CONST_M128_CAST(x) ((const __m128i *)(const void *)(x))
0219 #define M256_CAST(x) ((__m256i *)(void *)(x))
0220 #define CONST_M256_CAST(x) ((const __m256i *)(const void *)(x))
0221 
0222 #endif  // CRYPTOPP_DISABLE_ASM

0223 
0224 #endif  // X86, X32, X64

0225 
0226 // ***************** ARM CPU features ********************

0227 
0228 #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8)
0229 
0230 // We don't have an ARM big endian test rig. Disable

0231 // ARM-BE ASM and instrinsics until we can test it.

0232 #if (CRYPTOPP_BIG_ENDIAN)
0233 # define CRYPTOPP_DISABLE_ASM 1
0234 #endif
0235 
0236 // Guard everything in CRYPTOPP_DISABLE_ASM

0237 #if !defined(CRYPTOPP_DISABLE_ASM)
0238 
0239 // Requires ACLE 1.0. -mfpu=neon or above must be present

0240 // Requires GCC 4.3, Clang 2.8 or Visual Studio 2012

0241 // Do not use APPLE_CLANG_VERSION; use __ARM_FEATURE_XXX instead.

0242 #if !defined(CRYPTOPP_ARM_NEON_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_NEON)
0243 # if defined(__arm__) || defined(__ARM_NEON) || defined(__ARM_FEATURE_NEON) || defined(_M_ARM)
0244 #  if (CRYPTOPP_GCC_VERSION >= 40300) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) || \
0245       (CRYPTOPP_APPLE_CLANG_VERSION >= 30200) || (CRYPTOPP_MSC_VERSION >= 1700)
0246 #   define CRYPTOPP_ARM_NEON_AVAILABLE 1
0247 #  endif  // Compilers

0248 # endif  // Platforms

0249 #endif
0250 
0251 // ARMv8 and ASIMD. -march=armv8-a or above must be present

0252 // Requires GCC 4.8, Clang 3.3 or Visual Studio 2017

0253 // Do not use APPLE_CLANG_VERSION; use __ARM_FEATURE_XXX instead.

0254 #if !defined(CRYPTOPP_ARM_ASIMD_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_ASIMD)
0255 # if defined(__aarch32__) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
0256 #  if defined(__ARM_NEON) || defined(__ARM_ASIMD) || defined(__ARM_FEATURE_NEON) || defined(__ARM_FEATURE_ASIMD) || \
0257       (CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || \
0258       (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || (CRYPTOPP_MSC_VERSION >= 1916)
0259 #   define CRYPTOPP_ARM_NEON_AVAILABLE 1
0260 #   define CRYPTOPP_ARM_ASIMD_AVAILABLE 1
0261 #  endif  // Compilers

0262 # endif  // Platforms

0263 #endif
0264 
0265 // ARMv8 and ASIMD. -march=armv8-a+crc or above must be present

0266 // Requires GCC 4.8, Clang 3.3 or Visual Studio 2017

0267 #if !defined(CRYPTOPP_ARM_CRC32_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_CRC32)
0268 # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
0269 #  if defined(__ARM_FEATURE_CRC32) || (CRYPTOPP_GCC_VERSION >= 40800) || \
0270       (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
0271       (CRYPTOPP_MSC_VERSION >= 1916)
0272 #   define CRYPTOPP_ARM_CRC32_AVAILABLE 1
0273 #  endif  // Compilers

0274 # endif  // Platforms

0275 #endif
0276 
0277 // ARMv8 and AES. -march=armv8-a+crypto or above must be present

0278 // Requires GCC 4.8, Clang 3.3 or Visual Studio 2017

0279 #if !defined(CRYPTOPP_ARM_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_AES)
0280 # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
0281 #  if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
0282       (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
0283       (CRYPTOPP_MSC_VERSION >= 1916)
0284 #   define CRYPTOPP_ARM_AES_AVAILABLE 1
0285 #  endif  // Compilers

0286 # endif  // Platforms

0287 #endif
0288 
0289 // ARMv8 and PMULL. -march=armv8-a+crypto or above must be present

0290 // Requires GCC 4.8, Clang 3.3 or Visual Studio 2017

0291 #if !defined(CRYPTOPP_ARM_PMULL_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_PMULL)
0292 # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
0293 #  if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
0294       (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
0295       (CRYPTOPP_MSC_VERSION >= 1916)
0296 #   define CRYPTOPP_ARM_PMULL_AVAILABLE 1
0297 #  endif  // Compilers

0298 # endif  // Platforms

0299 #endif
0300 
0301 // ARMv8 and SHA-1, SHA-256. -march=armv8-a+crypto or above must be present

0302 // Requires GCC 4.8, Clang 3.3 or Visual Studio 2017

0303 #if !defined(CRYPTOPP_ARM_SHA_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SHA)
0304 # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
0305 #  if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
0306       (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
0307       (CRYPTOPP_MSC_VERSION >= 1916)
0308 #   define CRYPTOPP_ARM_SHA1_AVAILABLE 1
0309 #   define CRYPTOPP_ARM_SHA2_AVAILABLE 1
0310 #  endif  // Compilers

0311 # endif  // Platforms

0312 #endif
0313 
0314 // Buggy Microsoft compiler, https://github.com/weidai11/cryptopp/issues/1096

0315 #if defined(CRYPTOPP_MSC_VERSION)
0316 # undef CRYPTOPP_ARM_SHA1_AVAILABLE
0317 # undef CRYPTOPP_ARM_SHA2_AVAILABLE
0318 #endif
0319 
0320 // ARMv8 and SHA-512, SHA-3. -march=armv8.2-a+crypto or above must be present

0321 // Requires GCC 8.0, Clang 11.0, Apple Clang 12.0 or Visual Studio 20??

0322 #if !defined(CRYPTOPP_ARM_SHA3_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SHA)
0323 # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
0324 #  if defined(__ARM_FEATURE_SHA3) || (CRYPTOPP_GCC_VERSION >= 80000) || \
0325       (CRYPTOPP_APPLE_CLANG_VERSION >= 120000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 110000)
0326 #   define CRYPTOPP_ARM_SHA512_AVAILABLE 1
0327 #   define CRYPTOPP_ARM_SHA3_AVAILABLE 1
0328 #  endif  // Compilers

0329 # endif  // Platforms

0330 #endif
0331 
0332 // ARMv8 and SM3, SM4. -march=armv8.2-a+crypto or above must be present

0333 // Requires GCC 8.0, Clang ??? or Visual Studio 20??

0334 // Do not use APPLE_CLANG_VERSION; use __ARM_FEATURE_XXX instead.

0335 #if !defined(CRYPTOPP_ARM_SM3_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SM3)
0336 # if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
0337 #  if defined(__ARM_FEATURE_SM3) || (CRYPTOPP_GCC_VERSION >= 80000)
0338 #   define CRYPTOPP_ARM_SM3_AVAILABLE 1
0339 #   define CRYPTOPP_ARM_SM4_AVAILABLE 1
0340 #  endif  // Compilers

0341 # endif  // Platforms

0342 #endif
0343 
0344 // Limit the <arm_neon.h> include.

0345 #if !defined(CRYPTOPP_ARM_NEON_HEADER)
0346 # if defined(CRYPTOPP_ARM_NEON_AVAILABLE) || defined (CRYPTOPP_ARM_ASIMD_AVAILABLE)
0347 #  if !defined(_M_ARM64)
0348 #   define CRYPTOPP_ARM_NEON_HEADER 1
0349 #  endif
0350 # endif
0351 #endif
0352 
0353 // Limit the <arm_acle.h> include.

0354 #if !defined(CRYPTOPP_ARM_ACLE_HEADER)
0355 # if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
0356 #  define CRYPTOPP_ARM_ACLE_HEADER 1
0357 # endif
0358 #endif
0359 
0360 // Apple M1 hack. Xcode cross-compiles for iOS lack

0361 // arm_acle.h. Apple M1 needs arm_acle.h. The problem

0362 // in practice is, we can't get CRYPTOPP_ARM_ACLE_HEADER

0363 // quite right based on ARM preprocessor macros.

0364 #if defined(__APPLE__) && !defined(__ARM_FEATURE_CRC32)
0365 # undef CRYPTOPP_ARM_ACLE_HEADER
0366 #endif
0367 
0368 // Cryptogams offers an ARM asm implementations for AES and SHA. Crypto++ does

0369 // not provide an asm implementation. The Cryptogams AES implementation is

0370 // about 50% faster than C/C++, and SHA implementation is about 30% faster

0371 // than C/C++. Define this to use the Cryptogams AES and SHA implementations

0372 // on GNU Linux systems. When defined, Crypto++ will use aes_armv4.S,

0373 // sha1_armv4.S and sha256_armv4.S. https://www.cryptopp.com/wiki/Cryptogams.

0374 #if !defined(CRYPTOPP_DISABLE_ARM_NEON)
0375 # if defined(__arm__) && defined(__linux__)
0376 #  if defined(__GNUC__) || defined(__clang__)
0377 #   define CRYPTOGAMS_ARM_AES      1
0378 #   define CRYPTOGAMS_ARM_SHA1     1
0379 #   define CRYPTOGAMS_ARM_SHA256   1
0380 #   define CRYPTOGAMS_ARM_SHA512   1
0381 #  endif
0382 # endif
0383 #endif
0384 
0385 // We are still having trouble with integrating Cryptogams AES. Ugh...

0386 // https://github.com/weidai11/cryptopp/issues/1236

0387 #undef CRYPTOGAMS_ARM_AES
0388 
0389 // Clang intrinsic casts, http://bugs.llvm.org/show_bug.cgi?id=20670

0390 #define UINT64_CAST(x) ((uint64_t *)(void *)(x))
0391 #define CONST_UINT64_CAST(x) ((const uint64_t *)(const void *)(x))
0392 
0393 #endif  // CRYPTOPP_DISABLE_ASM

0394 
0395 #endif  // ARM32, ARM64

0396 
0397 // ***************** AltiVec and Power8 ********************

0398 
0399 #if (CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64)
0400 
0401 // Guard everything in CRYPTOPP_DISABLE_ASM

0402 #if !defined(CRYPTOPP_DISABLE_ASM) && !defined(CRYPTOPP_DISABLE_ALTIVEC)
0403 
0404 // An old Apple G5 with GCC 4.01 has AltiVec, but its only Power4 or so.

0405 #if !defined(CRYPTOPP_ALTIVEC_AVAILABLE)
0406 # if defined(_ARCH_PWR4) || defined(__ALTIVEC__) || \
0407     (CRYPTOPP_XLC_VERSION >= 100000) || (CRYPTOPP_GCC_VERSION >= 40001) || \
0408     (CRYPTOPP_LLVM_CLANG_VERSION >= 20900)
0409 #  define CRYPTOPP_ALTIVEC_AVAILABLE 1
0410 # endif
0411 #endif
0412 
0413 #if defined(CRYPTOPP_ALTIVEC_AVAILABLE)
0414 
0415 // We need Power7 for unaligned loads and stores

0416 #if !defined(CRYPTOPP_POWER7_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER7)
0417 # if defined(_ARCH_PWR7) || (CRYPTOPP_XLC_VERSION >= 100000) || \
0418     (CRYPTOPP_GCC_VERSION >= 40100) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30100)
0419 #  define CRYPTOPP_POWER7_AVAILABLE 1
0420 # endif
0421 #endif
0422 
0423 #if defined(CRYPTOPP_POWER7_AVAILABLE)
0424 
0425 // We need Power8 for in-core crypto and 64-bit vector types

0426 #if !defined(CRYPTOPP_POWER8_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER8)
0427 # if defined(_ARCH_PWR8) || (CRYPTOPP_XLC_VERSION >= 130000) || \
0428     (CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 70000)
0429 #  define CRYPTOPP_POWER8_AVAILABLE 1
0430 # endif
0431 #endif
0432 
0433 #if !defined(CRYPTOPP_POWER8_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER8_AES) && defined(CRYPTOPP_POWER8_AVAILABLE)
0434 # if defined(__CRYPTO__) || defined(_ARCH_PWR8) || (CRYPTOPP_XLC_VERSION >= 130000) || \
0435     (CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 70000)
0436 //#  define CRYPTOPP_POWER8_CRC_AVAILABLE 1

0437 #  define CRYPTOPP_POWER8_AES_AVAILABLE 1
0438 #  define CRYPTOPP_POWER8_VMULL_AVAILABLE 1
0439 #  define CRYPTOPP_POWER8_SHA_AVAILABLE 1
0440 # endif
0441 #endif
0442 
0443 #if defined(CRYPTOPP_POWER8_AVAILABLE)
0444 
0445 // Power9 for random numbers

0446 #if !defined(CRYPTOPP_POWER9_AVAILABLE) && !defined(CRYPTOPP_DISABLE_POWER9)
0447 # if defined(_ARCH_PWR9) || (CRYPTOPP_XLC_VERSION >= 130200) || \
0448     (CRYPTOPP_GCC_VERSION >= 70000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 80000)
0449 #  define CRYPTOPP_POWER9_AVAILABLE 1
0450 # endif
0451 #endif
0452 
0453 #endif  // CRYPTOPP_POWER8_AVAILABLE

0454 #endif  // CRYPTOPP_POWER7_AVAILABLE

0455 #endif  // CRYPTOPP_ALTIVEC_AVAILABLE

0456 #endif  // CRYPTOPP_DISABLE_ASM

0457 #endif  // PPC32, PPC64

0458 
0459 // https://github.com/weidai11/cryptopp/issues/1015

0460 #if defined(CRYPTOPP_DISABLE_ANDROID_ADVANCED_ISA)
0461 # if defined(__ANDROID__) || defined(ANDROID)
0462 #  if (CRYPTOPP_BOOL_X86)
0463 #   undef CRYPTOPP_SSE41_AVAILABLE
0464 #   undef CRYPTOPP_SSE42_AVAILABLE
0465 #   undef CRYPTOPP_CLMUL_AVAILABLE
0466 #   undef CRYPTOPP_AESNI_AVAILABLE
0467 #   undef CRYPTOPP_SHANI_AVAILABLE
0468 #   undef CRYPTOPP_RDRAND_AVAILABLE
0469 #   undef CRYPTOPP_RDSEED_AVAILABLE
0470 #   undef CRYPTOPP_AVX_AVAILABLE
0471 #   undef CRYPTOPP_AVX2_AVAILABLE
0472 #  endif
0473 #  if (CRYPTOPP_BOOL_X64)
0474 #   undef CRYPTOPP_CLMUL_AVAILABLE
0475 #   undef CRYPTOPP_AESNI_AVAILABLE
0476 #   undef CRYPTOPP_SHANI_AVAILABLE
0477 #   undef CRYPTOPP_RDRAND_AVAILABLE
0478 #   undef CRYPTOPP_RDSEED_AVAILABLE
0479 #   undef CRYPTOPP_AVX_AVAILABLE
0480 #   undef CRYPTOPP_AVX2_AVAILABLE
0481 #  endif
0482 #  if (CRYPTOPP_BOOL_ARMV8)
0483 #   undef CRYPTOPP_ARM_CRC32_AVAILABLE
0484 #   undef CRYPTOPP_ARM_PMULL_AVAILABLE
0485 #   undef CRYPTOPP_ARM_AES_AVAILABLE
0486 #   undef CRYPTOPP_ARM_SHA1_AVAILABLE
0487 #   undef CRYPTOPP_ARM_SHA2_AVAILABLE
0488 #  endif
0489 # endif  // ANDROID

0490 #endif   // CRYPTOPP_DISABLE_ANDROID_ADVANCED_ISA

0491 
0492 #endif  // CRYPTOPP_CONFIG_ASM_H