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. 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 9 // OS_CHROMEOS is set by the build system 10 // 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 brief primer on #defines: 20 // 21 // - __ANDROID__ is automatically defined by the Android toolchain (see 22 // https://goo.gl/v61lXa). It's not defined when building host code. 23 // - __ANDROID_HOST__ is defined via -D by Android.mk when building host code 24 // within an Android checkout. 25 // - ANDROID is defined via -D when building code for either Android targets or 26 // hosts. Use __ANDROID__ and __ANDROID_HOST__ instead. 27 // - OS_ANDROID is a define used to build Chrome for Android within the NDK and 28 // to build Android targets. 29 30 // Android targets and hosts don't use tcmalloc. 31 #if defined(__ANDROID__) || defined(__ANDROID_HOST__) 32 #define NO_TCMALLOC 33 #endif // defined(__ANDROID__) || defined(__ANDROID_HOST__) 34 35 #if defined(__ANDROID__) // Android targets 36 37 #define OS_ANDROID 1 38 39 #elif !defined(__ANDROID_HOST__) // Chrome OS 40 41 #define OS_CHROMEOS 1 42 // TODO: Remove these once the GLib MessageLoopForUI isn't being used: 43 // https://crbug.com/361635 44 #define USE_GLIB 1 45 #define USE_OZONE 1 46 47 #endif // defined(__ANDROID__) 48 49 // A set of macros to use for platform detection. 50 #if defined(__native_client__) 51 // __native_client__ must be first, so that other OS_ defines are not set. 52 #define OS_NACL 1 53 // OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI. 54 // PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build 55 // mode, while it does not in SFI build mode. 56 #if defined(__native_client_nonsfi__) 57 #define OS_NACL_NONSFI 58 #else 59 #define OS_NACL_SFI 60 #endif 61 #elif defined(__APPLE__) 62 // only include TargetConditions after testing ANDROID as some android builds 63 // on mac don't have this header available and it's not needed unless the target 64 // is really mac/ios. 65 #include <TargetConditionals.h> 66 #define OS_MACOSX 1 67 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 68 #define OS_IOS 1 69 #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE 70 #elif defined(__linux__) 71 #define OS_LINUX 1 72 // include a system header to pull in features.h for glibc/uclibc macros. 73 #include <unistd.h> 74 #if defined(__GLIBC__) && !defined(__UCLIBC__) 75 // we really are using glibc, not uClibc pretending to be glibc 76 #define LIBC_GLIBC 1 77 #endif 78 #elif defined(_WIN32) 79 #define OS_WIN 1 80 #elif defined(__Fuchsia__) 81 #define OS_FUCHSIA 1 82 #elif defined(__FreeBSD__) 83 #define OS_FREEBSD 1 84 #elif defined(__NetBSD__) 85 #define OS_NETBSD 1 86 #elif defined(__OpenBSD__) 87 #define OS_OPENBSD 1 88 #elif defined(__sun) 89 #define OS_SOLARIS 1 90 #elif defined(__QNXNTO__) 91 #define OS_QNX 1 92 #elif defined(_AIX) 93 #define OS_AIX 1 94 #elif defined(__asmjs__) 95 #define OS_ASMJS 96 #else 97 #error Please add support for your platform in build/build_config.h 98 #endif 99 // NOTE: Adding a new port? Please follow 100 // https://chromium.googlesource.com/chromium/src/+/master/docs/new_port_policy.md 101 102 // For access to standard BSD features, use OS_BSD instead of a 103 // more specific macro. 104 #if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD) 105 #define OS_BSD 1 106 #endif 107 108 // For access to standard POSIXish features, use OS_POSIX instead of a 109 // more specific macro. 110 #if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) || \ 111 defined(OS_FREEBSD) || defined(OS_LINUX) || defined(OS_MACOSX) || \ 112 defined(OS_NACL) || defined(OS_NETBSD) || defined(OS_OPENBSD) || \ 113 defined(OS_QNX) || defined(OS_SOLARIS) 114 #define OS_POSIX 1 115 #endif 116 117 // Use tcmalloc 118 #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \ 119 !defined(NO_TCMALLOC) 120 #define USE_TCMALLOC 1 121 #endif 122 123 // Compiler detection. 124 #if defined(__GNUC__) 125 #define COMPILER_GCC 1 126 #elif defined(_MSC_VER) 127 #define COMPILER_MSVC 1 128 #else 129 #error Please add support for your compiler in build/build_config.h 130 #endif 131 132 // Processor architecture detection. For more info on what's defined, see: 133 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 134 // http://www.agner.org/optimize/calling_conventions.pdf 135 // or with gcc, run: "echo | gcc -E -dM -" 136 #if defined(_M_X64) || defined(__x86_64__) 137 #define ARCH_CPU_X86_FAMILY 1 138 #define ARCH_CPU_X86_64 1 139 #define ARCH_CPU_64_BITS 1 140 #define ARCH_CPU_LITTLE_ENDIAN 1 141 #elif defined(_M_IX86) || defined(__i386__) 142 #define ARCH_CPU_X86_FAMILY 1 143 #define ARCH_CPU_X86 1 144 #define ARCH_CPU_32_BITS 1 145 #define ARCH_CPU_LITTLE_ENDIAN 1 146 #elif defined(__s390x__) 147 #define ARCH_CPU_S390_FAMILY 1 148 #define ARCH_CPU_S390X 1 149 #define ARCH_CPU_64_BITS 1 150 #define ARCH_CPU_BIG_ENDIAN 1 151 #elif defined(__s390__) 152 #define ARCH_CPU_S390_FAMILY 1 153 #define ARCH_CPU_S390 1 154 #define ARCH_CPU_31_BITS 1 155 #define ARCH_CPU_BIG_ENDIAN 1 156 #elif (defined(__PPC64__) || defined(__PPC__)) && defined(__BIG_ENDIAN__) 157 #define ARCH_CPU_PPC64_FAMILY 1 158 #define ARCH_CPU_PPC64 1 159 #define ARCH_CPU_64_BITS 1 160 #define ARCH_CPU_BIG_ENDIAN 1 161 #elif defined(__PPC64__) 162 #define ARCH_CPU_PPC64_FAMILY 1 163 #define ARCH_CPU_PPC64 1 164 #define ARCH_CPU_64_BITS 1 165 #define ARCH_CPU_LITTLE_ENDIAN 1 166 #elif defined(__ARMEL__) 167 #define ARCH_CPU_ARM_FAMILY 1 168 #define ARCH_CPU_ARMEL 1 169 #define ARCH_CPU_32_BITS 1 170 #define ARCH_CPU_LITTLE_ENDIAN 1 171 #elif defined(__aarch64__) 172 #define ARCH_CPU_ARM_FAMILY 1 173 #define ARCH_CPU_ARM64 1 174 #define ARCH_CPU_64_BITS 1 175 #define ARCH_CPU_LITTLE_ENDIAN 1 176 #elif defined(__pnacl__) || defined(__asmjs__) 177 #define ARCH_CPU_32_BITS 1 178 #define ARCH_CPU_LITTLE_ENDIAN 1 179 #elif defined(__MIPSEL__) 180 #if defined(__LP64__) 181 #define ARCH_CPU_MIPS_FAMILY 1 182 #define ARCH_CPU_MIPS64EL 1 183 #define ARCH_CPU_64_BITS 1 184 #define ARCH_CPU_LITTLE_ENDIAN 1 185 #else 186 #define ARCH_CPU_MIPS_FAMILY 1 187 #define ARCH_CPU_MIPSEL 1 188 #define ARCH_CPU_32_BITS 1 189 #define ARCH_CPU_LITTLE_ENDIAN 1 190 #endif 191 #elif defined(__MIPSEB__) 192 #if defined(__LP64__) 193 #define ARCH_CPU_MIPS_FAMILY 1 194 #define ARCH_CPU_MIPS64 1 195 #define ARCH_CPU_64_BITS 1 196 #define ARCH_CPU_BIG_ENDIAN 1 197 #else 198 #define ARCH_CPU_MIPS_FAMILY 1 199 #define ARCH_CPU_MIPS 1 200 #define ARCH_CPU_32_BITS 1 201 #define ARCH_CPU_BIG_ENDIAN 1 202 #endif 203 #else 204 #error Please add support for your architecture in build/build_config.h 205 #endif 206 207 // Type detection for wchar_t. 208 #if defined(OS_WIN) 209 #define WCHAR_T_IS_UTF16 210 #elif defined(OS_FUCHSIA) 211 #define WCHAR_T_IS_UTF32 212 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ 213 (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) 214 #define WCHAR_T_IS_UTF32 215 #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ 216 (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) 217 // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to 218 // compile in this mode (in particular, Chrome doesn't). This is intended for 219 // other projects using base who manage their own dependencies and make sure 220 // short wchar works for them. 221 #define WCHAR_T_IS_UTF16 222 #else 223 #error Please add support for your compiler in build/build_config.h 224 #endif 225 226 #if defined(OS_ANDROID) 227 // The compiler thinks std::string::const_iterator and "const char*" are 228 // equivalent types. 229 #define STD_STRING_ITERATOR_IS_CHAR_POINTER 230 // The compiler thinks base::string16::const_iterator and "char16*" are 231 // equivalent types. 232 #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER 233 #endif 234 235 #endif // BUILD_BUILD_CONFIG_H_ 236