From 0f8871c9c9595c3290118c1bfb7f4d8f4223f000 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 3 Jul 2016 01:53:55 -0400 Subject: [PATCH 1/5] Updated documentation --- misc.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/misc.h b/misc.h index 894344a2..a888deef 100644 --- a/misc.h +++ b/misc.h @@ -219,10 +219,11 @@ struct NewObject //! \brief A memory barrier //! \details MEMORY_BARRIER attempts to ensure reads and writes are completed //! in the absence of a language synchronization point. It is used by the -//! Singleton class if the compiler supports it. The use is provided at the -//! customary check points in a double-checked initialization. -//! \details Internally, MEMORY_BARRIER uses intrinsic(_ReadWriteBarrier), -//! _ReadWriteBarrier() or __asm__("" ::: "memory"). +//! Singleton class if the compiler supports it. The barrier is provided at the +//! customary places in a double-checked initialization. +//! \details Internally, MEMORY_BARRIER uses std::atomic_thread_fence if +//! C++11 atomics are available. Otherwise, intrinsic(_ReadWriteBarrier), +//! _ReadWriteBarrier() or __asm__("" ::: "memory") is used. #define MEMORY_BARRIER ... #else #if defined(CRYPTOPP_CXX11_ATOMICS) @@ -246,8 +247,8 @@ struct NewObject //! \details This class safely initializes a static object in a multithreaded environment. For C++03 //! and below it will do so without using locks for portability. If two threads call Ref() at the same //! time, they may get back different references, and one object may end up being memory leaked. This -//! is by design. For C++11 and above, a standard double-checked locking pattern with memory fences -//! is used. The locks and fences are standard and do not hinder portability. +//! is by design. For C++11 and above, a standard double-checked locking pattern with thread fences +//! are used. The locks and fences are standard and do not hinder portability. //! \sa Double-Checked Locking is Fixed In C++11 template , int instance=0> class Singleton From 325ae3d93ba82bd31f4c5cbbfc538427c8a3d0e2 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 3 Jul 2016 18:54:57 -0400 Subject: [PATCH 2/5] Cleared "Local variable is initialized but not referenced" in MSC --- socketft.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/socketft.cpp b/socketft.cpp index 42a00182..ff6e0d40 100644 --- a/socketft.cpp +++ b/socketft.cpp @@ -109,10 +109,12 @@ void Socket::CloseSocket() BOOL result = CancelIoEx((HANDLE) m_s, NULL); assert(result || (!result && GetLastError() == ERROR_NOT_FOUND)); CheckAndHandleError_int("closesocket", closesocket(m_s)); + CRYPTOPP_UNUSED(result); // Used by assert in debug builds # else BOOL result = CancelIo((HANDLE) m_s); assert(result || (!result && GetLastError() == ERROR_NOT_FOUND)); CheckAndHandleError_int("closesocket", closesocket(m_s)); + CRYPTOPP_UNUSED(result); # endif #else CheckAndHandleError_int("close", close(m_s)); @@ -368,9 +370,11 @@ SocketReceiver::~SocketReceiver() # if defined(USE_WINDOWS8_API) BOOL result = CancelIoEx((HANDLE) m_s.GetSocket(), NULL); assert(result || (!result && GetLastError() == ERROR_NOT_FOUND)); + CRYPTOPP_UNUSED(result); // Used by assert in debug builds # else BOOL result = CancelIo((HANDLE) m_s.GetSocket()); assert(result || (!result && GetLastError() == ERROR_NOT_FOUND)); + CRYPTOPP_UNUSED(result); # endif #endif } @@ -456,9 +460,11 @@ SocketSender::~SocketSender() # if defined(USE_WINDOWS8_API) BOOL result = CancelIoEx((HANDLE) m_s.GetSocket(), NULL); assert(result || (!result && GetLastError() == ERROR_NOT_FOUND)); + CRYPTOPP_UNUSED(result); // Used by assert in debug builds # else BOOL result = CancelIo((HANDLE) m_s.GetSocket()); assert(result || (!result && GetLastError() == ERROR_NOT_FOUND)); + CRYPTOPP_UNUSED(result); # endif #endif } From cb9defd0c4c0fd1c071b86080e60f414c05f7f00 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 3 Jul 2016 22:34:57 -0400 Subject: [PATCH 3/5] Add gnu++11, gnu++14 and gnu++17 testing --- cryptest.sh | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 205 insertions(+), 1 deletion(-) diff --git a/cryptest.sh b/cryptest.sh index 7ba1aaa6..0d13f0a7 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -173,6 +173,14 @@ if [[ (-z "$HAVE_CXX17") ]]; then fi fi +if [[ (-z "$HAVE_GNU17") ]]; then + HAVE_GNU17=0 + "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++17 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + HAVE_GNU17=1 + fi +fi + # Hit or miss, mostly miss. if [[ (-z "$HAVE_CXX14") ]]; then HAVE_CXX14=0 @@ -182,6 +190,14 @@ if [[ (-z "$HAVE_CXX14") ]]; then fi fi +if [[ (-z "$HAVE_GNU14") ]]; then + HAVE_GNU14=0 + "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++14 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + HAVE_GNU14=1 + fi +fi + # Hit or miss, mostly hit. if [[ (-z "$HAVE_CXX11") ]]; then HAVE_CXX11=0 @@ -191,6 +207,14 @@ if [[ (-z "$HAVE_CXX11") ]]; then fi fi +if [[ (-z "$HAVE_GNU11") ]]; then + HAVE_GNU11=0 + "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++11 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + if [[ "$?" -eq "0" ]]; then + HAVE_GNU11=1 + fi +fi + # OpenBSD 5.7 and OS X 10.5 cannot consume -std=c++03 if [[ (-z "$HAVE_CXX03") ]]; then HAVE_CXX03=0 @@ -470,9 +494,12 @@ fi echo | tee -a "$TEST_RESULTS" echo "HAVE_CXX03: $HAVE_CXX03" | tee -a "$TEST_RESULTS" echo "HAVE_CXX11: $HAVE_CXX11" | tee -a "$TEST_RESULTS" -if [[ ("$HAVE_CXX14" -ne "0" || "$HAVE_CXX17" -ne "0") ]]; then +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 echo "HAVE_CXX14: $HAVE_CXX14" | tee -a "$TEST_RESULTS" + echo "HAVE_GNU14: $HAVE_GNU14" | tee -a "$TEST_RESULTS" echo "HAVE_CXX17: $HAVE_CXX17" | tee -a "$TEST_RESULTS" + echo "HAVE_GNU17: $HAVE_GNU17" | tee -a "$TEST_RESULTS" fi if [[ "$HAVE_LDGOLD" -ne "0" ]]; then echo "HAVE_LDGOLD: $HAVE_LDGOLD" | tee -a "$TEST_RESULTS" @@ -984,6 +1011,65 @@ if [[ "$HAVE_CXX11" -ne "0" ]]; then fi fi +############################################ +# gnu++11 debug and release build +if [[ "$HAVE_GNU11" -ne "0" ]]; then + + ############################################ + # Debug build + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: debug, gnu++11" | 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++11 ${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++11" | 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++11 ${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++14 debug and release build if [[ "$HAVE_CXX14" -ne "0" ]]; then @@ -1043,6 +1129,65 @@ if [[ "$HAVE_CXX14" -ne "0" ]]; then fi fi +############################################ +# gnu++14 debug and release build +if [[ "$HAVE_GNU14" -ne "0" ]]; then + + ############################################ + # Debug build + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: debug, gnu++14" | 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++14 ${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++14" | 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++14 ${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++17 debug and release build if [[ "$HAVE_CXX17" -ne "0" ]]; then @@ -1102,6 +1247,65 @@ if [[ "$HAVE_CXX17" -ne "0" ]]; then fi fi +############################################ +# gnu++17 debug and release build +if [[ "$HAVE_GNU17" -ne "0" ]]; then + + ############################################ + # Debug build + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: debug, gnu++17" | 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++17 ${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++17" | 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++17 ${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 + ############################################ # X32 debug and release build if [[ "$HAVE_X32" -ne "0" ]]; then From e1e70494590cf7dc69393297c79c125f37b156a9 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 3 Jul 2016 22:38:04 -0400 Subject: [PATCH 4/5] Add gnu++11, gnu++14 and gnu++17 testing --- cryptest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cryptest.sh b/cryptest.sh index 0d13f0a7..192147b5 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -192,7 +192,7 @@ fi if [[ (-z "$HAVE_GNU14") ]]; then HAVE_GNU14=0 - "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++14 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++14 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ "$?" -eq "0" ]]; then HAVE_GNU14=1 fi @@ -209,7 +209,7 @@ fi if [[ (-z "$HAVE_GNU11") ]]; then HAVE_GNU11=0 - "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=c++11 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 + "$CXX" -DCRYPTOPP_ADHOC_MAIN -std=gnu++11 adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ "$?" -eq "0" ]]; then HAVE_GNU11=1 fi From 6cd587da4c3927b771cf19b8055c8853475dfd18 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 3 Jul 2016 22:50:02 -0400 Subject: [PATCH 5/5] Add PowerPC reporting --- cryptest.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cryptest.sh b/cryptest.sh index 192147b5..f88287d4 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -458,6 +458,9 @@ elif [[ "$IS_DARWIN" -ne "0" ]]; then echo "IS_DARWIN: $IS_DARWIN" | tee -a "$TEST_RESULTS" fi +if [[ "$IS_PPC" -ne "0" ]]; then + echo "IS_PPC: $IS_PPC" | tee -a "$TEST_RESULTS" +fi if [[ "$IS_ARM64" -ne "0" ]]; then echo "IS_ARM64: $IS_ARM64" | tee -a "$TEST_RESULTS" elif [[ "$IS_ARM32" -ne "0" ]]; then