From 5f608c0a23487ae78cdc134b1e685a6c3cd4ec19 Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 19 Nov 2014 08:01:28 -0700 Subject: OPEN-282 Use pthreads for TLS on mac --- indra/llcommon/llthreadlocalstorage.h | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'indra/llcommon/llthreadlocalstorage.h') diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h index ec3b52c8cb..da648902aa 100644 --- a/indra/llcommon/llthreadlocalstorage.h +++ b/indra/llcommon/llthreadlocalstorage.h @@ -130,56 +130,29 @@ class LLThreadLocalSingletonPointer public: LL_FORCE_INLINE static DERIVED_TYPE* getInstance() { -#if LL_DARWIN - createTLSKey(); - return (DERIVED_TYPE*)pthread_getspecific(sInstanceKey); -#else return sInstance; -#endif } static void setInstance(DERIVED_TYPE* instance) { -#if LL_DARWIN - createTLSKey(); - pthread_setspecific(sInstanceKey, (void*)instance); -#else sInstance = instance; -#endif } private: #if LL_WINDOWS static __declspec(thread) DERIVED_TYPE* sInstance; -#elif LL_LINUX +#else static __thread DERIVED_TYPE* sInstance; -#elif LL_DARWIN - static void TLSError() - { - LL_ERRS() << "Could not create thread local storage" << LL_ENDL; - } - static void createTLSKey() - { - static S32 key_created = pthread_key_create(&sInstanceKey, NULL); - if (key_created != 0) - { - LL_ERRS() << "Could not create thread local storage" << LL_ENDL; - } - } - static pthread_key_t sInstanceKey; #endif }; #if LL_WINDOWS template __declspec(thread) DERIVED_TYPE* LLThreadLocalSingletonPointer::sInstance = NULL; -#elif LL_LINUX +#else template __thread DERIVED_TYPE* LLThreadLocalSingletonPointer::sInstance = NULL; -#elif LL_DARWIN -template -pthread_key_t LLThreadLocalSingletonPointer::sInstanceKey; #endif #endif // LL_LLTHREADLOCALSTORAGE_H -- cgit v1.2.3 From 6df6aef62176328c3b0fafa43fd611d4e25ef35c Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 19 Nov 2014 22:27:36 -0700 Subject: OPEN-282 - Define LL_THREAD_LOCAL for our platforms in order to unify TLS support --- indra/llcommon/llthreadlocalstorage.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'indra/llcommon/llthreadlocalstorage.h') diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h index da648902aa..3b5786023f 100644 --- a/indra/llcommon/llthreadlocalstorage.h +++ b/indra/llcommon/llthreadlocalstorage.h @@ -139,20 +139,10 @@ public: } private: - -#if LL_WINDOWS - static __declspec(thread) DERIVED_TYPE* sInstance; -#else - static __thread DERIVED_TYPE* sInstance; -#endif + static LL_THREAD_LOCAL DERIVED_TYPE* sInstance; }; -#if LL_WINDOWS -template -__declspec(thread) DERIVED_TYPE* LLThreadLocalSingletonPointer::sInstance = NULL; -#else template -__thread DERIVED_TYPE* LLThreadLocalSingletonPointer::sInstance = NULL; -#endif +LL_THREAD_LOCAL DERIVED_TYPE* LLThreadLocalSingletonPointer::sInstance = NULL; #endif // LL_LLTHREADLOCALSTORAGE_H -- cgit v1.2.3