1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file adds defines about the platform we're currently building on.
7 // OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX) /
8 // OS_NACL (NACL_SFI or NACL_NONSFI) / OS_NACL_SFI / OS_NACL_NONSFI
9 // OS_CHROMEOS is set by the build system
11 // COMPILER_MSVC / COMPILER_GCC
13 // ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
14 // ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
16 #ifndef BUILD_BUILD_CONFIG_H_
17 #define BUILD_BUILD_CONFIG_H_
19 // A set of macros to use for platform detection.
20 #if defined(__native_client__)
21 // __native_client__ must be first, so that other OS_ defines are not set.
23 // OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI.
24 // PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build
25 // mode, while it does not in SFI build mode.
26 #if defined(__native_client_nonsfi__)
27 #define OS_NACL_NONSFI
31 #elif defined(ANDROID)
33 #elif defined(__APPLE__)
34 // only include TargetConditions after testing ANDROID as some android builds
35 // on mac don't have this header available and it's not needed unless the target
37 #include <TargetConditionals.h>
39 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
41 #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
42 #elif defined(__linux__)
44 // include a system header to pull in features.h for glibc/uclibc macros.
46 #if defined(__GLIBC__) && !defined(__UCLIBC__)
47 // we really are using glibc, not uClibc pretending to be glibc
52 #elif defined(__Fuchsia__)
54 #elif defined(__FreeBSD__)
56 #elif defined(__NetBSD__)
58 #elif defined(__OpenBSD__)
62 #elif defined(__QNXNTO__)
66 #elif defined(__asmjs__)
69 #error Please add support for your platform in build/build_config.h
71 // NOTE: Adding a new port? Please follow
72 // https://chromium.googlesource.com/chromium/src/+/master/docs/new_port_policy.md
74 // For access to standard BSD features, use OS_BSD instead of a
75 // more specific macro.
76 #if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD)
80 // For access to standard POSIXish features, use OS_POSIX instead of a
81 // more specific macro.
82 #if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) || \
83 defined(OS_FREEBSD) || defined(OS_LINUX) || defined(OS_MACOSX) || \
84 defined(OS_NACL) || defined(OS_NETBSD) || defined(OS_OPENBSD) || \
85 defined(OS_QNX) || defined(OS_SOLARIS)
90 #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
92 #define USE_TCMALLOC 1
95 // Compiler detection.
97 #define COMPILER_GCC 1
98 #elif defined(_MSC_VER)
99 #define COMPILER_MSVC 1
101 #error Please add support for your compiler in build/build_config.h
104 // Processor architecture detection. For more info on what's defined, see:
105 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx
106 // http://www.agner.org/optimize/calling_conventions.pdf
107 // or with gcc, run: "echo | gcc -E -dM -"
108 #if defined(_M_X64) || defined(__x86_64__)
109 #define ARCH_CPU_X86_FAMILY 1
110 #define ARCH_CPU_X86_64 1
111 #define ARCH_CPU_64_BITS 1
112 #define ARCH_CPU_LITTLE_ENDIAN 1
113 #elif defined(_M_IX86) || defined(__i386__)
114 #define ARCH_CPU_X86_FAMILY 1
115 #define ARCH_CPU_X86 1
116 #define ARCH_CPU_32_BITS 1
117 #define ARCH_CPU_LITTLE_ENDIAN 1
118 #elif defined(__s390x__)
119 #define ARCH_CPU_S390_FAMILY 1
120 #define ARCH_CPU_S390X 1
121 #define ARCH_CPU_64_BITS 1
122 #define ARCH_CPU_BIG_ENDIAN 1
123 #elif defined(__s390__)
124 #define ARCH_CPU_S390_FAMILY 1
125 #define ARCH_CPU_S390 1
126 #define ARCH_CPU_31_BITS 1
127 #define ARCH_CPU_BIG_ENDIAN 1
128 #elif (defined(__PPC64__) || defined(__PPC__)) && defined(__BIG_ENDIAN__)
129 #define ARCH_CPU_PPC64_FAMILY 1
130 #define ARCH_CPU_PPC64 1
131 #define ARCH_CPU_64_BITS 1
132 #define ARCH_CPU_BIG_ENDIAN 1
133 #elif defined(__PPC64__)
134 #define ARCH_CPU_PPC64_FAMILY 1
135 #define ARCH_CPU_PPC64 1
136 #define ARCH_CPU_64_BITS 1
137 #define ARCH_CPU_LITTLE_ENDIAN 1
138 #elif defined(__ARMEL__)
139 #define ARCH_CPU_ARM_FAMILY 1
140 #define ARCH_CPU_ARMEL 1
141 #define ARCH_CPU_32_BITS 1
142 #define ARCH_CPU_LITTLE_ENDIAN 1
143 #elif defined(__aarch64__) || defined(_M_ARM64)
144 #define ARCH_CPU_ARM_FAMILY 1
145 #define ARCH_CPU_ARM64 1
146 #define ARCH_CPU_64_BITS 1
147 #define ARCH_CPU_LITTLE_ENDIAN 1
148 #elif defined(__pnacl__) || defined(__asmjs__)
149 #define ARCH_CPU_32_BITS 1
150 #define ARCH_CPU_LITTLE_ENDIAN 1
151 #elif defined(__MIPSEL__)
152 #if defined(__LP64__)
153 #define ARCH_CPU_MIPS_FAMILY 1
154 #define ARCH_CPU_MIPS64EL 1
155 #define ARCH_CPU_64_BITS 1
156 #define ARCH_CPU_LITTLE_ENDIAN 1
158 #define ARCH_CPU_MIPS_FAMILY 1
159 #define ARCH_CPU_MIPSEL 1
160 #define ARCH_CPU_32_BITS 1
161 #define ARCH_CPU_LITTLE_ENDIAN 1
163 #elif defined(__MIPSEB__)
164 #if defined(__LP64__)
165 #define ARCH_CPU_MIPS_FAMILY 1
166 #define ARCH_CPU_MIPS64 1
167 #define ARCH_CPU_64_BITS 1
168 #define ARCH_CPU_BIG_ENDIAN 1
170 #define ARCH_CPU_MIPS_FAMILY 1
171 #define ARCH_CPU_MIPS 1
172 #define ARCH_CPU_32_BITS 1
173 #define ARCH_CPU_BIG_ENDIAN 1
176 #error Please add support for your architecture in build/build_config.h
179 // Type detection for wchar_t.
181 #define WCHAR_T_IS_UTF16
182 #elif defined(OS_FUCHSIA)
183 #define WCHAR_T_IS_UTF32
184 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
185 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
186 #define WCHAR_T_IS_UTF32
187 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
188 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
189 // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
190 // compile in this mode (in particular, Chrome doesn't). This is intended for
191 // other projects using base who manage their own dependencies and make sure
192 // short wchar works for them.
193 #define WCHAR_T_IS_UTF16
195 #error Please add support for your compiler in build/build_config.h
198 #if defined(OS_ANDROID)
199 // The compiler thinks std::string::const_iterator and "const char*" are
201 #define STD_STRING_ITERATOR_IS_CHAR_POINTER
202 // The compiler thinks base::string16::const_iterator and "char16*" are
204 #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
207 #endif // BUILD_BUILD_CONFIG_H_