blob: c6f81fdd7e665e3a1c97a33e33a4e61c66ef160e [file] [log] [blame]
Keith Whitwell6dc85572003-07-17 13:43:59 +00001/**
2 * \file glheader.h
3 * Top-most include file.
Kendall Bennettb29b8ca2003-09-12 22:01:01 +00004 *
Keith Whitwell6dc85572003-07-17 13:43:59 +00005 * 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 Sapountzisb7666432006-12-06 06:40:18 +02008 * headers. This allows system-dependent hacks/workarounds to be
9 * collected in one place.
Keith Whitwell6dc85572003-07-17 13:43:59 +000010 *
11 * \note Actually, a lot of system-dependent stuff is now in imports.[ch].
Kendall Bennettb29b8ca2003-09-12 22:01:01 +000012 *
Keith Whitwell6dc85572003-07-17 13:43:59 +000013 * 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 Paulfbd8f211999-11-11 01:22:25 +000020
21/*
22 * Mesa 3-D graphics library
Brian Paul49b2d2e2005-11-27 23:46:55 +000023 * Version: 6.5
Brian Paulfbd8f211999-11-11 01:22:25 +000024 *
Brian Paul914746b2005-01-26 14:45:38 +000025 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
Brian Paulfbd8f211999-11-11 01:22:25 +000026 *
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 Paulfbd8f211999-11-11 01:22:25 +000049#include <assert.h>
50#include <ctype.h>
Brian Paulf7a4bca2000-09-15 15:42:45 +000051#if defined(__alpha__) && defined(CCPML)
George Sapountzisb7666432006-12-06 06:40:18 +020052#include <cpml.h> /* use Compaq's Fast Math Library on Alpha */
Brian Paulf7a4bca2000-09-15 15:42:45 +000053#else
Brian Paulfbd8f211999-11-11 01:22:25 +000054#include <math.h>
Brian Paulf7a4bca2000-09-15 15:42:45 +000055#endif
Brian Paulfbd8f211999-11-11 01:22:25 +000056#include <limits.h>
57#include <stdlib.h>
58#include <stdio.h>
59#include <string.h>
Gareth Hughes22144ab2001-03-12 00:48:37 +000060#if defined(__linux__) && defined(__i386__)
Brian Paul780c4e02000-03-22 23:20:12 +000061#include <fpu_control.h>
62#endif
Brian Paule39ed582000-02-12 15:55:34 +000063#include <float.h>
Brian Paul4753d602002-06-15 02:38:15 +000064#include <stdarg.h>
Brian Paule39ed582000-02-12 15:55:34 +000065
Brian Paulfbd8f211999-11-11 01:22:25 +000066
Karl Schultz6258b762005-05-05 21:08:07 +000067/* Get typedefs for uintptr_t and friends */
Brian Paul49b2d2e2005-11-27 23:46:55 +000068#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 Schultz6258b762005-05-05 21:08:07 +000075#else
Brian Paul49b2d2e2005-11-27 23:46:55 +000076# include <inttypes.h>
Karl Schultz6258b762005-05-05 21:08:07 +000077#endif
78
Kendall Bennett2cdd6992003-10-08 01:53:30 +000079#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
Brian Paul936028f2004-11-25 23:22:56 +000080# define __WIN32__
81# define finite _finite
Brian Paul87a78972000-05-22 16:30:47 +000082#endif
83
Kendall Bennett2cdd6992003-10-08 01:53:30 +000084#if defined(__WATCOMC__)
Brian Paul936028f2004-11-25 23:22:56 +000085# define finite _finite
86# pragma disable_message(201) /* Disable unreachable code warnings */
Kendall Bennett2cdd6992003-10-08 01:53:30 +000087#endif
88
zhang37aca212007-06-28 08:12:52 -060089#ifdef WGLAPI
Zhang76fb8082007-07-21 11:28:06 -060090# undef WGLAPI
zhang37aca212007-06-28 08:12:52 -060091#endif
Brian Paul936028f2004-11-25 23:22:56 +000092
Kendall Bennett2cdd6992003-10-08 01:53:30 +000093#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
Brian Paul86e001b2004-08-25 14:59:45 +000094# 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 Paul87a78972000-05-22 16:30:47 +0000106# endif
Brian Paul83889ff2004-11-08 15:08:48 +0000107# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
Brian Paul87a78972000-05-22 16:30:47 +0000108# define WGLAPI __declspec(dllexport)
Brian Paul83889ff2004-11-08 15:08:48 +0000109# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
Brian Paul87a78972000-05-22 16:30:47 +0000110# define WGLAPI __declspec(dllimport)
111# else /* for use with static link lib build of Win32 edition only */
Brian Paul87a78972000-05-22 16:30:47 +0000112# define WGLAPI __declspec(dllimport)
113# endif /* _STATIC_MESA support */
Brian Pauldf544632000-05-22 19:41:34 +0000114#endif /* WIN32 / CYGWIN bracket */
Brian Paul87a78972000-05-22 16:30:47 +0000115
Brian Paul87a78972000-05-22 16:30:47 +0000116
Brian Paul1013e462002-06-12 00:52:50 +0000117/*
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 Paul936028f2004-11-25 23:22:56 +0000138#define GL_GLEXT_PROTOTYPES
Brian Paul1e016322000-05-26 15:52:06 +0000139#include "GL/gl.h"
140#include "GL/glext.h"
141
142
Brian Paul936028f2004-11-25 23:22:56 +0000143#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
Brian Paula1503b02001-07-16 15:54:23 +0000144#define CAPI _cdecl
Brian Paula1503b02001-07-16 15:54:23 +0000145#endif
Brian Paulb1394fa2000-09-26 20:53:53 +0000146
147
Brian Paul936028f2004-11-25 23:22:56 +0000148/* This is a macro on IRIX */
149#ifdef _P
150#undef _P
Kendall Bennettbe599f81999-11-12 16:46:56 +0000151#endif
152
Brian Paulfbd8f211999-11-11 01:22:25 +0000153
Brian Paul2da507d1999-11-12 18:23:47 +0000154/* Turn off macro checking systems used by other libraries */
155#ifdef CHECK
156#undef CHECK
Brian Paulfbd8f211999-11-11 01:22:25 +0000157#endif
Brian Paul2da507d1999-11-12 18:23:47 +0000158
159
160/* Create a macro so that asm functions can be linked into compilers other
161 * than GNU C
162 */
163#ifndef _ASMAPI
Brian Paul5e83c2a2004-01-28 22:01:47 +0000164#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
Brian Paul2da507d1999-11-12 18:23:47 +0000165#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 Paul0ab16e02001-05-14 23:11:12 +0000185/* Function inlining */
186#if defined(__GNUC__)
187# define INLINE __inline__
188#elif defined(__MSC__)
189# define INLINE __inline
Brian Paula1503b02001-07-16 15:54:23 +0000190#elif defined(_MSC_VER)
191# define INLINE __inline
192#elif defined(__ICL)
193# define INLINE __inline
Eric Anholt527078a2003-12-09 23:59:16 +0000194#elif defined(__INTEL_COMPILER)
195# define INLINE inline
Kendall Bennettb29b8ca2003-09-12 22:01:01 +0000196#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
197# define INLINE __inline
Brian Paul0ab16e02001-05-14 23:11:12 +0000198#else
199# define INLINE
200#endif
201
202
Brian Paul936028f2004-11-25 23:22:56 +0000203/* 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 Jackson489ccef2004-12-15 17:18:06 +0000205 *
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 Paul936028f2004-11-25 23:22:56 +0000208 */
209#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
210# define PUBLIC __attribute__((visibility("default")))
Adam Jackson489ccef2004-12-15 17:18:06 +0000211# define USED __attribute__((used))
Brian Paul936028f2004-11-25 23:22:56 +0000212#else
213# define PUBLIC
Adam Jackson489ccef2004-12-15 17:18:06 +0000214# define USED
Brian Paul936028f2004-11-25 23:22:56 +0000215#endif
216
217
Brian Paul0ab16e02001-05-14 23:11:12 +0000218/* 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 Bennett2cdd6992003-10-08 01:53:30 +0000226#if defined(BUILD_FOR_SNAP) && defined(CHECKED)
Kendall Bennettadbbea92003-10-02 23:50:44 +0000227# define ASSERT(X) _CHECK(X)
228#elif defined(DEBUG)
Brian Paul0ab16e02001-05-14 23:11:12 +0000229# define ASSERT(X) assert(X)
230#else
231# define ASSERT(X)
232#endif
233
234
Brian882e0e02008-03-09 10:55:01 -0600235#if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900)
Brian Paul936028f2004-11-25 23:22:56 +0000236# define __builtin_expect(x, y) x
Ian Romanick8e77da12004-06-29 19:08:20 +0000237#endif
238
Brian Paul38332a62005-06-19 14:57:34 +0000239/* 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 Schultzeac76882005-07-01 20:11:46 +0000241 * Don't define it if using a newer Windows compiler.
Brian Paul38332a62005-06-19 14:57:34 +0000242 */
243#if defined(__VMS)
Brian Paula186c802006-04-13 01:52:32 +0000244# 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 Paul38332a62005-06-19 14:57:34 +0000250#endif
251
252
Keith Whitwell6dc85572003-07-17 13:43:59 +0000253#include "config.h"
254
Brian Paul2da507d1999-11-12 18:23:47 +0000255#endif /* GLHEADER_H */