michael@0: // michael@0: // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: #include "compiler/InitializeParseContext.h" michael@0: michael@0: #include "compiler/osinclude.h" michael@0: michael@0: OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX; michael@0: michael@0: bool InitializeParseContextIndex() michael@0: { michael@0: assert(GlobalParseContextIndex == OS_INVALID_TLS_INDEX); michael@0: michael@0: GlobalParseContextIndex = OS_AllocTLSIndex(); michael@0: return GlobalParseContextIndex != OS_INVALID_TLS_INDEX; michael@0: } michael@0: michael@0: void FreeParseContextIndex() michael@0: { michael@0: assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); michael@0: michael@0: OS_FreeTLSIndex(GlobalParseContextIndex); michael@0: GlobalParseContextIndex = OS_INVALID_TLS_INDEX; michael@0: } michael@0: michael@0: void SetGlobalParseContext(TParseContext* context) michael@0: { michael@0: assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); michael@0: OS_SetTLSValue(GlobalParseContextIndex, context); michael@0: } michael@0: michael@0: TParseContext* GetGlobalParseContext() michael@0: { michael@0: assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX); michael@0: return static_cast(OS_GetTLSValue(GlobalParseContextIndex)); michael@0: } michael@0: