Add IBM XLC init priority support

This commit is contained in:
Jeffrey Walton 2018-11-30 08:23:35 -05:00
parent 52613240ae
commit 3e909c13d4
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
4 changed files with 21 additions and 21 deletions

@ -373,6 +373,8 @@ NAMESPACE_END
#define CRYPTOPP_SECTION_INIT __attribute__((section ("__DATA,__data")))
#elif (defined(__ELF__) && (CRYPTOPP_GCC_VERSION >= 40300))
#define CRYPTOPP_SECTION_INIT __attribute__((section ("nocommon")))
#elif defined(__ELF__) && (defined(__xlC__) || defined(__ibmxl__))
#define CRYPTOPP_SECTION_INIT __attribute__((section ("nocommon")))
#else
#define CRYPTOPP_SECTION_INIT
#endif
@ -858,7 +860,7 @@ NAMESPACE_END
#if defined(_MSC_VER)
# define CRYPTOPP_NOINLINE_DOTDOTDOT
# define CRYPTOPP_NOINLINE __declspec(noinline)
#elif defined(__xlc__) || defined(__xlC__)
#elif defined(__xlc__) || defined(__xlC__) || defined(__ibmxl__)
# define CRYPTOPP_NOINLINE_DOTDOTDOT ...
# define CRYPTOPP_NOINLINE __attribute__((noinline))
#elif defined(__GNUC__)
@ -904,10 +906,8 @@ NAMESPACE_END
// CRYPTOPP_USER_PRIORITY is for other libraries and user code that is using Crypto++
// and managing C++ static object creation. It is guaranteed not to conflict with
// values used by (or would be used by) the Crypto++ library.
#if defined(CRYPTOPP_INIT_PRIORITY) && (CRYPTOPP_INIT_PRIORITY > 0)
# define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY + 101)
#else
# define CRYPTOPP_USER_PRIORITY 350
#ifndef CRYPTOPP_USER_PRIORITY
# define CRYPTOPP_USER_PRIORITY (CRYPTOPP_INIT_PRIORITY+101)
#endif
// Most platforms allow us to specify when to create C++ objects. Apple and Sun do not.
@ -916,6 +916,8 @@ NAMESPACE_END
# define HAVE_GCC_INIT_PRIORITY 1
# elif (CRYPTOPP_MSC_VERSION >= 1310)
# define HAVE_MSC_INIT_PRIORITY 1
# elif defined(__xlc__) || defined(__xlC__) || defined(__ibmxl__)
# define HAVE_XLC_INIT_PRIORITY 1
# endif
#endif // CRYPTOPP_INIT_PRIORITY, NO_OS_DEPENDENCE, Apple, Sun
@ -1050,15 +1052,6 @@ NAMESPACE_END
# define CRYPTOPP_DEPRECATED(msg)
#endif
// ************** Instrumentation ***************
// GCC does not support; see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=78204
#if (CRYPTOPP_LLVM_CLANG_VERSION >= 30700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70000)
# define CRYPTOPP_NO_SANITIZE(x) __attribute__((no_sanitize(x)))
#else
# define CRYPTOPP_NO_SANITIZE(x)
#endif
// ***************** C++11 related ********************
// Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx

@ -1069,6 +1069,10 @@ public:
#pragma init_seg(".CRT$XCU")
const InitCpu s_init;
#pragma warning(default: 4075)
#elif HAVE_XLC_INIT_PRIORITY
// XLC needs constant, not a define
#pragma priority(270)
const InitCpu s_init;
#else
const InitCpu s_init;
#endif

@ -4826,6 +4826,13 @@ public:
const Integer g_one(1L);
const Integer g_two(2L);
#pragma warning(default: 4075)
#elif HAVE_XLC_INIT_PRIORITY
// XLC needs constant, not a define
#pragma priority(280)
const InitInteger s_init;
const Integer g_zero(0L);
const Integer g_one(1L);
const Integer g_two(2L);
#else
const InitInteger s_init;
#endif
@ -4834,7 +4841,7 @@ public:
const Integer &Integer::Zero()
{
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY)
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_zero;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT)
static const Integer s_zero(0L);
@ -4846,7 +4853,7 @@ const Integer &Integer::Zero()
const Integer &Integer::One()
{
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY)
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_one;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT)
static const Integer s_one(1L);
@ -4858,7 +4865,7 @@ const Integer &Integer::One()
const Integer &Integer::Two()
{
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY)
#if defined(HAVE_GCC_INIT_PRIORITY) || defined(HAVE_MSC_INIT_PRIORITY) || defined(HAVE_XLC_INIT_PRIORITY)
return g_two;
#elif defined(CRYPTOPP_CXX11_DYNAMIC_INIT)
static const Integer s_two(2L);

@ -51,8 +51,6 @@ bool CPU_ProbePower9()
{
#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
return false;
#elif defined(__xlC__) && defined(__linux__)
return false;
#elif defined(CRYPTOPP_POWER9_AVAILABLE)
# if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY)
// longjmp and clobber warnings. Volatile is required.
@ -100,8 +98,6 @@ bool CPU_ProbeDARN()
{
#if defined(CRYPTOPP_NO_CPU_FEATURE_PROBES)
return false;
#elif defined(__xlC__) && defined(__linux__)
return false;
#else
# if defined(CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY)
// longjmp and clobber warnings. Volatile is required.