blob: 89922fef3f411edbb83b522412b6cf728c3f9f39 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
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
daniel@transgaming.combbf56f72010-04-20 18:52:13 +00007#include "compiler/osinclude.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008//
9// This file contains contains the window's specific functions
10//
11
alokp@chromium.org277ec182010-04-23 16:07:34 +000012#if !defined(ANGLE_OS_WIN)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000013#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}