summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-11 09:13:12 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-11 09:13:12 +0000
commitfc55c1a5dea1b96db0fd36b9c854000ad4137bf1 (patch)
treefccd8d4b77a0fcdcf0f94c2bd91fd67a3b3edf72
parent0e9fb2487d1e8a4143e6a25d34e8b39439392926 (diff)
downloadcryptopp-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.h15
-rw-r--r--factory.h5
-rw-r--r--misc.h6
3 files changed, 19 insertions, 7 deletions
diff --git a/config.h b/config.h
index f031510..30414e5 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 67c9768..50e4313 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<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;
diff --git a/misc.h b/misc.h
index 0b166ec..35462b8 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 <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;