blob: fd5489f6459bedf3045a19cc3887821144a9eef6 [file] [log] [blame]
Luis Hector Chavez645501c2016-12-28 10:56:26 -08001// 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.
4
5// This file adds defines about the platform we're currently building on.
6// Operating System:
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
Jay Civellicfc1eaa2017-08-21 17:18:10 -07009// OS_CHROMEOS is set by the build system
Luis Hector Chavez645501c2016-12-28 10:56:26 -080010// Compiler:
11// COMPILER_MSVC / COMPILER_GCC
12// Processor:
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
15
16#ifndef BUILD_BUILD_CONFIG_H_
17#define BUILD_BUILD_CONFIG_H_
18
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.
22#define OS_NACL 1
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
28#else
29#define OS_NACL_SFI
30#endif
31#elif defined(ANDROID)
32#define OS_ANDROID 1
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
36// is really mac/ios.
37#include <TargetConditionals.h>
38#define OS_MACOSX 1
39#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
40#define OS_IOS 1
41#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
42#elif defined(__linux__)
43#define OS_LINUX 1
44// include a system header to pull in features.h for glibc/uclibc macros.
45#include <unistd.h>
46#if defined(__GLIBC__) && !defined(__UCLIBC__)
47// we really are using glibc, not uClibc pretending to be glibc
48#define LIBC_GLIBC 1
49#endif
50#elif defined(_WIN32)
51#define OS_WIN 1
Luis Hector Chavez645501c2016-12-28 10:56:26 -080052#elif defined(__FreeBSD__)
53#define OS_FREEBSD 1
Jay Civellicfc1eaa2017-08-21 17:18:10 -070054#elif defined(__NetBSD__)
55#define OS_NETBSD 1
Luis Hector Chavez645501c2016-12-28 10:56:26 -080056#elif defined(__OpenBSD__)
57#define OS_OPENBSD 1
58#elif defined(__sun)
59#define OS_SOLARIS 1
60#elif defined(__QNXNTO__)
61#define OS_QNX 1
62#else
63#error Please add support for your platform in build/build_config.h
64#endif
65
66#if defined(USE_OPENSSL_CERTS) && defined(USE_NSS_CERTS)
67#error Cannot use both OpenSSL and NSS for certificates
68#endif
69
70// For access to standard BSD features, use OS_BSD instead of a
71// more specific macro.
Jay Civellicfc1eaa2017-08-21 17:18:10 -070072#if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD)
Luis Hector Chavez645501c2016-12-28 10:56:26 -080073#define OS_BSD 1
74#endif
75
76// For access to standard POSIXish features, use OS_POSIX instead of a
77// more specific macro.
78#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
Jay Civellicfc1eaa2017-08-21 17:18:10 -070079 defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_SOLARIS) || \
80 defined(OS_ANDROID) || defined(OS_OPENBSD) || defined(OS_SOLARIS) || \
81 defined(OS_ANDROID) || defined(OS_NACL) || defined(OS_QNX)
Luis Hector Chavez645501c2016-12-28 10:56:26 -080082#define OS_POSIX 1
83#endif
84
85// Use tcmalloc
86#if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
87 !defined(NO_TCMALLOC)
88#define USE_TCMALLOC 1
89#endif
90
91// Compiler detection.
92#if defined(__GNUC__)
93#define COMPILER_GCC 1
94#elif defined(_MSC_VER)
95#define COMPILER_MSVC 1
96#else
97#error Please add support for your compiler in build/build_config.h
98#endif
99
100// Processor architecture detection. For more info on what's defined, see:
101// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
102// http://www.agner.org/optimize/calling_conventions.pdf
103// or with gcc, run: "echo | gcc -E -dM -"
104#if defined(_M_X64) || defined(__x86_64__)
105#define ARCH_CPU_X86_FAMILY 1
106#define ARCH_CPU_X86_64 1
107#define ARCH_CPU_64_BITS 1
108#define ARCH_CPU_LITTLE_ENDIAN 1
109#elif defined(_M_IX86) || defined(__i386__)
110#define ARCH_CPU_X86_FAMILY 1
111#define ARCH_CPU_X86 1
112#define ARCH_CPU_32_BITS 1
113#define ARCH_CPU_LITTLE_ENDIAN 1
Jay Civellicfc1eaa2017-08-21 17:18:10 -0700114#elif defined(__s390x__)
115#define ARCH_CPU_S390_FAMILY 1
116#define ARCH_CPU_S390X 1
117#define ARCH_CPU_64_BITS 1
118#define ARCH_CPU_BIG_ENDIAN 1
119#elif defined(__s390__)
120#define ARCH_CPU_S390_FAMILY 1
121#define ARCH_CPU_S390 1
122#define ARCH_CPU_31_BITS 1
123#define ARCH_CPU_BIG_ENDIAN 1
124#elif defined(__PPC64__) && defined(__BIG_ENDIAN__)
125#define ARCH_CPU_PPC64_FAMILY 1
126#define ARCH_CPU_PPC64 1
127#define ARCH_CPU_64_BITS 1
128#define ARCH_CPU_BIG_ENDIAN 1
129#elif defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
130#define ARCH_CPU_PPC64_FAMILY 1
131#define ARCH_CPU_PPC64 1
132#define ARCH_CPU_64_BITS 1
133#define ARCH_CPU_LITTLE_ENDIAN 1
134#elif defined(__PPC__)
135#define ARCH_CPU_PPC_FAMILY 1
136#define ARCH_CPU_PPC 1
137#define ARCH_CPU_32_BITS 1
138#define ARCH_CPU_BIG_ENDIAN 1
Luis Hector Chavez645501c2016-12-28 10:56:26 -0800139#elif defined(__ARMEL__)
140#define ARCH_CPU_ARM_FAMILY 1
141#define ARCH_CPU_ARMEL 1
142#define ARCH_CPU_32_BITS 1
143#define ARCH_CPU_LITTLE_ENDIAN 1
144#elif defined(__aarch64__)
145#define ARCH_CPU_ARM_FAMILY 1
146#define ARCH_CPU_ARM64 1
147#define ARCH_CPU_64_BITS 1
148#define ARCH_CPU_LITTLE_ENDIAN 1
149#elif defined(__pnacl__)
150#define ARCH_CPU_32_BITS 1
151#define ARCH_CPU_LITTLE_ENDIAN 1
152#elif defined(__MIPSEL__)
153#if defined(__LP64__)
154#define ARCH_CPU_MIPS_FAMILY 1
155#define ARCH_CPU_MIPS64EL 1
156#define ARCH_CPU_64_BITS 1
157#define ARCH_CPU_LITTLE_ENDIAN 1
158#else
159#define ARCH_CPU_MIPS_FAMILY 1
160#define ARCH_CPU_MIPSEL 1
161#define ARCH_CPU_32_BITS 1
162#define ARCH_CPU_LITTLE_ENDIAN 1
163#endif
164#else
165#error Please add support for your architecture in build/build_config.h
166#endif
167
168// Type detection for wchar_t.
169#if defined(OS_WIN)
170#define WCHAR_T_IS_UTF16
171#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
172 defined(__WCHAR_MAX__) && \
173 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
174#define WCHAR_T_IS_UTF32
175#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
176 defined(__WCHAR_MAX__) && \
177 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
178// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
179// compile in this mode (in particular, Chrome doesn't). This is intended for
180// other projects using base who manage their own dependencies and make sure
181// short wchar works for them.
182#define WCHAR_T_IS_UTF16
183#else
184#error Please add support for your compiler in build/build_config.h
185#endif
186
187#if defined(OS_ANDROID)
188// The compiler thinks std::string::const_iterator and "const char*" are
189// equivalent types.
190#define STD_STRING_ITERATOR_IS_CHAR_POINTER
191// The compiler thinks base::string16::const_iterator and "char16*" are
192// equivalent types.
193#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
194#endif
195
196#endif // BUILD_BUILD_CONFIG_H_