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.
7 // tls.h: Simple cross-platform interface for thread local storage.
12 #include "common/platform.h"
14 #ifdef ANGLE_PLATFORM_WINDOWS
15 typedef DWORD TLSIndex;
16 # define TLS_INVALID_INDEX (TLS_OUT_OF_INDEXES)
17 #elif defined(ANGLE_PLATFORM_POSIX)
19 # include <semaphore.h>
21 typedef pthread_key_t TLSIndex;
22 # define TLS_INVALID_INDEX (static_cast<TLSIndex>(-1))
24 # error Unsupported platform.
27 TLSIndex CreateTLSIndex();
28 bool DestroyTLSIndex(TLSIndex index);
30 bool SetTLSValue(TLSIndex index, void *value);
31 void *GetTLSValue(TLSIndex index);
33 #endif // COMMON_TLS_H_