gfx/angle/src/compiler/ossource_posix.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/angle/src/compiler/ossource_posix.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +//
     1.5 +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
     1.6 +// Use of this source code is governed by a BSD-style license that can be
     1.7 +// found in the LICENSE file.
     1.8 +//
     1.9 +
    1.10 +//
    1.11 +// This file contains the posix specific functions
    1.12 +//
    1.13 +#include "compiler/osinclude.h"
    1.14 +
    1.15 +#if !defined(ANGLE_OS_POSIX)
    1.16 +#error Trying to build a posix specific file in a non-posix build.
    1.17 +#endif
    1.18 +
    1.19 +//
    1.20 +// Thread Local Storage Operations
    1.21 +//
    1.22 +OS_TLSIndex OS_AllocTLSIndex()
    1.23 +{
    1.24 +    pthread_key_t pPoolIndex;
    1.25 +
    1.26 +    //
    1.27 +    // Create global pool key.
    1.28 +    //
    1.29 +    if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
    1.30 +        assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
    1.31 +        return false;
    1.32 +    }
    1.33 +    else {
    1.34 +        return pPoolIndex;
    1.35 +    }
    1.36 +}
    1.37 +
    1.38 +
    1.39 +bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
    1.40 +{
    1.41 +    if (nIndex == OS_INVALID_TLS_INDEX) {
    1.42 +        assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
    1.43 +        return false;
    1.44 +    }
    1.45 +
    1.46 +    if (pthread_setspecific(nIndex, lpvValue) == 0)
    1.47 +        return true;
    1.48 +    else
    1.49 +        return false;
    1.50 +}
    1.51 +
    1.52 +
    1.53 +bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
    1.54 +{
    1.55 +    if (nIndex == OS_INVALID_TLS_INDEX) {
    1.56 +        assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
    1.57 +        return false;
    1.58 +    }
    1.59 +
    1.60 +    //
    1.61 +    // Delete the global pool key.
    1.62 +    //
    1.63 +    if (pthread_key_delete(nIndex) == 0)
    1.64 +        return true;
    1.65 +    else
    1.66 +        return false;
    1.67 +}

mercurial