1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/compiler/osinclude.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +// 1.5 +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +#ifndef __OSINCLUDE_H 1.11 +#define __OSINCLUDE_H 1.12 + 1.13 +// 1.14 +// This file contains contains os-specific datatypes and 1.15 +// declares any os-specific functions. 1.16 +// 1.17 + 1.18 +#if defined(_WIN32) || defined(_WIN64) 1.19 +#define ANGLE_OS_WIN 1.20 +#elif defined(__APPLE__) || defined(__linux__) || \ 1.21 + defined(__FreeBSD__) || defined(__OpenBSD__) || \ 1.22 + defined(__sun) || defined(ANDROID) || \ 1.23 + defined(__GLIBC__) || defined(__GNU__) || \ 1.24 + defined(__QNX__) 1.25 +#define ANGLE_OS_POSIX 1.26 +#else 1.27 +#error Unsupported platform. 1.28 +#endif 1.29 + 1.30 +#if defined(ANGLE_OS_WIN) 1.31 +#define STRICT 1.32 +#define VC_EXTRALEAN 1 1.33 +#include <windows.h> 1.34 +#elif defined(ANGLE_OS_POSIX) 1.35 +#include <pthread.h> 1.36 +#include <semaphore.h> 1.37 +#include <errno.h> 1.38 +#endif // ANGLE_OS_WIN 1.39 + 1.40 + 1.41 +#include "compiler/compiler_debug.h" 1.42 + 1.43 +// 1.44 +// Thread Local Storage Operations 1.45 +// 1.46 +#if defined(ANGLE_OS_WIN) 1.47 +typedef DWORD OS_TLSIndex; 1.48 +#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES) 1.49 +#elif defined(ANGLE_OS_POSIX) 1.50 +typedef pthread_key_t OS_TLSIndex; 1.51 +#define OS_INVALID_TLS_INDEX (static_cast<OS_TLSIndex>(-1)) 1.52 +#endif // ANGLE_OS_WIN 1.53 + 1.54 +OS_TLSIndex OS_AllocTLSIndex(); 1.55 +bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue); 1.56 +bool OS_FreeTLSIndex(OS_TLSIndex nIndex); 1.57 + 1.58 +inline void* OS_GetTLSValue(OS_TLSIndex nIndex) 1.59 +{ 1.60 + ASSERT(nIndex != OS_INVALID_TLS_INDEX); 1.61 +#if defined(ANGLE_OS_WIN) 1.62 + return TlsGetValue(nIndex); 1.63 +#elif defined(ANGLE_OS_POSIX) 1.64 + return pthread_getspecific(nIndex); 1.65 +#endif // ANGLE_OS_WIN 1.66 +} 1.67 + 1.68 +#endif // __OSINCLUDE_H