-"fix" page flipping
[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 Mesa to be integrated into XFree86 and
9 * allows system-dependent hacks/workarounds to be 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.3
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
50 #if defined(XFree86LOADER) && defined(IN_MODULE)
51 #include "xf86_ansic.h"
52 #else
53 #include <assert.h>
54 #include <ctype.h>
55 /* If we can use Compaq's Fast Math Library on Alpha */
56 #if defined(__alpha__) && defined(CCPML)
57 #include <cpml.h>
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 #endif
69 #include <float.h>
70 #include <stdarg.h>
71
72
73 /* This is no longer uses since we dumped autoconf/automake! */
74 #ifdef HAVE_CONFIG_H
75 #include "conf.h"
76 #endif
77
78 /* Get typedefs for uintptr_t and friends */
79 #if defined(_WIN32)
80 #include <BaseTsd.h>
81 #if _MSC_VER == 1200
82 typedef UINT_PTR uintptr_t;
83 #endif
84 #if defined(__MINGW32__)
85 #include <stdint.h>
86 #endif
87 #else
88 #include <inttypes.h>
89 #endif
90
91 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
92 # define __WIN32__
93 # define finite _finite
94 #endif
95
96 #if defined(__WATCOMC__)
97 # define finite _finite
98 # pragma disable_message(201) /* Disable unreachable code warnings */
99 #endif
100
101
102 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
103 # if !defined(__GNUC__) /* mingw environment */
104 # pragma warning( disable : 4068 ) /* unknown pragma */
105 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
106 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
107 # pragma warning( disable : 4127 ) /* conditional expression is constant */
108 # if defined(MESA_MINWARN)
109 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
110 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
111 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
112 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
113 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
114 # endif
115 # endif
116 # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
117 # define WGLAPI __declspec(dllexport)
118 # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
119 # define WGLAPI __declspec(dllimport)
120 # else /* for use with static link lib build of Win32 edition only */
121 # define WGLAPI __declspec(dllimport)
122 # endif /* _STATIC_MESA support */
123 #endif /* WIN32 / CYGWIN bracket */
124
125
126 #ifndef __MINGW32__
127 /* XXX why is this here?
128 * It should probaby be somewhere in src/mesa/drivers/windows/
129 */
130 #if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(BUILD_FOR_SNAP)
131 # define WGL_FONT_LINES 0
132 # define WGL_FONT_POLYGONS 1
133 #ifndef _GNU_H_WINDOWS32_FUNCTIONS
134 # ifdef UNICODE
135 # define wglUseFontBitmaps wglUseFontBitmapsW
136 # define wglUseFontOutlines wglUseFontOutlinesW
137 # else
138 # define wglUseFontBitmaps wglUseFontBitmapsA
139 # define wglUseFontOutlines wglUseFontOutlinesA
140 # endif /* !UNICODE */
141 #endif /* _GNU_H_WINDOWS32_FUNCTIONS */
142 typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
143 typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
144 typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
145 #if !defined(GLX_USE_MESA)
146 #include <GL/mesa_wgl.h>
147 #endif
148 #endif
149 #endif /* !__MINGW32__ */
150
151
152 /*
153 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
154 * Do not use them unless absolutely necessary!
155 * Try to use a runtime test instead.
156 * For now, only used by some DRI hardware drivers for color/texel packing.
157 */
158 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
159 #if defined(__linux__)
160 #include <byteswap.h>
161 #define CPU_TO_LE32( x ) bswap_32( x )
162 #else /*__linux__*/
163 #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
164 #endif /*__linux__*/
165 #define MESA_BIG_ENDIAN 1
166 #else
167 #define CPU_TO_LE32( x ) ( x )
168 #define MESA_LITTLE_ENDIAN 1
169 #endif
170 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
171
172
173 #define GL_GLEXT_PROTOTYPES
174 #include "GL/gl.h"
175 #include "GL/glext.h"
176
177
178 #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
179 #define CAPI _cdecl
180 #endif
181 #include <GL/internal/glcore.h>
182
183
184 /* This is a macro on IRIX */
185 #ifdef _P
186 #undef _P
187 #endif
188
189
190 /* Turn off macro checking systems used by other libraries */
191 #ifdef CHECK
192 #undef CHECK
193 #endif
194
195
196 /* Create a macro so that asm functions can be linked into compilers other
197 * than GNU C
198 */
199 #ifndef _ASMAPI
200 #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
201 #define _ASMAPI __cdecl
202 #else
203 #define _ASMAPI
204 #endif
205 #ifdef PTR_DECL_IN_FRONT
206 #define _ASMAPIP * _ASMAPI
207 #else
208 #define _ASMAPIP _ASMAPI *
209 #endif
210 #endif
211
212 #ifdef USE_X86_ASM
213 #define _NORMAPI _ASMAPI
214 #define _NORMAPIP _ASMAPIP
215 #else
216 #define _NORMAPI
217 #define _NORMAPIP *
218 #endif
219
220
221 /* Function inlining */
222 #if defined(__GNUC__)
223 # define INLINE __inline__
224 #elif defined(__MSC__)
225 # define INLINE __inline
226 #elif defined(_MSC_VER)
227 # define INLINE __inline
228 #elif defined(__ICL)
229 # define INLINE __inline
230 #elif defined(__INTEL_COMPILER)
231 # define INLINE inline
232 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
233 # define INLINE __inline
234 #else
235 # define INLINE
236 #endif
237
238
239 /* If we build the library with gcc's -fvisibility=hidden flag, we'll
240 * use the PUBLIC macro to mark functions that are to be exported.
241 *
242 * We also need to define a USED attribute, so the optimizer doesn't
243 * inline a static function that we later use in an alias. - ajax
244 */
245 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
246 # define PUBLIC __attribute__((visibility("default")))
247 # define USED __attribute__((used))
248 #else
249 # define PUBLIC
250 # define USED
251 #endif
252
253
254 /* Some compilers don't like some of Mesa's const usage */
255 #ifdef NO_CONST
256 # define CONST
257 #else
258 # define CONST const
259 #endif
260
261
262 #if defined(BUILD_FOR_SNAP) && defined(CHECKED)
263 # define ASSERT(X) _CHECK(X)
264 #elif defined(DEBUG)
265 # define ASSERT(X) assert(X)
266 #else
267 # define ASSERT(X)
268 #endif
269
270
271 #if !defined __GNUC__ || __GNUC__ < 3
272 # define __builtin_expect(x, y) x
273 #endif
274
275 /* Windows does not have the ffs() function */
276 #if defined(_WIN32) && !defined(__MINGW32__)
277 int INLINE ffs(int value)
278 {
279 int bit;
280 if (value == 0)
281 return 0;
282 for (bit=1; !(value & 1); bit++)
283 value >>= 1;
284 return bit;
285 }
286 #endif
287
288
289 /* The __FUNCTION__ gcc variable is generally only used for debugging.
290 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
291 */
292 #if defined(__VMS)
293 #define __FUNCTION__ "VMS$NL:"
294 #elif !(defined(__GNUC__) && __GNUC__ >= 2)
295 #define __FUNCTION__ "unknown"
296 #endif
297
298
299 #include "config.h"
300
301 #endif /* GLHEADER_H */