build_config.h revision 0529e5d033099cbfc42635f6f6183833b09dff6e
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//  Compiler:
9//    COMPILER_MSVC / COMPILER_GCC
10//  Processor:
11//    ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
12//    ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
13
14#ifndef BUILD_BUILD_CONFIG_H_
15#define BUILD_BUILD_CONFIG_H_
16
17#if defined(__APPLE__)
18#include <TargetConditionals.h>
19#endif
20
21// A set of macros to use for platform detection.
22#if defined(ANDROID)
23#define OS_ANDROID 1
24#elif defined(__APPLE__)
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(__native_client__)
30#define OS_NACL 1
31#elif defined(__linux__)
32#define OS_LINUX 1
33// include a system header to pull in features.h for glibc/uclibc macros.
34#include <unistd.h>
35#if defined(__GLIBC__) && !defined(__UCLIBC__)
36// we really are using glibc, not uClibc pretending to be glibc
37#define LIBC_GLIBC 1
38#endif
39#elif defined(_WIN32)
40#define OS_WIN 1
41#define TOOLKIT_VIEWS 1
42#elif defined(__FreeBSD__)
43#define OS_FREEBSD 1
44#elif defined(__OpenBSD__)
45#define OS_OPENBSD 1
46#elif defined(__sun)
47#define OS_SOLARIS 1
48#elif defined(__QNXNTO__)
49#define OS_QNX 1
50#else
51#error Please add support for your platform in build/build_config.h
52#endif
53
54#if defined(USE_OPENSSL) && defined(USE_NSS)
55#error Cannot use both OpenSSL and NSS
56#endif
57
58// For access to standard BSD features, use OS_BSD instead of a
59// more specific macro.
60#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
61#define OS_BSD 1
62#endif
63
64// For access to standard POSIXish features, use OS_POSIX instead of a
65// more specific macro.
66#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) ||     \
67    defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) ||  \
68    defined(OS_NACL) || defined(OS_QNX)
69#define OS_POSIX 1
70#endif
71
72// Use tcmalloc
73#if (defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)) && \
74    !defined(NO_TCMALLOC)
75#define USE_TCMALLOC 1
76#endif
77
78// Compiler detection.
79#if defined(__GNUC__)
80#define COMPILER_GCC 1
81#elif defined(_MSC_VER)
82#define COMPILER_MSVC 1
83#else
84#error Please add support for your compiler in build/build_config.h
85#endif
86
87// Processor architecture detection.  For more info on what's defined, see:
88//   http://msdn.microsoft.com/en-us/library/b0084kay.aspx
89//   http://www.agner.org/optimize/calling_conventions.pdf
90//   or with gcc, run: "echo | gcc -E -dM -"
91#if defined(_M_X64) || defined(__x86_64__)
92#define ARCH_CPU_X86_FAMILY 1
93#define ARCH_CPU_X86_64 1
94#define ARCH_CPU_64_BITS 1
95#define ARCH_CPU_LITTLE_ENDIAN 1
96#elif defined(_M_IX86) || defined(__i386__)
97#define ARCH_CPU_X86_FAMILY 1
98#define ARCH_CPU_X86 1
99#define ARCH_CPU_32_BITS 1
100#define ARCH_CPU_LITTLE_ENDIAN 1
101#elif defined(__ARMEL__)
102#define ARCH_CPU_ARM_FAMILY 1
103#define ARCH_CPU_ARMEL 1
104#define ARCH_CPU_32_BITS 1
105#define ARCH_CPU_LITTLE_ENDIAN 1
106#elif defined(__aarch64__)
107#define ARCH_CPU_ARM_FAMILY 1
108#define ARCH_CPU_ARM64 1
109#define ARCH_CPU_64_BITS 1
110#define ARCH_CPU_LITTLE_ENDIAN 1
111#elif defined(__pnacl__)
112#define ARCH_CPU_32_BITS 1
113#define ARCH_CPU_LITTLE_ENDIAN 1
114#elif defined(__MIPSEL__)
115#define ARCH_CPU_MIPS_FAMILY 1
116#define ARCH_CPU_MIPSEL 1
117#define ARCH_CPU_32_BITS 1
118#define ARCH_CPU_LITTLE_ENDIAN 1
119#else
120#error Please add support for your architecture in build/build_config.h
121#endif
122
123// Type detection for wchar_t.
124#if defined(OS_WIN)
125#define WCHAR_T_IS_UTF16
126#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
127    defined(__WCHAR_MAX__) && \
128    (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
129#define WCHAR_T_IS_UTF32
130#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
131    defined(__WCHAR_MAX__) && \
132    (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
133// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
134// compile in this mode (in particular, Chrome doesn't). This is intended for
135// other projects using base who manage their own dependencies and make sure
136// short wchar works for them.
137#define WCHAR_T_IS_UTF16
138#else
139#error Please add support for your compiler in build/build_config.h
140#endif
141
142#if defined(__ARMEL__) && !defined(OS_IOS)
143#define WCHAR_T_IS_UNSIGNED 1
144#elif defined(__MIPSEL__)
145#define WCHAR_T_IS_UNSIGNED 0
146#endif
147
148#if defined(OS_ANDROID)
149// The compiler thinks std::string::const_iterator and "const char*" are
150// equivalent types.
151#define STD_STRING_ITERATOR_IS_CHAR_POINTER
152// The compiler thinks base::string16::const_iterator and "char16*" are
153// equivalent types.
154#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
155#endif
156
157#endif  // BUILD_BUILD_CONFIG_H_
158