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