diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 995eebd16aa279ec591e818fb82d4ef189b14255..fb2868ff98d417cd3952c196e15337dbc4954f0f 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -49,7 +49,7 @@ class ThreadTimerStack : public BlockTimerStackRecord, public LLThreadLocalSingleton<ThreadTimerStack> { - friend LLThreadLocalSingleton<ThreadTimerStack>; + friend class LLThreadLocalSingleton<ThreadTimerStack>; ThreadTimerStack() {} diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index e725bdd9fae7d2fa4b6ffbfcbaf38edcffd6b937..7e73afe06a63aa5450cf9713d591451e4e23d5d2 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -27,6 +27,7 @@ #define LLMEMORY_H #include "linden_common.h" +#include "stdint.h" class LLMutex ; diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h index fdf0c1808502796cad9f388bfae58d65685471ab..5a38d54eea30034cd18a80a0f87df8c61fc0a21c 100644 --- a/indra/llcommon/llthreadlocalstorage.h +++ b/indra/llcommon/llthreadlocalstorage.h @@ -215,15 +215,28 @@ class LLThreadLocalSingleton LLThreadLocalSingleton(const LLThreadLocalSingleton& other); virtual void initSingleton() {} +#ifdef LL_WINDOWS static __declspec(thread) DERIVED_TYPE* sInstance; static __declspec(thread) EInitState sInitState; +#elif LL_LINUX + static __thread DERIVED_TYPE* sInstance; + static __thread EInitState sInitState; +#endif }; +#ifdef LL_WINDOWS template<typename DERIVED_TYPE> __declspec(thread) DERIVED_TYPE* LLThreadLocalSingleton<DERIVED_TYPE>::sInstance = NULL; template<typename DERIVED_TYPE> __declspec(thread) typename LLThreadLocalSingleton<DERIVED_TYPE>::EInitState LLThreadLocalSingleton<DERIVED_TYPE>::sInitState = LLThreadLocalSingleton<DERIVED_TYPE>::UNINITIALIZED; +#elif LL_LINUX +template<typename DERIVED_TYPE> +__thread DERIVED_TYPE* LLThreadLocalSingleton<DERIVED_TYPE>::sInstance = NULL; + +template<typename DERIVED_TYPE> +__thread typename LLThreadLocalSingleton<DERIVED_TYPE>::EInitState LLThreadLocalSingleton<DERIVED_TYPE>::sInitState = LLThreadLocalSingleton<DERIVED_TYPE>::UNINITIALIZED; +#endif template<typename DERIVED_TYPE> class LLThreadLocalSingletonPointer @@ -245,10 +258,18 @@ class LLThreadLocalSingletonPointer } private: +#ifdef LL_WINDOWS static __declspec(thread) DERIVED_TYPE* sInstance; +#elif LL_LINUX + static __thread DERIVED_TYPE* sInstance; +#endif }; template<typename DERIVED_TYPE> +#ifdef LL_WINDOWS __declspec(thread) DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL; +#elif LL_LINUX +__thread DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL; +#endif #endif // LL_LLTHREADLOCALSTORAGE_H diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 285d4389af3465b3065bfe42a46867e428c0242f..e15cffd7d2ab8ea51880a348c13253c448549d78 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -614,7 +614,7 @@ struct MemFootprint<T*> static size_t measure() { - return MemFootPrint<T>::measure(); + return MemFootprint<T>::measure(); } }; @@ -730,17 +730,17 @@ class MemTrackable } // claim memory associated with other objects/data as our own, adding to our calculated footprint - template<typename T> - T& memClaim(T& value) + template<typename CLAIM_T> + CLAIM_T& memClaim(CLAIM_T& value) { - TrackMemImpl<T>::claim(*this, value); + TrackMemImpl<CLAIM_T>::claim(*this, value); return value; } - template<typename T> - const T& memClaim(const T& value) + template<typename CLAIM_T> + const CLAIM_T& memClaim(const CLAIM_T& value) { - TrackMemImpl<T>::claim(*this, value); + TrackMemImpl<CLAIM_T>::claim(*this, value); return value; } @@ -756,17 +756,17 @@ class MemTrackable } // remove memory we had claimed from our calculated footprint - template<typename T> - T& memDisclaim(T& value) + template<typename CLAIM_T> + CLAIM_T& memDisclaim(CLAIM_T& value) { - TrackMemImpl<T>::disclaim(*this, value); + TrackMemImpl<CLAIM_T>::disclaim(*this, value); return value; } - template<typename T> - const T& memDisclaim(const T& value) + template<typename CLAIM_T> + const CLAIM_T& memDisclaim(const CLAIM_T& value) { - TrackMemImpl<T>::disclaim(*this, value); + TrackMemImpl<CLAIM_T>::disclaim(*this, value); return value; } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index f2d7d42211b80a903333581cc126ddfe0c82be29..aa3200e5ad9ff99d5ac1cb7622beb0ddf5ebbff9 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -141,7 +141,7 @@ namespace LLTrace template <typename T> T getSum(const Count<T>& stat) const { - return (T)getSum(static_cast<const TraceType<CountAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getSum(static_cast<const TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getPerSec(const TraceType<CountAccumulator<F64> >& stat) const; @@ -149,7 +149,7 @@ namespace LLTrace template <typename T> T getPerSec(const Count<T>& stat) const { - return (T)getPerSec(static_cast<const TraceType<CountAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getPerSec(static_cast<const TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } U32 getSampleCount(const TraceType<CountAccumulator<F64> >& stat) const; @@ -162,7 +162,7 @@ namespace LLTrace template <typename T> T getSum(const Measurement<T>& stat) const { - return (T)getSum(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getSum(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getPerSec(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -170,7 +170,7 @@ namespace LLTrace template <typename T> T getPerSec(const Measurement<T>& stat) const { - return (T)getPerSec(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getPerSec(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMin(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -178,7 +178,7 @@ namespace LLTrace template <typename T> T getMin(const Measurement<T>& stat) const { - return (T)getMin(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getMin(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMax(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -186,7 +186,7 @@ namespace LLTrace template <typename T> T getMax(const Measurement<T>& stat) const { - return (T)getMax(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getMax(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getMean(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -194,7 +194,7 @@ namespace LLTrace template <typename T> T getMean(Measurement<T>& stat) const { - return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getStandardDeviation(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -202,7 +202,7 @@ namespace LLTrace template <typename T> T getStandardDeviation(const Measurement<T>& stat) const { - return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getMean(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } F64 getLastValue(const TraceType<MeasurementAccumulator<F64> >& stat) const; @@ -210,7 +210,7 @@ namespace LLTrace template <typename T> T getLastValue(const Measurement<T>& stat) const { - return (T)getLastValue(static_cast<const TraceType<MeasurementAccumulator<LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); + return (T)getLastValue(static_cast<const TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat)); } U32 getSampleCount(const TraceType<MeasurementAccumulator<F64> >& stat) const;