From f7c9c07973ff5a1041036478fcae87f77457d737 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 14 Sep 2010 15:13:43 +0200 Subject: Use __thread keyword if available --- odb/details/config.h.in | 2 ++ odb/details/tls.hxx | 28 +++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'odb/details') diff --git a/odb/details/config.h.in b/odb/details/config.h.in index a55352a..acab724 100644 --- a/odb/details/config.h.in +++ b/odb/details/config.h.in @@ -12,6 +12,8 @@ #undef ODB_THREADS_NONE #undef ODB_THREADS_POSIX #undef ODB_THREADS_WIN32 +#undef ODB_THREADS_TLS_KEYWORD +#undef ODB_THREADS_TLS_DECLSPEC #undef LIBODB_STATIC_LIB diff --git a/odb/details/tls.hxx b/odb/details/tls.hxx index 2ed68ab..2c19081 100644 --- a/odb/details/tls.hxx +++ b/odb/details/tls.hxx @@ -54,7 +54,33 @@ namespace odb #elif defined(ODB_THREADS_POSIX) # include -# define ODB_TLS_POINTER(type) tls + +# ifdef ODB_THREADS_TLS_KEYWORD +# define ODB_TLS_POINTER(type) __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 +# define ODB_TLS_POINTER(type) tls +# endif # define ODB_TLS_OBJECT(type) tls #elif defined(ODB_THREADS_WIN32) -- cgit v1.1