Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / mesa / main / glheader.h
1 /**
2 * \file glheader.h
3 * Top-most include file.
4 *
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.
10 *
11 * \note Actually, a lot of system-dependent stuff is now in imports.[ch].
12 *
13 * If you touch this file, everything gets recompiled!
14 *
15 * This file should be included before any other header in the .c files.
16 *
17 * Put compiler/OS/assembly pragmas and macros here to avoid
18 * cluttering other source files.
19 */
20
21 /*
22 * Mesa 3-D graphics library
23 * Version: 6.5
24 *
25 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
26 *
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:
33 *
34 * The above copyright notice and this permission notice shall be included
35 * in all copies or substantial portions of the Software.
36 *
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.
43 */
44
45
46 #ifndef GLHEADER_H
47 #define GLHEADER_H
48
49 /* This allows Mesa to be integrated into XFree86 */
50 #ifdef HAVE_DIX_CONFIG_H
51 #include "dix-config.h"
52 #endif
53
54 #include <assert.h>
55 #include <ctype.h>
56 #if defined(__alpha__) && defined(CCPML)
57 #include <cpml.h> /* use Compaq's Fast Math Library on Alpha */
58 #else
59 #include <math.h>
60 #endif
61 #include <limits.h>
62 #include <stdlib.h>
63 #include <stdio.h>
64 #include <string.h>
65 #if defined(__linux__) && defined(__i386__)
66 #include <fpu_control.h>
67 #endif
68 #include <float.h>
69 #include <stdarg.h>
70
71
72 /* Get standard integer types */
73 #if defined(_MSC_VER)
74
75 typedef __int8 int8_t;
76 typedef unsigned __int8 uint8_t;
77 typedef __int16 int16_t;
78 typedef unsigned __int16 uint16_t;
79 # ifndef __eglplatform_h_
80 typedef __int32 int32_t;
81 # endif
82 typedef unsigned __int32 uint32_t;
83 typedef __int64 int64_t;
84 typedef unsigned __int64 uint64_t;
85
86 # if defined(_WIN64)
87 typedef __int64 intptr_t;
88 typedef unsigned __int64 uintptr_t;
89 # else
90 typedef __int32 intptr_t;
91 typedef unsigned __int32 uintptr_t;
92 # endif
93
94 # define INT64_C(__val) __val##i64
95 # define UINT64_C(__val) __val##ui64
96
97 #else
98 # include <stdint.h>
99 #endif
100
101 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
102 # define __WIN32__
103 # define finite _finite
104 #endif
105
106 #if defined(__WATCOMC__)
107 # define finite _finite
108 # pragma disable_message(201) /* Disable unreachable code warnings */
109 #endif
110
111 #ifdef WGLAPI
112 # undef WGLAPI
113 #endif
114
115 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
116 # if !defined(__GNUC__) /* mingw environment */
117 # pragma warning( disable : 4068 ) /* unknown pragma */
118 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
119 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
120 # pragma warning( disable : 4127 ) /* conditional expression is constant */
121 # if defined(MESA_MINWARN)
122 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
123 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
124 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
125 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
126 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
127 # endif
128 # endif
129 # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
130 # define WGLAPI __declspec(dllexport)
131 # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
132 # define WGLAPI __declspec(dllimport)
133 # else /* for use with static link lib build of Win32 edition only */
134 # define WGLAPI __declspec(dllimport)
135 # endif /* _STATIC_MESA support */
136 #endif /* WIN32 / CYGWIN bracket */
137
138
139 /*
140 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
141 * Do not use them unless absolutely necessary!
142 * Try to use a runtime test instead.
143 * For now, only used by some DRI hardware drivers for color/texel packing.
144 */
145 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
146 #if defined(__linux__)
147 #include <byteswap.h>
148 #define CPU_TO_LE32( x ) bswap_32( x )
149 #else /*__linux__*/
150 #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
151 #endif /*__linux__*/
152 #define MESA_BIG_ENDIAN 1
153 #else
154 #define CPU_TO_LE32( x ) ( x )
155 #define MESA_LITTLE_ENDIAN 1
156 #endif
157 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
158
159
160 #define GL_GLEXT_PROTOTYPES
161 #include "GL/gl.h"
162 #include "GL/glext.h"
163
164
165 #ifndef GL_FIXED
166 #define GL_FIXED 0x140C
167 #endif
168
169
170 #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
171 #define CAPI _cdecl
172 #endif
173
174
175 /* This is a macro on IRIX */
176 #ifdef _P
177 #undef _P
178 #endif
179
180
181 /* Turn off macro checking systems used by other libraries */
182 #ifdef CHECK
183 #undef CHECK
184 #endif
185
186
187 /* Create a macro so that asm functions can be linked into compilers other
188 * than GNU C
189 */
190 #ifndef _ASMAPI
191 #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
192 #define _ASMAPI __cdecl
193 #else
194 #define _ASMAPI
195 #endif
196 #ifdef PTR_DECL_IN_FRONT
197 #define _ASMAPIP * _ASMAPI
198 #else
199 #define _ASMAPIP _ASMAPI *
200 #endif
201 #endif
202
203 #ifdef USE_X86_ASM
204 #define _NORMAPI _ASMAPI
205 #define _NORMAPIP _ASMAPIP
206 #else
207 #define _NORMAPI
208 #define _NORMAPIP *
209 #endif
210
211
212 /* Function inlining */
213 #if defined(__GNUC__)
214 # define INLINE __inline__
215 #elif defined(__MSC__)
216 # define INLINE __inline
217 #elif defined(_MSC_VER)
218 # define INLINE __inline
219 #elif defined(__ICL)
220 # define INLINE __inline
221 #elif defined(__INTEL_COMPILER)
222 # define INLINE inline
223 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
224 # define INLINE __inline
225 #else
226 # define INLINE
227 #endif
228
229
230 /* If we build the library with gcc's -fvisibility=hidden flag, we'll
231 * use the PUBLIC macro to mark functions that are to be exported.
232 *
233 * We also need to define a USED attribute, so the optimizer doesn't
234 * inline a static function that we later use in an alias. - ajax
235 */
236 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
237 # define PUBLIC __attribute__((visibility("default")))
238 # define USED __attribute__((used))
239 #else
240 # define PUBLIC
241 # define USED
242 #endif
243
244
245 /* Some compilers don't like some of Mesa's const usage */
246 #ifdef NO_CONST
247 # define CONST
248 #else
249 # define CONST const
250 #endif
251
252
253 #if !defined(_WIN32_WCE)
254 #if defined(BUILD_FOR_SNAP) && defined(CHECKED)
255 # define ASSERT(X) _CHECK(X)
256 #elif defined(DEBUG)
257 # define ASSERT(X) assert(X)
258 #else
259 # define ASSERT(X)
260 #endif
261 #endif
262
263
264 #if !defined __GNUC__ || __GNUC__ < 3
265 # define __builtin_expect(x, y) x
266 #endif
267
268 /* The __FUNCTION__ gcc variable is generally only used for debugging.
269 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
270 * Don't define it if using a newer Windows compiler.
271 */
272 #if defined(__VMS)
273 # define __FUNCTION__ "VMS$NL:"
274 #elif __STDC_VERSION__ < 199901L
275 # if ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
276 (!defined(_MSC_VER) || _MSC_VER < 1300)
277 # define __FUNCTION__ "<unknown>"
278 # endif
279 #endif
280
281
282 #include "config.h"
283
284 #endif /* GLHEADER_H */