gfx/angle/src/compiler/ossource_posix.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 //
     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.
     5 //
     7 //
     8 // This file contains the posix specific functions
     9 //
    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.
    14 #endif
    16 //
    17 // Thread Local Storage Operations
    18 //
    19 OS_TLSIndex OS_AllocTLSIndex()
    20 {
    21     pthread_key_t pPoolIndex;
    23     //
    24     // Create global pool key.
    25     //
    26     if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
    27         assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
    28         return false;
    29     }
    30     else {
    31         return pPoolIndex;
    32     }
    33 }
    36 bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
    37 {
    38     if (nIndex == OS_INVALID_TLS_INDEX) {
    39         assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
    40         return false;
    41     }
    43     if (pthread_setspecific(nIndex, lpvValue) == 0)
    44         return true;
    45     else
    46         return false;
    47 }
    50 bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
    51 {
    52     if (nIndex == OS_INVALID_TLS_INDEX) {
    53         assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
    54         return false;
    55     }
    57     //
    58     // Delete the global pool key.
    59     //
    60     if (pthread_key_delete(nIndex) == 0)
    61         return true;
    62     else
    63         return false;
    64 }

mercurial