From 0efd9386568600205373df85341b3c14fe24accf Mon Sep 17 00:00:00 2001 From: weidai Date: Mon, 11 Dec 2006 09:13:12 +0000 Subject: [PATCH] improved method of disable inlining, fix compile on NetBSD --- config.h | 15 ++++++++++++++- factory.h | 5 ++--- misc.h | 6 +++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index f0315101..30414e59 100644 --- a/config.h +++ b/config.h @@ -212,6 +212,19 @@ NAMESPACE_END #define CRYPTOPP_X86ASM_AVAILABLE #endif +// how to disable inlining +#if defined(_MSC_VER) && _MSC_VER >= 1300 +# define CRYPTOPP_NOINLINE_DOTDOTDOT +# define CRYPTOPP_NOINLINE __declspec(noinline) +#elif defined(__GNUC__) +# define CRYPTOPP_NOINLINE_DOTDOTDOT +# define CRYPTOPP_NOINLINE __attribute__((noinline)) +#else +# define CRYPTOPP_NOINLINE_DOTDOTDOT ... +# define CRYPTOPP_NOINLINE +#endif + + // ***************** determine availability of OS features ******************** #ifndef NO_OS_DEPENDENCE @@ -220,7 +233,7 @@ NAMESPACE_END #define CRYPTOPP_WIN32_AVAILABLE #endif -#if defined(__unix__) || defined(__MACH__) +#if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__) #define CRYPTOPP_UNIX_AVAILABLE #endif diff --git a/factory.h b/factory.h index 67c97688..50e4313a 100644 --- a/factory.h +++ b/factory.h @@ -65,8 +65,7 @@ public: return factory->CreateObject(); } - // VC60 workaround: use "..." to prevent this function from being inlined - static ObjectFactoryRegistry & Registry(...); + CRYPTOPP_NOINLINE static ObjectFactoryRegistry & Registry(CRYPTOPP_NOINLINE_DOTDOTDOT); private: // use void * instead of ObjectFactory * to save code size @@ -75,7 +74,7 @@ private: }; template -ObjectFactoryRegistry & ObjectFactoryRegistry::Registry(...) +ObjectFactoryRegistry & ObjectFactoryRegistry::Registry(CRYPTOPP_NOINLINE_DOTDOTDOT) { static ObjectFactoryRegistry s_registry; return s_registry; diff --git a/misc.h b/misc.h index 0b166ecf..35462b8b 100644 --- a/misc.h +++ b/misc.h @@ -77,15 +77,15 @@ class Singleton public: Singleton(F objectFactory = F()) : m_objectFactory(objectFactory) {} - // VC60 workaround: use "..." to prevent this function from being inlined - const T & Ref(...) const; + // prevent this function from being inlined + CRYPTOPP_NOINLINE const T & Ref(CRYPTOPP_NOINLINE_DOTDOTDOT) const; private: F m_objectFactory; }; template -const T & Singleton::Ref(...) const +const T & Singleton::Ref(CRYPTOPP_NOINLINE_DOTDOTDOT) const { static simple_ptr s_pObject; static char s_objectState = 0;