3 * Top-most include file.
5 * This is the top-most include file of the Mesa sources.
6 * It includes gl.h and all system headers which are needed.
7 * Other Mesa source files should \e not directly include any system
8 * headers. This allows system-dependent hacks/workarounds to be
9 * collected in one place.
11 * \note Actually, a lot of system-dependent stuff is now in imports.[ch].
13 * If you touch this file, everything gets recompiled!
15 * This file should be included before any other header in the .c files.
17 * Put compiler/OS/assembly pragmas and macros here to avoid
18 * cluttering other source files.
22 * Mesa 3-D graphics library
25 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
27 * Permission is hereby granted, free of charge, to any person obtaining a
28 * copy of this software and associated documentation files (the "Software"),
29 * to deal in the Software without restriction, including without limitation
30 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
31 * and/or sell copies of the Software, and to permit persons to whom the
32 * Software is furnished to do so, subject to the following conditions:
34 * The above copyright notice and this permission notice shall be included
35 * in all copies or substantial portions of the Software.
37 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
38 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
40 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
41 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
51 #if defined(__alpha__) && defined(CCPML)
52 #include <cpml.h> /* use Compaq's Fast Math Library on Alpha */
60 #if defined(__linux__) && defined(__i386__)
61 #include <fpu_control.h>
67 /* Get typedefs for uintptr_t and friends */
68 #if defined(__MINGW32__) || defined(__NetBSD__)
73 typedef UINT_PTR
uintptr_t;
76 # include <inttypes.h>
79 /* For platforms that have the C99 standard uint*_t,
80 but not the commonly used u_int*_t */
82 # define u_int8_t uint8_t
83 # define u_int16_t uint16_t
84 # define u_int32_t uint32_t
85 # define u_int64_t uint64_t
86 # define u_intptr_t uintptr_t
89 /* Sun compilers define __i386 instead of the gcc-style __i386__ */
91 # if !defined(__i386__) && defined(__i386)
93 # elif !defined(__amd64__) && defined(__amd64)
95 # elif !defined(__sparc__) && defined(__sparc)
98 # if !defined(__volatile)
99 # define __volatile volatile
103 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
105 # define finite _finite
108 #if defined(__WATCOMC__)
109 # define finite _finite
110 # pragma disable_message(201) /* Disable unreachable code warnings */
117 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
118 # if !defined(__GNUC__) /* mingw environment */
119 # pragma warning( disable : 4068 ) /* unknown pragma */
120 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
121 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
122 # pragma warning( disable : 4127 ) /* conditional expression is constant */
123 # if defined(MESA_MINWARN)
124 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
125 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
126 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
127 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
128 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
131 # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
132 # define WGLAPI __declspec(dllexport)
133 # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
134 # define WGLAPI __declspec(dllimport)
135 # else /* for use with static link lib build of Win32 edition only */
136 # define WGLAPI __declspec(dllimport)
137 # endif /* _STATIC_MESA support */
138 #endif /* WIN32 / CYGWIN bracket */
142 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
143 * Do not use them unless absolutely necessary!
144 * Try to use a runtime test instead.
145 * For now, only used by some DRI hardware drivers for color/texel packing.
147 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
148 #if defined(__linux__)
149 #include <byteswap.h>
150 #define CPU_TO_LE32( x ) bswap_32( x )
152 #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
154 #define MESA_BIG_ENDIAN 1
156 #define CPU_TO_LE32( x ) ( x )
157 #define MESA_LITTLE_ENDIAN 1
159 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
162 #define GL_GLEXT_PROTOTYPES
164 #include "GL/glext.h"
167 #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
172 /* This is a macro on IRIX */
178 /* Turn off macro checking systems used by other libraries */
184 /* Create a macro so that asm functions can be linked into compilers other
188 #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
189 #define _ASMAPI __cdecl
193 #ifdef PTR_DECL_IN_FRONT
194 #define _ASMAPIP * _ASMAPI
196 #define _ASMAPIP _ASMAPI *
201 #define _NORMAPI _ASMAPI
202 #define _NORMAPIP _ASMAPIP
209 /* Function inlining */
210 #if defined(__GNUC__)
211 # define INLINE __inline__
212 #elif defined(__MSC__)
213 # define INLINE __inline
214 #elif defined(_MSC_VER)
215 # define INLINE __inline
217 # define INLINE __inline
218 #elif defined(__INTEL_COMPILER)
219 # define INLINE inline
220 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
221 # define INLINE __inline
222 #elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
223 # define INLINE inline
224 # define __inline inline
225 # define __inline__ inline
226 #elif (__STDC_VERSION__ >= 199901L) /* C99 */
227 # define INLINE inline
233 /* If we build the library with gcc's -fvisibility=hidden flag, we'll
234 * use the PUBLIC macro to mark functions that are to be exported.
236 * We also need to define a USED attribute, so the optimizer doesn't
237 * inline a static function that we later use in an alias. - ajax
239 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
240 # define PUBLIC __attribute__((visibility("default")))
241 # define USED __attribute__((used))
248 /* Some compilers don't like some of Mesa's const usage */
256 #if defined(BUILD_FOR_SNAP) && defined(CHECKED)
257 # define ASSERT(X) _CHECK(X)
259 # define ASSERT(X) assert(X)
265 #if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900)
266 # define __builtin_expect(x, y) x
269 /* The __FUNCTION__ gcc variable is generally only used for debugging.
270 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
271 * Don't define it if using a newer Windows compiler.
275 # define __FUNCTION__ "VMS$NL:"
276 # elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
277 (!defined(_MSC_VER) || _MSC_VER < 1300)
278 # if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
279 (defined(__SUNPRO_C) && defined(__C99FEATURES__))
280 # define __FUNCTION__ __func__
282 # define __FUNCTION__ "<unknown>"
290 #endif /* GLHEADER_H */