diff --git a/include/bx/macros.h b/include/bx/macros.h index 279343b..4ee97a8 100644 --- a/include/bx/macros.h +++ b/include/bx/macros.h @@ -48,6 +48,18 @@ #define BX_ALIGNOF(_type) __alignof(_type) +#if defined(__has_feature) +# define BX_CLANG_HAS_FEATURE(_x) __has_feature(_x) +#else +# define BX_CLANG_HAS_FEATURE(_x) 0 +#endif // defined(__has_feature) + +#if defined(__has_extension) +# define BX_CLANG_HAS_EXTENSION(_x) __has_extension(_x) +#else +# define BX_CLANG_HAS_EXTENSION(_x) 0 +#endif // defined(__has_extension) + #if BX_COMPILER_GCC || BX_COMPILER_CLANG # define BX_ALIGN_DECL(_align, _decl) _decl __attribute__( (aligned(_align) ) ) # define BX_ALLOW_UNUSED __attribute__( (unused) ) @@ -60,11 +72,12 @@ # define BX_NO_VTABLE # define BX_OVERRIDE # define BX_PRINTF_ARGS(_format, _args) __attribute__ ( (format(__printf__, _format, _args) ) ) -# if BX_COMPILER_CLANG && (BX_PLATFORM_OSX || BX_PLATFORM_IOS) -# define BX_THREAD /* not supported right now */ -# else -# define BX_THREAD __thread +# if BX_CLANG_HAS_FEATURE(cxx_thread_local) +# define BX_THREAD_LOCAL __thread # endif // BX_COMPILER_CLANG +# if BX_COMPILER_GCC >= 40200 +# define BX_THREAD_LOCAL __thread +# endif // BX_COMPILER_GCC # define BX_ATTRIBUTE(_x) __attribute__( (_x) ) # if BX_COMPILER_MSVC_COMPATIBLE # define __stdcall @@ -81,18 +94,12 @@ # define BX_NO_VTABLE __declspec(novtable) # define BX_OVERRIDE override # define BX_PRINTF_ARGS(_format, _args) -# define BX_THREAD __declspec(thread) +# define BX_THREAD_LOCAL __declspec(thread) # define BX_ATTRIBUTE(_x) #else # error "Unknown BX_COMPILER_?" #endif -#if defined(__has_extension) -# define BX_CLANG_HAS_EXTENSION(_x) __has_extension(_x) -#else -# define BX_CLANG_HAS_EXTENSION(_x) 0 -#endif // defined(__has_extension) - // #define BX_STATIC_ASSERT(_condition, ...) static_assert(_condition, "" __VA_ARGS__) #define BX_STATIC_ASSERT(_condition, ...) typedef char BX_CONCATENATE(BX_STATIC_ASSERT_, __LINE__)[1][(_condition)] BX_ATTRIBUTE(unused) diff --git a/include/bx/thread.h b/include/bx/thread.h index 8b20d11..325b0aa 100644 --- a/include/bx/thread.h +++ b/include/bx/thread.h @@ -260,7 +260,7 @@ namespace bx uint32_t m_id; }; -#elif !(BX_PLATFORM_WINRT) +#elif !BX_PLATFORM_WINRT class TlsData { @@ -291,7 +291,7 @@ namespace bx private: pthread_key_t m_id; }; -#endif // BX_PLATFORM_WINDOWS +#endif // BX_PLATFORM_* } // namespace bx