1 | // |
2 | // Copyright (c) 2014 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 | // platform.h: Operating system specific includes and defines. |
8 | |
9 | #ifndef COMMON_PLATFORM_H_ |
10 | #define COMMON_PLATFORM_H_ |
11 | |
12 | #if defined(_WIN32) |
13 | # define ANGLE_PLATFORM_WINDOWS 1 |
14 | #elif defined(__Fuchsia__) |
15 | # define ANGLE_PLATFORM_FUCHSIA 1 |
16 | # define ANGLE_PLATFORM_POSIX 1 |
17 | #elif defined(__APPLE__) |
18 | # define ANGLE_PLATFORM_APPLE 1 |
19 | # define ANGLE_PLATFORM_POSIX 1 |
20 | #elif defined(ANDROID) |
21 | # define ANGLE_PLATFORM_ANDROID 1 |
22 | # define ANGLE_PLATFORM_POSIX 1 |
23 | #elif defined(__linux__) || defined(EMSCRIPTEN) |
24 | # define ANGLE_PLATFORM_LINUX 1 |
25 | # define ANGLE_PLATFORM_POSIX 1 |
26 | #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ |
27 | defined(__DragonFly__) || defined(__sun) || defined(__GLIBC__) || defined(__GNU__) || \ |
28 | defined(__QNX__) || defined(__Fuchsia__) || defined(__HAIKU__) |
29 | # define ANGLE_PLATFORM_POSIX 1 |
30 | #else |
31 | # error Unsupported platform. |
32 | #endif |
33 | |
34 | #ifdef ANGLE_PLATFORM_WINDOWS |
35 | # ifndef STRICT |
36 | # define STRICT 1 |
37 | # endif |
38 | # ifndef WIN32_LEAN_AND_MEAN |
39 | # define WIN32_LEAN_AND_MEAN 1 |
40 | # endif |
41 | # ifndef NOMINMAX |
42 | # define NOMINMAX 1 |
43 | # endif |
44 | |
45 | # include <intrin.h> |
46 | # include <windows.h> |
47 | |
48 | # if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) |
49 | # define ANGLE_ENABLE_WINDOWS_STORE 1 |
50 | # endif |
51 | |
52 | # if defined(ANGLE_ENABLE_D3D9) |
53 | # include <d3d9.h> |
54 | # include <d3dcompiler.h> |
55 | # endif |
56 | |
57 | // Include D3D11 headers when OpenGL is enabled on Windows for interop extensions. |
58 | # if defined(ANGLE_ENABLE_D3D11) || defined(ANGLE_ENABLE_OPENGL) |
59 | # include <d3d10_1.h> |
60 | # include <d3d11.h> |
61 | # include <d3d11_3.h> |
62 | # include <d3dcompiler.h> |
63 | # include <dxgi.h> |
64 | # include <dxgi1_2.h> |
65 | # endif |
66 | |
67 | # if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11) |
68 | # include <wrl.h> |
69 | # endif |
70 | |
71 | # if defined(ANGLE_ENABLE_WINDOWS_STORE) |
72 | # include <dxgi1_3.h> |
73 | # if defined(_DEBUG) |
74 | # include <DXProgrammableCapture.h> |
75 | # include <dxgidebug.h> |
76 | # endif |
77 | # endif |
78 | |
79 | # undef near |
80 | # undef far |
81 | #endif |
82 | |
83 | #if defined(_MSC_VER) && !defined(_M_ARM) && !defined(_M_ARM64) |
84 | # include <intrin.h> |
85 | # define ANGLE_USE_SSE |
86 | #elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) |
87 | # include <x86intrin.h> |
88 | # define ANGLE_USE_SSE |
89 | #endif |
90 | |
91 | // Mips and arm devices need to include stddef for size_t. |
92 | #if defined(__mips__) || defined(__arm__) || defined(__aarch64__) |
93 | # include <stddef.h> |
94 | #endif |
95 | |
96 | // The MemoryBarrier function name collides with a macro under Windows |
97 | // We will undef the macro so that the function name does not get replaced |
98 | #undef MemoryBarrier |
99 | |
100 | // Macro for hinting that an expression is likely to be true/false. |
101 | #if !defined(ANGLE_LIKELY) || !defined(ANGLE_UNLIKELY) |
102 | # if defined(__GNUC__) || defined(__clang__) |
103 | # define ANGLE_LIKELY(x) __builtin_expect(!!(x), 1) |
104 | # define ANGLE_UNLIKELY(x) __builtin_expect(!!(x), 0) |
105 | # else |
106 | # define ANGLE_LIKELY(x) (x) |
107 | # define ANGLE_UNLIKELY(x) (x) |
108 | # endif // defined(__GNUC__) || defined(__clang__) |
109 | #endif // !defined(ANGLE_LIKELY) || !defined(ANGLE_UNLIKELY) |
110 | |
111 | #endif // COMMON_PLATFORM_H_ |
112 | |