evan@chromium.org | 50dfbc4 | 2012-01-24 21:26:40 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 4 | |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 5 | // This file adds defines about the platform we're currently building on. |
| 6 | // Operating System: |
hidehiko | 721e604 | 2014-10-28 20:57:21 +0900 | [diff] [blame] | 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 |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 9 | // Compiler: |
| 10 | // COMPILER_MSVC / COMPILER_GCC |
| 11 | // Processor: |
| 12 | // ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64) |
| 13 | // ARCH_CPU_32_BITS / ARCH_CPU_64_BITS |
| 14 | |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 15 | #ifndef BUILD_BUILD_CONFIG_H_ |
| 16 | #define BUILD_BUILD_CONFIG_H_ |
| 17 | |
| 18 | // A set of macros to use for platform detection. |
sehr@chromium.org | a6ec66f | 2014-06-05 00:39:58 +0900 | [diff] [blame] | 19 | #if defined(__native_client__) |
| 20 | // __native_client__ must be first, so that other OS_ defines are not set. |
| 21 | #define OS_NACL 1 |
hidehiko | 721e604 | 2014-10-28 20:57:21 +0900 | [diff] [blame] | 22 | // OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI. |
| 23 | // PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build |
| 24 | // mode, while it does not in SFI build mode. |
| 25 | #if defined(__native_client_nonsfi__) |
| 26 | #define OS_NACL_NONSFI |
| 27 | #else |
| 28 | #define OS_NACL_SFI |
| 29 | #endif |
sehr@chromium.org | a6ec66f | 2014-06-05 00:39:58 +0900 | [diff] [blame] | 30 | #elif defined(ANDROID) |
torne@chromium.org | a00ac9d | 2013-04-04 20:51:27 +0900 | [diff] [blame] | 31 | #define OS_ANDROID 1 |
| 32 | #elif defined(__APPLE__) |
torne | d759f34 | 2014-09-05 19:33:07 +0900 | [diff] [blame] | 33 | // only include TargetConditions after testing ANDROID as some android builds |
| 34 | // on mac don't have this header available and it's not needed unless the target |
| 35 | // is really mac/ios. |
| 36 | #include <TargetConditionals.h> |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 37 | #define OS_MACOSX 1 |
bbudge@chromium.org | 3ed0c36 | 2012-07-05 00:23:39 +0900 | [diff] [blame] | 38 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
stuartmorgan@chromium.org | 791de94 | 2012-06-30 07:12:20 +0900 | [diff] [blame] | 39 | #define OS_IOS 1 |
bbudge@chromium.org | 3ed0c36 | 2012-07-05 00:23:39 +0900 | [diff] [blame] | 40 | #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
deanm@google.com | 5b70cbe | 2008-08-14 20:21:28 +0900 | [diff] [blame] | 41 | #elif defined(__linux__) |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 42 | #define OS_LINUX 1 |
mostynb@opera.com | b98da34 | 2014-04-19 08:40:16 +0900 | [diff] [blame] | 43 | // include a system header to pull in features.h for glibc/uclibc macros. |
| 44 | #include <unistd.h> |
mostynb@opera.com | 889d375 | 2013-05-23 21:00:10 +0900 | [diff] [blame] | 45 | #if defined(__GLIBC__) && !defined(__UCLIBC__) |
| 46 | // we really are using glibc, not uClibc pretending to be glibc |
mostynb@opera.com | e1df666 | 2014-04-08 08:51:45 +0900 | [diff] [blame] | 47 | #define LIBC_GLIBC 1 |
mostynb@opera.com | 889d375 | 2013-05-23 21:00:10 +0900 | [diff] [blame] | 48 | #endif |
maruel@chromium.org | 837a67f | 2009-02-10 00:42:08 +0900 | [diff] [blame] | 49 | #elif defined(_WIN32) |
mmentovai@google.com | 9a0fc8a | 2008-08-05 06:32:57 +0900 | [diff] [blame] | 50 | #define OS_WIN 1 |
sky@chromium.org | 95936bd | 2009-05-14 08:21:45 +0900 | [diff] [blame] | 51 | #define TOOLKIT_VIEWS 1 |
benl@chromium.org | 6b6b216 | 2009-09-08 01:39:46 +0900 | [diff] [blame] | 52 | #elif defined(__FreeBSD__) |
| 53 | #define OS_FREEBSD 1 |
evan@chromium.org | 21252b1 | 2009-12-12 05:04:06 +0900 | [diff] [blame] | 54 | #elif defined(__OpenBSD__) |
| 55 | #define OS_OPENBSD 1 |
evan@chromium.org | 089339c | 2010-04-01 09:35:15 +0900 | [diff] [blame] | 56 | #elif defined(__sun) |
evan@chromium.org | d0e6b85 | 2010-02-19 01:11:37 +0900 | [diff] [blame] | 57 | #define OS_SOLARIS 1 |
ctruta@blackberry.com | 57a7a05 | 2014-02-06 21:27:37 +0900 | [diff] [blame] | 58 | #elif defined(__QNXNTO__) |
| 59 | #define OS_QNX 1 |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 60 | #else |
| 61 | #error Please add support for your platform in build/build_config.h |
| 62 | #endif |
| 63 | |
davidben | dff9522 | 2015-04-22 11:36:41 +0900 | [diff] [blame] | 64 | #if defined(USE_OPENSSL_CERTS) && defined(USE_NSS_CERTS) |
| 65 | #error Cannot use both OpenSSL and NSS for certificates |
joth@chromium.org | 0dd3527 | 2010-10-22 22:12:34 +0900 | [diff] [blame] | 66 | #endif |
| 67 | |
robert.nagy@gmail.com | 5f343eb | 2011-11-15 09:06:16 +0900 | [diff] [blame] | 68 | // For access to standard BSD features, use OS_BSD instead of a |
| 69 | // more specific macro. |
| 70 | #if defined(OS_FREEBSD) || defined(OS_OPENBSD) |
| 71 | #define OS_BSD 1 |
| 72 | #endif |
| 73 | |
benl@chromium.org | 6b6b216 | 2009-09-08 01:39:46 +0900 | [diff] [blame] | 74 | // For access to standard POSIXish features, use OS_POSIX instead of a |
| 75 | // more specific macro. |
michaelbai@google.com | bd0b245 | 2011-06-28 04:13:10 +0900 | [diff] [blame] | 76 | #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \ |
| 77 | defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \ |
ctruta@blackberry.com | 57a7a05 | 2014-02-06 21:27:37 +0900 | [diff] [blame] | 78 | defined(OS_NACL) || defined(OS_QNX) |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 79 | #define OS_POSIX 1 |
benl@chromium.org | 6b6b216 | 2009-09-08 01:39:46 +0900 | [diff] [blame] | 80 | #endif |
| 81 | |
sgk@chromium.org | 1be49d8 | 2009-09-23 01:16:39 +0900 | [diff] [blame] | 82 | // Use tcmalloc |
bulach@chromium.org | 3b5d359 | 2013-05-23 00:17:03 +0900 | [diff] [blame] | 83 | #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \ |
| 84 | !defined(NO_TCMALLOC) |
sgk@chromium.org | 1be49d8 | 2009-09-23 01:16:39 +0900 | [diff] [blame] | 85 | #define USE_TCMALLOC 1 |
| 86 | #endif |
| 87 | |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 88 | // Compiler detection. |
| 89 | #if defined(__GNUC__) |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 90 | #define COMPILER_GCC 1 |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 91 | #elif defined(_MSC_VER) |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 92 | #define COMPILER_MSVC 1 |
| 93 | #else |
| 94 | #error Please add support for your compiler in build/build_config.h |
| 95 | #endif |
| 96 | |
| 97 | // Processor architecture detection. For more info on what's defined, see: |
| 98 | // http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
| 99 | // http://www.agner.org/optimize/calling_conventions.pdf |
thestig@chromium.org | 569de14 | 2009-05-02 02:57:09 +0900 | [diff] [blame] | 100 | // or with gcc, run: "echo | gcc -E -dM -" |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 101 | #if defined(_M_X64) || defined(__x86_64__) |
| 102 | #define ARCH_CPU_X86_FAMILY 1 |
| 103 | #define ARCH_CPU_X86_64 1 |
| 104 | #define ARCH_CPU_64_BITS 1 |
hclam@chromium.org | a94887c | 2011-06-25 05:46:06 +0900 | [diff] [blame] | 105 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 106 | #elif defined(_M_IX86) || defined(__i386__) |
| 107 | #define ARCH_CPU_X86_FAMILY 1 |
| 108 | #define ARCH_CPU_X86 1 |
| 109 | #define ARCH_CPU_32_BITS 1 |
hclam@chromium.org | a94887c | 2011-06-25 05:46:06 +0900 | [diff] [blame] | 110 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
thestig@chromium.org | 569de14 | 2009-05-02 02:57:09 +0900 | [diff] [blame] | 111 | #elif defined(__ARMEL__) |
| 112 | #define ARCH_CPU_ARM_FAMILY 1 |
| 113 | #define ARCH_CPU_ARMEL 1 |
| 114 | #define ARCH_CPU_32_BITS 1 |
hclam@chromium.org | a94887c | 2011-06-25 05:46:06 +0900 | [diff] [blame] | 115 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
primiano@chromium.org | 7c3e555 | 2014-04-01 07:10:30 +0900 | [diff] [blame] | 116 | #elif defined(__aarch64__) |
sdefresne@chromium.org | 97a13e9 | 2014-02-06 11:51:01 +0900 | [diff] [blame] | 117 | #define ARCH_CPU_ARM_FAMILY 1 |
| 118 | #define ARCH_CPU_ARM64 1 |
| 119 | #define ARCH_CPU_64_BITS 1 |
| 120 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
sehr@google.com | 15566f9 | 2011-08-27 04:03:20 +0900 | [diff] [blame] | 121 | #elif defined(__pnacl__) |
| 122 | #define ARCH_CPU_32_BITS 1 |
sergeyu@chromium.org | 0a59604 | 2013-12-03 11:33:06 +0900 | [diff] [blame] | 123 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
petarj@mips.com | d3a3e76 | 2012-06-18 11:47:05 +0900 | [diff] [blame] | 124 | #elif defined(__MIPSEL__) |
Gordana.Cmiljanovic@imgtec.com | ab30423 | 2014-08-15 02:14:05 +0900 | [diff] [blame] | 125 | #if defined(__LP64__) |
| 126 | #define ARCH_CPU_MIPS64_FAMILY 1 |
| 127 | #define ARCH_CPU_MIPS64EL 1 |
| 128 | #define ARCH_CPU_64_BITS 1 |
| 129 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
| 130 | #else |
petarj@mips.com | d3a3e76 | 2012-06-18 11:47:05 +0900 | [diff] [blame] | 131 | #define ARCH_CPU_MIPS_FAMILY 1 |
| 132 | #define ARCH_CPU_MIPSEL 1 |
| 133 | #define ARCH_CPU_32_BITS 1 |
| 134 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
Gordana.Cmiljanovic@imgtec.com | ab30423 | 2014-08-15 02:14:05 +0900 | [diff] [blame] | 135 | #endif |
deanm@google.com | d3d79a7 | 2008-08-05 20:56:30 +0900 | [diff] [blame] | 136 | #else |
| 137 | #error Please add support for your architecture in build/build_config.h |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 138 | #endif |
| 139 | |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 140 | // Type detection for wchar_t. |
| 141 | #if defined(OS_WIN) |
| 142 | #define WCHAR_T_IS_UTF16 |
| 143 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
thestig@chromium.org | 569de14 | 2009-05-02 02:57:09 +0900 | [diff] [blame] | 144 | defined(__WCHAR_MAX__) && \ |
| 145 | (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 146 | #define WCHAR_T_IS_UTF32 |
brettw@chromium.org | fd7a76b | 2009-10-23 03:04:17 +0900 | [diff] [blame] | 147 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
| 148 | defined(__WCHAR_MAX__) && \ |
| 149 | (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) |
| 150 | // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to |
| 151 | // compile in this mode (in particular, Chrome doesn't). This is intended for |
| 152 | // other projects using base who manage their own dependencies and make sure |
| 153 | // short wchar works for them. |
| 154 | #define WCHAR_T_IS_UTF16 |
brettw@google.com | e3c034a | 2008-08-08 03:31:40 +0900 | [diff] [blame] | 155 | #else |
| 156 | #error Please add support for your compiler in build/build_config.h |
| 157 | #endif |
| 158 | |
michaelbai@google.com | bd0b245 | 2011-06-28 04:13:10 +0900 | [diff] [blame] | 159 | #if defined(OS_ANDROID) |
| 160 | // The compiler thinks std::string::const_iterator and "const char*" are |
| 161 | // equivalent types. |
| 162 | #define STD_STRING_ITERATOR_IS_CHAR_POINTER |
| 163 | // The compiler thinks base::string16::const_iterator and "char16*" are |
| 164 | // equivalent types. |
| 165 | #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER |
| 166 | #endif |
| 167 | |
mmentovai@google.com | 3d555b8 | 2008-08-05 06:16:50 +0900 | [diff] [blame] | 168 | #endif // BUILD_BUILD_CONFIG_H_ |