1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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 <jrfonseca@tungstengraphics.com>
56 #define PIPE_CC_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
60 * Meaning of _MSC_VER value:
61 * - 1400: Visual C++ 2005
62 * - 1310: Visual C++ .NET 2003
63 * - 1300: Visual C++ .NET 2002
65 * __MSC__ seems to be an old macro -- it is not pre-defined on recent MSVC
68 #if defined(_MSC_VER) || defined(__MSC__)
78 * Processor architecture
81 #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(__mc68000) /* gcc */
94 #define PIPE_ARCH_M68K
97 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
98 #if defined(PIPE_CC_GCC) && !defined(__SSE2__)
99 /* #warning SSE2 support requires -msse -msse2 compiler options */
101 #define PIPE_ARCH_SSE
103 #if defined(PIPE_CC_GCC) && !defined(__SSSE3__)
104 /* #warning SSE3 support requires -msse3 compiler options */
106 #define PIPE_ARCH_SSSE3
110 #if defined(__ppc__) || defined(__ppc64__) || defined(__PPC__) || defined(__powerpc__)
111 #define PIPE_ARCH_PPC
112 #if defined(__ppc64__) || defined(__PPC64__)
113 #define PIPE_ARCH_PPC_64
125 #if __BYTE_ORDER == __LITTLE_ENDIAN
126 # define PIPE_ARCH_LITTLE_ENDIAN
127 #elif __BYTE_ORDER == __BIG_ENDIAN
128 # define PIPE_ARCH_BIG_ENDIAN
131 #elif defined(__APPLE__)
132 #include <machine/endian.h>
134 #if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
135 # define PIPE_ARCH_LITTLE_ENDIAN
136 #elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
137 # define PIPE_ARCH_BIG_ENDIAN
142 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) || defined(PIPE_ARCH_ARM)
143 #define PIPE_ARCH_LITTLE_ENDIAN
144 #elif defined(PIPE_ARCH_PPC) || defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_M68K)
145 #define PIPE_ARCH_BIG_ENDIAN
150 #if !defined(PIPE_ARCH_LITTLE_ENDIAN) && !defined(PIPE_ARCH_BIG_ENDIAN)
151 #error Unknown Endianness
155 * Auto-detect the operating system family.
157 * See subsystem below for a more fine-grained distinction.
161 * In some situations __AROS__ definition can coexist with anything of
162 * the below (for example this happens on ARM port which is compiled using Linux
163 * compiler at the moment). So if we have __AROS__ we don't evaluate anything else
165 #if defined(__AROS__)
169 #if defined(__linux__)
170 #define PIPE_OS_LINUX
174 #if defined(__FreeBSD__)
175 #define PIPE_OS_FREEBSD
180 #if defined(__OpenBSD__)
181 #define PIPE_OS_OPENBSD
186 #if defined(__NetBSD__)
187 #define PIPE_OS_NETBSD
198 #define PIPE_OS_SOLARIS
202 #if defined(__APPLE__)
203 #define PIPE_OS_APPLE
207 #if defined(_WIN32) || defined(WIN32)
208 #define PIPE_OS_WINDOWS
211 #if defined(__HAIKU__)
212 #define PIPE_OS_HAIKU
216 #if defined(__CYGWIN__)
217 #define PIPE_OS_CYGWIN
224 * Try to auto-detect the subsystem.
226 * NOTE: There is no way to auto-detect most of these.
229 #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
230 #define PIPE_SUBSYSTEM_DRI
231 #endif /* PIPE_OS_LINUX || PIPE_OS_BSD || PIPE_OS_SOLARIS */
233 #if defined(PIPE_OS_WINDOWS)
234 #if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
235 /* Windows 2000/XP Display Driver */
236 #elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
237 /* Windows 2000/XP Miniport Driver */
238 #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
239 /* Windows User-space Library */
240 #elif defined(PIPE_SUBSYSTEM_WINDOWS_CE)
241 /* Windows CE 5.0/6.0 */
244 #define PIPE_SUBSYSTEM_WINDOWS_CE
245 #else /* !_WIN32_WCE */
246 #error No PIPE_SUBSYSTEM_WINDOWS_xxx subsystem defined.
247 #endif /* !_WIN32_WCE */
249 #endif /* PIPE_OS_WINDOWS */
252 #endif /* P_CONFIG_H_ */