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/Makefile.am | 4 ++-- odb/details/config.h.in | 2 ++ odb/details/tls.hxx | 28 +++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) (limited to 'odb') diff --git a/odb/Makefile.am b/odb/Makefile.am index 9922a37..d671b16 100644 --- a/odb/Makefile.am +++ b/odb/Makefile.am @@ -22,5 +22,5 @@ libodb_la_SOURCES += __path__(win32_sources) __path__(win32_dll_sources) nobase_odbinclude_HEADERS += __path__(win32_headers) endif -libodb_la_CPPFLAGS= -I'$(top_builddir)' -I'$(top_srcdir)' -DLIBODB_DYNAMIC_LIB -libodb_la_LDFLAGS = -release __value__(interface_version) -no-undefined +AM_CPPFLAGS= -I'$(top_builddir)' -I'$(top_srcdir)' -DLIBODB_DYNAMIC_LIB +AM_LDFLAGS = -release __value__(interface_version) -no-undefined 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