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.
7
#include "compiler/InitializeDll.h"
9
#include "compiler/InitializeGlobals.h"
10
#include "compiler/InitializeParseContext.h"
11
#include "compiler/osinclude.h"
13
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
17
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) {
19
// Function is re-entrant.
24
ThreadInitializeIndex = OS_AllocTLSIndex();
26
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
27
assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
32
if (!InitializePoolIndex()) {
33
assert(0 && "InitProcess(): Failed to initalize global pool");
37
if (!InitializeParseContextIndex()) {
38
assert(0 && "InitProcess(): Failed to initalize parse context");
49
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
52
success = DetachThread();
54
if (!FreeParseContextIndex())
59
OS_FreeTLSIndex(ThreadInitializeIndex);
60
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
68
// This function is re-entrant
70
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
71
assert(0 && "InitThread(): Process hasn't been initalised.");
75
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
78
InitializeGlobalPools();
80
if (!InitializeGlobalParseContext())
83
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
84
assert(0 && "InitThread(): Unable to set init flag.");
95
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
99
// Function is re-entrant and this thread may not have been initalised.
101
if (OS_GetTLSValue(ThreadInitializeIndex) != 0) {
102
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0)) {
103
assert(0 && "DetachThread(): Unable to clear init flag.");
107
if (!FreeParseContext())