improved method of disable inlining, fix compile on NetBSD
parent
813d784ea5
commit
0efd938656
15
config.h
15
config.h
|
|
@ -212,6 +212,19 @@ NAMESPACE_END
|
||||||
#define CRYPTOPP_X86ASM_AVAILABLE
|
#define CRYPTOPP_X86ASM_AVAILABLE
|
||||||
#endif
|
#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 ********************
|
// ***************** determine availability of OS features ********************
|
||||||
|
|
||||||
#ifndef NO_OS_DEPENDENCE
|
#ifndef NO_OS_DEPENDENCE
|
||||||
|
|
@ -220,7 +233,7 @@ NAMESPACE_END
|
||||||
#define CRYPTOPP_WIN32_AVAILABLE
|
#define CRYPTOPP_WIN32_AVAILABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__unix__) || defined(__MACH__)
|
#if defined(__unix__) || defined(__MACH__) || defined(__NetBSD__)
|
||||||
#define CRYPTOPP_UNIX_AVAILABLE
|
#define CRYPTOPP_UNIX_AVAILABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,7 @@ public:
|
||||||
return factory->CreateObject();
|
return factory->CreateObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
// VC60 workaround: use "..." to prevent this function from being inlined
|
CRYPTOPP_NOINLINE static ObjectFactoryRegistry<AbstractClass, instance> & Registry(CRYPTOPP_NOINLINE_DOTDOTDOT);
|
||||||
static ObjectFactoryRegistry<AbstractClass, instance> & Registry(...);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// use void * instead of ObjectFactory<AbstractClass> * to save code size
|
// use void * instead of ObjectFactory<AbstractClass> * to save code size
|
||||||
|
|
@ -75,7 +74,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class AbstractClass, int instance>
|
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;
|
static ObjectFactoryRegistry<AbstractClass, instance> s_registry;
|
||||||
return s_registry;
|
return s_registry;
|
||||||
|
|
|
||||||
6
misc.h
6
misc.h
|
|
@ -77,15 +77,15 @@ class Singleton
|
||||||
public:
|
public:
|
||||||
Singleton(F objectFactory = F()) : m_objectFactory(objectFactory) {}
|
Singleton(F objectFactory = F()) : m_objectFactory(objectFactory) {}
|
||||||
|
|
||||||
// VC60 workaround: use "..." to prevent this function from being inlined
|
// prevent this function from being inlined
|
||||||
const T & Ref(...) const;
|
CRYPTOPP_NOINLINE const T & Ref(CRYPTOPP_NOINLINE_DOTDOTDOT) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
F m_objectFactory;
|
F m_objectFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class F, int instance>
|
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 simple_ptr<T> s_pObject;
|
||||||
static char s_objectState = 0;
|
static char s_objectState = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue