Use define CRYPTOPP_CXX11_STATIC_INIT name

This commit is contained in:
Jeffrey Walton 2020-08-07 19:11:47 -04:00
parent 7d0859d9db
commit 2c6e4b17d7
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
11 changed files with 15 additions and 15 deletions

View File

@ -722,9 +722,9 @@ rm -f config_cxx.h.new
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_staticinit.cxx -o ${TOUT} 2>&1 | wc -w) CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_staticinit.cxx -o ${TOUT} 2>&1 | wc -w)
if [[ "${CXX_RESULT}" -eq 0 ]]; then if [[ "${CXX_RESULT}" -eq 0 ]]; then
echo '#define CRYPTOPP_CXX11_DYNAMIC_INIT 1' echo '#define CRYPTOPP_CXX11_STATIC_INIT 1'
else else
echo '// #define CRYPTOPP_CXX11_DYNAMIC_INIT 1' echo '// #define CRYPTOPP_CXX11_STATIC_INIT 1'
fi fi
CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_deletefn.cxx -o ${TOUT} 2>&1 | wc -w) CXX_RESULT=$(${CXX} ${CXXFLAGS} TestPrograms/test_cxx11_deletefn.cxx -o ${TOUT} 2>&1 | wc -w)

View File

@ -124,7 +124,7 @@
(CRYPTOPP_MSC_VERSION >= 1900) && ((WINVER >= 0x0600) || (_WIN32_WINNT >= 0x0600)) || \ (CRYPTOPP_MSC_VERSION >= 1900) && ((WINVER >= 0x0600) || (_WIN32_WINNT >= 0x0600)) || \
(CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || \ (CRYPTOPP_LLVM_CLANG_VERSION >= 20900) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || \
(__INTEL_COMPILER >= 1110) || (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130) (__INTEL_COMPILER >= 1110) || (CRYPTOPP_GCC_VERSION >= 40300) || (__SUNPRO_CC >= 0x5130)
# define CRYPTOPP_CXX11_DYNAMIC_INIT 1 # define CRYPTOPP_CXX11_STATIC_INIT 1
#endif // Dynamic Initialization compilers #endif // Dynamic Initialization compilers
// deleted functions: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 5.13. // deleted functions: MS at VS2013 (18.00); GCC at 4.3; Clang at 2.9; Intel 12.1; SunCC 5.13.

View File

@ -234,7 +234,7 @@ private:
void GetAppleMachineInfo(unsigned int& device, unsigned int& version, unsigned int& arch) void GetAppleMachineInfo(unsigned int& device, unsigned int& version, unsigned int& arch)
{ {
#if CRYPTOPP_CXX11_DYNAMIC_INIT #if CRYPTOPP_CXX11_STATIC_INIT
static const AppleMachineInfo info; static const AppleMachineInfo info;
#else #else
using CryptoPP::Singleton; using CryptoPP::Singleton;

View File

@ -198,7 +198,7 @@ const EC2N::Point& EC2N::Identity() const
{ {
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY) #if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_identity; return g_identity;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #elif defined(CRYPTOPP_CXX11_STATIC_INIT)
static const EC2N::Point g_identity; static const EC2N::Point g_identity;
return g_identity; return g_identity;
#else #else

View File

@ -719,7 +719,7 @@ const ECP::Point& ECP::Identity() const
{ {
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY) #if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_identity; return g_identity;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #elif defined(CRYPTOPP_CXX11_STATIC_INIT)
static const ECP::Point g_identity; static const ECP::Point g_identity;
return g_identity; return g_identity;
#else #else

View File

@ -166,7 +166,7 @@ const PolynomialMod2 &PolynomialMod2::Zero()
{ {
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY) #if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_zero; return g_zero;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #elif defined(CRYPTOPP_CXX11_STATIC_INIT)
static const PolynomialMod2 g_zero; static const PolynomialMod2 g_zero;
return g_zero; return g_zero;
#else #else
@ -178,7 +178,7 @@ const PolynomialMod2 &PolynomialMod2::One()
{ {
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY) #if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_one; return g_one;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #elif defined(CRYPTOPP_CXX11_STATIC_INIT)
static const PolynomialMod2 g_one(1); static const PolynomialMod2 g_one(1);
return g_one; return g_one;
#else #else

View File

@ -4857,7 +4857,7 @@ const Integer &Integer::Zero()
{ {
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY) #if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_zero; return g_zero;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #elif defined(CRYPTOPP_CXX11_STATIC_INIT)
static const Integer s_zero(0L); static const Integer s_zero(0L);
return s_zero; return s_zero;
#else // Potential memory leak. Avoid if possible. #else // Potential memory leak. Avoid if possible.
@ -4869,7 +4869,7 @@ const Integer &Integer::One()
{ {
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY) #if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_one; return g_one;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #elif defined(CRYPTOPP_CXX11_STATIC_INIT)
static const Integer s_one(1L); static const Integer s_one(1L);
return s_one; return s_one;
#else // Potential memory leak. Avoid if possible. #else // Potential memory leak. Avoid if possible.
@ -4881,7 +4881,7 @@ const Integer &Integer::Two()
{ {
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY) #if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_two; return g_two;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #elif defined(CRYPTOPP_CXX11_STATIC_INIT)
static const Integer s_two(2L); static const Integer s_two(2L);
return s_two; return s_two;
#else // Potential memory leak. Avoid if possible. #else // Potential memory leak. Avoid if possible.

2
misc.h
View File

@ -324,7 +324,7 @@ private:
template <class T, class F, int instance> template <class T, class F, int instance>
const T & Singleton<T, F, instance>::Ref(CRYPTOPP_NOINLINE_DOTDOTDOT) const const T & Singleton<T, F, instance>::Ref(CRYPTOPP_NOINLINE_DOTDOTDOT) const
{ {
#if defined(CRYPTOPP_CXX11_ATOMIC) && defined(CRYPTOPP_CXX11_SYNCHRONIZATION) && defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #if defined(CRYPTOPP_CXX11_ATOMIC) && defined(CRYPTOPP_CXX11_SYNCHRONIZATION) && defined(CRYPTOPP_CXX11_STATIC_INIT)
static std::mutex s_mutex; static std::mutex s_mutex;
static std::atomic<T*> s_pObject; static std::atomic<T*> s_pObject;

View File

@ -154,7 +154,7 @@ void NonblockingRng::GenerateBlock(byte *output, size_t size)
{ {
#ifdef CRYPTOPP_WIN32_AVAILABLE #ifdef CRYPTOPP_WIN32_AVAILABLE
// Acquiring a provider is expensive. Do it once and retain the reference. // Acquiring a provider is expensive. Do it once and retain the reference.
# if defined(CRYPTOPP_CXX11_DYNAMIC_INIT) # if defined(CRYPTOPP_CXX11_STATIC_INIT)
static const MicrosoftCryptoProvider hProvider = MicrosoftCryptoProvider(); static const MicrosoftCryptoProvider hProvider = MicrosoftCryptoProvider();
# else # else
const MicrosoftCryptoProvider &hProvider = Singleton<MicrosoftCryptoProvider>().Ref(); const MicrosoftCryptoProvider &hProvider = Singleton<MicrosoftCryptoProvider>().Ref();

View File

@ -322,7 +322,7 @@ inline std::string DataDir(const std::string& filename)
std::string name; std::string name;
std::ifstream file; std::ifstream file;
#if CRYPTOPP_CXX11_DYNAMIC_INIT #if CRYPTOPP_CXX11_STATIC_INIT
static std::string path = AddSeparator(GetDataDir()); static std::string path = AddSeparator(GetDataDir());
name = path + filename; name = path + filename;
file.open(name.c_str()); file.open(name.c_str());

View File

@ -13,7 +13,7 @@ NAMESPACE_BEGIN(CryptoPP)
const GFP2Element & GFP2Element::Zero() const GFP2Element & GFP2Element::Zero()
{ {
#if defined(CRYPTOPP_CXX11_DYNAMIC_INIT) #if defined(CRYPTOPP_CXX11_STATIC_INIT)
static const GFP2Element s_zero; static const GFP2Element s_zero;
return s_zero; return s_zero;
#else #else