Revert changes that migrate to thread_local.

iOS 8 does not support `thread_local`, which is still in use.
Another approach will have to be found.

This change is a revert of the following changes:

a3845240 - "Simplify PoolAlloc with use of thread_local."
abf92c80 - "Deprecate InitializeDll functions"
33585c87 - "Limit visibility of symbols for internal libraries"

Issue: #2346
This commit is contained in:
Ben Clayton 2020-07-31 07:09:17 +01:00
parent 7ab4564696
commit 2a44064885
8 changed files with 161 additions and 35 deletions

View file

@ -35,28 +35,34 @@
#include "../Include/Common.h"
#include "../Include/PoolAlloc.h"
#include "../Include/InitializeGlobals.h"
#include "../OSDependent/osinclude.h"
namespace glslang {
namespace {
thread_local TPoolAllocator* threadPoolAllocator = nullptr;
TPoolAllocator* GetDefaultThreadPoolAllocator()
{
thread_local TPoolAllocator defaultAllocator;
return &defaultAllocator;
}
} // anonymous namespace
// Process-wide TLS index
OS_TLSIndex PoolIndex;
// Return the thread-specific current pool.
TPoolAllocator& GetThreadPoolAllocator()
{
return *(threadPoolAllocator ? threadPoolAllocator : GetDefaultThreadPoolAllocator());
return *static_cast<TPoolAllocator*>(OS_GetTLSValue(PoolIndex));
}
// Set the thread-specific current pool.
void SetThreadPoolAllocator(TPoolAllocator* poolAllocator)
{
threadPoolAllocator = poolAllocator;
OS_SetTLSValue(PoolIndex, poolAllocator);
}
// Process-wide set up of the TLS pool storage.
bool InitializePoolIndex()
{
// Allocate a TLS index.
if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)
return false;
return true;
}
//