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

@ -52,7 +52,6 @@ add_library(GenericCodeGen STATIC
GenericCodeGen/Link.cpp)
set_property(TARGET GenericCodeGen PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET GenericCodeGen PROPERTY FOLDER glslang)
glslang_default_to_hidden_visibility(GenericCodeGen)
################################################################################
# MachineIndependent
@ -134,7 +133,6 @@ endif(ENABLE_HLSL)
add_library(MachineIndependent STATIC ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS})
set_property(TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET MachineIndependent PROPERTY FOLDER glslang)
glslang_only_export_explicit_symbols(MachineIndependent)
glslang_add_build_info_dependency(MachineIndependent)
@ -170,7 +168,7 @@ set_target_properties(glslang PROPERTIES
POSITION_INDEPENDENT_CODE ON
VERSION "${GLSLANG_VERSION}"
SOVERSION "${GLSLANG_VERSION_MAJOR}")
target_link_libraries(glslang PRIVATE OGLCompiler MachineIndependent)
target_link_libraries(glslang PRIVATE OGLCompiler OSDependent MachineIndependent)
target_include_directories(glslang PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

View file

@ -37,7 +37,7 @@
namespace glslang {
inline bool InitializePoolIndex() { return true; } // DEPRECATED: No need to call
bool InitializePoolIndex();
} // end namespace glslang

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;
}
//