diff --git a/include/wx/string.h b/include/wx/string.h index 9377c541ca..603a75983b 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -48,14 +48,7 @@ // notice that this optimization is well worth using even in debug builds as it // changes asymptotic complexity of algorithms using indices to iterate over // wxString back to expected linear from quadratic -// -// also notice that wxTLS_TYPE() (__declspec(thread) in this case) is unsafe to -// use in DLL build under pre-Vista Windows so we disable this code for now, if -// anybody really needs to use UTF-8 build under Windows with this optimization -// it would have to be re-tested and probably corrected -// CS: under OSX release builds the string destructor/cache cleanup sometimes -// crashes, disable until we find the true reason or a better workaround -#if wxUSE_UNICODE_UTF8 && !defined(__WINDOWS__) && !defined(__WXOSX__) +#if wxUSE_UNICODE_UTF8 #define wxUSE_STRING_POS_CACHE 1 #else #define wxUSE_STRING_POS_CACHE 0 @@ -445,8 +438,8 @@ private: unsigned lastUsed; }; - static wxTLS_TYPE(Cache) ms_cache; - static Cache& GetCache() { return wxTLS_VALUE(ms_cache); } + static wxTHREAD_SPECIFIC_DECL Cache ms_cache; + static Cache& GetCache() { return ms_cache; } static Cache::Element *GetCacheBegin() { return GetCache().cached; } static Cache::Element *GetCacheEnd() { return GetCacheBegin() + Cache::SIZE; } diff --git a/src/common/string.cpp b/src/common/string.cpp index c7f9ceac60..743be57b2b 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -81,7 +81,7 @@ const size_t wxString::npos = (size_t) -1; #if wxUSE_STRING_POS_CACHE -wxTLS_TYPE(wxString::Cache) wxString::ms_cache; +wxTHREAD_SPECIFIC_DECL wxString::Cache wxString::ms_cache; // gdb seems to be unable to display thread-local variables correctly, at least // not my 6.4.98 version under amd64, so provide this debugging helper to do it diff --git a/src/common/threadinfo.cpp b/src/common/threadinfo.cpp index 17fc9d612a..af681cd47c 100644 --- a/src/common/threadinfo.cpp +++ b/src/common/threadinfo.cpp @@ -45,14 +45,14 @@ inline wxAllThreadInfos& GetAllThreadInfos() } // Pointer to the current thread's instance -inline wxTLS_TYPE_REF(wxThreadSpecificInfo*) GetThisThreadInfo() +inline wxThreadSpecificInfo*& GetThisThreadInfo() { - static wxTLS_TYPE(wxThreadSpecificInfo*) s_thisThreadInfo; + static wxTHREAD_SPECIFIC_DECL wxThreadSpecificInfo* s_thisThreadInfo; return s_thisThreadInfo; } -#define wxTHIS_THREAD_INFO wxTLS_VALUE(GetThisThreadInfo()) +#define wxTHIS_THREAD_INFO GetThisThreadInfo() } // anonymous namespace diff --git a/tests/benchmarks/tls.cpp b/tests/benchmarks/tls.cpp index 75568a9f32..f946ffb654 100644 --- a/tests/benchmarks/tls.cpp +++ b/tests/benchmarks/tls.cpp @@ -175,8 +175,7 @@ BENCHMARK_FUNC(BoostTLS) BENCHMARK_FUNC(wxTLS) { - static wxTLS_TYPE(int) s_globalVar; - #define s_global wxTLS_VALUE(s_globalVar) + static wxTHREAD_SPECIFIC_DECL int s_global; for ( int n = 0; n < NUM_ITER; n++ ) { diff --git a/tests/thread/tls.cpp b/tests/thread/tls.cpp index 0b66049dbb..9877e31c86 100644 --- a/tests/thread/tls.cpp +++ b/tests/thread/tls.cpp @@ -35,11 +35,8 @@ struct PerThreadData int number; }; -wxTLS_TYPE(PerThreadData) gs_threadDataVar; -#define gs_threadData wxTLS_VALUE(gs_threadDataVar) - -wxTLS_TYPE(int) gs_threadIntVar; -#define gs_threadInt wxTLS_VALUE(gs_threadIntVar) +wxTHREAD_SPECIFIC_DECL PerThreadData gs_threadData; +wxTHREAD_SPECIFIC_DECL int gs_threadInt; // ---------------------------------------------------------------------------- // test thread