diff options
author | Jeffrey Walton <noloader@gmail.com> | 2017-03-20 08:51:10 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2017-03-20 08:51:10 -0400 |
commit | f502ee9218c3a090920bc1584334a3a8e3fbb043 (patch) | |
tree | fd94377d93df7208db33dc660fc9a31b378dbe30 /cryptlib.cpp | |
parent | 0c6510b0a580af487b939d34369f2d533a9f73f7 (diff) | |
download | cryptopp-git-f502ee9218c3a090920bc1584334a3a8e3fbb043.tar.gz |
Simplify C++ dynamic object initialization
Wrap DetectArmFeatures and DetectX86Features in InitializeCpu class
Use init_priority for InitializeCpu
Remove HAVE_GCC_CONSTRUCTOR1 and HAVE_GCC_CONSTRUCTOR0
Use init_seg(<name>) on Windows and explicitly insert at XCU segment
Simplify logic for HAVE_GAS
Remove special recipies for MACPORTS_GCC_COMPILER
Move C++ static initializers into anonymous namespace when possible
Add default NullNameValuePairs ctor for Clang
Diffstat (limited to 'cryptlib.cpp')
-rw-r--r-- | cryptlib.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/cryptlib.cpp b/cryptlib.cpp index 189f7759..19ea1c6a 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -45,31 +45,11 @@ CRYPTOPP_COMPILE_ASSERT(sizeof(dword) == 2*sizeof(word)); class NullNameValuePairs : public NameValuePairs
{
public:
- NullNameValuePairs() {} // Clang complaint a default ctor must be avilable
+ NullNameValuePairs() {} // Clang complains a default ctor must be avilable
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
{CRYPTOPP_UNUSED(name); CRYPTOPP_UNUSED(valueType); CRYPTOPP_UNUSED(pValue); return false;}
};
-#if HAVE_GCC_INIT_PRIORITY
-const std::string DEFAULT_CHANNEL __attribute__ ((init_priority (CRYPTOPP_INIT_PRIORITY + 10))) = "";
-const std::string AAD_CHANNEL __attribute__ ((init_priority (CRYPTOPP_INIT_PRIORITY + 11))) = "AAD";
-const NullNameValuePairs s_nullNameValuePairs __attribute__ ((init_priority (CRYPTOPP_INIT_PRIORITY + 12)));
-const NameValuePairs &g_nullNameValuePairs = dynamic_cast<const NameValuePairs&>(s_nullNameValuePairs);
-#elif HAVE_MSC_INIT_PRIORITY
-#pragma warning(disable: 4073)
-#pragma init_seg(lib)
-const std::string DEFAULT_CHANNEL = "";
-const std::string AAD_CHANNEL = "AAD";
-const NullNameValuePairs s_nullNameValuePairs;
-const NameValuePairs &g_nullNameValuePairs = dynamic_cast<const NameValuePairs&>(s_nullNameValuePairs);
-#pragma warning(default: 4073)
-#else
-const std::string DEFAULT_CHANNEL = "";
-const std::string AAD_CHANNEL = "AAD";
-const simple_ptr<NullNameValuePairs> s_pNullNameValuePairs(new NullNameValuePairs);
-const NameValuePairs &g_nullNameValuePairs = *s_pNullNameValuePairs.m_p;
-#endif
-
BufferedTransformation & TheBitBucket()
{
static BitBucket bitBucket;
@@ -948,6 +928,31 @@ int LibraryVersion(CRYPTOPP_NOINLINE_DOTDOTDOT) {
return CRYPTOPP_BUILD_VERSION;
}
-NAMESPACE_END
+// ***************** C++ Static Initialization ********************
+// We can't put these in the anonymous namespace. DEFAULT_CHANNEL,
+// AAD_CHANNEL and g_nullNameValuePairs must be defined in CryptoPP.
+
+#if HAVE_GCC_INIT_PRIORITY
+const std::string DEFAULT_CHANNEL __attribute__ ((init_priority (CRYPTOPP_INIT_PRIORITY + 10))) = "";
+const std::string AAD_CHANNEL __attribute__ ((init_priority (CRYPTOPP_INIT_PRIORITY + 11))) = "AAD";
+const NullNameValuePairs s_nullNameValuePairs __attribute__ ((init_priority (CRYPTOPP_INIT_PRIORITY + 12)));
+const NameValuePairs &g_nullNameValuePairs = dynamic_cast<const NameValuePairs&>(s_nullNameValuePairs);
+#elif HAVE_MSC_INIT_PRIORITY
+#pragma warning(disable: 4075)
+#pragma init_seg(".CRT$XCU-010")
+const std::string DEFAULT_CHANNEL("");
+const std::string AAD_CHANNEL("AAD");
+const NullNameValuePairs s_nullNameValuePairs;
+const NameValuePairs &g_nullNameValuePairs = dynamic_cast<const NameValuePairs&>(s_nullNameValuePairs);
+#pragma warning(default: 4075)
+#else
+const std::string DEFAULT_CHANNEL = "";
+const std::string AAD_CHANNEL = "AAD";
+const simple_ptr<NullNameValuePairs> s_pNullNameValuePairs(new NullNameValuePairs);
+const NameValuePairs &g_nullNameValuePairs = *s_pNullNameValuePairs.m_p;
#endif
+
+NAMESPACE_END // CryptoPP
+
+#endif // CRYPTOPP_IMPORTS
|