blob: 89922fef3f411edbb83b522412b6cf728c3f9f39 [file] [log] [blame]
John Bauman89401822014-05-06 15:04:28 -04001//
2// Copyright (c) 2002-2010 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#include "compiler/osinclude.h"
8//
9// This file contains contains the window's specific functions
10//
11
12#if !defined(ANGLE_OS_WIN)
13#error Trying to build a windows specific file in a non windows build.
14#endif
15
16
17//
18// Thread Local Storage Operations
19//
20OS_TLSIndex OS_AllocTLSIndex()
21{
22 DWORD dwIndex = TlsAlloc();
23 if (dwIndex == TLS_OUT_OF_INDEXES) {
24 assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
25 return OS_INVALID_TLS_INDEX;
26 }
27
28 return dwIndex;
29}
30
31
32bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
33{
34 if (nIndex == OS_INVALID_TLS_INDEX) {
35 assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
36 return false;
37 }
38
39 if (TlsSetValue(nIndex, lpvValue))
40 return true;
41 else
42 return false;
43}
44
45
46bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
47{
48 if (nIndex == OS_INVALID_TLS_INDEX) {
49 assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
50 return false;
51 }
52
53 if (TlsFree(nIndex))
54 return true;
55 else
56 return false;
57}