From 6fb470a39ef8900b71634333b0a2227dc8b62799 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Aug 2010 14:52:12 +0200 Subject: Add support for creating other build systems (meta-building) Add support for automake, VC++ 9, and VC++ 10. Also add the Win32 and 'NULL' threading model implementations. --- odb/details/tls.hxx | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 3 deletions(-) (limited to 'odb/details/tls.hxx') diff --git a/odb/details/tls.hxx b/odb/details/tls.hxx index 6d38e6b..7ce5c19 100644 --- a/odb/details/tls.hxx +++ b/odb/details/tls.hxx @@ -6,9 +6,101 @@ #ifndef ODB_DETAILS_TLS_HXX #define ODB_DETAILS_TLS_HXX -#include +#include -#define ODB_TLS_POINTER(type) tls -#define ODB_TLS_OBJECT(type) tls +#include + +#ifdef ODB_THREADS_NONE + +# define ODB_TLS_POINTER(type) type* +# define ODB_TLS_OBJECT(type) type + +namespace odb +{ + namespace details + { + template + inline T& + tls_get (T& x) + { + return x; + } + + template + inline T* + tls_get (T* p) + { + return p; + } + + template + inline void + tls_set (T*& rp, T* p) + { + rp = p; + } + } +} + +#elif defined(ODB_THREADS_POSIX) + +# include +# define ODB_TLS_POINTER(type) tls +# define ODB_TLS_OBJECT(type) tls + +#elif defined(ODB_THREADS_WIN32) + +# ifdef ODB_THREADS_TLS_DECLSPEC_POINTER +# define ODB_TLS_POINTER(type) __declspec(thread) type* + +namespace odb +{ + namespace details + { + template + inline T* + tls_get (T* p) + { + return p; + } + + template + inline void + tls_set (T*& rp, T* p) + { + rp = p; + } + } +} + +# else +# error unsupported TLS pointer model +# endif + +# ifdef ODB_THREADS_TLS_DECLSPEC_OBJECT +# define ODB_TLS_OBJECT(type) __declspec(thread) type + +namespace odb +{ + namespace details + { + template + inline T& + tls_get (T& x) + { + return x; + } + } +} + +# else +# error unsupported TLS object model +# endif + +#else +# error unknown threading model +#endif + +#include #endif // ODB_DETAILS_TLS_HXX -- cgit v1.1