gfx/angle/src/compiler/ossource_posix.cpp

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 //
michael@0 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
michael@0 3 // Use of this source code is governed by a BSD-style license that can be
michael@0 4 // found in the LICENSE file.
michael@0 5 //
michael@0 6
michael@0 7 //
michael@0 8 // This file contains the posix specific functions
michael@0 9 //
michael@0 10 #include "compiler/osinclude.h"
michael@0 11
michael@0 12 #if !defined(ANGLE_OS_POSIX)
michael@0 13 #error Trying to build a posix specific file in a non-posix build.
michael@0 14 #endif
michael@0 15
michael@0 16 //
michael@0 17 // Thread Local Storage Operations
michael@0 18 //
michael@0 19 OS_TLSIndex OS_AllocTLSIndex()
michael@0 20 {
michael@0 21 pthread_key_t pPoolIndex;
michael@0 22
michael@0 23 //
michael@0 24 // Create global pool key.
michael@0 25 //
michael@0 26 if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
michael@0 27 assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
michael@0 28 return false;
michael@0 29 }
michael@0 30 else {
michael@0 31 return pPoolIndex;
michael@0 32 }
michael@0 33 }
michael@0 34
michael@0 35
michael@0 36 bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
michael@0 37 {
michael@0 38 if (nIndex == OS_INVALID_TLS_INDEX) {
michael@0 39 assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
michael@0 40 return false;
michael@0 41 }
michael@0 42
michael@0 43 if (pthread_setspecific(nIndex, lpvValue) == 0)
michael@0 44 return true;
michael@0 45 else
michael@0 46 return false;
michael@0 47 }
michael@0 48
michael@0 49
michael@0 50 bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
michael@0 51 {
michael@0 52 if (nIndex == OS_INVALID_TLS_INDEX) {
michael@0 53 assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
michael@0 54 return false;
michael@0 55 }
michael@0 56
michael@0 57 //
michael@0 58 // Delete the global pool key.
michael@0 59 //
michael@0 60 if (pthread_key_delete(nIndex) == 0)
michael@0 61 return true;
michael@0 62 else
michael@0 63 return false;
michael@0 64 }

mercurial