Remove tests for wxHAS_COMPILER_TLS from wx code

It is now always defined, so they're useless.
This commit is contained in:
Vadim Zeitlin 2022-10-26 02:11:07 +01:00
parent 4e802e6fc7
commit 16a746ec35
2 changed files with 0 additions and 59 deletions

View file

@ -445,34 +445,8 @@ private:
unsigned lastUsed;
};
#ifndef wxHAS_COMPILER_TLS
// we must use an accessor function and not a static variable when the TLS
// variables support is implemented in the library (and not by the compiler)
// because the global s_cache variable could be not yet initialized when a
// ctor of another global object is executed and if that ctor uses any
// wxString methods, bad things happen
//
// however notice that this approach does not work when compiler TLS is used,
// at least not with g++ 4.1.2 under amd64 as it apparently compiles code
// using this accessor incorrectly when optimizations are enabled (-O2 is
// enough) -- luckily we don't need it then either as static __thread
// variables are initialized by 0 anyhow then and so we can use the variable
// directly
WXEXPORT static Cache& GetCache()
{
static wxTLS_TYPE(Cache) s_cache;
return wxTLS_VALUE(s_cache);
}
// this helper struct is used to ensure that GetCache() is called during
// static initialization time, i.e. before any threads creation, as otherwise
// the static s_cache construction inside GetCache() wouldn't be MT-safe
friend struct wxStrCacheInitializer;
#else // wxHAS_COMPILER_TLS
static wxTLS_TYPE(Cache) ms_cache;
static Cache& GetCache() { return wxTLS_VALUE(ms_cache); }
#endif // !wxHAS_COMPILER_TLS/wxHAS_COMPILER_TLS
static Cache::Element *GetCacheBegin() { return GetCache().cached; }
static Cache::Element *GetCacheEnd() { return GetCacheBegin() + Cache::SIZE; }
@ -523,12 +497,6 @@ private:
// simple loop instead of starting from the last used element (there are
// a lot of misses in this function...)
Cache::Element * const cacheBegin = GetCacheBegin();
#ifndef wxHAS_COMPILER_TLS
// during destruction tls calls may return nullptr, in this case return nullptr
// immediately without accessing anything else
if ( cacheBegin == nullptr )
return nullptr;
#endif
// gcc 7 warns about not being able to optimize this loop because of
// possible loop variable overflow, really not sure what to do about

View file

@ -81,35 +81,8 @@ const size_t wxString::npos = (size_t) -1;
#if wxUSE_STRING_POS_CACHE
#ifdef wxHAS_COMPILER_TLS
wxTLS_TYPE(wxString::Cache) wxString::ms_cache;
#else // !wxHAS_COMPILER_TLS
struct wxStrCacheInitializer
{
wxStrCacheInitializer()
{
// calling this function triggers s_cache initialization in it, and
// from now on it becomes safe to call from multiple threads
wxString::GetCache();
}
};
/*
wxString::Cache& wxString::GetCache()
{
static wxTLS_TYPE(Cache) s_cache;
return wxTLS_VALUE(s_cache);
}
*/
static wxStrCacheInitializer gs_stringCacheInit;
#endif // wxHAS_COMPILER_TLS/!wxHAS_COMPILER_TLS
// 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
#if wxDEBUG_LEVEL >= 2