diff options
author | 2016-07-13 14:48:02 +0100 | |
---|---|---|
committer | 2016-07-13 14:48:02 +0100 | |
commit | 6256946dee9ac9c7da85e10405ab754aafdb8253 (patch) | |
tree | a91ad553f882872071ded987349ea23b6c4e2493 /3rdparty/bx | |
parent | 423097c40f2e2c645930ff16954b75c920a80da5 (diff) |
bx: further refactor #ifdefs
Trying to evaluate __GLIBC__ will result in an error if is not defined,
if the preprocessor does not short-cut the evaluation.
Split the macros onto separate lines and define the result in a new
BX_USE_GLIBC_PTHREAD_SETNAME_NP macro to avoid duplication.
Diffstat (limited to '3rdparty/bx')
-rw-r--r-- | 3rdparty/bx/include/bx/thread.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/3rdparty/bx/include/bx/thread.h b/3rdparty/bx/include/bx/thread.h index bd74f66f4e3..268ca779dfa 100644 --- a/3rdparty/bx/include/bx/thread.h +++ b/3rdparty/bx/include/bx/thread.h @@ -6,12 +6,19 @@ #ifndef BX_THREAD_H_HEADER_GUARD #define BX_THREAD_H_HEADER_GUARD +#define BX_USE_GLIBC_PTHREAD_SETNAME_NP 0 +#if defined(__GLIBC__) +# if ( (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) ) ) +# define BX_USE_GLIBC_PTHREAD_SETNAME_NP 1 +# endif +#endif + #if BX_PLATFORM_POSIX # include <pthread.h> -# if defined(__GLIBC__) -# if !( (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) ) ) -# include <sys/prctl.h> -# endif +# if BX_USE_GLIBC_PTHREAD_SETNAME_NP +/* pthread.h provides pthread_setname_np */ +# elif defined(BX_PLATFORM_LINUX) +# include <sys/prctl.h> # elif defined(BX_PLATFORM_BSD) # include <pthread_np.h> # endif @@ -158,7 +165,7 @@ namespace bx { #if BX_PLATFORM_OSX || BX_PLATFORM_IOS pthread_setname_np(_name); -#elif defined(__GLIBC__) && (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) ) +#elif BX_USE_GLIBC_PTHREAD_SETNAME_NP pthread_setname_np(m_handle, _name); #elif BX_PLATFORM_LINUX prctl(PR_SET_NAME,_name, 0, 0, 0); |