blob: e26d75e5723aa8999c78fe576d1058bf6c44af91 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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// Compiler:
9// COMPILER_MSVC / COMPILER_GCC
10// Processor:
11// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
12// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
13
14#ifndef BUILD_BUILD_CONFIG_H_
15#define BUILD_BUILD_CONFIG_H_
16
17#if defined(__APPLE__)
18#include <TargetConditionals.h>
19#endif
20
21// A set of macros to use for platform detection.
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +010022#if defined(ANDROID)
23#define OS_ANDROID 1
24#elif defined(__APPLE__)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000025#define OS_MACOSX 1
26#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
27#define OS_IOS 1
28#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
Torne (Richard Coles)58218062012-11-14 11:43:16 +000029#elif defined(__native_client__)
30#define OS_NACL 1
31#elif defined(__linux__)
32#define OS_LINUX 1
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010033#if defined(__GLIBC__) && !defined(__UCLIBC__)
34// we really are using glibc, not uClibc pretending to be glibc
Ben Murdochc5cede92014-04-10 11:22:14 +010035#define LIBC_GLIBC 1
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010036#endif
Torne (Richard Coles)58218062012-11-14 11:43:16 +000037#elif defined(_WIN32)
38#define OS_WIN 1
39#define TOOLKIT_VIEWS 1
40#elif defined(__FreeBSD__)
41#define OS_FREEBSD 1
Torne (Richard Coles)58218062012-11-14 11:43:16 +000042#elif defined(__OpenBSD__)
43#define OS_OPENBSD 1
Torne (Richard Coles)58218062012-11-14 11:43:16 +000044#elif defined(__sun)
45#define OS_SOLARIS 1
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000046#elif defined(__QNXNTO__)
47#define OS_QNX 1
Torne (Richard Coles)58218062012-11-14 11:43:16 +000048#else
49#error Please add support for your platform in build/build_config.h
50#endif
51
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000052// Use TOOLKIT_GTK on X11 if TOOLKIT_VIEWS and USE_AURA aren't defined.
53#if defined(USE_X11) && !defined(TOOLKIT_VIEWS) && !defined(USE_AURA) && \
54 !defined(OS_NACL)
55#define TOOLKIT_GTK
56#endif
57
Torne (Richard Coles)58218062012-11-14 11:43:16 +000058#if defined(USE_OPENSSL) && defined(USE_NSS)
59#error Cannot use both OpenSSL and NSS
60#endif
61
62// For access to standard BSD features, use OS_BSD instead of a
63// more specific macro.
64#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
65#define OS_BSD 1
66#endif
67
68// For access to standard POSIXish features, use OS_POSIX instead of a
69// more specific macro.
70#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
71 defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000072 defined(OS_NACL) || defined(OS_QNX)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000073#define OS_POSIX 1
74#endif
75
Torne (Richard Coles)58218062012-11-14 11:43:16 +000076// Use tcmalloc
Torne (Richard Coles)90dce4d2013-05-29 14:40:03 +010077#if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
78 !defined(NO_TCMALLOC)
Torne (Richard Coles)58218062012-11-14 11:43:16 +000079#define USE_TCMALLOC 1
80#endif
81
82// Compiler detection.
83#if defined(__GNUC__)
84#define COMPILER_GCC 1
85#elif defined(_MSC_VER)
86#define COMPILER_MSVC 1
87#else
88#error Please add support for your compiler in build/build_config.h
89#endif
90
91// Processor architecture detection. For more info on what's defined, see:
92// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
93// http://www.agner.org/optimize/calling_conventions.pdf
94// or with gcc, run: "echo | gcc -E -dM -"
95#if defined(_M_X64) || defined(__x86_64__)
96#define ARCH_CPU_X86_FAMILY 1
97#define ARCH_CPU_X86_64 1
98#define ARCH_CPU_64_BITS 1
99#define ARCH_CPU_LITTLE_ENDIAN 1
100#elif defined(_M_IX86) || defined(__i386__)
101#define ARCH_CPU_X86_FAMILY 1
102#define ARCH_CPU_X86 1
103#define ARCH_CPU_32_BITS 1
104#define ARCH_CPU_LITTLE_ENDIAN 1
105#elif defined(__ARMEL__)
106#define ARCH_CPU_ARM_FAMILY 1
107#define ARCH_CPU_ARMEL 1
108#define ARCH_CPU_32_BITS 1
109#define ARCH_CPU_LITTLE_ENDIAN 1
Ben Murdoche5d81f52014-04-03 12:29:45 +0100110#elif defined(__aarch64__)
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +0000111#define ARCH_CPU_ARM_FAMILY 1
112#define ARCH_CPU_ARM64 1
113#define ARCH_CPU_64_BITS 1
114#define ARCH_CPU_LITTLE_ENDIAN 1
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000115#elif defined(__pnacl__)
116#define ARCH_CPU_32_BITS 1
Torne (Richard Coles)a3f6a492013-12-18 16:25:09 +0000117#define ARCH_CPU_LITTLE_ENDIAN 1
Torne (Richard Coles)58218062012-11-14 11:43:16 +0000118#elif defined(__MIPSEL__)
119#define ARCH_CPU_MIPS_FAMILY 1
120#define ARCH_CPU_MIPSEL 1
121#define ARCH_CPU_32_BITS 1
122#define ARCH_CPU_LITTLE_ENDIAN 1
123#else
124#error Please add support for your architecture in build/build_config.h
125#endif
126
127// Type detection for wchar_t.
128#if defined(OS_WIN)
129#define WCHAR_T_IS_UTF16
130#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
131 defined(__WCHAR_MAX__) && \
132 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
133#define WCHAR_T_IS_UTF32
134#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
135 defined(__WCHAR_MAX__) && \
136 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
137// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
138// compile in this mode (in particular, Chrome doesn't). This is intended for
139// other projects using base who manage their own dependencies and make sure
140// short wchar works for them.
141#define WCHAR_T_IS_UTF16
142#else
143#error Please add support for your compiler in build/build_config.h
144#endif
145
146#if defined(__ARMEL__) && !defined(OS_IOS)
147#define WCHAR_T_IS_UNSIGNED 1
148#elif defined(__MIPSEL__)
149#define WCHAR_T_IS_UNSIGNED 0
150#endif
151
152#if defined(OS_ANDROID)
153// The compiler thinks std::string::const_iterator and "const char*" are
154// equivalent types.
155#define STD_STRING_ITERATOR_IS_CHAR_POINTER
156// The compiler thinks base::string16::const_iterator and "char16*" are
157// equivalent types.
158#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
159#endif
160
161#endif // BUILD_BUILD_CONFIG_H_