1//
2// Copyright (c) 2002-2010 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 <assert.h>
10#include "common/tls.h"
11
12TLSIndex PoolIndex = TLS_INVALID_INDEX;
13
14bool InitializePoolIndex()
15{
16 assert(PoolIndex == TLS_INVALID_INDEX);
17
18 PoolIndex = CreateTLSIndex();
19 return PoolIndex != TLS_INVALID_INDEX;
20}
21
22void FreePoolIndex()
23{
24 assert(PoolIndex != TLS_INVALID_INDEX);
25
26 DestroyTLSIndex(PoolIndex);
27 PoolIndex = TLS_INVALID_INDEX;
28}
29
30angle::PoolAllocator *GetGlobalPoolAllocator()
31{
32 assert(PoolIndex != TLS_INVALID_INDEX);
33 return static_cast<angle::PoolAllocator *>(GetTLSValue(PoolIndex));
34}
35
36void SetGlobalPoolAllocator(angle::PoolAllocator *poolAllocator)
37{
38 assert(PoolIndex != TLS_INVALID_INDEX);
39 SetTLSValue(PoolIndex, poolAllocator);
40}
41