Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file glheader.h |
| 3 | * Top-most include file. |
Kendall Bennett | b29b8ca | 2003-09-12 22:01:01 +0000 | [diff] [blame] | 4 | * |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 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 |
George Sapountzis | b766643 | 2006-12-06 06:40:18 +0200 | [diff] [blame] | 8 | * headers. This allows system-dependent hacks/workarounds to be |
| 9 | * collected in one place. |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 10 | * |
| 11 | * \note Actually, a lot of system-dependent stuff is now in imports.[ch]. |
Kendall Bennett | b29b8ca | 2003-09-12 22:01:01 +0000 | [diff] [blame] | 12 | * |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 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 | */ |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 20 | |
| 21 | /* |
| 22 | * Mesa 3-D graphics library |
Brian Paul | 49b2d2e | 2005-11-27 23:46:55 +0000 | [diff] [blame] | 23 | * Version: 6.5 |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 24 | * |
Brian Paul | 914746b | 2005-01-26 14:45:38 +0000 | [diff] [blame] | 25 | * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 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 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 49 | #include <assert.h> |
| 50 | #include <ctype.h> |
Brian Paul | f7a4bca | 2000-09-15 15:42:45 +0000 | [diff] [blame] | 51 | #if defined(__alpha__) && defined(CCPML) |
George Sapountzis | b766643 | 2006-12-06 06:40:18 +0200 | [diff] [blame] | 52 | #include <cpml.h> /* use Compaq's Fast Math Library on Alpha */ |
Brian Paul | f7a4bca | 2000-09-15 15:42:45 +0000 | [diff] [blame] | 53 | #else |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 54 | #include <math.h> |
Brian Paul | f7a4bca | 2000-09-15 15:42:45 +0000 | [diff] [blame] | 55 | #endif |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 56 | #include <limits.h> |
| 57 | #include <stdlib.h> |
| 58 | #include <stdio.h> |
| 59 | #include <string.h> |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 60 | #if defined(__linux__) && defined(__i386__) |
Brian Paul | 780c4e0 | 2000-03-22 23:20:12 +0000 | [diff] [blame] | 61 | #include <fpu_control.h> |
| 62 | #endif |
Brian Paul | e39ed58 | 2000-02-12 15:55:34 +0000 | [diff] [blame] | 63 | #include <float.h> |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 64 | #include <stdarg.h> |
Brian Paul | e39ed58 | 2000-02-12 15:55:34 +0000 | [diff] [blame] | 65 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 66 | |
Karl Schultz | 6258b76 | 2005-05-05 21:08:07 +0000 | [diff] [blame] | 67 | /* Get typedefs for uintptr_t and friends */ |
Brian Paul | 49b2d2e | 2005-11-27 23:46:55 +0000 | [diff] [blame] | 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 |
Karl Schultz | 6258b76 | 2005-05-05 21:08:07 +0000 | [diff] [blame] | 75 | #else |
Brian Paul | 49b2d2e | 2005-11-27 23:46:55 +0000 | [diff] [blame] | 76 | # include <inttypes.h> |
Karl Schultz | 6258b76 | 2005-05-05 21:08:07 +0000 | [diff] [blame] | 77 | #endif |
| 78 | |
Kendall Bennett | 2cdd699 | 2003-10-08 01:53:30 +0000 | [diff] [blame] | 79 | #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP) |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 80 | # define __WIN32__ |
| 81 | # define finite _finite |
Brian Paul | 87a7897 | 2000-05-22 16:30:47 +0000 | [diff] [blame] | 82 | #endif |
| 83 | |
Kendall Bennett | 2cdd699 | 2003-10-08 01:53:30 +0000 | [diff] [blame] | 84 | #if defined(__WATCOMC__) |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 85 | # define finite _finite |
| 86 | # pragma disable_message(201) /* Disable unreachable code warnings */ |
Kendall Bennett | 2cdd699 | 2003-10-08 01:53:30 +0000 | [diff] [blame] | 87 | #endif |
| 88 | |
zhang | 37aca21 | 2007-06-28 08:12:52 -0600 | [diff] [blame] | 89 | #ifdef WGLAPI |
Zhang | 76fb808 | 2007-07-21 11:28:06 -0600 | [diff] [blame] | 90 | # undef WGLAPI |
zhang | 37aca21 | 2007-06-28 08:12:52 -0600 | [diff] [blame] | 91 | #endif |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 92 | |
Kendall Bennett | 2cdd699 | 2003-10-08 01:53:30 +0000 | [diff] [blame] | 93 | #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) |
Brian Paul | 86e001b | 2004-08-25 14:59:45 +0000 | [diff] [blame] | 94 | # if !defined(__GNUC__) /* mingw environment */ |
| 95 | # pragma warning( disable : 4068 ) /* unknown pragma */ |
| 96 | # pragma warning( disable : 4710 ) /* function 'foo' not inlined */ |
| 97 | # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ |
| 98 | # pragma warning( disable : 4127 ) /* conditional expression is constant */ |
| 99 | # if defined(MESA_MINWARN) |
| 100 | # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ |
| 101 | # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ |
| 102 | # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ |
| 103 | # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ |
| 104 | # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ |
| 105 | # endif |
Brian Paul | 87a7897 | 2000-05-22 16:30:47 +0000 | [diff] [blame] | 106 | # endif |
Brian Paul | 83889ff | 2004-11-08 15:08:48 +0000 | [diff] [blame] | 107 | # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ |
Brian Paul | 87a7897 | 2000-05-22 16:30:47 +0000 | [diff] [blame] | 108 | # define WGLAPI __declspec(dllexport) |
Brian Paul | 83889ff | 2004-11-08 15:08:48 +0000 | [diff] [blame] | 109 | # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ |
Brian Paul | 87a7897 | 2000-05-22 16:30:47 +0000 | [diff] [blame] | 110 | # define WGLAPI __declspec(dllimport) |
| 111 | # else /* for use with static link lib build of Win32 edition only */ |
Brian Paul | 87a7897 | 2000-05-22 16:30:47 +0000 | [diff] [blame] | 112 | # define WGLAPI __declspec(dllimport) |
| 113 | # endif /* _STATIC_MESA support */ |
Brian Paul | df54463 | 2000-05-22 19:41:34 +0000 | [diff] [blame] | 114 | #endif /* WIN32 / CYGWIN bracket */ |
Brian Paul | 87a7897 | 2000-05-22 16:30:47 +0000 | [diff] [blame] | 115 | |
Brian Paul | 87a7897 | 2000-05-22 16:30:47 +0000 | [diff] [blame] | 116 | |
Brian Paul | 1013e46 | 2002-06-12 00:52:50 +0000 | [diff] [blame] | 117 | /* |
| 118 | * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN. |
| 119 | * Do not use them unless absolutely necessary! |
| 120 | * Try to use a runtime test instead. |
| 121 | * For now, only used by some DRI hardware drivers for color/texel packing. |
| 122 | */ |
| 123 | #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN |
| 124 | #if defined(__linux__) |
| 125 | #include <byteswap.h> |
| 126 | #define CPU_TO_LE32( x ) bswap_32( x ) |
| 127 | #else /*__linux__*/ |
| 128 | #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */ |
| 129 | #endif /*__linux__*/ |
| 130 | #define MESA_BIG_ENDIAN 1 |
| 131 | #else |
| 132 | #define CPU_TO_LE32( x ) ( x ) |
| 133 | #define MESA_LITTLE_ENDIAN 1 |
| 134 | #endif |
| 135 | #define LE32_TO_CPU( x ) CPU_TO_LE32( x ) |
| 136 | |
| 137 | |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 138 | #define GL_GLEXT_PROTOTYPES |
Brian Paul | 1e01632 | 2000-05-26 15:52:06 +0000 | [diff] [blame] | 139 | #include "GL/gl.h" |
| 140 | #include "GL/glext.h" |
| 141 | |
| 142 | |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 143 | #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) |
Brian Paul | a1503b0 | 2001-07-16 15:54:23 +0000 | [diff] [blame] | 144 | #define CAPI _cdecl |
Brian Paul | a1503b0 | 2001-07-16 15:54:23 +0000 | [diff] [blame] | 145 | #endif |
Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 146 | |
| 147 | |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 148 | /* This is a macro on IRIX */ |
| 149 | #ifdef _P |
| 150 | #undef _P |
Kendall Bennett | be599f8 | 1999-11-12 16:46:56 +0000 | [diff] [blame] | 151 | #endif |
| 152 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 153 | |
Brian Paul | 2da507d | 1999-11-12 18:23:47 +0000 | [diff] [blame] | 154 | /* Turn off macro checking systems used by other libraries */ |
| 155 | #ifdef CHECK |
| 156 | #undef CHECK |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 157 | #endif |
Brian Paul | 2da507d | 1999-11-12 18:23:47 +0000 | [diff] [blame] | 158 | |
| 159 | |
| 160 | /* Create a macro so that asm functions can be linked into compilers other |
| 161 | * than GNU C |
| 162 | */ |
| 163 | #ifndef _ASMAPI |
Brian Paul | 5e83c2a | 2004-01-28 22:01:47 +0000 | [diff] [blame] | 164 | #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/ |
Brian Paul | 2da507d | 1999-11-12 18:23:47 +0000 | [diff] [blame] | 165 | #define _ASMAPI __cdecl |
| 166 | #else |
| 167 | #define _ASMAPI |
| 168 | #endif |
| 169 | #ifdef PTR_DECL_IN_FRONT |
| 170 | #define _ASMAPIP * _ASMAPI |
| 171 | #else |
| 172 | #define _ASMAPIP _ASMAPI * |
| 173 | #endif |
| 174 | #endif |
| 175 | |
| 176 | #ifdef USE_X86_ASM |
| 177 | #define _NORMAPI _ASMAPI |
| 178 | #define _NORMAPIP _ASMAPIP |
| 179 | #else |
| 180 | #define _NORMAPI |
| 181 | #define _NORMAPIP * |
| 182 | #endif |
| 183 | |
| 184 | |
Brian Paul | 0ab16e0 | 2001-05-14 23:11:12 +0000 | [diff] [blame] | 185 | /* Function inlining */ |
| 186 | #if defined(__GNUC__) |
| 187 | # define INLINE __inline__ |
| 188 | #elif defined(__MSC__) |
| 189 | # define INLINE __inline |
Brian Paul | a1503b0 | 2001-07-16 15:54:23 +0000 | [diff] [blame] | 190 | #elif defined(_MSC_VER) |
| 191 | # define INLINE __inline |
| 192 | #elif defined(__ICL) |
| 193 | # define INLINE __inline |
Eric Anholt | 527078a | 2003-12-09 23:59:16 +0000 | [diff] [blame] | 194 | #elif defined(__INTEL_COMPILER) |
| 195 | # define INLINE inline |
Kendall Bennett | b29b8ca | 2003-09-12 22:01:01 +0000 | [diff] [blame] | 196 | #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100) |
| 197 | # define INLINE __inline |
Brian Paul | 0ab16e0 | 2001-05-14 23:11:12 +0000 | [diff] [blame] | 198 | #else |
| 199 | # define INLINE |
| 200 | #endif |
| 201 | |
| 202 | |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 203 | /* If we build the library with gcc's -fvisibility=hidden flag, we'll |
| 204 | * use the PUBLIC macro to mark functions that are to be exported. |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 205 | * |
| 206 | * We also need to define a USED attribute, so the optimizer doesn't |
| 207 | * inline a static function that we later use in an alias. - ajax |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 208 | */ |
| 209 | #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 |
| 210 | # define PUBLIC __attribute__((visibility("default"))) |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 211 | # define USED __attribute__((used)) |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 212 | #else |
| 213 | # define PUBLIC |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 214 | # define USED |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 215 | #endif |
| 216 | |
| 217 | |
Brian Paul | 0ab16e0 | 2001-05-14 23:11:12 +0000 | [diff] [blame] | 218 | /* Some compilers don't like some of Mesa's const usage */ |
| 219 | #ifdef NO_CONST |
| 220 | # define CONST |
| 221 | #else |
| 222 | # define CONST const |
| 223 | #endif |
| 224 | |
| 225 | |
Kendall Bennett | 2cdd699 | 2003-10-08 01:53:30 +0000 | [diff] [blame] | 226 | #if defined(BUILD_FOR_SNAP) && defined(CHECKED) |
Kendall Bennett | adbbea9 | 2003-10-02 23:50:44 +0000 | [diff] [blame] | 227 | # define ASSERT(X) _CHECK(X) |
| 228 | #elif defined(DEBUG) |
Brian Paul | 0ab16e0 | 2001-05-14 23:11:12 +0000 | [diff] [blame] | 229 | # define ASSERT(X) assert(X) |
| 230 | #else |
| 231 | # define ASSERT(X) |
| 232 | #endif |
| 233 | |
| 234 | |
Brian | 882e0e0 | 2008-03-09 10:55:01 -0600 | [diff] [blame] | 235 | #if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900) |
Brian Paul | 936028f | 2004-11-25 23:22:56 +0000 | [diff] [blame] | 236 | # define __builtin_expect(x, y) x |
Ian Romanick | 8e77da1 | 2004-06-29 19:08:20 +0000 | [diff] [blame] | 237 | #endif |
| 238 | |
Brian Paul | 38332a6 | 2005-06-19 14:57:34 +0000 | [diff] [blame] | 239 | /* The __FUNCTION__ gcc variable is generally only used for debugging. |
| 240 | * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. |
Karl Schultz | eac7688 | 2005-07-01 20:11:46 +0000 | [diff] [blame] | 241 | * Don't define it if using a newer Windows compiler. |
Brian Paul | 38332a6 | 2005-06-19 14:57:34 +0000 | [diff] [blame] | 242 | */ |
| 243 | #if defined(__VMS) |
Brian Paul | a186c80 | 2006-04-13 01:52:32 +0000 | [diff] [blame] | 244 | # define __FUNCTION__ "VMS$NL:" |
| 245 | #elif __STDC_VERSION__ < 199901L |
| 246 | # if ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \ |
| 247 | (!defined(_MSC_VER) || _MSC_VER < 1300) |
| 248 | # define __FUNCTION__ "<unknown>" |
| 249 | # endif |
Brian Paul | 38332a6 | 2005-06-19 14:57:34 +0000 | [diff] [blame] | 250 | #endif |
| 251 | |
| 252 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 253 | #include "config.h" |
| 254 | |
Brian Paul | 2da507d | 1999-11-12 18:23:47 +0000 | [diff] [blame] | 255 | #endif /* GLHEADER_H */ |