build_config.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. // This file adds defines about the platform we're currently building on.
  5. //
  6. // Operating System:
  7. // OS_AIX / OS_ANDROID / OS_ASMJS / OS_FREEBSD / OS_FUCHSIA / OS_IOS /
  8. // OS_LINUX / OS_MAC / OS_NACL (SFI or NONSFI) / OS_NETBSD / OS_OPENBSD /
  9. // OS_QNX / OS_SOLARIS / OS_WIN
  10. // Operating System family:
  11. // OS_APPLE: IOS or MAC
  12. // OS_BSD: FREEBSD or NETBSD or OPENBSD
  13. // OS_POSIX: AIX or ANDROID or ASMJS or CHROMEOS or FREEBSD or IOS or LINUX
  14. // or MAC or NACL or NETBSD or OPENBSD or QNX or SOLARIS
  15. //
  16. // /!\ Note: OS_CHROMEOS is set by the build system, not this file
  17. //
  18. // Compiler:
  19. // COMPILER_MSVC / COMPILER_GCC
  20. //
  21. // Processor:
  22. // ARCH_CPU_ARM64 / ARCH_CPU_ARMEL / ARCH_CPU_MIPS / ARCH_CPU_MIPS64 /
  23. // ARCH_CPU_MIPS64EL / ARCH_CPU_MIPSEL / ARCH_CPU_PPC64 / ARCH_CPU_S390 /
  24. // ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64
  25. // Processor family:
  26. // ARCH_CPU_ARM_FAMILY: ARMEL or ARM64
  27. // ARCH_CPU_MIPS_FAMILY: MIPS64EL or MIPSEL or MIPS64 or MIPS
  28. // ARCH_CPU_PPC64_FAMILY: PPC64
  29. // ARCH_CPU_S390_FAMILY: S390 or S390X
  30. // ARCH_CPU_X86_FAMILY: X86 or X86_64
  31. // Processor features:
  32. // ARCH_CPU_31_BITS / ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
  33. // ARCH_CPU_BIG_ENDIAN / ARCH_CPU_LITTLE_ENDIAN
  34. #ifndef BUILD_BUILD_CONFIG_H_
  35. #define BUILD_BUILD_CONFIG_H_
  36. // A set of macros to use for platform detection.
  37. #if defined(__native_client__)
  38. // __native_client__ must be first, so that other OS_ defines are not set.
  39. #define OS_NACL 1
  40. // OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI.
  41. // PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build
  42. // mode, while it does not in SFI build mode.
  43. #if defined(__native_client_nonsfi__)
  44. #define OS_NACL_NONSFI
  45. #else
  46. #define OS_NACL_SFI
  47. #endif
  48. #elif defined(ANDROID)
  49. #define OS_ANDROID 1
  50. #elif defined(__APPLE__)
  51. // Only include TargetConditionals after testing ANDROID as some Android builds
  52. // on the Mac have this header available and it's not needed unless the target
  53. // is really an Apple platform.
  54. #include <TargetConditionals.h>
  55. #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
  56. #define OS_IOS 1
  57. #else
  58. #define OS_MAC 1
  59. #endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
  60. #elif defined(__linux__)
  61. #define OS_LINUX 1
  62. // Include a system header to pull in features.h for glibc/uclibc macros.
  63. #include <unistd.h>
  64. #if defined(__GLIBC__) && !defined(__UCLIBC__)
  65. // We really are using glibc, not uClibc pretending to be glibc.
  66. #define LIBC_GLIBC 1
  67. #endif
  68. #elif defined(_WIN32)
  69. #define OS_WIN 1
  70. #elif defined(__Fuchsia__)
  71. #define OS_FUCHSIA 1
  72. #elif defined(__FreeBSD__)
  73. #define OS_FREEBSD 1
  74. #elif defined(__NetBSD__)
  75. #define OS_NETBSD 1
  76. #elif defined(__OpenBSD__)
  77. #define OS_OPENBSD 1
  78. #elif defined(__sun)
  79. #define OS_SOLARIS 1
  80. #elif defined(__QNXNTO__)
  81. #define OS_QNX 1
  82. #elif defined(_AIX)
  83. #define OS_AIX 1
  84. #elif defined(__asmjs__) || defined(__wasm__)
  85. #define OS_ASMJS 1
  86. #else
  87. #error Please add support for your platform in build/build_config.h
  88. #endif
  89. // NOTE: Adding a new port? Please follow
  90. // https://chromium.googlesource.com/chromium/src/+/master/docs/new_port_policy.md
  91. #if defined(OS_MAC) || defined(OS_IOS)
  92. #define OS_APPLE 1
  93. #endif
  94. // For access to standard BSD features, use OS_BSD instead of a
  95. // more specific macro.
  96. #if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD)
  97. #define OS_BSD 1
  98. #endif
  99. // For access to standard POSIXish features, use OS_POSIX instead of a
  100. // more specific macro.
  101. #if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) || \
  102. defined(OS_FREEBSD) || defined(OS_IOS) || defined(OS_LINUX) || \
  103. defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_NACL) || \
  104. defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_QNX) || \
  105. defined(OS_SOLARIS)
  106. #define OS_POSIX 1
  107. #endif
  108. // Compiler detection. Note: clang masquerades as GCC on POSIX and as MSVC on
  109. // Windows.
  110. #if defined(__GNUC__)
  111. #define COMPILER_GCC 1
  112. #elif defined(_MSC_VER)
  113. #define COMPILER_MSVC 1
  114. #else
  115. #error Please add support for your compiler in build/build_config.h
  116. #endif
  117. // Processor architecture detection. For more info on what's defined, see:
  118. // http://msdn.microsoft.com/en-us/library/b0084kay.aspx
  119. // http://www.agner.org/optimize/calling_conventions.pdf
  120. // or with gcc, run: "echo | gcc -E -dM -"
  121. #if defined(_M_X64) || defined(__x86_64__)
  122. #define ARCH_CPU_X86_FAMILY 1
  123. #define ARCH_CPU_X86_64 1
  124. #define ARCH_CPU_64_BITS 1
  125. #define ARCH_CPU_LITTLE_ENDIAN 1
  126. #elif defined(_M_IX86) || defined(__i386__)
  127. #define ARCH_CPU_X86_FAMILY 1
  128. #define ARCH_CPU_X86 1
  129. #define ARCH_CPU_32_BITS 1
  130. #define ARCH_CPU_LITTLE_ENDIAN 1
  131. #elif defined(__s390x__)
  132. #define ARCH_CPU_S390_FAMILY 1
  133. #define ARCH_CPU_S390X 1
  134. #define ARCH_CPU_64_BITS 1
  135. #define ARCH_CPU_BIG_ENDIAN 1
  136. #elif defined(__s390__)
  137. #define ARCH_CPU_S390_FAMILY 1
  138. #define ARCH_CPU_S390 1
  139. #define ARCH_CPU_31_BITS 1
  140. #define ARCH_CPU_BIG_ENDIAN 1
  141. #elif (defined(__PPC64__) || defined(__PPC__)) && defined(__BIG_ENDIAN__)
  142. #define ARCH_CPU_PPC64_FAMILY 1
  143. #define ARCH_CPU_PPC64 1
  144. #define ARCH_CPU_64_BITS 1
  145. #define ARCH_CPU_BIG_ENDIAN 1
  146. #elif defined(__PPC64__)
  147. #define ARCH_CPU_PPC64_FAMILY 1
  148. #define ARCH_CPU_PPC64 1
  149. #define ARCH_CPU_64_BITS 1
  150. #define ARCH_CPU_LITTLE_ENDIAN 1
  151. #elif defined(__ARMEL__)
  152. #define ARCH_CPU_ARM_FAMILY 1
  153. #define ARCH_CPU_ARMEL 1
  154. #define ARCH_CPU_32_BITS 1
  155. #define ARCH_CPU_LITTLE_ENDIAN 1
  156. #elif defined(__aarch64__) || defined(_M_ARM64)
  157. #define ARCH_CPU_ARM_FAMILY 1
  158. #define ARCH_CPU_ARM64 1
  159. #define ARCH_CPU_64_BITS 1
  160. #define ARCH_CPU_LITTLE_ENDIAN 1
  161. #elif defined(__pnacl__) || defined(__asmjs__) || defined(__wasm__)
  162. #define ARCH_CPU_32_BITS 1
  163. #define ARCH_CPU_LITTLE_ENDIAN 1
  164. #elif defined(__MIPSEL__)
  165. #if defined(__LP64__)
  166. #define ARCH_CPU_MIPS_FAMILY 1
  167. #define ARCH_CPU_MIPS64EL 1
  168. #define ARCH_CPU_64_BITS 1
  169. #define ARCH_CPU_LITTLE_ENDIAN 1
  170. #else
  171. #define ARCH_CPU_MIPS_FAMILY 1
  172. #define ARCH_CPU_MIPSEL 1
  173. #define ARCH_CPU_32_BITS 1
  174. #define ARCH_CPU_LITTLE_ENDIAN 1
  175. #endif
  176. #elif defined(__MIPSEB__)
  177. #if defined(__LP64__)
  178. #define ARCH_CPU_MIPS_FAMILY 1
  179. #define ARCH_CPU_MIPS64 1
  180. #define ARCH_CPU_64_BITS 1
  181. #define ARCH_CPU_BIG_ENDIAN 1
  182. #else
  183. #define ARCH_CPU_MIPS_FAMILY 1
  184. #define ARCH_CPU_MIPS 1
  185. #define ARCH_CPU_32_BITS 1
  186. #define ARCH_CPU_BIG_ENDIAN 1
  187. #endif
  188. #else
  189. #error Please add support for your architecture in build/build_config.h
  190. #endif
  191. // Type detection for wchar_t.
  192. #if defined(OS_WIN)
  193. #define WCHAR_T_IS_UTF16
  194. #elif defined(OS_FUCHSIA)
  195. #define WCHAR_T_IS_UTF32
  196. #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
  197. (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
  198. #define WCHAR_T_IS_UTF32
  199. #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
  200. (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
  201. // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
  202. // compile in this mode (in particular, Chrome doesn't). This is intended for
  203. // other projects using base who manage their own dependencies and make sure
  204. // short wchar works for them.
  205. #define WCHAR_T_IS_UTF16
  206. #else
  207. #error Please add support for your compiler in build/build_config.h
  208. #endif
  209. #if defined(OS_ANDROID)
  210. // The compiler thinks std::string::const_iterator and "const char*" are
  211. // equivalent types.
  212. #define STD_STRING_ITERATOR_IS_CHAR_POINTER
  213. // The compiler thinks base::string16::const_iterator and "char16*" are
  214. // equivalent types.
  215. #define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
  216. #endif
  217. #endif // BUILD_BUILD_CONFIG_H_