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.
8 // This file contains the posix specific functions
10 #include "compiler/osinclude.h"
12 #if !defined(ANGLE_OS_POSIX)
13 #error Trying to build a posix specific file in a non-posix build.
17 // Thread Local Storage Operations
19 OS_TLSIndex OS_AllocTLSIndex()
21 pthread_key_t pPoolIndex;
24 // Create global pool key.
26 if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
27 assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
36 bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
38 if (nIndex == OS_INVALID_TLS_INDEX) {
39 assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
43 if (pthread_setspecific(nIndex, lpvValue) == 0)
50 bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
52 if (nIndex == OS_INVALID_TLS_INDEX) {
53 assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
58 // Delete the global pool key.
60 if (pthread_key_delete(nIndex) == 0)