• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 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(__ggp__)
24 #    define ANGLE_PLATFORM_GGP 1
25 #    define ANGLE_PLATFORM_POSIX 1
26 #elif defined(__linux__) || defined(EMSCRIPTEN)
27 #    define ANGLE_PLATFORM_LINUX 1
28 #    define ANGLE_PLATFORM_POSIX 1
29 #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) ||              \
30     defined(__DragonFly__) || defined(__sun) || defined(__GLIBC__) || defined(__GNU__) || \
31     defined(__QNX__) || defined(__Fuchsia__) || defined(__HAIKU__)
32 #    define ANGLE_PLATFORM_POSIX 1
33 #else
34 #    error Unsupported platform.
35 #endif
36 
37 #ifdef ANGLE_PLATFORM_WINDOWS
38 #    ifndef STRICT
39 #        define STRICT 1
40 #    endif
41 #    ifndef WIN32_LEAN_AND_MEAN
42 #        define WIN32_LEAN_AND_MEAN 1
43 #    endif
44 #    ifndef NOMINMAX
45 #        define NOMINMAX 1
46 #    endif
47 
48 #    include <intrin.h>
49 #    include <windows.h>
50 
51 #    if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP)
52 #        define ANGLE_ENABLE_WINDOWS_UWP 1
53 #    endif
54 
55 #    if defined(ANGLE_ENABLE_D3D9)
56 #        include <d3d9.h>
57 #        include <d3dcompiler.h>
58 #    endif
59 
60 // Include D3D11 headers when OpenGL is enabled on Windows for interop extensions.
61 #    if defined(ANGLE_ENABLE_D3D11) || defined(ANGLE_ENABLE_OPENGL)
62 #        include <d3d10_1.h>
63 #        include <d3d11.h>
64 #        include <d3d11_3.h>
65 #        include <d3d11on12.h>
66 #        include <d3d12.h>
67 #        include <d3dcompiler.h>
68 #        include <dxgi.h>
69 #        include <dxgi1_2.h>
70 #        include <dxgi1_4.h>
71 #    endif
72 
73 #    if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11)
74 #        include <wrl.h>
75 #    endif
76 
77 #    if defined(ANGLE_ENABLE_WINDOWS_UWP)
78 #        include <dxgi1_3.h>
79 #        if defined(_DEBUG)
80 #            include <DXProgrammableCapture.h>
81 #            include <dxgidebug.h>
82 #        endif
83 #    endif
84 
85 #    undef near
86 #    undef far
87 #endif
88 
89 #if defined(_MSC_VER) && !defined(_M_ARM) && !defined(_M_ARM64)
90 #    include <intrin.h>
91 #    define ANGLE_USE_SSE
92 #elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
93 #    include <x86intrin.h>
94 #    define ANGLE_USE_SSE
95 #endif
96 
97 // Mips and arm devices need to include stddef for size_t.
98 #if defined(__mips__) || defined(__arm__) || defined(__aarch64__)
99 #    include <stddef.h>
100 #endif
101 
102 // The MemoryBarrier function name collides with a macro under Windows
103 // We will undef the macro so that the function name does not get replaced
104 #undef MemoryBarrier
105 
106 // Macro for hinting that an expression is likely to be true/false.
107 #if !defined(ANGLE_LIKELY) || !defined(ANGLE_UNLIKELY)
108 #    if defined(__GNUC__) || defined(__clang__)
109 #        define ANGLE_LIKELY(x) __builtin_expect(!!(x), 1)
110 #        define ANGLE_UNLIKELY(x) __builtin_expect(!!(x), 0)
111 #    else
112 #        define ANGLE_LIKELY(x) (x)
113 #        define ANGLE_UNLIKELY(x) (x)
114 #    endif  // defined(__GNUC__) || defined(__clang__)
115 #endif      // !defined(ANGLE_LIKELY) || !defined(ANGLE_UNLIKELY)
116 
117 #ifdef ANGLE_PLATFORM_APPLE
118 #    include <TargetConditionals.h>
119 #    if TARGET_OS_OSX
120 #        define ANGLE_PLATFORM_MACOS 1
121 #    elif TARGET_OS_IPHONE
122 #        define ANGLE_PLATFORM_IOS 1
123 #        define GLES_SILENCE_DEPRECATION
124 #        if TARGET_OS_SIMULATOR
125 #            define ANGLE_PLATFORM_IOS_SIMULATOR 1
126 #        endif
127 #        if TARGET_OS_MACCATALYST
128 #            define ANGLE_PLATFORM_MACCATALYST
129 #        endif
130 #    endif
131 #endif
132 
133 // Define ANGLE_WITH_ASAN macro.
134 #if defined(__has_feature)
135 #    if __has_feature(address_sanitizer)
136 #        define ANGLE_WITH_ASAN 1
137 #    endif
138 #endif
139 
140 #endif  // COMMON_PLATFORM_H_
141