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