1 // 2 // Copyright 2002 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 #include "compiler/translator/PoolAlloc.h" 8 9 #include "common/debug.h" 10 #include "common/tls.h" 11 12 angle::TLSIndex PoolIndex = TLS_INVALID_INDEX; 13 InitializePoolIndex()14bool InitializePoolIndex() 15 { 16 ASSERT(PoolIndex == TLS_INVALID_INDEX); 17 18 PoolIndex = angle::CreateTLSIndex(nullptr); 19 return PoolIndex != TLS_INVALID_INDEX; 20 } 21 FreePoolIndex()22void FreePoolIndex() 23 { 24 ASSERT(PoolIndex != TLS_INVALID_INDEX); 25 26 angle::DestroyTLSIndex(PoolIndex); 27 PoolIndex = TLS_INVALID_INDEX; 28 } 29 GetGlobalPoolAllocator()30angle::PoolAllocator *GetGlobalPoolAllocator() 31 { 32 ASSERT(PoolIndex != TLS_INVALID_INDEX); 33 return static_cast<angle::PoolAllocator *>(angle::GetTLSValue(PoolIndex)); 34 } 35 SetGlobalPoolAllocator(angle::PoolAllocator * poolAllocator)36void SetGlobalPoolAllocator(angle::PoolAllocator *poolAllocator) 37 { 38 ASSERT(PoolIndex != TLS_INVALID_INDEX); 39 angle::SetTLSValue(PoolIndex, poolAllocator); 40 } 41