Skip to content

Commit

Permalink
enable thread-local variables when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Jun 22, 2016
1 parent 097312f commit 6fc4e97
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/ua_util.h
Expand Up @@ -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

/********************/
Expand Down

0 comments on commit 6fc4e97

Please sign in to comment.