• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 // This file adds defines about the platform we're currently building on.
31 //
32 //  Operating System:
33 //    OS_AIX / OS_ANDROID / OS_ASMJS / OS_FREEBSD / OS_FUCHSIA / OS_IOS /
34 //    OS_LINUX / OS_MAC / OS_NACL (SFI or NONSFI) / OS_NETBSD / OS_OPENBSD /
35 //    OS_QNX / OS_SOLARIS / OS_WIN
36 //  Operating System family:
37 //    OS_APPLE: IOS or MAC
38 //    OS_BSD: FREEBSD or NETBSD or OPENBSD
39 //    OS_POSIX: AIX or ANDROID or ASMJS or CHROMEOS or FREEBSD or IOS or LINUX
40 //              or MAC or NACL or NETBSD or OPENBSD or QNX or SOLARIS
41 //
42 //  /!\ Note: OS_CHROMEOS is set by the build system, not this file
43 //
44 //  Compiler:
45 //    COMPILER_MSVC / COMPILER_GCC
46 //
47 //  Processor:
48 //    ARCH_CPU_ARM64 / ARCH_CPU_ARMEL / ARCH_CPU_MIPS / ARCH_CPU_MIPS64 /
49 //    ARCH_CPU_MIPS64EL / ARCH_CPU_MIPSEL / ARCH_CPU_PPC64 / ARCH_CPU_S390 /
50 //    ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64
51 //  Processor family:
52 //    ARCH_CPU_ARM_FAMILY: ARMEL or ARM64
53 //    ARCH_CPU_MIPS_FAMILY: MIPS64EL or MIPSEL or MIPS64 or MIPS
54 //    ARCH_CPU_PPC64_FAMILY: PPC64
55 //    ARCH_CPU_S390_FAMILY: S390 or S390X
56 //    ARCH_CPU_X86_FAMILY: X86 or X86_64
57 //  Processor features:
58 //    ARCH_CPU_31_BITS / ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
59 //    ARCH_CPU_BIG_ENDIAN / ARCH_CPU_LITTLE_ENDIAN
60 
61 #ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_
62 #define CEF_INCLUDE_BASE_CEF_BUILD_H_
63 #pragma once
64 
65 #if defined(USING_CHROMIUM_INCLUDES)
66 // When building CEF include the Chromium header directly.
67 #include "build/build_config.h"
68 #else  // !USING_CHROMIUM_INCLUDES
69 // The following is substantially similar to the Chromium implementation.
70 // If the Chromium implementation diverges the below implementation should be
71 // updated to match.
72 
73 // A set of macros to use for platform detection.
74 #if defined(ANDROID)
75 #define OS_ANDROID 1
76 #elif defined(__APPLE__)
77 // Only include TargetConditionals after testing ANDROID as some Android builds
78 // on the Mac have this header available and it's not needed unless the target
79 // is really an Apple platform.
80 #include <TargetConditionals.h>
81 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
82 #define OS_IOS 1
83 #else
84 #define OS_MAC 1
85 // For backwards compatibility.
86 #define OS_MACOSX 1
87 #endif  // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
88 #elif defined(__linux__)
89 #if !defined(OS_CHROMEOS)
90 // Do not define OS_LINUX on Chrome OS build.
91 // The OS_CHROMEOS macro is defined in GN.
92 #define OS_LINUX 1
93 #endif  // !defined(OS_CHROMEOS)
94 // Include a system header to pull in features.h for glibc/uclibc macros.
95 #include <unistd.h>
96 #if defined(__GLIBC__) && !defined(__UCLIBC__)
97 // We really are using glibc, not uClibc pretending to be glibc.
98 #define LIBC_GLIBC 1
99 #endif
100 #elif defined(_WIN32)
101 #define OS_WIN 1
102 #elif defined(__Fuchsia__)
103 #define OS_FUCHSIA 1
104 #elif defined(__FreeBSD__)
105 #define OS_FREEBSD 1
106 #elif defined(__NetBSD__)
107 #define OS_NETBSD 1
108 #elif defined(__OpenBSD__)
109 #define OS_OPENBSD 1
110 #elif defined(__sun)
111 #define OS_SOLARIS 1
112 #elif defined(__QNXNTO__)
113 #define OS_QNX 1
114 #elif defined(_AIX)
115 #define OS_AIX 1
116 #elif defined(__asmjs__) || defined(__wasm__)
117 #define OS_ASMJS 1
118 #else
119 #error Please add support for your platform in include/base/cef_build.h
120 #endif
121 // NOTE: Adding a new port? Please follow
122 // https://chromium.googlesource.com/chromium/src/+/master/docs/new_port_policy.md
123 
124 #if defined(OS_MAC) || defined(OS_IOS)
125 #define OS_APPLE 1
126 #endif
127 
128 // For access to standard BSD features, use OS_BSD instead of a
129 // more specific macro.
130 #if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD)
131 #define OS_BSD 1
132 #endif
133 
134 // For access to standard POSIXish features, use OS_POSIX instead of a
135 // more specific macro.
136 #if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) ||  \
137     defined(OS_FREEBSD) || defined(OS_IOS) || defined(OS_LINUX) ||  \
138     defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_NACL) ||  \
139     defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_QNX) || \
140     defined(OS_SOLARIS)
141 #define OS_POSIX 1
142 #endif
143 
144 // Compiler detection. Note: clang masquerades as GCC on POSIX and as MSVC on
145 // Windows.
146 #if defined(__GNUC__)
147 #define COMPILER_GCC 1
148 #elif defined(_MSC_VER)
149 #define COMPILER_MSVC 1
150 #else
151 #error Please add support for your compiler in build/build_config.h
152 #endif
153 
154 // Processor architecture detection.  For more info on what's defined, see:
155 //   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
156 //   http://www.agner.org/optimize/calling_conventions.pdf
157 //   or with gcc, run: "echo | gcc -E -dM -"
158 #if defined(_M_X64) || defined(__x86_64__)
159 #define ARCH_CPU_X86_FAMILY 1
160 #define ARCH_CPU_X86_64 1
161 #define ARCH_CPU_64_BITS 1
162 #define ARCH_CPU_LITTLE_ENDIAN 1
163 #elif defined(_M_IX86) || defined(__i386__)
164 #define ARCH_CPU_X86_FAMILY 1
165 #define ARCH_CPU_X86 1
166 #define ARCH_CPU_32_BITS 1
167 #define ARCH_CPU_LITTLE_ENDIAN 1
168 #elif defined(__s390x__)
169 #define ARCH_CPU_S390_FAMILY 1
170 #define ARCH_CPU_S390X 1
171 #define ARCH_CPU_64_BITS 1
172 #define ARCH_CPU_BIG_ENDIAN 1
173 #elif defined(__s390__)
174 #define ARCH_CPU_S390_FAMILY 1
175 #define ARCH_CPU_S390 1
176 #define ARCH_CPU_31_BITS 1
177 #define ARCH_CPU_BIG_ENDIAN 1
178 #elif (defined(__PPC64__) || defined(__PPC__)) && defined(__BIG_ENDIAN__)
179 #define ARCH_CPU_PPC64_FAMILY 1
180 #define ARCH_CPU_PPC64 1
181 #define ARCH_CPU_64_BITS 1
182 #define ARCH_CPU_BIG_ENDIAN 1
183 #elif defined(__PPC64__)
184 #define ARCH_CPU_PPC64_FAMILY 1
185 #define ARCH_CPU_PPC64 1
186 #define ARCH_CPU_64_BITS 1
187 #define ARCH_CPU_LITTLE_ENDIAN 1
188 #elif defined(__ARMEL__)
189 #define ARCH_CPU_ARM_FAMILY 1
190 #define ARCH_CPU_ARMEL 1
191 #define ARCH_CPU_32_BITS 1
192 #define ARCH_CPU_LITTLE_ENDIAN 1
193 #elif defined(__aarch64__) || defined(_M_ARM64)
194 #define ARCH_CPU_ARM_FAMILY 1
195 #define ARCH_CPU_ARM64 1
196 #define ARCH_CPU_64_BITS 1
197 #define ARCH_CPU_LITTLE_ENDIAN 1
198 #elif defined(__pnacl__) || defined(__asmjs__) || defined(__wasm__)
199 #define ARCH_CPU_32_BITS 1
200 #define ARCH_CPU_LITTLE_ENDIAN 1
201 #elif defined(__MIPSEL__)
202 #if defined(__LP64__)
203 #define ARCH_CPU_MIPS_FAMILY 1
204 #define ARCH_CPU_MIPS64EL 1
205 #define ARCH_CPU_64_BITS 1
206 #define ARCH_CPU_LITTLE_ENDIAN 1
207 #else
208 #define ARCH_CPU_MIPS_FAMILY 1
209 #define ARCH_CPU_MIPSEL 1
210 #define ARCH_CPU_32_BITS 1
211 #define ARCH_CPU_LITTLE_ENDIAN 1
212 #endif
213 #elif defined(__MIPSEB__)
214 #if defined(__LP64__)
215 #define ARCH_CPU_MIPS_FAMILY 1
216 #define ARCH_CPU_MIPS64 1
217 #define ARCH_CPU_64_BITS 1
218 #define ARCH_CPU_BIG_ENDIAN 1
219 #else
220 #define ARCH_CPU_MIPS_FAMILY 1
221 #define ARCH_CPU_MIPS 1
222 #define ARCH_CPU_32_BITS 1
223 #define ARCH_CPU_BIG_ENDIAN 1
224 #endif
225 #else
226 #error Please add support for your architecture in include/base/cef_build.h
227 #endif
228 
229 // Type detection for wchar_t.
230 #if defined(OS_WIN)
231 #define WCHAR_T_IS_UTF16
232 #elif defined(OS_FUCHSIA)
233 #define WCHAR_T_IS_UTF32
234 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
235     (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
236 #define WCHAR_T_IS_UTF32
237 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
238     (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
239 // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
240 // compile in this mode (in particular, Chrome doesn't). This is intended for
241 // other projects using base who manage their own dependencies and make sure
242 // short wchar works for them.
243 #define WCHAR_T_IS_UTF16
244 #else
245 #error Please add support for your compiler in include/base/cef_build.h
246 #endif
247 
248 #if defined(OS_ANDROID)
249 // The compiler thinks std::string::const_iterator and "const char*" are
250 // equivalent types.
251 #define STD_STRING_ITERATOR_IS_CHAR_POINTER
252 // The compiler thinks std::u16string::const_iterator and "char16*" are
253 // equivalent types.
254 #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
255 #endif
256 
257 #endif  // !USING_CHROMIUM_INCLUDES
258 
259 #endif  // CEF_INCLUDE_BASE_CEF_BUILD_H_
260