Home | History | Annotate | Download | only in common
      1 //
      2 // Copyright (c) 2014 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 //
      6 
      7 // tls.h: Simple cross-platform interface for thread local storage.
      8 
      9 #ifndef COMMON_TLS_H_
     10 #define COMMON_TLS_H_
     11 
     12 #include "common/platform.h"
     13 
     14 #ifdef ANGLE_PLATFORM_WINDOWS
     15     typedef DWORD TLSIndex;
     16 #   define TLS_INVALID_INDEX (TLS_OUT_OF_INDEXES)
     17 #elif defined(ANGLE_PLATFORM_POSIX)
     18 #   include <pthread.h>
     19 #   include <semaphore.h>
     20 #   include <errno.h>
     21     typedef pthread_key_t TLSIndex;
     22 #   define TLS_INVALID_INDEX (static_cast<TLSIndex>(-1))
     23 #else
     24 #   error Unsupported platform.
     25 #endif
     26 
     27 TLSIndex CreateTLSIndex();
     28 bool DestroyTLSIndex(TLSIndex index);
     29 
     30 bool SetTLSValue(TLSIndex index, void *value);
     31 void *GetTLSValue(TLSIndex index);
     32 
     33 #endif // COMMON_TLS_H_
     34