webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
tls.h
Go to the documentation of this file.
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 
16 // TLS does not exist for Windows Store and needs to be emulated
17 # ifdef ANGLE_ENABLE_WINDOWS_STORE
18 # ifndef TLS_OUT_OF_INDEXES
19 # define TLS_OUT_OF_INDEXES static_cast<DWORD>(0xFFFFFFFF)
20 # endif
21 # ifndef CREATE_SUSPENDED
22 # define CREATE_SUSPENDED 0x00000004
23 # endif
24 # endif
25  typedef DWORD TLSIndex;
26 # define TLS_INVALID_INDEX (TLS_OUT_OF_INDEXES)
27 #elif defined(ANGLE_PLATFORM_POSIX)
28 # include <pthread.h>
29 # include <semaphore.h>
30 # include <errno.h>
31  typedef pthread_key_t TLSIndex;
32 # define TLS_INVALID_INDEX (static_cast<TLSIndex>(-1))
33 #else
34 # error Unsupported platform.
35 #endif
36 
37 // TODO(kbr): for POSIX platforms this will have to be changed to take
38 // in a destructor function pointer, to allow the thread-local storage
39 // to be properly deallocated upon thread exit.
40 TLSIndex CreateTLSIndex();
41 bool DestroyTLSIndex(TLSIndex index);
42 
43 bool SetTLSValue(TLSIndex index, void *value);
44 void *GetTLSValue(TLSIndex index);
45 
46 #endif // COMMON_TLS_H_
bool DestroyTLSIndex(TLSIndex index)
Definition: tls.cpp:69
TLSIndex CreateTLSIndex()
Definition: tls.cpp:37
bool SetTLSValue(TLSIndex index, void *value)
Definition: tls.cpp:99
void * GetTLSValue(TLSIndex index)
Definition: tls.cpp:131
GLuint index
Definition: gl2.h:383
EGLAttrib * value
Definition: eglext.h:120