Browse Source

always enable thread-local variables

Julius Pfrommer 7 years ago
parent
commit
86d9030a67
1 changed files with 14 additions and 14 deletions
  1. 14 14
      src/ua_util.h

+ 14 - 14
src/ua_util.h

@@ -17,21 +17,21 @@ extern "C" {
 /* Macro-Expand for MSVC workarounds */
 #define UA_MACRO_EXPAND(x) x
 
-#ifdef UA_ENABLE_MULTITHREADING
-/* Thread Local Storage */
-# if defined(__STDC_VERSION__) && __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
+/* Thread-Local Storage
+ * --------------------
+ * Thread-local variables are always enabled. Also when the library is built
+ * with ``UA_ENABLE_MULTITHREADING`` disabled. Otherwise, if multiple clients
+ * run in separate threads, race conditions may occur via global variables in
+ * the encoding layer. */
+#if defined(__STDC_VERSION__) && __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 support thread-local variables
+# define UA_THREAD_LOCAL
 #endif
 
 /* Integer Shortnames