1 /*-------------------------------------------------------------------------
2 * dEQP glslang integration
3 * ------------------------
5 * Copyright 2015 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief glslang OS interface.
22 *//*--------------------------------------------------------------------*/
24 #include "osinclude.h"
27 #include "deThreadLocal.h"
32 DE_STATIC_ASSERT(sizeof(deThreadLocal) == sizeof(OS_TLSIndex));
33 DE_STATIC_ASSERT(sizeof(deThread) == sizeof(void*));
37 OS_TLSIndex OS_AllocTLSIndex (void)
39 return (OS_TLSIndex)deThreadLocal_create();
42 bool OS_SetTLSValue (OS_TLSIndex nIndex, void* lpvValue)
44 deThreadLocal_set((deThreadLocal)nIndex, lpvValue);
48 bool OS_FreeTLSIndex (OS_TLSIndex nIndex)
50 deThreadLocal_destroy((deThreadLocal)nIndex);
54 void* OS_GetTLSValue (OS_TLSIndex nIndex)
56 return deThreadLocal_get((deThreadLocal)nIndex);
59 // Global lock - not used
61 void InitGlobalLock (void)
65 void GetGlobalLock (void)
69 void ReleaseGlobalLock (void)
75 DE_STATIC_ASSERT(sizeof(void*) >= sizeof(deThread));
77 static void EnterGenericThread (void* entry)
79 ((TThreadEntrypoint)entry)(DE_NULL);
82 void* OS_CreateThread (TThreadEntrypoint entry)
84 return (void*)(deUintptr)deThread_create(EnterGenericThread, (void*)entry, DE_NULL);
87 void OS_WaitForAllThreads (void* threads, int numThreads)
89 for (int ndx = 0; ndx < numThreads; ndx++)
91 const deThread thread = (deThread)(deUintptr)((void**)threads)[ndx];
92 deThread_join(thread);
93 deThread_destroy(thread);
97 void OS_Sleep (int milliseconds)
99 deSleep(milliseconds);
102 void OS_DumpMemoryCounters (void)