Skip to content

Commit

Permalink
always enable thread-local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Sep 19, 2017
1 parent 9637329 commit 89ec582
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/ua_util.h
Expand Up @@ -18,18 +18,20 @@
#define container_of(ptr, type, member) \
(type *)((uintptr_t)ptr - offsetof(type,member))

/* Thread Local Storage */
#ifdef UA_ENABLE_MULTITHREADING
# 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
# error The compiler does not support thread-local variables.
# 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
# warning The compiler does not support thread-local variables
# define UA_THREAD_LOCAL
#endif

Expand Down

0 comments on commit 89ec582

Please sign in to comment.