1 /**************************************************************************
3 * Copyright 2008 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Gallium configuration defines.
32 * This header file sets several defines based on the compiler, processor
33 * architecture, and operating system being used. These defines should be used
34 * throughout the code to facilitate porting to new platforms. It is likely that
35 * this file is auto-generated by an autoconf-like tool at some point, as some
36 * things cannot be determined by pre-defined environment alone.
39 * - http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
40 * - echo | gcc -dM -E - | sort
41 * - http://msdn.microsoft.com/en-us/library/b0084kay.aspx
43 * @author José Fonseca <jfonseca@vmware.com>
56 #define PIPE_CC_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
60 * Meaning of _MSC_VER value:
61 * - 1800: Visual Studio 2013
62 * - 1700: Visual Studio 2012
63 * - 1600: Visual Studio 2010
64 * - 1500: Visual Studio 2008
65 * - 1400: Visual C++ 2005
66 * - 1310: Visual C++ .NET 2003
67 * - 1300: Visual C++ .NET 2002
69 * __MSC__ seems to be an old macro -- it is not pre-defined on recent MSVC
72 #if defined(_MSC_VER) || defined(__MSC__)
82 * Processor architecture
85 #if defined(__i386__) /* gcc */ || defined(_M_IX86) /* msvc */ || defined(_X86_) || defined(__386__) || defined(i386) || defined(__i386) /* Sun cc */
89 #if defined(__x86_64__) /* gcc */ || defined(_M_X64) /* msvc */ || defined(_M_AMD64) /* msvc */ || defined(__x86_64) /* Sun cc */
90 #define PIPE_ARCH_X86_64
93 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
94 #if defined(PIPE_CC_GCC) && !defined(__SSE2__)
95 /* #warning SSE2 support requires -msse -msse2 compiler options */
99 #if defined(PIPE_CC_GCC) && (__GNUC__ * 100 + __GNUC_MINOR__) < 409 && !defined(__SSSE3__)
100 /* #warning SSE3 support requires -msse3 compiler options before GCC 4.9 */
102 #define PIPE_ARCH_SSSE3
106 #if defined(__ppc__) || defined(__ppc64__) || defined(__PPC__)
107 #define PIPE_ARCH_PPC
108 #if defined(__ppc64__) || defined(__PPC64__)
109 #define PIPE_ARCH_PPC_64
113 #if defined(__s390x__)
114 #define PIPE_ARCH_S390
118 #define PIPE_ARCH_ARM
121 #if defined(__aarch64__)
122 #define PIPE_ARCH_AARCH64
132 #if __BYTE_ORDER == __LITTLE_ENDIAN
133 # define PIPE_ARCH_LITTLE_ENDIAN
134 #elif __BYTE_ORDER == __BIG_ENDIAN
135 # define PIPE_ARCH_BIG_ENDIAN
138 #elif defined(__APPLE__)
139 #include <machine/endian.h>
141 #if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
142 # define PIPE_ARCH_LITTLE_ENDIAN
143 #elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
144 # define PIPE_ARCH_BIG_ENDIAN
148 #include <sys/isa_defs.h>
150 #if defined(_LITTLE_ENDIAN)
151 # define PIPE_ARCH_LITTLE_ENDIAN
152 #elif defined(_BIG_ENDIAN)
153 # define PIPE_ARCH_BIG_ENDIAN
156 #elif defined(__OpenBSD__) || defined(__NetBSD__)
157 #include <sys/types.h>
158 #include <machine/endian.h>
160 #if _BYTE_ORDER == _LITTLE_ENDIAN
161 # define PIPE_ARCH_LITTLE_ENDIAN
162 #elif _BYTE_ORDER == _BIG_ENDIAN
163 # define PIPE_ARCH_BIG_ENDIAN
168 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64)
169 #define PIPE_ARCH_LITTLE_ENDIAN
170 #elif defined(PIPE_ARCH_PPC) || defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390)
171 #define PIPE_ARCH_BIG_ENDIAN
176 #if !defined(PIPE_ARCH_LITTLE_ENDIAN) && !defined(PIPE_ARCH_BIG_ENDIAN)
177 #error Unknown Endianness
181 * Auto-detect the operating system family.
183 * See subsystem below for a more fine-grained distinction.
186 #if defined(__linux__)
187 #define PIPE_OS_LINUX
192 * Android defines __linux__ so PIPE_OS_LINUX and PIPE_OS_UNIX will also be
196 #define PIPE_OS_ANDROID
199 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
200 #define PIPE_OS_FREEBSD
205 #if defined(__OpenBSD__)
206 #define PIPE_OS_OPENBSD
211 #if defined(__NetBSD__)
212 #define PIPE_OS_NETBSD
217 #if defined(__DragonFly__)
218 #define PIPE_OS_DRAGONFLY
229 #define PIPE_OS_SOLARIS
233 #if defined(__APPLE__)
234 #define PIPE_OS_APPLE
238 #if defined(_WIN32) || defined(WIN32)
239 #define PIPE_OS_WINDOWS
242 #if defined(__HAIKU__)
243 #define PIPE_OS_HAIKU
247 #if defined(__CYGWIN__)
248 #define PIPE_OS_CYGWIN
253 * Try to auto-detect the subsystem.
255 * NOTE: There is no way to auto-detect most of these.
258 #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
259 #define PIPE_SUBSYSTEM_DRI
260 #endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
262 #if defined(PIPE_OS_WINDOWS)
263 #if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
264 /* Windows User-space Library */
266 #define PIPE_SUBSYSTEM_WINDOWS_USER
268 #endif /* PIPE_OS_WINDOWS */
271 #endif /* P_CONFIG_H_ */