626806d35f6486bb5d140c96065a2e9e1bc8afda
[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 typedefs for uintptr_t and friends */
68 #if defined(__MINGW32__) || defined(__NetBSD__)
69 # include <stdint.h>
70 #elif defined(_WIN32)
71 # include <BaseTsd.h>
72 # if _MSC_VER == 1200
73 typedef UINT_PTR uintptr_t;
74 # endif
75 #elif defined(__INTERIX)
76 /* Interix 3.x has a gcc that shadows this. */
77 # ifndef _UINTPTR_T_DEFINED
78 typedef unsigned long uintptr_t;
79 # define _UINTPTR_T_DEFINED
80 # endif
81 #else
82 # include <inttypes.h>
83 #endif
84
85
86 /* Sun compilers define __i386 instead of the gcc-style __i386__ */
87 #ifdef __SUNPRO_C
88 # if !defined(__i386__) && defined(__i386)
89 # define __i386__
90 # elif !defined(__amd64__) && defined(__amd64)
91 # define __amd64__
92 # elif !defined(__sparc__) && defined(__sparc)
93 # define __sparc__
94 # endif
95 # if !defined(__volatile)
96 # define __volatile volatile
97 # endif
98 #endif
99
100 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
101 # define __WIN32__
102 # define finite _finite
103 #endif
104
105 #if defined(__WATCOMC__)
106 # define finite _finite
107 # pragma disable_message(201) /* Disable unreachable code warnings */
108 #endif
109
110 #ifdef WGLAPI
111 # undef WGLAPI
112 #endif
113
114 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
115 # if !defined(__GNUC__) /* mingw environment */
116 # pragma warning( disable : 4068 ) /* unknown pragma */
117 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
118 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
119 # pragma warning( disable : 4127 ) /* conditional expression is constant */
120 # if defined(MESA_MINWARN)
121 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
122 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
123 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
124 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
125 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
126 # endif
127 # endif
128 # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
129 # define WGLAPI __declspec(dllexport)
130 # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
131 # define WGLAPI __declspec(dllimport)
132 # else /* for use with static link lib build of Win32 edition only */
133 # define WGLAPI __declspec(dllimport)
134 # endif /* _STATIC_MESA support */
135 #endif /* WIN32 / CYGWIN bracket */
136
137
138 /*
139 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
140 * Do not use them unless absolutely necessary!
141 * Try to use a runtime test instead.
142 * For now, only used by some DRI hardware drivers for color/texel packing.
143 */
144 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
145 #if defined(__linux__)
146 #include <byteswap.h>
147 #define CPU_TO_LE32( x ) bswap_32( x )
148 #else /*__linux__*/
149 #include <sys/endian.h>
150 #define CPU_TO_LE32( x ) bswap32( x )
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 #ifndef GL_OES_point_size_array
171 #define GL_POINT_SIZE_ARRAY_OES 0x8B9C
172 #define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A
173 #define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B
174 #define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C
175 #define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F
176 #endif
177
178
179 #ifndef GL_OES_draw_texture
180 #define GL_TEXTURE_CROP_RECT_OES 0x8B9D
181 #endif
182
183
184 #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
185 #define CAPI _cdecl
186 #endif
187
188
189 /* This is a macro on IRIX */
190 #ifdef _P
191 #undef _P
192 #endif
193
194
195 /* Turn off macro checking systems used by other libraries */
196 #ifdef CHECK
197 #undef CHECK
198 #endif
199
200
201 /* Create a macro so that asm functions can be linked into compilers other
202 * than GNU C
203 */
204 #ifndef _ASMAPI
205 #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
206 #define _ASMAPI __cdecl
207 #else
208 #define _ASMAPI
209 #endif
210 #ifdef PTR_DECL_IN_FRONT
211 #define _ASMAPIP * _ASMAPI
212 #else
213 #define _ASMAPIP _ASMAPI *
214 #endif
215 #endif
216
217 #ifdef USE_X86_ASM
218 #define _NORMAPI _ASMAPI
219 #define _NORMAPIP _ASMAPIP
220 #else
221 #define _NORMAPI
222 #define _NORMAPIP *
223 #endif
224
225
226 /* Function inlining */
227 #if defined(__GNUC__)
228 # define INLINE __inline__
229 #elif defined(__MSC__)
230 # define INLINE __inline
231 #elif defined(_MSC_VER)
232 # define INLINE __inline
233 #elif defined(__ICL)
234 # define INLINE __inline
235 #elif defined(__INTEL_COMPILER)
236 # define INLINE inline
237 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
238 # define INLINE __inline
239 #elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
240 # define INLINE inline
241 # define __inline inline
242 # define __inline__ inline
243 #elif (__STDC_VERSION__ >= 199901L) /* C99 */
244 # define INLINE inline
245 #else
246 # define INLINE
247 #endif
248
249
250 /* If we build the library with gcc's -fvisibility=hidden flag, we'll
251 * use the PUBLIC macro to mark functions that are to be exported.
252 *
253 * We also need to define a USED attribute, so the optimizer doesn't
254 * inline a static function that we later use in an alias. - ajax
255 */
256 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
257 # define PUBLIC __attribute__((visibility("default")))
258 # define USED __attribute__((used))
259 #else
260 # define PUBLIC
261 # define USED
262 #endif
263
264
265 /* Some compilers don't like some of Mesa's const usage */
266 #ifdef NO_CONST
267 # define CONST
268 #else
269 # define CONST const
270 #endif
271
272
273 #if !defined(_WIN32_WCE)
274 #if defined(BUILD_FOR_SNAP) && defined(CHECKED)
275 # define ASSERT(X) _CHECK(X)
276 #elif defined(DEBUG)
277 # define ASSERT(X) assert(X)
278 #else
279 # define ASSERT(X)
280 #endif
281 #endif
282
283
284 #if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900)
285 # define __builtin_expect(x, y) x
286 #endif
287
288 /* The __FUNCTION__ gcc variable is generally only used for debugging.
289 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
290 * Don't define it if using a newer Windows compiler.
291 */
292 #ifndef __FUNCTION__
293 # if defined(__VMS)
294 # define __FUNCTION__ "VMS$NL:"
295 # elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
296 (!defined(_MSC_VER) || _MSC_VER < 1300)
297 # if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
298 (defined(__SUNPRO_C) && defined(__C99FEATURES__))
299 # define __FUNCTION__ __func__
300 # else
301 # define __FUNCTION__ "<unknown>"
302 # endif
303 # endif
304 #endif
305
306
307 #include "config.h"
308
309 #endif /* GLHEADER_H */