From c4f9a7cfceabd64f829ebcc335be44be01634e79 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 13 Jul 2016 01:45:09 -0400 Subject: [PATCH 1/2] Fix compile under iOS --- blake2.cpp | 8 +------- crc.cpp | 5 ----- rdrand.cpp | 16 +++++++++------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/blake2.cpp b/blake2.cpp index 2cc68ef2..1fa6ef44 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -40,12 +40,6 @@ NAMESPACE_BEGIN(CryptoPP) # undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE #endif -#if defined(CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE) && ((__SUNPRO_CC >= 0x5130) || defined(__clang__)) -# include // _mm_set_epi64x -# include // _mm_blend_epi16 -# include // _mm_shuffle_epi16 -#endif - // C/C++ implementation static void BLAKE2_CXX_Compress32(const byte* input, BLAKE2_State& state); static void BLAKE2_CXX_Compress64(const byte* input, BLAKE2_State& state); @@ -3994,7 +3988,7 @@ static void BLAKE2_NEON_Compress64(const byte* input, BLAKE2_State uint64x2_t row1l, row1h, row2l, row2h; uint64x2_t row3l, row3h, row4l, row4h; - uint64x2_t b0, b1, t0, t1; + uint64x2_t b0 = {0,0}, b1 = {0,0}, t0, t1; row1l = vld1q_u64((const uint64_t *)&state.h[0]); row1h = vld1q_u64((const uint64_t *)&state.h[2]); diff --git a/crc.cpp b/crc.cpp index f3383f2f..738d1238 100644 --- a/crc.cpp +++ b/crc.cpp @@ -13,11 +13,6 @@ NAMESPACE_BEGIN(CryptoPP) # undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE #endif -// SunCC 12.4 and above -#if defined(CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE) && ((__SUNPRO_CC >= 0x5130) || defined(__clang__)) -# include -#endif - /* Table of CRC-32's of all single byte values (made by makecrc.c) */ const word32 CRC32::m_tab[] = { #ifdef IS_LITTLE_ENDIAN diff --git a/rdrand.cpp b/rdrand.cpp index b67f30bb..637f5cab 100644 --- a/rdrand.cpp +++ b/rdrand.cpp @@ -45,22 +45,23 @@ ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// +// In general, the library's ASM code is best on Windows, and Intrinsics is +// the best code under GCC. Clang is missing symbols, so it gets ASM. +// The NASM code is optimized well on Linux, but its not easy to cut-in. #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) # ifndef CRYPTOPP_CPUID_AVAILABLE # define CRYPTOPP_CPUID_AVAILABLE # endif #endif -// In general, the library's ASM code is best on Windows, and Intrinsics is -// the best code under GCC. Clang is missing symbols, so it gets ASM. -// The NASM code is optimized well on Linux, but its not easy to cut-in. -#if defined(CRYPTOPP_MSC_VERSION) +#if defined(CRYPTOPP_CPUID_AVAILABLE) +# if defined(CRYPTOPP_MSC_VERSION) # define MASM_RDRAND_ASM_AVAILABLE 1 # define MASM_RDSEED_ASM_AVAILABLE 1 -#elif defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) +# elif defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) # define GCC_RDRAND_ASM_AVAILABLE 1 # define GCC_RDSEED_ASM_AVAILABLE 1 -#elif defined(__SUNPRO_CC) +# elif defined(__SUNPRO_CC) # if defined(__RDRND__) && (__SUNPRO_CC >= 0x5130) # define ALL_RDRAND_INTRIN_AVAILABLE 1 # elif (__SUNPRO_CC >= 0x5100) @@ -71,7 +72,7 @@ # elif (__SUNPRO_CC >= 0x5100) # define GCC_RDSEED_ASM_AVAILABLE 1 # endif -#elif defined(CRYPTOPP_GCC_VERSION) +# elif defined(CRYPTOPP_GCC_VERSION) # if defined(__RDRND__) && (CRYPTOPP_GCC_VERSION >= 30200) # define ALL_RDRAND_INTRIN_AVAILABLE 1 # else @@ -82,6 +83,7 @@ # else # define GCC_RDSEED_ASM_AVAILABLE 1 # endif +# endif #endif // Debug diagnostics From 77b36f5a0a0451b6ee71b49abaf4b922d0efc1d4 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 13 Jul 2016 02:13:18 -0400 Subject: [PATCH 2/2] Add AVX and AVX2 for Sun Studio --- cpu.h | 7 +++++++ cryptest.sh | 2 ++ 2 files changed, 9 insertions(+) diff --git a/cpu.h b/cpu.h index b1414a91..2949fa6f 100644 --- a/cpu.h +++ b/cpu.h @@ -137,6 +137,13 @@ NAMESPACE_END #endif // wmmintrin.h #endif // CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE +#if (CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE) && ((__SUNPRO_CC >= 0x5110) || defined(__clang__) || defined(__INTEL_COMPILER)) +# include // _mm_set_epi64x +# include // _mm_blend_epi16 +# include // _mm_shuffle_epi16 +# include // _mm_crc32_u{8|16|32} +#endif + NAMESPACE_BEGIN(CryptoPP) #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_DOXYGEN_PROCESSING diff --git a/cryptest.sh b/cryptest.sh index 6958b754..f0ce0897 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -841,6 +841,8 @@ if [[ ("$IS_SOLARIS" -ne "0") && ("$SUNCC_121_OR_ABOVE" -ne "0") ]]; then if [[ ($(echo "$ISAINFO" | "$GREP" -c "pclmulqdq") -ne "0") ]]; then PLATFORM_CXXFLAGS+="-D__PCLMUL__ "; fi if [[ ($(echo "$ISAINFO" | "$GREP" -c "rdrand") -ne "0") ]]; then PLATFORM_CXXFLAGS+="-D__RDRND__ "; fi if [[ ($(echo "$ISAINFO" | "$GREP" -c "rdseed") -ne "0") ]]; then PLATFORM_CXXFLAGS+="-D__RDSEED__ "; fi + if [[ ($(echo "$ISAINFO" | "$GREP" -c "avx") -ne "0") ]]; then PLATFORM_CXXFLAGS+="-D__AVX__ "; fi + if [[ ($(echo "$ISAINFO" | "$GREP" -c "avx2") -ne "0") ]]; then PLATFORM_CXXFLAGS+="-D__AVX2__ "; fi if [[ ($(echo "$ISAINFO" | "$GREP" -c "bmi") -ne "0") ]]; then PLATFORM_CXXFLAGS+="-D__BMI__ "; fi if [[ ($(echo "$ISAINFO" | "$GREP" -c "bmi2") -ne "0") ]]; then PLATFORM_CXXFLAGS+="-D__BMI2__ "; fi fi