Преглед на файлове

enable thread-local variables when possible (#654)

Julius Pfrommer преди 8 години
родител
ревизия
a5c41a4c14
променени са 1 файла, в които са добавени 7 реда и са изтрити 8 реда
  1. 7 8
      src/ua_util.h

+ 7 - 8
src/ua_util.h

@@ -47,16 +47,15 @@
 /* Thread Local Storage */
 /************************/
 
-#ifdef UA_ENABLE_MULTITHREADING
-# ifdef __GNUC__
-#  define UA_THREAD_LOCAL __thread
-# elif defined(_MSC_VER)
-#  define UA_THREAD_LOCAL __declspec(thread)
-# else
-#  error No thread local storage keyword defined for this compiler
-# endif
+#if __STDC_VERSION__ >= 201112L
+# define UA_THREAD_LOCAL _Thread_local /* C11 */
+#elif defined(__GNUC__)
+# define UA_THREAD_LOCAL __thread /* GNU extension */
+#elif defined(_MSC_VER)
+# define UA_THREAD_LOCAL __declspec(thread) /* MSVC extension */
 #else
 # define UA_THREAD_LOCAL
+# warning The compiler does not allow thread-local variables. The library can be built, but will not be thread safe.
 #endif
 
 /********************/