• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_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 
15 #ifndef BUILD_BUILD_CONFIG_H_
16 #define BUILD_BUILD_CONFIG_H_
17 
18 #if defined(ANDROID)
19 #define OS_ANDROID 1
20 #elif defined(__APPLE__)
21 // only include TargetConditions after testing ANDROID as some android builds
22 // on mac don't have this header available and it's not needed unless the target
23 // is really mac/ios.
24 #include <TargetConditionals.h>
25 #define OS_MACOSX 1
26 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
27 #define OS_IOS 1
28 #endif  // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
29 #elif defined(__linux__)
30 #define OS_LINUX 1
31 // include a system header to pull in features.h for glibc/uclibc macros.
32 #include <unistd.h>
33 #if defined(__GLIBC__) && !defined(__UCLIBC__)
34 // we really are using glibc, not uClibc pretending to be glibc
35 #define LIBC_GLIBC 1
36 #endif
37 #elif defined(__MSYS__)
38 #define OS_MSYS 1
39 #elif defined(_WIN32)
40 #define OS_WIN 1
41 #elif defined(__Fuchsia__)
42 #define OS_FUCHSIA 1
43 #elif defined(__FreeBSD__)
44 #define OS_FREEBSD 1
45 #elif defined(__NetBSD__)
46 #define OS_NETBSD 1
47 #elif defined(__OpenBSD__)
48 #define OS_OPENBSD 1
49 #elif defined(__sun)
50 #define OS_SOLARIS 1
51 #elif defined(__QNXNTO__)
52 #define OS_QNX 1
53 #elif defined(_AIX)
54 #define OS_AIX 1
55 #elif defined(__asmjs__)
56 #define OS_ASMJS 1
57 #elif defined(__HAIKU__)
58 #define OS_HAIKU 1
59 #elif defined(__MVS__)
60 #include "zos-base.h"
61 #define OS_ZOS 1
62 #else
63 #error Please add support for your platform in build_config.h
64 #endif
65 // NOTE: Adding a new port? Please follow
66 // https://chromium.googlesource.com/chromium/src/+/master/docs/new_port_policy.md
67 
68 // For access to standard BSD features, use OS_BSD instead of a
69 // more specific macro.
70 #if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD)
71 #define OS_BSD 1
72 #endif
73 
74 // For access to standard POSIXish features, use OS_POSIX instead of a
75 // more specific macro.
76 #if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) ||    \
77     defined(OS_FREEBSD) || defined(OS_LINUX) || defined(OS_MACOSX) || \
78     defined(OS_NACL) || defined(OS_NETBSD) || defined(OS_OPENBSD) ||  \
79     defined(OS_QNX) || defined(OS_SOLARIS) || defined(OS_HAIKU) || \
80     defined(OS_MSYS) || defined(OS_ZOS)
81 #define OS_POSIX 1
82 #endif
83 
84 // Use tcmalloc
85 #if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
86     !defined(NO_TCMALLOC)
87 #define USE_TCMALLOC 1
88 #endif
89 
90 // Compiler detection.
91 #if defined(__GNUC__)
92 #define COMPILER_GCC 1
93 #elif defined(_MSC_VER)
94 #define COMPILER_MSVC 1
95 #else
96 #error Please add support for your compiler in build_config.h
97 #endif
98 
99 // Processor architecture detection.  For more info on what's defined, see:
100 //   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
101 //   http://www.agner.org/optimize/calling_conventions.pdf
102 //   or with gcc, run: "echo | gcc -E -dM -"
103 #if defined(_M_X64) || defined(__x86_64__)
104 #define ARCH_CPU_X86_FAMILY 1
105 #define ARCH_CPU_X86_64 1
106 #define ARCH_CPU_64_BITS 1
107 #define ARCH_CPU_LITTLE_ENDIAN 1
108 #elif defined(_M_IX86) || defined(__i386__)
109 #define ARCH_CPU_X86_FAMILY 1
110 #define ARCH_CPU_X86 1
111 #define ARCH_CPU_32_BITS 1
112 #define ARCH_CPU_LITTLE_ENDIAN 1
113 #elif defined(__s390x__)
114 #define ARCH_CPU_S390_FAMILY 1
115 #define ARCH_CPU_S390X 1
116 #define ARCH_CPU_64_BITS 1
117 #define ARCH_CPU_BIG_ENDIAN 1
118 #elif defined(__s390__)
119 #define ARCH_CPU_S390_FAMILY 1
120 #define ARCH_CPU_S390 1
121 #define ARCH_CPU_31_BITS 1
122 #define ARCH_CPU_BIG_ENDIAN 1
123 #elif (defined(__PPC64__) || defined(__PPC__)) && defined(__BIG_ENDIAN__)
124 #define ARCH_CPU_PPC64_FAMILY 1
125 #define ARCH_CPU_PPC64 1
126 #define ARCH_CPU_64_BITS 1
127 #define ARCH_CPU_BIG_ENDIAN 1
128 #elif defined(__PPC64__)
129 #define ARCH_CPU_PPC64_FAMILY 1
130 #define ARCH_CPU_PPC64 1
131 #define ARCH_CPU_64_BITS 1
132 #define ARCH_CPU_LITTLE_ENDIAN 1
133 #elif defined(__ARMEL__)
134 #define ARCH_CPU_ARM_FAMILY 1
135 #define ARCH_CPU_ARMEL 1
136 #define ARCH_CPU_32_BITS 1
137 #define ARCH_CPU_LITTLE_ENDIAN 1
138 #elif defined(__aarch64__)
139 #define ARCH_CPU_ARM_FAMILY 1
140 #define ARCH_CPU_ARM64 1
141 #define ARCH_CPU_64_BITS 1
142 #define ARCH_CPU_LITTLE_ENDIAN 1
143 #elif defined(__pnacl__) || defined(__asmjs__)
144 #define ARCH_CPU_32_BITS 1
145 #define ARCH_CPU_LITTLE_ENDIAN 1
146 #elif defined(__MIPSEL__)
147 #if defined(__LP64__)
148 #define ARCH_CPU_MIPS_FAMILY 1
149 #define ARCH_CPU_MIPS64EL 1
150 #define ARCH_CPU_64_BITS 1
151 #define ARCH_CPU_LITTLE_ENDIAN 1
152 #else
153 #define ARCH_CPU_MIPS_FAMILY 1
154 #define ARCH_CPU_MIPSEL 1
155 #define ARCH_CPU_32_BITS 1
156 #define ARCH_CPU_LITTLE_ENDIAN 1
157 #endif
158 #elif defined(__MIPSEB__)
159 #if defined(__LP64__)
160 #define ARCH_CPU_MIPS_FAMILY 1
161 #define ARCH_CPU_MIPS64 1
162 #define ARCH_CPU_64_BITS 1
163 #define ARCH_CPU_BIG_ENDIAN 1
164 #else
165 #define ARCH_CPU_MIPS_FAMILY 1
166 #define ARCH_CPU_MIPS 1
167 #define ARCH_CPU_32_BITS 1
168 #define ARCH_CPU_BIG_ENDIAN 1
169 #endif
170 #elif defined(__e2k__)
171 #define ARCH_CPU_64_BITS 1
172 #define ARCH_CPU_LITTLE_ENDIAN 1
173 #elif defined(__riscv) && (__riscv_xlen == 64)
174 #define ARCH_CPU_64_BITS 1
175 #define ARCH_CPU_LITTLE_ENDIAN 1
176 #elif defined(__loongarch__)
177 #if defined(__LP64__)
178 #define ARCH_CPU_LOONG_FAMILY 1
179 #define ARCH_CPU_LOONG64 1
180 #define ARCH_CPU_64_BITS 1
181 #define ARCH_CPU_LITTLE_ENDIAN 1
182 #else
183 #define ARCH_CPU_LOONG_FAMILY 1
184 #define ARCH_CPU_LOONG32 1
185 #define ARCH_CPU_32_BITS 1
186 #define ARCH_CPU_LITTLE_ENDIAN 1
187 #endif
188 #else
189 #error Please add support for your architecture in build_config.h
190 #endif
191 
192 #endif  // BUILD_BUILD_CONFIG_H_
193