##############################################################################
# Find dependencies
+# Check for compiler TLS support. We don't use compiler TLS support on Windows
+# because, even if the compiler supports it, Windows XP does not support TLS on
+# DLLs.
+if (NOT WIN32)
+ include (CheckCXXSourceCompiles)
+ check_cxx_source_compiles("__thread int i; int main() { return 0; }" HAVE_COMPILER_TLS)
+ if (HAVE_COMPILER_TLS)
+ add_definitions (-DHAVE_COMPILER_TLS=__thread)
+ else ()
+ message (WARNING "C++ compiler does not support __thread keyword.")
+ endif ()
+endif ()
+
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set (CMAKE_USE_PYTHON_VERSION 2.7 2.6)
/*
- * These features are not supported on Windows XP
+ * This feature is not supported on Windows XP
*/
-#define USE_WIN32_DECLSPEC_THREAD 0
#define USE_WIN32_CONDITION_VARIABLES 0
* - http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/Thread_002dLocal.html
* - http://msdn.microsoft.com/en-us/library/9w1sdazb.aspx
*/
-#if !defined(_WIN32) || USE_WIN32_DECLSPEC_THREAD
-# if defined(_MSC_VER)
-# define OS_THREAD_SPECIFIC_PTR(_type) __declspec(thread) _type *
-# elif defined(__GNUC__)
-# define OS_THREAD_SPECIFIC_PTR(_type) __thread _type *
-# endif
-#endif
-#if !defined(OS_THREAD_SPECIFIC_PTR)
+#if defined(HAVE_COMPILER_TLS)
+# define OS_THREAD_SPECIFIC_PTR(_type) HAVE_COMPILER_TLS _type *
+#else
# define OS_THREAD_SPECIFIC_PTR(_type) os::thread_specific_ptr< _type >
#endif