Merge branch 'master' into hmqv

pull/263/head
Jeffrey Walton 2016-08-02 09:30:23 -04:00
commit 0338347929
5 changed files with 88 additions and 71 deletions

View File

@ -492,7 +492,7 @@ NAMESPACE_END
# endif # endif
#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. // 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 // 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(CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
@ -501,7 +501,7 @@ NAMESPACE_END
# endif # endif
#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. // 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 // 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(CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)

View File

@ -492,7 +492,7 @@ NAMESPACE_END
# endif # endif
#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. // 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 // 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(CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
@ -501,7 +501,7 @@ NAMESPACE_END
# endif # endif
#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. // 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 // 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(CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)

10
cpu.cpp
View File

@ -101,9 +101,11 @@ bool CpuId(word32 input, word32 output[4])
if (oldHandler == SIG_ERR) if (oldHandler == SIG_ERR)
return false; return false;
# ifndef __MINGW32__
volatile sigset_t oldMask; volatile sigset_t oldMask;
if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) if (sigprocmask(0, NULL, (sigset_t*)&oldMask))
return false; return false;
# endif
if (setjmp(s_jmpNoCPUID)) if (setjmp(s_jmpNoCPUID))
result = false; result = false;
@ -123,7 +125,10 @@ bool CpuId(word32 input, word32 output[4])
); );
} }
# ifndef __MINGW32__
sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL);
# endif
signal(SIGILL, oldHandler); signal(SIGILL, oldHandler);
return result; return result;
#endif #endif
@ -160,9 +165,11 @@ static bool TrySSE2()
if (oldHandler == SIG_ERR) if (oldHandler == SIG_ERR)
return false; return false;
# ifndef __MINGW32__
volatile sigset_t oldMask; volatile sigset_t oldMask;
if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) if (sigprocmask(0, NULL, (sigset_t*)&oldMask))
return false; return false;
# endif
if (setjmp(s_jmpNoSSE2)) if (setjmp(s_jmpNoSSE2))
result = false; result = false;
@ -176,7 +183,10 @@ static bool TrySSE2()
#endif #endif
} }
# ifndef __MINGW32__
sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL);
# endif
signal(SIGILL, oldHandler); signal(SIGILL, oldHandler);
return result; return result;
#endif #endif

64
cpu.h
View File

@ -10,22 +10,47 @@
#include "config.h" #include "config.h"
#if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64) #if (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
# if defined(_MSC_VER) || defined(__BORLANDC__) # if __GNUC__
# define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY # include <stdint.h>
# else
# define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
# endif # endif
# if CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE # if CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE
# include <arm_neon.h> # include <arm_neon.h>
# endif # endif
# if (CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) # if (CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE)
# include <stdint.h> # if (defined(__ARM_ACLE))
# if (defined(__ARM_ACLE) || defined(__GNUC__)) && !defined(__APPLE__)
# include <arm_acle.h> # include <arm_acle.h>
# endif # endif
# endif # endif
#endif // ARM-32 or ARM-64 #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 #ifdef CRYPTOPP_GENERATE_X64_MASM
#define CRYPTOPP_X86_ASM_AVAILABLE #define CRYPTOPP_X86_ASM_AVAILABLE
@ -39,12 +64,6 @@
# include <emmintrin.h> # include <emmintrin.h>
# endif # 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 #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. // 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 #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 NAMESPACE_END
#endif // CRYPTOPP_CPU_H #endif // CRYPTOPP_CPU_H

View File

@ -331,56 +331,65 @@ else
fi fi
fi fi
HAVE_O3=0 if [[ (-z "$HAVE_O3") ]]; then
OPT_O3= HAVE_O3=0
rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 OPT_O3=
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O3=1
OPT_O3=-O3
else
rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 rm -f "$TMP/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 "$CXX" -DCRYPTOPP_ADHOC_MAIN -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then if [[ ("$?" -eq "0") ]]; then
HAVE_O3=1 HAVE_O3=1
OPT_O3=-xO3 OPT_O3=-O3
else
rm -f "$TMP/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O3=1
OPT_O3=-xO3
fi
fi fi
fi fi
# Hit or miss, mostly hit # Hit or miss, mostly hit
HAVE_O5=0 if [[ (-z "$HAVE_O5") ]]; then
OPT_O5= HAVE_O5=0
rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 OPT_O5=
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O5 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O5=1
OPT_O5=-O5
else
rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 rm -f "$TMP/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO5 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 "$CXX" -DCRYPTOPP_ADHOC_MAIN -O5 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then if [[ ("$?" -eq "0") ]]; then
HAVE_O5=1 HAVE_O5=1
OPT_O5=-xO5 OPT_O5=-O5
else
rm -f "$TMP/adhoc.exe" > /dev/null 2>&1
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO5 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then
HAVE_O5=1
OPT_O5=-xO5
fi
fi fi
fi fi
# Hit or miss, mostly hit # Hit or miss, mostly hit
HAVE_OS=0 if [[ (-z "$HAVE_OS") ]]; then
OPT_OS= HAVE_OS=0
rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 OPT_OS=
"$CXX" -DCRYPTOPP_ADHOC_MAIN -Os adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 rm -f "$TMP/adhoc.exe" > /dev/null 2>&1
if [[ ("$?" -eq "0") ]]; then "$CXX" -DCRYPTOPP_ADHOC_MAIN -Os adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
HAVE_OS=1 if [[ ("$?" -eq "0") ]]; then
OPT_OS=-Os HAVE_OS=1
HAVE_OS=-Os
fi
fi fi
HAVE_OFAST=0 # Hit or miss, mostly hit
OPT_OFAST= if [[ (-z "$HAVE_OFAST") ]]; then
rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 HAVE_OFAST=0
"$CXX" -DCRYPTOPP_ADHOC_MAIN -Ofast adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 OPT_OFAST=
if [[ ("$?" -eq "0") ]]; then rm -f "$TMP/adhoc.exe" > /dev/null 2>&1
HAVE_OFAST=1 "$CXX" -DCRYPTOPP_ADHOC_MAIN -Ofast adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1
OPT_OFAST=-Ofast if [[ ("$?" -eq "0") ]]; then
HAVE_OFAST=1
OPT_OFAST=-Ofast
fi
fi fi
# Use a fallback strategy so OPT_G2 can be used with RELEASE_CXXFLAGS # Use a fallback strategy so OPT_G2 can be used with RELEASE_CXXFLAGS