From 44cc14fbee8c9cb033dcb94d9c54f532427a5768 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 11 Jan 2013 13:11:07 -0800 Subject: fix for mac builds --- indra/llcommon/llthreadlocalstorage.h | 69 ++++++++++++++++++----- indra/media_plugins/webkit/mac_volume_catcher.cpp | 1 + indra/newview/llfasttimerview.cpp | 2 +- indra/newview/llvowlsky.cpp | 2 +- 4 files changed, 58 insertions(+), 16 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h index 5a38d54eea..91f45d4f5f 100644 --- a/indra/llcommon/llthreadlocalstorage.h +++ b/indra/llcommon/llthreadlocalstorage.h @@ -152,43 +152,48 @@ public: virtual ~LLThreadLocalSingleton() { sInstance = NULL; - sInitState = DELETED; + setInitState(DELETED); } static void deleteSingleton() { delete sInstance; sInstance = NULL; - sInitState = DELETED; + setInitState(DELETED); } static DERIVED_TYPE* getInstance() { - if (sInitState == CONSTRUCTING) + EInitState init_state = getInitState(); + if (init_state == CONSTRUCTING) { llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << llendl; } - if (sInitState == DELETED) + if (init_state == DELETED) { llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; } - if (!sInstance) + if (!getIfExists()) { - sInitState = CONSTRUCTING; + setInitState(CONSTRUCTING); sInstance = new DERIVED_TYPE(); - sInitState = INITIALIZING; + setInitState(INITIALIZING); sInstance->initSingleton(); - sInitState = INITIALIZED; + setInitState(INITIALIZED); } - return sInstance; + return getIfExists(); } static DERIVED_TYPE* getIfExists() { +#if LL_DARWIN + return sInstance.get(); +#else return sInstance; +#endif } // Reference version of getInstance() @@ -202,16 +207,33 @@ public: // Use this to avoid accessing singletons before the can safely be constructed static bool instanceExists() { - return sInitState == INITIALIZED; + return getInitState() == INITIALIZED; } // Has this singleton already been deleted? // Use this to avoid accessing singletons from a static object's destructor static bool destroyed() { - return sInitState == DELETED; + return getInitState() == DELETED; } private: + static EInitState getInitState() + { +#if LL_DARWIN + return (EInitState)(int)sInitState.get(); +#else + return sInitState; +#endif + } + + static void setInitState(EInitState state) + { +#if LL_DARWIN + sInitState = (int*)state; +#else + sInitState = state; +#endif + } LLThreadLocalSingleton(const LLThreadLocalSingleton& other); virtual void initSingleton() {} @@ -221,10 +243,13 @@ private: #elif LL_LINUX static __thread DERIVED_TYPE* sInstance; static __thread EInitState sInitState; +#elif LL_DARWIN + static LLThreadLocalPointer sInstance; + static LLThreadLocalPointer sInitState; #endif }; -#ifdef LL_WINDOWS +#if LL_WINDOWS template __declspec(thread) DERIVED_TYPE* LLThreadLocalSingleton::sInstance = NULL; @@ -236,6 +261,12 @@ __thread DERIVED_TYPE* LLThreadLocalSingleton::sInstance = NULL; template __thread typename LLThreadLocalSingleton::EInitState LLThreadLocalSingleton::sInitState = LLThreadLocalSingleton::UNINITIALIZED; +#elif LL_DARWIN +template +LLThreadLocalPointer LLThreadLocalSingleton::sInstance; + +template +LLThreadLocalPointer LLThreadLocalSingleton::sInitState; #endif template @@ -249,7 +280,11 @@ public: LL_FORCE_INLINE static DERIVED_TYPE* getInstance() { +#if LL_DARWIN + return sInstance.get(); +#else return sInstance; +#endif } LL_FORCE_INLINE static void setInstance(DERIVED_TYPE* instance) @@ -258,18 +293,24 @@ public: } private: -#ifdef LL_WINDOWS +#if LL_WINDOWS static __declspec(thread) DERIVED_TYPE* sInstance; #elif LL_LINUX static __thread DERIVED_TYPE* sInstance; +#elif LL_DARWIN + static LLThreadLocalPointer sInstance; #endif }; +#if LL_WINDOWS template -#ifdef LL_WINDOWS __declspec(thread) DERIVED_TYPE* LLThreadLocalSingletonPointer::sInstance = NULL; #elif LL_LINUX +template __thread DERIVED_TYPE* LLThreadLocalSingletonPointer::sInstance = NULL; +#elif LL_DARWIN +template +LLThreadLocalPointer LLThreadLocalSingletonPointer::sInstance; #endif #endif // LL_LLTHREADLOCALSTORAGE_H diff --git a/indra/media_plugins/webkit/mac_volume_catcher.cpp b/indra/media_plugins/webkit/mac_volume_catcher.cpp index 8a06bb8487..c20bcd374d 100644 --- a/indra/media_plugins/webkit/mac_volume_catcher.cpp +++ b/indra/media_plugins/webkit/mac_volume_catcher.cpp @@ -38,6 +38,7 @@ #include #include #include +#include struct VolumeCatcherStorage; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 32ed662548..ba298ed819 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -514,7 +514,7 @@ void LLFastTimerView::draw() else { ms = LLUnit(frame_recording.getPeriodMean(*idp)); - calls = (S32)frame_recording.getPeriodMean((F32)idp->callCount()); + calls = (S32)frame_recording.getPeriodMean(idp->callCount()); } if (mDisplayCalls) diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 7f17fd3e56..717f215d3d 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -394,7 +394,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) segment->flush(); } - llinfos << "completed in " << llformat("%.2f", timer.getElapsedTimeF32()) << "seconds" << llendl; + llinfos << "completed in " << llformat("%.2f", timer.getElapsedTimeF32().value()) << "seconds" << llendl; } #else mStripsVerts = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); -- cgit v1.2.3