Fix copy-and-paste mistake in comment ("scaling" should read "translation").
[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.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 #ifdef HAVE_DIX_CONFIG_H
50 #include "dix-config.h"
51 #endif
52
53 #if defined(XFree86LOADER) && defined(IN_MODULE) && !defined(NO_LIBCWRAPPER)
54 #include "xf86_ansic.h"
55 #else
56 #include <assert.h>
57 #include <ctype.h>
58 /* If we can use Compaq's Fast Math Library on Alpha */
59 #if defined(__alpha__) && defined(CCPML)
60 #include <cpml.h>
61 #else
62 #include <math.h>
63 #endif
64 #include <limits.h>
65 #include <stdlib.h>
66 #include <stdio.h>
67 #include <string.h>
68 #if defined(__linux__) && defined(__i386__)
69 #include <fpu_control.h>
70 #endif
71 #endif
72 #include <float.h>
73 #include <stdarg.h>
74
75
76 /* Get typedefs for uintptr_t and friends */
77 #if defined(__MINGW32__) || defined(__NetBSD__)
78 # include <stdint.h>
79 #elif defined(_WIN32)
80 # include <BaseTsd.h>
81 # if _MSC_VER == 1200
82 typedef UINT_PTR uintptr_t;
83 # endif
84 #else
85 # include <inttypes.h>
86 #endif
87
88 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
89 # define __WIN32__
90 # define finite _finite
91 #endif
92
93 #if defined(__WATCOMC__)
94 # define finite _finite
95 # pragma disable_message(201) /* Disable unreachable code warnings */
96 #endif
97
98
99 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
100 # if !defined(__GNUC__) /* mingw environment */
101 # pragma warning( disable : 4068 ) /* unknown pragma */
102 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
103 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
104 # pragma warning( disable : 4127 ) /* conditional expression is constant */
105 # if defined(MESA_MINWARN)
106 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
107 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
108 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
109 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
110 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
111 # endif
112 # endif
113 # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
114 # define WGLAPI __declspec(dllexport)
115 # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
116 # define WGLAPI __declspec(dllimport)
117 # else /* for use with static link lib build of Win32 edition only */
118 # define WGLAPI __declspec(dllimport)
119 # endif /* _STATIC_MESA support */
120 #endif /* WIN32 / CYGWIN bracket */
121
122
123 /*
124 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
125 * Do not use them unless absolutely necessary!
126 * Try to use a runtime test instead.
127 * For now, only used by some DRI hardware drivers for color/texel packing.
128 */
129 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
130 #if defined(__linux__)
131 #include <byteswap.h>
132 #define CPU_TO_LE32( x ) bswap_32( x )
133 #else /*__linux__*/
134 #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
135 #endif /*__linux__*/
136 #define MESA_BIG_ENDIAN 1
137 #else
138 #define CPU_TO_LE32( x ) ( x )
139 #define MESA_LITTLE_ENDIAN 1
140 #endif
141 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
142
143
144 #define GL_GLEXT_PROTOTYPES
145 #include "GL/gl.h"
146 #include "GL/glext.h"
147
148
149 #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
150 #define CAPI _cdecl
151 #endif
152
153
154 /* This is a macro on IRIX */
155 #ifdef _P
156 #undef _P
157 #endif
158
159
160 /* Turn off macro checking systems used by other libraries */
161 #ifdef CHECK
162 #undef CHECK
163 #endif
164
165
166 /* Create a macro so that asm functions can be linked into compilers other
167 * than GNU C
168 */
169 #ifndef _ASMAPI
170 #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
171 #define _ASMAPI __cdecl
172 #else
173 #define _ASMAPI
174 #endif
175 #ifdef PTR_DECL_IN_FRONT
176 #define _ASMAPIP * _ASMAPI
177 #else
178 #define _ASMAPIP _ASMAPI *
179 #endif
180 #endif
181
182 #ifdef USE_X86_ASM
183 #define _NORMAPI _ASMAPI
184 #define _NORMAPIP _ASMAPIP
185 #else
186 #define _NORMAPI
187 #define _NORMAPIP *
188 #endif
189
190
191 /* Function inlining */
192 #if defined(__GNUC__)
193 # define INLINE __inline__
194 #elif defined(__MSC__)
195 # define INLINE __inline
196 #elif defined(_MSC_VER)
197 # define INLINE __inline
198 #elif defined(__ICL)
199 # define INLINE __inline
200 #elif defined(__INTEL_COMPILER)
201 # define INLINE inline
202 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
203 # define INLINE __inline
204 #else
205 # define INLINE
206 #endif
207
208
209 /* If we build the library with gcc's -fvisibility=hidden flag, we'll
210 * use the PUBLIC macro to mark functions that are to be exported.
211 *
212 * We also need to define a USED attribute, so the optimizer doesn't
213 * inline a static function that we later use in an alias. - ajax
214 */
215 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
216 # define PUBLIC __attribute__((visibility("default")))
217 # define USED __attribute__((used))
218 #else
219 # define PUBLIC
220 # define USED
221 #endif
222
223
224 /* Some compilers don't like some of Mesa's const usage */
225 #ifdef NO_CONST
226 # define CONST
227 #else
228 # define CONST const
229 #endif
230
231
232 #if defined(BUILD_FOR_SNAP) && defined(CHECKED)
233 # define ASSERT(X) _CHECK(X)
234 #elif defined(DEBUG)
235 # define ASSERT(X) assert(X)
236 #else
237 # define ASSERT(X)
238 #endif
239
240
241 #if !defined __GNUC__ || __GNUC__ < 3
242 # define __builtin_expect(x, y) x
243 #endif
244
245 /* The __FUNCTION__ gcc variable is generally only used for debugging.
246 * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
247 * Don't define it if using a newer Windows compiler.
248 */
249 #if defined(__VMS)
250 # define __FUNCTION__ "VMS$NL:"
251 #elif __STDC_VERSION__ < 199901L
252 # if ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
253 (!defined(_MSC_VER) || _MSC_VER < 1300)
254 # define __FUNCTION__ "<unknown>"
255 # endif
256 #endif
257
258
259 #include "config.h"
260
261 #endif /* GLHEADER_H */