aboutsummaryrefslogtreecommitdiff
path: root/odb/details
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-09-14 15:13:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-09-14 15:13:43 +0200
commitf7c9c07973ff5a1041036478fcae87f77457d737 (patch)
tree53c048a7b1f9a06af8d3ce029ac77451a5beeb8f /odb/details
parentf7bf16d50f6f08c66b1bae35e2dab327d560b0f3 (diff)
Use __thread keyword if available
Diffstat (limited to 'odb/details')
-rw-r--r--odb/details/config.h.in2
-rw-r--r--odb/details/tls.hxx28
2 files changed, 29 insertions, 1 deletions
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 <odb/details/posix/tls.hxx>
-# define ODB_TLS_POINTER(type) tls<type*>
+
+# ifdef ODB_THREADS_TLS_KEYWORD
+# define ODB_TLS_POINTER(type) __thread type*
+
+namespace odb
+{
+ namespace details
+ {
+ template <typename T>
+ inline T*
+ tls_get (T* p)
+ {
+ return p;
+ }
+
+ template <typename T>
+ inline void
+ tls_set (T*& rp, T* p)
+ {
+ rp = p;
+ }
+ }
+}
+
+# else
+# define ODB_TLS_POINTER(type) tls<type*>
+# endif
# define ODB_TLS_OBJECT(type) tls<type>
#elif defined(ODB_THREADS_WIN32)