Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / common / tls.h
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 #       define TLS_OUT_OF_INDEXES -1
19 #       ifndef CREATE_SUSPENDED
20 #           define CREATE_SUSPENDED 0x00000004
21 #       endif
22 #   endif
23     typedef DWORD TLSIndex;
24 #   define TLS_INVALID_INDEX (TLS_OUT_OF_INDEXES)
25 #elif defined(ANGLE_PLATFORM_POSIX)
26 #   include <pthread.h>
27 #   include <semaphore.h>
28 #   include <errno.h>
29     typedef pthread_key_t TLSIndex;
30 #   define TLS_INVALID_INDEX (static_cast<TLSIndex>(-1))
31 #else
32 #   error Unsupported platform.
33 #endif
34
35 // TODO(kbr): for POSIX platforms this will have to be changed to take
36 // in a destructor function pointer, to allow the thread-local storage
37 // to be properly deallocated upon thread exit.
38 TLSIndex CreateTLSIndex();
39 bool DestroyTLSIndex(TLSIndex index);
40
41 bool SetTLSValue(TLSIndex index, void *value);
42 void *GetTLSValue(TLSIndex index);
43
44 #endif // COMMON_TLS_H_