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