blob: a442167f1d820a26bd45bc9820f6f545734a5348 [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
John Bauman89401822014-05-06 15:04:28 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
John Bauman89401822014-05-06 15:04:28 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
John Bauman89401822014-05-06 15:04:28 -040014
Nicolas Capenscc863da2015-01-21 15:50:55 -050015#include "osinclude.h"
John Bauman89401822014-05-06 15:04:28 -040016//
17// This file contains contains the window's specific functions
18//
19
20#if !defined(ANGLE_OS_WIN)
21#error Trying to build a windows specific file in a non windows build.
22#endif
23
24
25//
26// Thread Local Storage Operations
27//
28OS_TLSIndex OS_AllocTLSIndex()
29{
30 DWORD dwIndex = TlsAlloc();
31 if (dwIndex == TLS_OUT_OF_INDEXES) {
32 assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
33 return OS_INVALID_TLS_INDEX;
34 }
35
36 return dwIndex;
37}
38
39
40bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
41{
42 if (nIndex == OS_INVALID_TLS_INDEX) {
43 assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
44 return false;
45 }
46
47 if (TlsSetValue(nIndex, lpvValue))
48 return true;
49 else
50 return false;
51}
52
53
54bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
55{
56 if (nIndex == OS_INVALID_TLS_INDEX) {
57 assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
58 return false;
59 }
60
61 if (TlsFree(nIndex))
62 return true;
63 else
64 return false;
65}