From b67c628270df5b428f297e09a77227a73b40a262 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 3 Jul 2016 23:57:25 -0400 Subject: [PATCH 01/10] Add additional warnings to ELEVATED_CXXFLAGS for GCC 6.0 and above --- cryptest.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cryptest.sh b/cryptest.sh index f88287d4..1d7ec1fe 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -135,6 +135,7 @@ if [[ ($("$CXX" -dM -E - /dev/null | "$EGREP" -c '(__x64_64__|__amd fi # Now that the compiler is fixed, see if its GCC 5.1 or above with -Wabi, -Wabi-tag and -Wodr +GCC_60_OR_ABOVE=$("$CXX" -v 2>&1 | "$EGREP" -i -c 'gcc version (6\.[0-9]|[7-9])') GCC_51_OR_ABOVE=$("$CXX" -v 2>&1 | "$EGREP" -i -c 'gcc version (5\.[1-9]|[6-9])') GCC_48_COMPILER=$("$CXX" -v 2>&1 | "$EGREP" -i -c 'gcc version 4\.8') # SunCC 12.2 and below needs one set of CXXFLAGS; SunCC 12.3 and above needs another set of CXXFLAGS @@ -696,6 +697,9 @@ if [[ ("$GCC_COMPILER" -ne "0") ]]; then "-Wno-unknown-pragmas" "-Wstrict-aliasing=3" "-Wstrict-overflow" "-Waggressive-loop-optimizations" "-Wcast-align" "-Wwrite-strings" "-Wformat=2" "-Wformat-security" "-Wtrampolines") + if [[ ("$GCC_60_OR_ABOVE" -ne "0") ]]; then + ELEVATED_CXXFLAGS+=("-Wshift-negative-value -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond -Wodr-type-mismatch") + fi if [[ ("$GCC_51_OR_ABOVE" -ne "0") ]]; then ELEVATED_CXXFLAGS+=("-Wabi" "-Wodr") fi From 685371614790b2f8879595e98bd69ab1b07bcc95 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 4 Jul 2016 06:25:35 -0400 Subject: [PATCH 02/10] Format output --- cryptest.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/cryptest.sh b/cryptest.sh index 1d7ec1fe..c28f80c7 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -128,6 +128,8 @@ fi SUN_COMPILER=$("$CXX" -V 2>&1 | "$EGREP" -i -c "CC: Sun") GCC_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "(gcc|g\+\+)") +INTEL_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "\(ICC\)") +MACPORTS_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "MacPorts") CLANG_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "clang") if [[ ($("$CXX" -dM -E - /dev/null | "$EGREP" -c '(__x64_64__|__amd64__)') -ne "0") && ($("$CXX" -dM -E -/dev/null | "$EGREP" -c '(__ILP32|__ILP32)') -ne "0") ]]; then @@ -3888,6 +3890,75 @@ if [[ ("$INTEL_COMPILER" -eq "0") ]]; then fi fi +############################################ +# Perform a quick check with MacPorts compilers, if available. +if [[ ("$MACPORTS_COMPILER" -eq "0") ]]; then + + MACPORTS_CXX=$(find /opt/local/bin -name 'g++*' 2>/dev/null | head -1) + if [[ (-z "$MACPORTS_CXX") ]]; then + "$MACPORTS_CXX" -x c++ -DCRYPTOPP_ADHOC_MAIN adhoc.cpp.proto -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + + ############################################ + # GCC build + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: MacPorts GCC compiler" | tee -a "$TEST_RESULTS" + echo + + unset CXXFLAGS + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + "$MAKE" "${MAKEARGS[@]}" CXX="$MACPORTS_CXX" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi + fi + fi + + MACPORTS_CXX=$(find /opt/local/bin -name 'clang++*' 2>/dev/null | head -1) + if [[ (-z "$MACPORTS_CXX") ]]; then + "$MACPORTS_CXX" -x c++ -DCRYPTOPP_ADHOC_MAIN adhoc.cpp.proto -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + + ############################################ + # Clang build + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: MacPorts Clang compiler" | tee -a "$TEST_RESULTS" + echo + + unset CXXFLAGS + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + "$MAKE" "${MAKEARGS[@]}" CXX="$MACPORTS_CXX" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi + fi + fi +fi + ############################################ # Perform a quick check with Xcode compiler, if available. if [[ "$IS_DARWIN" -ne "0" ]]; then @@ -4094,14 +4165,14 @@ fi # Report warnings echo -echo "************************************************" | tee -a "$WARN_RESULTS" -echo | tee -a "$WARN_RESULTS" +echo "************************************************" | tee -a "$TEST_RESULTS" "$WARN_RESULTS" +echo | tee -a "$TEST_RESULTS" "$WARN_RESULTS" WCOUNT=$("$EGREP" -a '(warning:)' $WARN_RESULTS | "$GREP" -v 'deprecated-declarations' | wc -l | "$AWK" '{print $1}') if (( "$WCOUNT" == "0" )); then - echo "No warnings detected" | tee -a "$WARN_RESULTS" | tee -a "$WARN_RESULTS" + echo "No warnings detected" | tee -a "$TEST_RESULTS" "$WARN_RESULTS" | tee -a "$TEST_RESULTS" "$WARN_RESULTS" else - echo "$WCOUNT warnings detected. See $WARN_RESULTS for details" | tee -a "$WARN_RESULTS" + echo "$WCOUNT warnings detected. See $WARN_RESULTS for details" | tee -a "$TEST_RESULTS" "$WARN_RESULTS" # "$EGREP" -an '(warning:)' $WARN_RESULTS | "$GREP" -v 'deprecated-declarations' fi @@ -4110,8 +4181,8 @@ fi echo echo "************************************************" | tee -a "$TEST_RESULTS" "$WARN_RESULTS" +echo | tee -a "$TEST_RESULTS" "$WARN_RESULTS" -echo echo "Testing started: $TEST_BEGIN" | tee -a "$TEST_RESULTS" "$WARN_RESULTS" echo "Testing finished: $TEST_END" | tee -a "$TEST_RESULTS" "$WARN_RESULTS" echo From be80fcdbba204b58e96c41b624807460d9eb2d7e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 4 Jul 2016 09:24:39 -0400 Subject: [PATCH 03/10] Cleared C4589 under VS2015 (Issue 214) --- wait.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wait.h b/wait.h index 13e6ba33..e274b19f 100644 --- a/wait.h +++ b/wait.h @@ -32,6 +32,13 @@ # endif #endif +// http://connect.microsoft.com/VisualStudio/feedback/details/1581706 +// and http://github.com/weidai11/cryptopp/issues/214 +#if CRYPTOPP_MSC_VERSION == 1900 +# pragma warning(push) +# pragma warning(disable: 4589) +#endif + NAMESPACE_BEGIN(CryptoPP) class Tracer @@ -223,6 +230,10 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION == 1900 +# pragma warning(pop) +#endif + #endif #endif From e36270fa7c15b1a47bd7336d09ccc0d7e9e81eec Mon Sep 17 00:00:00 2001 From: Mouse Date: Mon, 4 Jul 2016 13:11:15 -0400 Subject: [PATCH 04/10] Do not re-define macros already provided by native compiler --- misc.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/misc.h b/misc.h index a888deef..3e16e0e1 100644 --- a/misc.h +++ b/misc.h @@ -63,10 +63,18 @@ #if defined(__GNUC__) && defined(__BMI__) # include # if defined(__clang__) +#ifndef _tzcnt_u32 # define _tzcnt_u32(x) __tzcnt_u32(x) +#endif +#ifndef _tzcnt_u64 # define _tzcnt_u64(x) __tzcnt_u64(x) +#endif +#ifndef _blsr_u32 # define _blsr_u32(x) __blsr_u32(x) +#endif +#ifndef _blsr_u64 # define _blsr_u64(x) __blsr_u64(x) +#endif # endif #endif From 2d0dd95ddaa610559ba2ac4caa3bc196fb398916 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 4 Jul 2016 17:51:09 -0400 Subject: [PATCH 05/10] Fix "CRYPTOPP_USE_FIPS_202_SHA3 redfined" when using config.recommned with CRYPTOPP_USE_FIPS_202_SHA3 defined on command line --- config.h | 4 +++- config.recommend | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 7ac17fda..bd25d2cb 100644 --- a/config.h +++ b/config.h @@ -63,7 +63,9 @@ // Define this to choose the FIPS 202 version of SHA3, and not the original version of SHA3. NIST selected Keccak as SHA3 // in January 2013. SHA3 was finalized in FIPS 202 in August 2015, and it was a modified version of the original selection. // If CRYPTOPP_USE_FIPS_202_SHA3 is defined, then sha3_fips_202.txt test vectors will be used instead of sha3.txt. -// #define CRYPTOPP_USE_FIPS_202_SHA3 +// #ifndef CRYPTOPP_USE_FIPS_202_SHA3 +// # define CRYPTOPP_USE_FIPS_202_SHA3 +// #endif // ***************** Less Important Settings *************** diff --git a/config.recommend b/config.recommend index c9064240..7b45b308 100644 --- a/config.recommend +++ b/config.recommend @@ -63,7 +63,9 @@ // Define this to choose the FIPS 202 version of SHA3, and not the original version of SHA3. NIST selected Keccak as SHA3 // in January 2013. SHA3 was finalized in FIPS 202 in August 2015, and it was a modified version of the original selection. // If CRYPTOPP_USE_FIPS_202_SHA3 is defined, then sha3_fips_202.txt test vectors will be used instead of sha3.txt. -#define CRYPTOPP_USE_FIPS_202_SHA3 +#ifndef CRYPTOPP_USE_FIPS_202_SHA3 +# define CRYPTOPP_USE_FIPS_202_SHA3 +#endif // ***************** Less Important Settings *************** From a890e8851e16d75e72a3f1ca06e5f9ff41a0b7e9 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 4 Jul 2016 18:06:44 -0400 Subject: [PATCH 06/10] Add test for -std=gnu++03 --- cryptest.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/cryptest.sh b/cryptest.sh index c28f80c7..6b04f892 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -227,6 +227,14 @@ if [[ (-z "$HAVE_CXX03") ]]; then fi fi +if [[ (-z "$HAVE_GNU03") ]]; then + HAVE_GNU03=0 + "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++03 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + HAVE_GNU03=1 + fi +fi + HAVE_O3=0 OPT_O3= "$CXX" -DCRYPTOPP_ADHOC_MAIN -O3 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 @@ -499,6 +507,7 @@ fi # C++03, C++11, C++14 and C++17 echo | tee -a "$TEST_RESULTS" echo "HAVE_CXX03: $HAVE_CXX03" | tee -a "$TEST_RESULTS" +echo "HAVE_GNU03: $HAVE_GNU03" | tee -a "$TEST_RESULTS" echo "HAVE_CXX11: $HAVE_CXX11" | tee -a "$TEST_RESULTS" echo "HAVE_GNU11: $HAVE_GNU11" | tee -a "$TEST_RESULTS" if [[ ("$HAVE_CXX14" -ne "0" || "$HAVE_CXX17" -ne "0" || "$HAVE_GNU14" -ne "0" || "$HAVE_GNU17" -ne "0") ]]; then @@ -961,6 +970,65 @@ if [[ "$HAVE_CXX03" -ne "0" ]]; then fi fi +############################################ +# gnu++03 debug and release build +if [[ "$HAVE_GNU03" -ne "0" ]]; then + + ############################################ + # Debug build + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: debug, gnu++03" | tee -a "$TEST_RESULTS" + echo + + unset CXXFLAGS + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + export CXXFLAGS="$DEBUG_CXXFLAGS -std=gnu++03 ${RETAINED_CXXFLAGS[@]}" + "$MAKE" "${MAKEARGS[@]}" CXX="$CXX" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi + + ############################################ + # Release build + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: release, gnu++03" | tee -a "$TEST_RESULTS" + echo + + unset CXXFLAGS + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + export CXXFLAGS="$RELEASE_CXXFLAGS -std=gnu++03 ${RETAINED_CXXFLAGS[@]}" + "$MAKE" "${MAKEARGS[@]}" CXX="$CXX" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi +fi + ############################################ # c++11 debug and release build if [[ "$HAVE_CXX11" -ne "0" ]]; then From 36a459130422d7e6b8b7a0f6f539b79a0ab32b23 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 4 Jul 2016 22:14:51 -0400 Subject: [PATCH 07/10] Fix typo for -std=gnu++03 --- cryptest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptest.sh b/cryptest.sh index 6b04f892..d177cd1e 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -229,7 +229,7 @@ fi if [[ (-z "$HAVE_GNU03") ]]; then HAVE_GNU03=0 - "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++03 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++03 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ "$?" -eq "0" ]]; then HAVE_GNU03=1 fi From fb72dbc8cb750be749a4ec3e2f27d164fe89d431 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 5 Jul 2016 02:48:27 -0400 Subject: [PATCH 08/10] Add MacPorts GCC compiler and Clang integrated assembler support. This is a merge of the development branch 'clang-ia' --- GNUmakefile | 7 +++++-- blake2.cpp | 2 +- config.h | 12 +++++++----- cpu.cpp | 2 +- cpu.h | 8 ++++---- default.h | 12 ++++++------ eccrypto.h | 24 ++++++++++++------------ gcm.cpp | 14 +++++++------- misc.h | 2 +- panama.h | 4 ++-- rdrand.cpp | 4 ++-- rijndael.h | 2 +- sha.h | 2 +- 13 files changed, 50 insertions(+), 45 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index f1db629b..12b1542c 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -30,9 +30,9 @@ IS_DARWIN := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "Darwin") IS_NETBSD := $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -i -c "NetBSD") SUN_COMPILER := $(shell $(CXX) -V 2>&1 | $(EGREP) -i -c "CC: Sun") -GCC_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "(gcc|g\+\+)") +GCC_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -v "clang" | $(EGREP) -i -c "(gcc|g\+\+)") CLANG_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang") -INTEL_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)") +INTEL_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "\(icc\)") MACPORTS_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "macports") # Sun Studio 12.0 (0x0510) and 12.3 (0x0512) @@ -179,6 +179,9 @@ ifeq ($(GCC_COMPILER)$(MACPORTS_COMPILER),11) ifneq ($(findstring -Wa,-q,$(CXXFLAGS)),-Wa,-q) CXXFLAGS += -Wa,-q endif +ifneq ($(findstring -Wa,-q,$(CXXFLAGS)),-DCRYPTOPP_CLANG_INTEGRATED_ASSEMBLER) +CXXFLAGS += -DCRYPTOPP_CLANG_INTEGRATED_ASSEMBLER=1 +endif endif # Allow use of "/" operator for GNU Assembler. diff --git a/blake2.cpp b/blake2.cpp index 77eef8ce..0cb858b1 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -35,7 +35,7 @@ NAMESPACE_BEGIN(CryptoPP) // Apple Clang 6.0/Clang 3.5 does not have SSSE3 intrinsics // http://llvm.org/bugs/show_bug.cgi?id=20213 -#if (defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION <= 60000)) || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION <= 30500)) +#if (defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION <= 60000)) || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION <= 30500)) # undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE #endif diff --git a/config.h b/config.h index bd25d2cb..9a40f2ba 100644 --- a/config.h +++ b/config.h @@ -238,9 +238,11 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff); // Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7 #if defined(__clang__ ) && !defined(__apple_build_version__) - #define CRYPTOPP_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) + #define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) + #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1 #elif defined(__clang__ ) && defined(__apple_build_version__) #define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) + #define CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER 1 #endif #ifdef _MSC_VER @@ -248,13 +250,13 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff); #endif // Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}" -#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000) +#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000) #define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1 #endif // Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232 // TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes. -#if (defined(CRYPTOPP_CLANG_VERSION) && CRYPTOPP_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) +#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && CRYPTOPP_LLVM_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER) #define CRYPTOPP_DISABLE_INTEL_ASM 1 #endif @@ -728,7 +730,7 @@ NAMESPACE_END // ************** Deprecated *************** -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) # define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated (msg))); #elif (CRYPTOPP_GCC_VERSION) # define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated)); @@ -781,7 +783,7 @@ NAMESPACE_END # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1200) # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 -#elif (CRYPTOPP_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) +#elif (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 #elif (CRYPTOPP_GCC_VERSION >= 40400) # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 diff --git a/cpu.cpp b/cpu.cpp index 7c39cccd..b13dd255 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -27,7 +27,7 @@ NAMESPACE_BEGIN(CryptoPP) #ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY // MacPorts/GCC does not provide constructor(priority). Apple/GCC and Fink/GCC do provide it. -#define HAVE_GCC_CONSTRUCTOR1 (__GNUC__ && (CRYPTOPP_INIT_PRIORITY > 0) && ((CRYPTOPP_GCC_VERSION >= 40300) || (CRYPTOPP_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 300)) && !(MACPORTS_GCC_COMPILER > 0)) +#define HAVE_GCC_CONSTRUCTOR1 (__GNUC__ && (CRYPTOPP_INIT_PRIORITY > 0) && ((CRYPTOPP_GCC_VERSION >= 40300) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (_INTEL_COMPILER >= 300)) && !(MACPORTS_GCC_COMPILER > 0)) #define HAVE_GCC_CONSTRUCTOR0 (__GNUC__ && (CRYPTOPP_INIT_PRIORITY > 0) && !(MACPORTS_GCC_COMPILER > 0)) extern "C" { diff --git a/cpu.h b/cpu.h index 890f53db..91b03b4b 100644 --- a/cpu.h +++ b/cpu.h @@ -52,7 +52,7 @@ #endif // PUSHFB needs Clang 3.3 and Apple Clang 5.0. -#if !defined(__GNUC__) || defined(__SSSE3__)|| defined(__INTEL_COMPILER) || (CRYPTOPP_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) +#if !defined(__GNUC__) || defined(__SSSE3__)|| defined(__INTEL_COMPILER) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) #include #else NAMESPACE_BEGIN(CryptoPP) @@ -66,7 +66,7 @@ NAMESPACE_END #endif // tmmintrin.h // PEXTRD needs Clang 3.3 and Apple Clang 5.0. -#if !defined(__GNUC__) || defined(__SSE4_1__)|| defined(__INTEL_COMPILER) || (CRYPTOPP_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) +#if !defined(__GNUC__) || defined(__SSE4_1__)|| defined(__INTEL_COMPILER) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) #include #else NAMESPACE_BEGIN(CryptoPP) @@ -87,7 +87,7 @@ NAMESPACE_END #endif // smmintrin.h // AES needs Clang 2.8 and Apple Clang 4.6. PCLMUL needs Clang 3.4 and Apple Clang 6.0 -#if !defined(__GNUC__) || (defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || (CRYPTOPP_CLANG_VERSION >= 30400) || (CRYPTOPP_APPLE_CLANG_VERSION >= 60000) +#if !defined(__GNUC__) || (defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30400) || (CRYPTOPP_APPLE_CLANG_VERSION >= 60000) #include #else NAMESPACE_BEGIN(CryptoPP) @@ -415,7 +415,7 @@ inline int GetCacheLineSize() #else #define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY -#if defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) +#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;" diff --git a/default.h b/default.h index 00ec6647..6b30f2e4 100644 --- a/default.h +++ b/default.h @@ -48,7 +48,7 @@ private: SecByteBlock m_passphrase; CBC_Mode::Encryption m_cipher; -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) } __attribute__((deprecated ("DefaultEncryptor will be changing in the near future because the algorithms are no longer secure"))); #elif (CRYPTOPP_GCC_VERSION) } __attribute__((deprecated)); @@ -68,7 +68,7 @@ public: //! \param attachment a BufferedTransformation to attach to this object //! \param throwException a flag specifiying whether an Exception should be thrown on error DefaultDecryptor(const char *passphrase, BufferedTransformation *attachment = NULL, bool throwException=true); - + //! \brief Constructs a DefaultDecryptor //! \param passphrase a byte string password //! \param passphraseLength the length of the byte string password @@ -79,7 +79,7 @@ public: class Err : public Exception { public: - Err(const std::string &s) + Err(const std::string &s) : Exception(DATA_INTEGRITY_CHECK_FAILED, s) {} }; class KeyBadErr : public Err {public: KeyBadErr() : Err("DefaultDecryptor: cannot decrypt message with this passphrase") {}}; @@ -101,7 +101,7 @@ private: member_ptr m_decryptor; bool m_throwException; -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) } __attribute__((deprecated ("DefaultDecryptor will be changing in the near future because the algorithms are no longer secure"))); #elif (CRYPTOPP_GCC_VERSION) } __attribute__((deprecated)); @@ -139,7 +139,7 @@ protected: private: member_ptr m_mac; -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) } __attribute__((deprecated ("DefaultEncryptorWithMAC will be changing in the near future because the algorithms are no longer secure"))); #elif (CRYPTOPP_GCC_VERSION) } __attribute__((deprecated)); @@ -188,7 +188,7 @@ private: HashVerifier *m_hashVerifier; bool m_throwException; -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) } __attribute__((deprecated ("DefaultDecryptorWithMAC will be changing in the near future because the algorithms are no longer secure"))); #elif (CRYPTOPP_GCC_VERSION) } __attribute__((deprecated)); diff --git a/eccrypto.h b/eccrypto.h index a3d15e95..cba037fb 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -130,7 +130,7 @@ public: const Integer& GetBasePointOrder() const {return this->GetSubgroupOrder();} void LoadRecommendedParameters(const OID &oid) {Initialize(oid);} #endif - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_GroupParameters_EC() {} #endif @@ -160,7 +160,7 @@ public: // X509PublicKey void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size); void DEREncodePublicKey(BufferedTransformation &bt) const; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_PublicKey_EC() {} #endif @@ -185,7 +185,7 @@ public: // PKCS8PrivateKey void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size); void DEREncodePrivateKey(BufferedTransformation &bt) const; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_PrivateKey_EC() {} #endif @@ -196,7 +196,7 @@ template , COFACTOR_OPTION> Domain; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECDH() {} #endif @@ -207,7 +207,7 @@ template , COFACTOR_OPTION> Domain; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECMQV() {} #endif @@ -219,7 +219,7 @@ struct DL_Keys_EC { typedef DL_PublicKey_EC PublicKey; typedef DL_PrivateKey_EC PrivateKey; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Keys_EC() {} #endif @@ -234,7 +234,7 @@ struct DL_Keys_ECDSA { typedef DL_PublicKey_EC PublicKey; typedef DL_PrivateKey_WithSignaturePairwiseConsistencyTest, ECDSA > PrivateKey; - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Keys_ECDSA() {} #endif @@ -246,7 +246,7 @@ class DL_Algorithm_ECDSA : public DL_Algorithm_GDSA { public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECDSA";} - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Algorithm_ECDSA() {} #endif @@ -258,7 +258,7 @@ class DL_Algorithm_ECNR : public DL_Algorithm_NR { public: static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECNR";} - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~DL_Algorithm_ECNR() {} #endif @@ -296,12 +296,12 @@ struct ECIES ECIES > { static std::string CRYPTOPP_API StaticAlgorithmName() {return "ECIES";} // TODO: fix this after name is standardized - + #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 virtual ~ECIES() {} #endif - -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) + +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) } __attribute__((deprecated ("ECIES will be changing in the near future due to (1) an implementation bug and (2) an interop issue"))); #elif (CRYPTOPP_GCC_VERSION) } __attribute__((deprecated)); diff --git a/gcm.cpp b/gcm.cpp index fd82bddb..fd6731f0 100644 --- a/gcm.cpp +++ b/gcm.cpp @@ -13,7 +13,7 @@ #ifndef CRYPTOPP_GENERATE_X64_MASM // Clang 3.3 integrated assembler crash on Linux -#if defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400) +#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER) # undef CRYPTOPP_X86_ASM_AVAILABLE # undef CRYPTOPP_X32_ASM_AVAILABLE # undef CRYPTOPP_X64_ASM_AVAILABLE @@ -703,9 +703,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len) AS2( pxor xmm5, xmm2 ) AS2( psrldq xmm0, 15 ) -#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000) +#if (CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000) AS2( movd edi, xmm0 ) -#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE) +#elif (defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE) AS2( mov WORD_REG(di), xmm0 ) #else // GNU Assembler AS2( movd WORD_REG(di), xmm0 ) @@ -718,9 +718,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len) AS2( pxor xmm4, xmm5 ) AS2( psrldq xmm1, 15 ) -#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000) +#if (CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000) AS2( movd edi, xmm1 ) -#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE) +#elif (defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE) AS2( mov WORD_REG(di), xmm1 ) #else AS2( movd WORD_REG(di), xmm1 ) @@ -729,9 +729,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len) AS2( shl eax, 8 ) AS2( psrldq xmm0, 15 ) -#if (CRYPTOPP_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000) +#if (CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000) AS2( movd edi, xmm0 ) -#elif (defined(CRYPTOPP_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE) +#elif (defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION)) && defined(CRYPTOPP_X64_ASM_AVAILABLE) AS2( mov WORD_REG(di), xmm0 ) #else AS2( movd WORD_REG(di), xmm0 ) diff --git a/misc.h b/misc.h index 3e16e0e1..e3980441 100644 --- a/misc.h +++ b/misc.h @@ -471,7 +471,7 @@ template inline const T& STDMAX(const T& a, const T& b) #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wsign-compare" -# if (CRYPTOPP_CLANG_VERSION >= 20800) || (CRYPTOPP_APPLE_CLANG_VERSION >= 30000) +# if (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) || (CRYPTOPP_APPLE_CLANG_VERSION >= 30000) # pragma GCC diagnostic ignored "-Wtautological-compare" # elif (CRYPTOPP_GCC_VERSION >= 40300) # pragma GCC diagnostic ignored "-Wtype-limits" diff --git a/panama.h b/panama.h index b7db323a..e7f20c95 100644 --- a/panama.h +++ b/panama.h @@ -11,7 +11,7 @@ #include "secblock.h" // Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler error with .intel_syntax -#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30500)) +#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30500)) # define CRYPTOPP_DISABLE_PANAMA_ASM #endif @@ -128,7 +128,7 @@ struct PanamaCipherInfo : public FixedKeyLength<32, SimpleKeyingInterface::UNIQU //! _ template -class PanamaCipherPolicy : public AdditiveCipherConcretePolicy, +class PanamaCipherPolicy : public AdditiveCipherConcretePolicy, public PanamaCipherInfo, protected Panama { diff --git a/rdrand.cpp b/rdrand.cpp index 6149315e..4edb1bd8 100644 --- a/rdrand.cpp +++ b/rdrand.cpp @@ -67,8 +67,8 @@ #endif #if defined(CRYPTOPP_CPUID_AVAILABLE) -# define MSC_INTRIN_COMPILER ((CRYPTOPP_MSC_VERSION >= 1700) || (CRYPTOPP_CLANG_VERSION >= 30200) || (_INTEL_COMPILER >= 1210)) -# define GCC_INTRIN_COMPILER ((CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_CLANG_VERSION >= 30200) || (_INTEL_COMPILER >= 1210)) +# define MSC_INTRIN_COMPILER ((CRYPTOPP_MSC_VERSION >= 1700) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (_INTEL_COMPILER >= 1210)) +# define GCC_INTRIN_COMPILER ((CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30200) || (_INTEL_COMPILER >= 1210)) #else # define MSC_INTRIN_COMPILER 0 # define GCC_INTRIN_COMPILER 0 diff --git a/rijndael.h b/rijndael.h index ed856d94..50fdf1eb 100644 --- a/rijndael.h +++ b/rijndael.h @@ -12,7 +12,7 @@ #include "secblock.h" // Clang 3.3 integrated assembler crash on Linux -#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400)) +#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400)) # define CRYPTOPP_DISABLE_RIJNDAEL_ASM #endif diff --git a/sha.h b/sha.h index 544e8056..c70d9d1f 100644 --- a/sha.h +++ b/sha.h @@ -11,7 +11,7 @@ #include "iterhash.h" // Clang 3.3 integrated assembler crash on Linux -#if defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400) +#if defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION < 30400) # define CRYPTOPP_DISABLE_SHA_ASM #endif From 34e95a7cde503891b76b2ce35176bf24b4b0c29a Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 5 Jul 2016 02:49:33 -0400 Subject: [PATCH 09/10] Add MacPorts GCC compiler and Clang integrated assembler support. This is a merge of the development branch 'clang-ia' --- config.recommend | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config.recommend b/config.recommend index 7b45b308..15b7e781 100644 --- a/config.recommend +++ b/config.recommend @@ -238,7 +238,7 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff); // Apple and LLVM's Clang. Apple Clang version 7.0 roughly equals LLVM Clang version 3.7 #if defined(__clang__ ) && !defined(__apple_build_version__) - #define CRYPTOPP_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) + #define CRYPTOPP_LLVM_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) #elif defined(__clang__ ) && defined(__apple_build_version__) #define CRYPTOPP_APPLE_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) #endif @@ -248,13 +248,13 @@ const lword LWORD_MAX = W64LIT(0xffffffffffffffff); #endif // Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}" -#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000) +#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000) #define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1 #endif // Clang due to "Inline assembly operands don't work with .intel_syntax", http://llvm.org/bugs/show_bug.cgi?id=24232 // TODO: supply the upper version when LLVM fixes it. We set it to 20.0 for compilation purposes. -#if (defined(CRYPTOPP_CLANG_VERSION) && CRYPTOPP_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) +#if (defined(CRYPTOPP_LLVM_CLANG_VERSION) && CRYPTOPP_LLVM_CLANG_VERSION <= 200000) || (defined(CRYPTOPP_APPLE_CLANG_VERSION) && CRYPTOPP_APPLE_CLANG_VERSION <= 200000) #define CRYPTOPP_DISABLE_INTEL_ASM 1 #endif @@ -726,7 +726,7 @@ NAMESPACE_END // ************** Deprecated *************** -#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_CLANG_VERSION >= 20800) +#if (CRYPTOPP_GCC_VERSION >= 40500) || (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) # define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated (msg))); #elif (CRYPTOPP_GCC_VERSION) # define CRYPTOPP_DEPRECATED(msg) __attribute__((deprecated)); @@ -779,7 +779,7 @@ NAMESPACE_END # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 #elif defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1200) # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 -#elif (CRYPTOPP_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) +#elif (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000) # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 #elif (CRYPTOPP_GCC_VERSION >= 40400) # define CRYPTOPP_CXX11_SYNCHRONIZATION 1 From 66ada4cc61d62afc2ddda4d8d0bc4e5c8d188991 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 5 Jul 2016 11:49:13 -0400 Subject: [PATCH 10/10] Updated documentation --- cpu.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/cpu.h b/cpu.h index 91b03b4b..b1414a91 100644 --- a/cpu.h +++ b/cpu.h @@ -2,9 +2,7 @@ //! \file cpu.h //! \brief Functions for CPU features and intrinsics -//! \details At the moment, the functions are used heavily in X86/X32/X64 code paths -// for SSE, SSE2 and SSE4. The funtions are also used on occassion for AArch32 -//! and AArch64 code paths for NEON. +//! \details The functions are used in X86/X32/X64 and NEON code paths #ifndef CRYPTOPP_CPU_H #define CRYPTOPP_CPU_H @@ -141,11 +139,13 @@ NAMESPACE_END NAMESPACE_BEGIN(CryptoPP) -#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 +#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 || CRYPTOPP_DOXYGEN_PROCESSING #define CRYPTOPP_CPUID_AVAILABLE -// these should not be used directly +// Hide from Doxygen +#ifndef CRYPTOPP_DOXYGEN_PROCESSING +// These should not be used directly extern CRYPTOPP_DLL bool g_x86DetectionDone; extern CRYPTOPP_DLL bool g_hasMMX; extern CRYPTOPP_DLL bool g_hasISSE; @@ -166,7 +166,12 @@ extern CRYPTOPP_DLL word32 g_cacheLineSize; CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features(); CRYPTOPP_DLL bool CRYPTOPP_API CpuId(word32 input, word32 output[4]); +#endif // CRYPTOPP_DOXYGEN_PROCESSING +//! \brief Determines MMX availability +//! \returns true if MMX is determined to be available, false otherwise +//! \details MMX, SSE and SSE2 are core processor features for x86_64, and +//! the function always returns true for the platform. inline bool HasMMX() { #if CRYPTOPP_BOOL_X64 @@ -178,6 +183,10 @@ inline bool HasMMX() #endif } +//! \brief Determines SSE availability +//! \returns true if SSE is determined to be available, false otherwise +//! \details MMX, SSE and SSE2 are core processor features for x86_64, and +//! the function always returns true for the platform. inline bool HasISSE() { #if CRYPTOPP_BOOL_X64 @@ -189,6 +198,10 @@ inline bool HasISSE() #endif } +//! \brief Determines SSE2 availability +//! \returns true if SSE2 is determined to be available, false otherwise +//! \details MMX, SSE and SSE2 are core processor features for x86_64, and +//! the function always returns true for the platform. inline bool HasSSE2() { #if CRYPTOPP_BOOL_X64 @@ -200,6 +213,10 @@ inline bool HasSSE2() #endif } +//! \brief Determines SSSE3 availability +//! \returns true if SSSE3 is determined to be available, false otherwise +//! \details HasSSSE3() is a runtime check performed using CPUID +//! \note Some Clang compilers incorrectly omit SSSE3 even though its native to the processor. inline bool HasSSSE3() { if (!g_x86DetectionDone) @@ -207,6 +224,9 @@ inline bool HasSSSE3() return g_hasSSSE3; } +//! \brief Determines SSE4 availability +//! \returns true if SSE4.1 and SSE4.2 are determined to be available, false otherwise +//! \details HasSSE4() is a runtime check performed using CPUID which requires both SSE4.1 and SSE4.2 inline bool HasSSE4() { if (!g_x86DetectionDone) @@ -214,6 +234,9 @@ inline bool HasSSE4() return g_hasSSE4; } +//! \brief Determines AES-NI availability +//! \returns true if AES-NI is determined to be available, false otherwise +//! \details HasAESNI() is a runtime check performed using CPUID inline bool HasAESNI() { if (!g_x86DetectionDone) @@ -221,6 +244,9 @@ inline bool HasAESNI() return g_hasAESNI; } +//! \brief Determines Carryless Multiply availability +//! \returns true if pclmulqdq is determined to be available, false otherwise +//! \details HasCLMUL() is a runtime check performed using CPUID inline bool HasCLMUL() { if (!g_x86DetectionDone) @@ -228,6 +254,9 @@ inline bool HasCLMUL() return g_hasCLMUL; } +//! \brief Determines if the CPU is an Intel P4 +//! \returns true if the CPU is a P4, false otherwise +//! \details IsP4() is a runtime check performed using CPUID inline bool IsP4() { if (!g_x86DetectionDone) @@ -235,6 +264,9 @@ inline bool IsP4() return g_isP4; } +//! \brief Determines RDRAND availability +//! \returns true if RDRAND is determined to be available, false otherwise +//! \details HasRDRAND() is a runtime check performed using CPUID inline bool HasRDRAND() { if (!g_x86DetectionDone) @@ -242,6 +274,9 @@ inline bool HasRDRAND() return g_hasRDRAND; } +//! \brief Determines RDSEED availability +//! \returns true if RDSEED is determined to be available, false otherwise +//! \details HasRDSEED() is a runtime check performed using CPUID inline bool HasRDSEED() { if (!g_x86DetectionDone) @@ -249,6 +284,9 @@ inline bool HasRDSEED() return g_hasRDSEED; } +//! \brief Determines Padlock RNG availability +//! \returns true if VIA Padlock RNG is determined to be available, false otherwise +//! \details HasPadlockRNG() is a runtime check performed using CPUID inline bool HasPadlockRNG() { if (!g_x86DetectionDone) @@ -256,6 +294,9 @@ inline bool HasPadlockRNG() return g_hasPadlockRNG; } +//! \brief Determines Padlock ACE availability +//! \returns true if VIA Padlock ACE is determined to be available, false otherwise +//! \details HasPadlockACE() is a runtime check performed using CPUID inline bool HasPadlockACE() { if (!g_x86DetectionDone) @@ -263,6 +304,9 @@ inline bool HasPadlockACE() return g_hasPadlockACE; } +//! \brief Determines Padlock ACE2 availability +//! \returns true if VIA Padlock ACE2 is determined to be available, false otherwise +//! \details HasPadlockACE2() is a runtime check performed using CPUID inline bool HasPadlockACE2() { if (!g_x86DetectionDone) @@ -270,6 +314,9 @@ inline bool HasPadlockACE2() return g_hasPadlockACE2; } +//! \brief Determines Padlock PHE availability +//! \returns true if VIA Padlock PHE is determined to be available, false otherwise +//! \details HasPadlockPHE() is a runtime check performed using CPUID inline bool HasPadlockPHE() { if (!g_x86DetectionDone) @@ -277,6 +324,9 @@ inline bool HasPadlockPHE() return g_hasPadlockPHE; } +//! \brief Determines Padlock PMM availability +//! \returns true if VIA Padlock PMM is determined to be available, false otherwise +//! \details HasPadlockPMM() is a runtime check performed using CPUID inline bool HasPadlockPMM() { if (!g_x86DetectionDone) @@ -284,6 +334,13 @@ inline bool HasPadlockPMM() return g_hasPadlockPMM; } +//! \brief Provides the cache line size +//! \returns lower bound on the size of a cache line in bytes, if available +//! \details GetCacheLineSize() returns the lower bound on the size of a cache line, if it +//! is available. If the value is not available at runtime, then 32 is returned for a 32-bit +//! processor and 64 is returned for a 64-bit processor. +//! \details x86/x32/x64 uses CPUID to determine the value and its usually accurate. The ARM +//! processor equivalent is a privileged instruction, so a compile time value is returned. inline int GetCacheLineSize() { if (!g_x86DetectionDone)