Merge commit 'origin/gallium-0.1' into gallium-0.2
[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 #include <assert.h>
50 #include <ctype.h>
51 #if defined(__alpha__) && defined(CCPML)
52 #include <cpml.h> /* use Compaq's Fast Math Library on Alpha */
53 #else
54 #include <math.h>
55 #endif
56 #include <limits.h>
57 #include <stdlib.h>
58 #include <stdio.h>
59 #include <string.h>
60 #if defined(__linux__) && defined(__i386__)
61 #include <fpu_control.h>
62 #endif
63 #include <float.h>
64 #include <stdarg.h>
65
66
67 /* Get standard integer types */
68 #if defined(_MSC_VER)
69
70 typedef __int8 int8_t;
71 typedef unsigned __int8 uint8_t;
72 typedef __int16 int16_t;
73 typedef unsigned __int16 uint16_t;
74 # ifndef __eglplatform_h_
75 typedef __int32 int32_t;
76 # endif
77 typedef unsigned __int32 uint32_t;
78 typedef __int64 int64_t;
79 typedef unsigned __int64 uint64_t;
80
81 # if defined(_WIN64)
82 typedef __int64 intptr_t;
83 typedef unsigned __int64 uintptr_t;
84 # else
85 typedef __int32 intptr_t;
86 typedef unsigned __int32 uintptr_t;
87 # endif
88
89 # define INT64_C(__val) __val##i64
90 # define UINT64_C(__val) __val##ui64
91
92 #else
93 # include <stdint.h>
94 #endif
95
96 /* For platforms that have the C99 standard uint*_t,
97 but not the commonly used u_int*_t */
98 #if defined(__sun)
99 # define u_int8_t uint8_t
100 # define u_int16_t uint16_t
101 # define u_int32_t uint32_t
102 # define u_int64_t uint64_t
103 # define u_intptr_t uintptr_t
104 #endif
105
106 /* Sun compilers define __i386 instead of the gcc-style __i386__ */
107 #ifdef __SUNPRO_C
108 # if !defined(__i386__) && defined(__i386)
109 # define __i386__
110 # elif !defined(__amd64__) && defined(__amd64)
111 # define __amd64__
112 # elif !defined(__sparc__) && defined(__sparc)
113 # define __sparc__
114 # endif
115 # if !defined(__volatile)
116 # define __volatile volatile
117 # endif
118 #endif
119
120 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
121 # define __WIN32__
122 # define finite _finite
123 #endif
124
125 #if defined(__WATCOMC__)
126 # define finite _finite
127 # pragma disable_message(201) /* Disable unreachable code warnings */
128 #endif
129
130 #ifdef WGLAPI
131 # undef WGLAPI
132 #endif
133
134 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
135 # if !defined(__GNUC__) /* mingw environment */
136 # pragma warning( disable : 4068 ) /* unknown pragma */
137 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
138 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
139 # pragma warning( disable : 4127 ) /* conditional expression is constant */
140 # if defined(MESA_MINWARN)
141 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
142 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
143 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
144 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
145 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
146 # endif
147 # endif
148 # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
149 # define WGLAPI __declspec(dllexport)
150 # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
151 # define WGLAPI __declspec(dllimport)
152 # else /* for use with static link lib build of Win32 edition only */
153 # define WGLAPI __declspec(dllimport)
154 # endif /* _STATIC_MESA support */
155 #endif /* WIN32 / CYGWIN bracket */
156
157
158 /*
159 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
160 * Do not use them unless absolutely necessary!
161 * Try to use a runtime test instead.
162 * For now, only used by some DRI hardware drivers for color/texel packing.
163 */
164 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
165 #if defined(__linux__)
166 #include <byteswap.h>
167 #define CPU_TO_LE32( x ) bswap_32( x )
168 #else /*__linux__*/
169 #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
170 #endif /*__linux__*/
171 #define MESA_BIG_ENDIAN 1
172 #else
173 #define CPU_TO_LE32( x ) ( x )
174 #define MESA_LITTLE_ENDIAN 1
175 #endif
176 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
177
178
179 #define GL_GLEXT_PROTOTYPES
180 #include "GL/gl.h"
181 #include "GL/glext.h"
182
183
184 #ifndef GL_FIXED
185 #define GL_FIXED 0x140C
186 #endif
187
188
189 #ifndef GL_OES_point_size_array
190 #define GL_POINT_SIZE_ARRAY_OES 0x8B9C
191 #define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A
192 #define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B
193 #define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C
194 #define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F
195 #endif
196
197
198 #ifndef GL_OES_draw_texture
199 #define GL_TEXTURE_CROP_RECT_OES 0x8B9D
200 #endif
201
202
203 #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
204 #define CAPI _cdecl
205 #endif
206
207
208 /* This is a macro on IRIX */
209 #ifdef _P
210 #undef _P
211 #endif
212
213
214 /* Turn off macro checking systems used by other libraries */
215 #ifdef CHECK
216 #undef CHECK
217 #endif
218
219
220 /* Create a macro so that asm functions can be linked into compilers other
221 * than GNU C
222 */
223 #ifndef _ASMAPI
224 #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
225 #define _ASMAPI __cdecl
226 #else
227 #define _ASMAPI
228 #endif
229 #ifdef PTR_DECL_IN_FRONT
230 #define _ASMAPIP * _ASMAPI
231 #else
232 #define _ASMAPIP _ASMAPI *
233 #endif
234 #endif
235
236 #ifdef USE_X86_ASM
237 #define _NORMAPI _ASMAPI
238 #define _NORMAPIP _ASMAPIP
239 #else
240 #define _NORMAPI
241 #define _NORMAPIP *
242 #endif
243
244
245 /* Function inlining */
246 #if defined(__GNUC__)
247 # define INLINE __inline__
248 #elif defined(__MSC__)
249 # define INLINE __inline
250 #elif defined(_MSC_VER)
251 # define INLINE __inline
252 #elif defined(__ICL)
253 # define INLINE __inline
254 #elif defined(__INTEL_COMPILER)
255 # define INLINE inline
256 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
257 # define INLINE __inline
258 #elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
259 # define INLINE inline
260 # define __inline inline
261 # define __inline__ inline
262 #elif (__STDC_VERSION__ >= 199901L) /* C99 */
263 # define INLINE inline
264 #else
265 # define INLINE
266 #endif
267
268
269 /* If we build the library with gcc's -fvisibility=hidden flag, we'll
270 * use the PUBLIC macro to mark functions that are to be exported.
271 *
272 * We also need to define a USED attribute, so the optimizer doesn't
273 * inline a static function that we later use in an alias. - ajax
274 */
275 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
276 # define PUBLIC __attribute__((visibility("default")))
277 # define USED __attribute__((used))
278 #else
279 # define PUBLIC
280 # define USED
281 #endif
282
283
284 /* Some compilers don't like some of Mesa's const usage */
285 #ifdef NO_CONST
286 # define CONST
287 #else
288 # define CONST const
289 #endif
290
291
292 #if !defined(_WIN32_WCE)
293 #if defined(BUILD_FOR_SNAP) && defined(CHECKED)
294 # define ASSERT(X) _CHECK(X)
295 #elif defined(DEBUG)
296 # define ASSERT(X) assert(X)
297 #else
298 # define ASSERT(X)
299 #endif
300 #endif
301
302
303 #if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900)
304 # define __builtin_expect(x, y) x
305 #endif
306
307 /* The __FUNCTION__ gcc variable is generally only used for debugging.
308 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
309 * Don't define it if using a newer Windows compiler.
310 */
311 #ifndef __FUNCTION__
312 # if defined(__VMS)
313 # define __FUNCTION__ "VMS$NL:"
314 # elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
315 (!defined(_MSC_VER) || _MSC_VER < 1300)
316 # if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
317 (defined(__SUNPRO_C) && defined(__C99FEATURES__))
318 # define __FUNCTION__ __func__
319 # else
320 # define __FUNCTION__ "<unknown>"
321 # endif
322 # endif
323 #endif
324
325
326 #include "config.h"
327
328 #endif /* GLHEADER_H */