gfx/angle/src/compiler/ossource_posix.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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