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