• 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 #ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_
31 #define CEF_INCLUDE_BASE_CEF_BUILD_H_
32 #pragma once
33 
34 #if defined(USING_CHROMIUM_INCLUDES)
35 // When building CEF include the Chromium header directly.
36 #include "base/compiler_specific.h"
37 #else  // !USING_CHROMIUM_INCLUDES
38 // The following is substantially similar to the Chromium implementation.
39 // If the Chromium implementation diverges the below implementation should be
40 // updated to match.
41 
42 #if defined(_WIN32)
43 #ifndef OS_WIN
44 #define OS_WIN 1
45 #endif
46 #elif defined(__APPLE__)
47 // New platform defines after https://crbug.com/1105907.
48 #ifndef OS_MAC
49 #define OS_MAC 1
50 #endif
51 #ifndef OS_APPLE
52 #define OS_APPLE 1
53 #endif
54 // Old platform defines retained for backwards compatibility.
55 #ifndef OS_MACOSX
56 #define OS_MACOSX 1
57 #endif
58 #elif defined(__linux__)
59 #ifndef OS_LINUX
60 #define OS_LINUX 1
61 #endif
62 #else
63 #error Please add support for your platform in cef_build.h
64 #endif
65 
66 // For access to standard POSIXish features, use OS_POSIX instead of a
67 // more specific macro.
68 #if defined(OS_MAC) || defined(OS_LINUX)
69 #ifndef OS_POSIX
70 #define OS_POSIX 1
71 #endif
72 #endif
73 
74 // Compiler detection.
75 #if defined(__GNUC__)
76 #ifndef COMPILER_GCC
77 #define COMPILER_GCC 1
78 #endif
79 #elif defined(_MSC_VER)
80 #ifndef COMPILER_MSVC
81 #define COMPILER_MSVC 1
82 #endif
83 #else
84 #error Please add support for your compiler in cef_build.h
85 #endif
86 
87 // Processor architecture detection.  For more info on what's defined, see:
88 //   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
89 //   http://www.agner.org/optimize/calling_conventions.pdf
90 //   or with gcc, run: "echo | gcc -E -dM -"
91 #if defined(_M_X64) || defined(__x86_64__)
92 #define ARCH_CPU_X86_FAMILY 1
93 #define ARCH_CPU_X86_64 1
94 #define ARCH_CPU_64_BITS 1
95 #define ARCH_CPU_LITTLE_ENDIAN 1
96 #elif defined(_M_IX86) || defined(__i386__)
97 #define ARCH_CPU_X86_FAMILY 1
98 #define ARCH_CPU_X86 1
99 #define ARCH_CPU_32_BITS 1
100 #define ARCH_CPU_LITTLE_ENDIAN 1
101 #elif defined(__ARMEL__)
102 #define ARCH_CPU_ARM_FAMILY 1
103 #define ARCH_CPU_ARMEL 1
104 #define ARCH_CPU_32_BITS 1
105 #define ARCH_CPU_LITTLE_ENDIAN 1
106 #elif defined(__aarch64__) || defined(_M_ARM64)
107 #define ARCH_CPU_ARM_FAMILY 1
108 #define ARCH_CPU_ARM64 1
109 #define ARCH_CPU_64_BITS 1
110 #define ARCH_CPU_LITTLE_ENDIAN 1
111 #elif defined(__pnacl__)
112 #define ARCH_CPU_32_BITS 1
113 #define ARCH_CPU_LITTLE_ENDIAN 1
114 #elif defined(__MIPSEL__)
115 #define ARCH_CPU_MIPS_FAMILY 1
116 #define ARCH_CPU_MIPSEL 1
117 #define ARCH_CPU_32_BITS 1
118 #define ARCH_CPU_LITTLE_ENDIAN 1
119 #else
120 #error Please add support for your architecture in cef_build.h
121 #endif
122 
123 // Type detection for wchar_t.
124 #if defined(OS_WIN)
125 #define WCHAR_T_IS_UTF16
126 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
127     (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
128 #define WCHAR_T_IS_UTF32
129 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
130     (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
131 // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
132 // compile in this mode (in particular, Chrome doesn't). This is intended for
133 // other projects using base who manage their own dependencies and make sure
134 // short wchar works for them.
135 #define WCHAR_T_IS_UTF16
136 #else
137 #error Please add support for your compiler in cef_build.h
138 #endif
139 
140 // Annotate a function indicating the caller must examine the return value.
141 // Use like:
142 //   int foo() WARN_UNUSED_RESULT;
143 // To explicitly ignore a result, see |ignore_result()| in <base/macros.h>.
144 #ifndef WARN_UNUSED_RESULT
145 #if defined(COMPILER_GCC)
146 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
147 #else
148 #define WARN_UNUSED_RESULT
149 #endif
150 #endif  // WARN_UNUSED_RESULT
151 
152 // Annotate a typedef or function indicating it's ok if it's not used.
153 // Use like:
154 //   typedef Foo Bar ALLOW_UNUSED_TYPE;
155 #ifndef ALLOW_UNUSED_TYPE
156 #if defined(COMPILER_GCC)
157 #define ALLOW_UNUSED_TYPE __attribute__((unused))
158 #else
159 #define ALLOW_UNUSED_TYPE
160 #endif
161 #endif  // ALLOW_UNUSED_TYPE
162 
163 // Annotate a variable indicating it's ok if the variable is not used.
164 // (Typically used to silence a compiler warning when the assignment
165 // is important for some other reason.)
166 // Use like:
167 //   int x = ...;
168 //   ALLOW_UNUSED_LOCAL(x);
169 #ifndef ALLOW_UNUSED_LOCAL
170 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
171 #endif
172 
173 // Sanitizers annotations.
174 #if defined(__has_attribute)
175 #if __has_attribute(no_sanitize)
176 #define NO_SANITIZE(what) __attribute__((no_sanitize(what)))
177 #endif
178 #endif
179 #if !defined(NO_SANITIZE)
180 #define NO_SANITIZE(what)
181 #endif
182 
183 #endif  // !USING_CHROMIUM_INCLUDES
184 
185 // Annotate a virtual method indicating it must be overriding a virtual method
186 // in the parent class.
187 // Use like:
188 //   void foo() OVERRIDE;
189 // NOTE: This define should only be used in classes exposed to the client since
190 // C++11 support may not be enabled in client applications. CEF internal classes
191 // should use the `override` keyword directly.
192 #ifndef OVERRIDE
193 #if defined(__clang__)
194 #define OVERRIDE override
195 #elif defined(COMPILER_MSVC) && _MSC_VER >= 1600
196 // Visual Studio 2010 and later support override.
197 #define OVERRIDE override
198 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
199     (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
200 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
201 #define OVERRIDE override
202 #else
203 #define OVERRIDE
204 #endif
205 #endif  // OVERRIDE
206 
207 // Check for C++11 template alias support which was added in VS2013 and GCC4.7.
208 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
209 #if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1800) || \
210     (defined(__GNUC__) &&                                               \
211      (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700))
212 #define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT
213 #endif
214 
215 #endif  // CEF_INCLUDE_BASE_CEF_BUILD_H_
216