diff --git a/indra/cwdebug/debug.h b/indra/cwdebug/debug.h index f127da767..9e832a44c 100644 --- a/indra/cwdebug/debug.h +++ b/indra/cwdebug/debug.h @@ -38,15 +38,6 @@ #include -#if LL_WINDOWS -// On windows, thread-local data is automatically exported. -#define LL_COMMON_API_TLS __declspec(thread) -#define CWD_TLS __declspec(thread) -#else -#define LL_COMMON_API_TLS LL_COMMON_API __thread -#define CWD_TLS __thread -#endif - namespace debug { namespace libcwd { diff --git a/indra/llcommon/aithreadid.cpp b/indra/llcommon/aithreadid.cpp index dfb4a2660..7d179e8e3 100644 --- a/indra/llcommon/aithreadid.cpp +++ b/indra/llcommon/aithreadid.cpp @@ -34,8 +34,9 @@ AIThreadID const AIThreadID::sNone(AIThreadID::none); apr_os_thread_t AIThreadID::sMainThreadID; +apr_os_thread_t const undefinedID = (apr_os_thread_t)-1; #ifndef LL_DARWIN -apr_os_thread_t ll_thread_local AIThreadID::lCurrentThread = AIThreadID::undefinedID; +apr_os_thread_t CWD_TLS AIThreadID::lCurrentThread; #endif void AIThreadID::set_main_thread_id(void) diff --git a/indra/llcommon/aithreadid.h b/indra/llcommon/aithreadid.h index c565b5913..9f7893c66 100644 --- a/indra/llcommon/aithreadid.h +++ b/indra/llcommon/aithreadid.h @@ -33,28 +33,22 @@ #include // apr_os_thread_t, apr_os_thread_current(), apr_os_thread_equal(). #include // std::ostream. -#include "llpreprocessor.h" // LL_COMMON_API +#include "llpreprocessor.h" // LL_COMMON_API, LL_COMMON_API_TLS #include "llerror.h" -#if LL_WINDOWS -#define ll_thread_local __declspec(thread) -#else -#define ll_thread_local __thread -#endif - // Lightweight wrapper around apr_os_thread_t. // This class introduces no extra assembly code after optimization; it's only intend is to provide type-safety. -class LL_COMMON_API AIThreadID +class AIThreadID { private: apr_os_thread_t mID; - static apr_os_thread_t sMainThreadID; - static apr_os_thread_t const undefinedID = (apr_os_thread_t)-1; + static LL_COMMON_API apr_os_thread_t sMainThreadID; + static LL_COMMON_API apr_os_thread_t const undefinedID; #ifndef LL_DARWIN - static ll_thread_local apr_os_thread_t lCurrentThread; + static LL_COMMON_API_TLS apr_os_thread_t lCurrentThread; #endif public: - static AIThreadID const sNone; + static LL_COMMON_API AIThreadID const sNone; enum undefined_thread_t { none }; enum dout_print_t { DoutPrint }; diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h index 009871908..be0ec94a3 100644 --- a/indra/llcommon/llpreprocessor.h +++ b/indra/llcommon/llpreprocessor.h @@ -195,4 +195,16 @@ # define LL_COMMON_API #endif // LL_COMMON_LINK_SHARED +// Darwin does not support thread-local data. +#ifndef LL_DARWIN +#if LL_WINDOWS +// On windows, thread-local data is automatically exported. +#define LL_COMMON_API_TLS __declspec(thread) +#define CWD_TLS __declspec(thread) +#else // Linux +#define LL_COMMON_API_TLS LL_COMMON_API __thread +#define CWD_TLS __thread +#endif +#endif + #endif // not LL_LINDEN_PREPROCESSOR_H