build_config.h 6.6 KB

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