[email protected] | cea4aec | 2012-01-24 12:26:40 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 4 | |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 5 | // This file adds defines about the platform we're currently building on. |
| 6 | // Operating System: |
hidehiko | f7295f2 | 2014-10-28 11:57:21 | [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 |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [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 | |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [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. |
[email protected] | d33d222 | 2014-06-04 15:39:58 | [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 | f7295f2 | 2014-10-28 11:57:21 | [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 |
[email protected] | d33d222 | 2014-06-04 15:39:58 | [diff] [blame] | 30 | #elif defined(ANDROID) |
[email protected] | c57a370 | 2013-04-04 11:51:27 | [diff] [blame] | 31 | #define OS_ANDROID 1 |
| 32 | #elif defined(__APPLE__) |
torne | ecb2348 | 2014-09-05 10:33:07 | [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> |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 37 | #define OS_MACOSX 1 |
[email protected] | 3777ee7 | 2012-07-04 15:23:39 | [diff] [blame] | 38 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
[email protected] | 1e01367 | 2012-06-29 22:12:20 | [diff] [blame] | 39 | #define OS_IOS 1 |
[email protected] | 3777ee7 | 2012-07-04 15:23:39 | [diff] [blame] | 40 | #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
[email protected] | 1020d2f | 2008-08-14 11:21:28 | [diff] [blame] | 41 | #elif defined(__linux__) |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 42 | #define OS_LINUX 1 |
[email protected] | 145c705 | 2014-04-18 23:40:16 | [diff] [blame] | 43 | // include a system header to pull in features.h for glibc/uclibc macros. |
| 44 | #include <unistd.h> |
[email protected] | 292633f0 | 2013-05-23 12:00:10 | [diff] [blame] | 45 | #if defined(__GLIBC__) && !defined(__UCLIBC__) |
| 46 | // we really are using glibc, not uClibc pretending to be glibc |
[email protected] | 99f35287 | 2014-04-07 23:51:45 | [diff] [blame] | 47 | #define LIBC_GLIBC 1 |
[email protected] | 292633f0 | 2013-05-23 12:00:10 | [diff] [blame] | 48 | #endif |
[email protected] | f61b898b | 2009-02-09 15:42:08 | [diff] [blame] | 49 | #elif defined(_WIN32) |
[email protected] | 771b2fd | 2008-08-04 21:32:57 | [diff] [blame] | 50 | #define OS_WIN 1 |
[email protected] | 321792e | 2009-05-13 23:21:45 | [diff] [blame] | 51 | #define TOOLKIT_VIEWS 1 |
[email protected] | fb66f9d | 2009-09-07 16:39:46 | [diff] [blame] | 52 | #elif defined(__FreeBSD__) |
| 53 | #define OS_FREEBSD 1 |
krytarowski | 969759f | 2016-07-31 23:55:12 | [diff] [blame^] | 54 | #elif defined(__NetBSD__) |
| 55 | #define OS_NETBSD 1 |
[email protected] | c51e8d5 | 2009-12-11 20:04:06 | [diff] [blame] | 56 | #elif defined(__OpenBSD__) |
| 57 | #define OS_OPENBSD 1 |
[email protected] | 93f21e4 | 2010-04-01 00:35:15 | [diff] [blame] | 58 | #elif defined(__sun) |
[email protected] | b5c72b82 | 2010-02-18 16:11:37 | [diff] [blame] | 59 | #define OS_SOLARIS 1 |
[email protected] | eda7afa1 | 2014-02-06 12:27:37 | [diff] [blame] | 60 | #elif defined(__QNXNTO__) |
| 61 | #define OS_QNX 1 |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 62 | #else |
| 63 | #error Please add support for your platform in build/build_config.h |
| 64 | #endif |
| 65 | |
davidben | 2bcbc6bc | 2015-04-22 02:36:41 | [diff] [blame] | 66 | #if defined(USE_OPENSSL_CERTS) && defined(USE_NSS_CERTS) |
| 67 | #error Cannot use both OpenSSL and NSS for certificates |
[email protected] | 70372d4 | 2010-10-22 13:12:34 | [diff] [blame] | 68 | #endif |
| 69 | |
[email protected] | e37e88a0 | 2011-11-15 00:06:16 | [diff] [blame] | 70 | // For access to standard BSD features, use OS_BSD instead of a |
| 71 | // more specific macro. |
krytarowski | 969759f | 2016-07-31 23:55:12 | [diff] [blame^] | 72 | #if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD) |
[email protected] | e37e88a0 | 2011-11-15 00:06:16 | [diff] [blame] | 73 | #define OS_BSD 1 |
| 74 | #endif |
| 75 | |
[email protected] | fb66f9d | 2009-09-07 16:39:46 | [diff] [blame] | 76 | // For access to standard POSIXish features, use OS_POSIX instead of a |
| 77 | // more specific macro. |
[email protected] | be16cf2 | 2011-06-27 19:13:10 | [diff] [blame] | 78 | #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \ |
krytarowski | 969759f | 2016-07-31 23:55:12 | [diff] [blame^] | 79 | 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) |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 82 | #define OS_POSIX 1 |
[email protected] | fb66f9d | 2009-09-07 16:39:46 | [diff] [blame] | 83 | #endif |
| 84 | |
[email protected] | 833b88a | 2009-09-22 16:16:39 | [diff] [blame] | 85 | // Use tcmalloc |
[email protected] | 3c8fe548 | 2013-05-22 15:17:03 | [diff] [blame] | 86 | #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \ |
| 87 | !defined(NO_TCMALLOC) |
[email protected] | 833b88a | 2009-09-22 16:16:39 | [diff] [blame] | 88 | #define USE_TCMALLOC 1 |
| 89 | #endif |
| 90 | |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 91 | // Compiler detection. |
| 92 | #if defined(__GNUC__) |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 93 | #define COMPILER_GCC 1 |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 94 | #elif defined(_MSC_VER) |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 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 |
[email protected] | 697776a | 2009-05-01 17:57:09 | [diff] [blame] | 103 | // or with gcc, run: "echo | gcc -E -dM -" |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 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 |
[email protected] | 2377cdee | 2011-06-24 20:46:06 | [diff] [blame] | 108 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 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 |
[email protected] | 2377cdee | 2011-06-24 20:46:06 | [diff] [blame] | 113 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | 697776a | 2009-05-01 17:57:09 | [diff] [blame] | 114 | #elif defined(__ARMEL__) |
| 115 | #define ARCH_CPU_ARM_FAMILY 1 |
| 116 | #define ARCH_CPU_ARMEL 1 |
| 117 | #define ARCH_CPU_32_BITS 1 |
[email protected] | 2377cdee | 2011-06-24 20:46:06 | [diff] [blame] | 118 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | e199278 | 2014-03-31 22:10:30 | [diff] [blame] | 119 | #elif defined(__aarch64__) |
[email protected] | 70d3625 | 2014-02-06 02:51:01 | [diff] [blame] | 120 | #define ARCH_CPU_ARM_FAMILY 1 |
| 121 | #define ARCH_CPU_ARM64 1 |
| 122 | #define ARCH_CPU_64_BITS 1 |
| 123 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | 814127c | 2011-08-26 19:03:20 | [diff] [blame] | 124 | #elif defined(__pnacl__) |
| 125 | #define ARCH_CPU_32_BITS 1 |
[email protected] | 61e881cd | 2013-12-03 02:33:06 | [diff] [blame] | 126 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | f7d2fbd | 2012-06-18 02:47:05 | [diff] [blame] | 127 | #elif defined(__MIPSEL__) |
[email protected] | 5614f285 | 2014-08-14 17:14:05 | [diff] [blame] | 128 | #if defined(__LP64__) |
Gordana.Cmiljanovic | a43ce60 | 2016-04-27 09:17:05 | [diff] [blame] | 129 | #define ARCH_CPU_MIPS_FAMILY 1 |
[email protected] | 5614f285 | 2014-08-14 17:14:05 | [diff] [blame] | 130 | #define ARCH_CPU_MIPS64EL 1 |
| 131 | #define ARCH_CPU_64_BITS 1 |
| 132 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
| 133 | #else |
[email protected] | f7d2fbd | 2012-06-18 02:47:05 | [diff] [blame] | 134 | #define ARCH_CPU_MIPS_FAMILY 1 |
| 135 | #define ARCH_CPU_MIPSEL 1 |
| 136 | #define ARCH_CPU_32_BITS 1 |
| 137 | #define ARCH_CPU_LITTLE_ENDIAN 1 |
[email protected] | 5614f285 | 2014-08-14 17:14:05 | [diff] [blame] | 138 | #endif |
[email protected] | ab8c0b0 | 2008-08-05 11:56:30 | [diff] [blame] | 139 | #else |
| 140 | #error Please add support for your architecture in build/build_config.h |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 141 | #endif |
| 142 | |
[email protected] | 39be424 | 2008-08-07 18:31:40 | [diff] [blame] | 143 | // Type detection for wchar_t. |
| 144 | #if defined(OS_WIN) |
| 145 | #define WCHAR_T_IS_UTF16 |
| 146 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
[email protected] | 697776a | 2009-05-01 17:57:09 | [diff] [blame] | 147 | defined(__WCHAR_MAX__) && \ |
| 148 | (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) |
[email protected] | 39be424 | 2008-08-07 18:31:40 | [diff] [blame] | 149 | #define WCHAR_T_IS_UTF32 |
[email protected] | d9a30d9 | 2009-10-22 18:04:17 | [diff] [blame] | 150 | #elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ |
| 151 | defined(__WCHAR_MAX__) && \ |
| 152 | (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) |
| 153 | // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to |
| 154 | // compile in this mode (in particular, Chrome doesn't). This is intended for |
| 155 | // other projects using base who manage their own dependencies and make sure |
| 156 | // short wchar works for them. |
| 157 | #define WCHAR_T_IS_UTF16 |
[email protected] | 39be424 | 2008-08-07 18:31:40 | [diff] [blame] | 158 | #else |
| 159 | #error Please add support for your compiler in build/build_config.h |
| 160 | #endif |
| 161 | |
[email protected] | be16cf2 | 2011-06-27 19:13:10 | [diff] [blame] | 162 | #if defined(OS_ANDROID) |
| 163 | // The compiler thinks std::string::const_iterator and "const char*" are |
| 164 | // equivalent types. |
| 165 | #define STD_STRING_ITERATOR_IS_CHAR_POINTER |
| 166 | // The compiler thinks base::string16::const_iterator and "char16*" are |
| 167 | // equivalent types. |
| 168 | #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER |
| 169 | #endif |
| 170 | |
[email protected] | 4867b18 | 2008-08-04 21:16:50 | [diff] [blame] | 171 | #endif // BUILD_BUILD_CONFIG_H_ |