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 TLSIndex PoolIndex = TLS_INVALID_INDEX;
13 
InitializePoolIndex()14 bool InitializePoolIndex()
15 {
16     ASSERT(PoolIndex == TLS_INVALID_INDEX);
17 
18     PoolIndex = CreateTLSIndex();
19     return PoolIndex != TLS_INVALID_INDEX;
20 }
21 
FreePoolIndex()22 void FreePoolIndex()
23 {
24     ASSERT(PoolIndex != TLS_INVALID_INDEX);
25 
26     DestroyTLSIndex(PoolIndex);
27     PoolIndex = TLS_INVALID_INDEX;
28 }
29 
GetGlobalPoolAllocator()30 angle::PoolAllocator *GetGlobalPoolAllocator()
31 {
32     ASSERT(PoolIndex != TLS_INVALID_INDEX);
33     return static_cast<angle::PoolAllocator *>(GetTLSValue(PoolIndex));
34 }
35 
SetGlobalPoolAllocator(angle::PoolAllocator * poolAllocator)36 void SetGlobalPoolAllocator(angle::PoolAllocator *poolAllocator)
37 {
38     ASSERT(PoolIndex != TLS_INVALID_INDEX);
39     SetTLSValue(PoolIndex, poolAllocator);
40 }
41