diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2006-12-11 09:13:12 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2006-12-11 09:13:12 +0000 |
commit | fc55c1a5dea1b96db0fd36b9c854000ad4137bf1 (patch) | |
tree | fccd8d4b77a0fcdcf0f94c2bd91fd67a3b3edf72 | |
parent | 0e9fb2487d1e8a4143e6a25d34e8b39439392926 (diff) | |
download | cryptopp-fc55c1a5dea1b96db0fd36b9c854000ad4137bf1.tar.gz |
improved method of disable inlining, fix compile on NetBSD
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@250 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r-- | config.h | 15 | ||||
-rw-r--r-- | factory.h | 5 | ||||
-rw-r--r-- | misc.h | 6 |
3 files changed, 19 insertions, 7 deletions
@@ -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 @@ -65,8 +65,7 @@ public: return factory->CreateObject(); } - // VC60 workaround: use "..." to prevent this function from being inlined - static ObjectFactoryRegistry<AbstractClass, instance> & Registry(...); + CRYPTOPP_NOINLINE static ObjectFactoryRegistry<AbstractClass, instance> & Registry(CRYPTOPP_NOINLINE_DOTDOTDOT); private: // use void * instead of ObjectFactory<AbstractClass> * to save code size @@ -75,7 +74,7 @@ private: }; template <class AbstractClass, int instance> -ObjectFactoryRegistry<AbstractClass, instance> & ObjectFactoryRegistry<AbstractClass, instance>::Registry(...) +ObjectFactoryRegistry<AbstractClass, instance> & ObjectFactoryRegistry<AbstractClass, instance>::Registry(CRYPTOPP_NOINLINE_DOTDOTDOT) { static ObjectFactoryRegistry<AbstractClass, instance> s_registry; return s_registry; @@ -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 <class T, class F, int instance> -const T & Singleton<T, F, instance>::Ref(...) const +const T & Singleton<T, F, instance>::Ref(CRYPTOPP_NOINLINE_DOTDOTDOT) const { static simple_ptr<T> s_pObject; static char s_objectState = 0; |