Line data Source code
1 : //
2 : // Copyright (c) 2012 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/InitializeParseContext.h"
8 :
9 : #include "common/tls.h"
10 :
11 : #include <assert.h>
12 :
13 : namespace sh
14 : {
15 :
16 : TLSIndex GlobalParseContextIndex = TLS_INVALID_INDEX;
17 :
18 0 : bool InitializeParseContextIndex()
19 : {
20 0 : assert(GlobalParseContextIndex == TLS_INVALID_INDEX);
21 :
22 0 : GlobalParseContextIndex = CreateTLSIndex();
23 0 : return GlobalParseContextIndex != TLS_INVALID_INDEX;
24 : }
25 :
26 0 : void FreeParseContextIndex()
27 : {
28 0 : assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
29 :
30 0 : DestroyTLSIndex(GlobalParseContextIndex);
31 0 : GlobalParseContextIndex = TLS_INVALID_INDEX;
32 0 : }
33 :
34 0 : void SetGlobalParseContext(TParseContext* context)
35 : {
36 0 : assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
37 0 : SetTLSValue(GlobalParseContextIndex, context);
38 0 : }
39 :
40 0 : TParseContext* GetGlobalParseContext()
41 : {
42 0 : assert(GlobalParseContextIndex != TLS_INVALID_INDEX);
43 0 : return static_cast<TParseContext*>(GetTLSValue(GlobalParseContextIndex));
44 : }
45 :
46 : } // namespace sh
|