gfx/angle/src/compiler/InitializeParseContext.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/angle/src/compiler/InitializeParseContext.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +//
     1.5 +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
     1.6 +// Use of this source code is governed by a BSD-style license that can be
     1.7 +// found in the LICENSE file.
     1.8 +//
     1.9 +
    1.10 +#include "compiler/InitializeParseContext.h"
    1.11 +
    1.12 +#include "compiler/osinclude.h"
    1.13 +
    1.14 +OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
    1.15 +
    1.16 +bool InitializeParseContextIndex()
    1.17 +{
    1.18 +    assert(GlobalParseContextIndex == OS_INVALID_TLS_INDEX);
    1.19 +
    1.20 +    GlobalParseContextIndex = OS_AllocTLSIndex();
    1.21 +    return GlobalParseContextIndex != OS_INVALID_TLS_INDEX;
    1.22 +}
    1.23 +
    1.24 +void FreeParseContextIndex()
    1.25 +{
    1.26 +    assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
    1.27 +
    1.28 +    OS_FreeTLSIndex(GlobalParseContextIndex);
    1.29 +    GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
    1.30 +}
    1.31 +
    1.32 +void SetGlobalParseContext(TParseContext* context)
    1.33 +{
    1.34 +    assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
    1.35 +    OS_SetTLSValue(GlobalParseContextIndex, context);
    1.36 +}
    1.37 +
    1.38 +TParseContext* GetGlobalParseContext()
    1.39 +{
    1.40 +    assert(GlobalParseContextIndex != OS_INVALID_TLS_INDEX);
    1.41 +    return static_cast<TParseContext*>(OS_GetTLSValue(GlobalParseContextIndex));
    1.42 +}
    1.43 +

mercurial