summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-09-19 20:12:32 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-09-19 20:12:32 +0000
commitb3aefd1cfb6aacd1695c52911dd39da50d893ece (patch)
tree247125551b41cc22dec6f1f03bb1d6709c804bba /src/mesa/main
parenta01cb26a90aaa8f631c94d741617715dff89168c (diff)
additional wrapper updates, bug 4468
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/enums.c4
-rw-r--r--src/mesa/main/glheader.h41
-rw-r--r--src/mesa/main/imports.c81
-rw-r--r--src/mesa/main/imports.h22
-rw-r--r--src/mesa/main/mtypes.h1
-rw-r--r--src/mesa/main/texenvprogram.c12
6 files changed, 111 insertions, 50 deletions
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index 837618cd74..08522cdf7b 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -4542,7 +4542,7 @@ const char *_mesa_lookup_enum_by_nr( int nr )
{
unsigned * i;
- i = (unsigned *)bsearch( & nr, reduced_enums, Elements(reduced_enums),
+ i = (unsigned *)_mesa_bsearch( & nr, reduced_enums, Elements(reduced_enums),
sizeof(reduced_enums[0]), (cfunc) compar_nr );
if ( i != NULL ) {
@@ -4560,7 +4560,7 @@ int _mesa_lookup_enum_by_name( const char *symbol )
enum_elt * f = NULL;
if ( symbol != NULL ) {
- f = (enum_elt *)bsearch( symbol, all_enums, Elements(all_enums),
+ f = (enum_elt *)_mesa_bsearch( symbol, all_enums, Elements(all_enums),
sizeof( enum_elt ), (cfunc) compar_name );
}
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index ee34076fb7..4c75585c4d 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -118,32 +118,6 @@ typedef UINT_PTR uintptr_t;
#endif /* WIN32 / CYGWIN bracket */
-#ifndef __MINGW32__
-/* XXX why is this here?
- * It should probaby be somewhere in src/mesa/drivers/windows/
- */
-#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(BUILD_FOR_SNAP)
-# define WGL_FONT_LINES 0
-# define WGL_FONT_POLYGONS 1
-#ifndef _GNU_H_WINDOWS32_FUNCTIONS
-# ifdef UNICODE
-# define wglUseFontBitmaps wglUseFontBitmapsW
-# define wglUseFontOutlines wglUseFontOutlinesW
-# else
-# define wglUseFontBitmaps wglUseFontBitmapsA
-# define wglUseFontOutlines wglUseFontOutlinesA
-# endif /* !UNICODE */
-#endif /* _GNU_H_WINDOWS32_FUNCTIONS */
-typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
-typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
-typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
-#if !defined(GLX_USE_MESA)
-#include <GL/mesa_wgl.h>
-#endif
-#endif
-#endif /* !__MINGW32__ */
-
-
/*
* Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
* Do not use them unless absolutely necessary!
@@ -173,7 +147,6 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
#define CAPI _cdecl
#endif
-#include <GL/internal/glcore.h>
/* This is a macro on IRIX */
@@ -267,20 +240,6 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC
# define __builtin_expect(x, y) x
#endif
-/* Windows does not have the ffs() function */
-#if defined(_WIN32) && !defined(__MINGW32__)
-int INLINE ffs(int value)
-{
- int bit;
- if (value == 0)
- return 0;
- for (bit=1; !(value & 1); bit++)
- value >>= 1;
- return bit;
-}
-#endif
-
-
/* The __FUNCTION__ gcc variable is generally only used for debugging.
* If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
* Don't define it if using a newer Windows compiler.
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 8d39f77b41..f7d9de3669 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -23,7 +23,6 @@
* \todo Functions still needed:
* - scanf
* - qsort
- * - bsearch
* - rand and RAND_MAX
*
* \note When compiled into a XFree86 module these functions wrap around
@@ -529,6 +528,34 @@ _mesa_pow(double x, double y)
}
+/* Windows does not have the ffs() function */
+#if defined(_WIN32) && !defined(__MINGW32__)
+int INLINE ffs(int value)
+{
+ int bit;
+ if (value == 0)
+ return 0;
+ for (bit=1; !(value & 1); bit++)
+ value >>= 1;
+ return bit;
+}
+#endif
+
+
+/**
+ * Wrapper around either ffs() or xf86ffs().
+ */
+int
+_mesa_ffs(int i)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86ffs(i);
+#else
+ return ffs(i);
+#endif
+}
+
+
/**
* Return number of bits set in given GLuint.
*/
@@ -685,6 +712,27 @@ _mesa_half_to_float(GLhalfARB val)
/**********************************************************************/
+/** \name Sort & Search */
+/*@{*/
+
+/**
+ * Wrapper for bsearch().
+ */
+void *
+_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *) )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86bsearch(key, base, nmemb, size, compar);
+#else
+ return bsearch(key, base, nmemb, size, compar);
+#endif
+}
+
+/*@}*/
+
+
+/**********************************************************************/
/** \name Environment vars */
/*@{*/
@@ -860,6 +908,17 @@ _mesa_printf( const char *fmtString, ... )
#endif
}
+/** Wrapper around either vsprintf() or xf86vsprintf() */
+int
+_mesa_vsprintf( char *str, const char *fmt, va_list args )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86vsprintf( str, fmt, args );
+#else
+ return vsprintf( str, fmt, args );
+#endif
+}
+
/*@}*/
@@ -1036,6 +1095,26 @@ _mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
/**********************************************************************/
+/** \name Exit */
+/*@{*/
+
+/**
+ * Wrapper for exit().
+ */
+void
+_mesa_exit( int status )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ xf86exit(status);
+#else
+ exit(status);
+#endif
+}
+
+/*@}*/
+
+
+/**********************************************************************/
/** \name Default Imports Wrapper */
/*@{*/
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 134eff84b3..c02be4382a 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -39,6 +39,7 @@
/* XXX some of the stuff in glheader.h should be moved into this file.
*/
#include "glheader.h"
+#include <GL/internal/glcore.h>
#ifdef __cplusplus
@@ -274,6 +275,8 @@ static INLINE int GET_FLOAT_BITS( float x )
*** CEILF: ceiling of float
*** FLOORF: floor of float
*** FABSF: absolute value of float
+ *** LOGF: the natural logarithm (base e) of the value
+ *** EXPF: raise e to the value
*** LDEXPF: multiply value by an integral power of two
*** FREXPF: extract mantissa and exponent from value
***/
@@ -281,6 +284,8 @@ static INLINE int GET_FLOAT_BITS( float x )
#define CEILF(x) ((GLfloat) xf86ceil(x))
#define FLOORF(x) ((GLfloat) xf86floor(x))
#define FABSF(x) ((GLfloat) xf86fabs(x))
+#define LOGF(x) ((GLfloat) xf86log(x))
+#define EXPF(x) ((GLfloat) xf86exp(x))
#define LDEXPF(x,y) ((GLfloat) xf86ldexp(x,y))
#define FREXPF(x,y) ((GLfloat) xf86frexp(x,y))
#elif defined(__gnu_linux__)
@@ -288,12 +293,16 @@ static INLINE int GET_FLOAT_BITS( float x )
#define CEILF(x) ceilf(x)
#define FLOORF(x) floorf(x)
#define FABSF(x) fabsf(x)
+#define LOGF(x) logf(x)
+#define EXPF(x) expf(x)
#define LDEXPF(x,y) ldexpf(x,y)
#define FREXPF(x,y) frexpf(x,y)
#else
#define CEILF(x) ((GLfloat) ceil(x))
#define FLOORF(x) ((GLfloat) floor(x))
#define FABSF(x) ((GLfloat) fabs(x))
+#define LOGF(x) ((GLfloat) log(x))
+#define EXPF(x) ((GLfloat) exp(x))
#define LDEXPF(x,y) ((GLfloat) ldexp(x,y))
#define FREXPF(x,y) ((GLfloat) frexp(x,y))
#endif
@@ -637,6 +646,9 @@ _mesa_pow(double x, double y);
extern float
_mesa_log2(float x);
+extern int
+_mesa_ffs(int i);
+
extern unsigned int
_mesa_bitcount(unsigned int n);
@@ -647,6 +659,10 @@ extern float
_mesa_half_to_float(GLhalfARB h);
+extern void *
+_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
+ int (*compar)(const void *, const void *) );
+
extern char *
_mesa_getenv( const char *var );
@@ -686,6 +702,9 @@ _mesa_sprintf( char *str, const char *fmt, ... );
extern void
_mesa_printf( const char *fmtString, ... );
+extern int
+_mesa_vsprintf( char *str, const char *fmt, va_list args );
+
extern void
_mesa_warning( __GLcontext *gc, const char *fmtString, ... );
@@ -699,6 +718,9 @@ _mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
extern void
_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
+extern void
+_mesa_exit( int status );
+
extern void
_mesa_init_default_imports( __GLimports *imports, void *driverCtx );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8817205dec..0c3a63d2e3 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -36,6 +36,7 @@
#include "glheader.h"
+#include <GL/internal/glcore.h> /* GLimports/GLexports/GLcontextModes */
#include "config.h" /* Hardwired parameters */
#include "glapitable.h"
#include "glthread.h"
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 2ffb1774a3..6f9fe2dc45 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -350,16 +350,16 @@ static struct ureg get_temp( struct texenv_fragment_program *p )
/* First try and reuse temps which have been used already:
*/
- bit = ffs( ~p->temp_in_use & p->alu_temps );
+ bit = _mesa_ffs( ~p->temp_in_use & p->alu_temps );
/* Then any unused temporary:
*/
if (!bit)
- bit = ffs( ~p->temp_in_use );
+ bit = _mesa_ffs( ~p->temp_in_use );
if (!bit) {
_mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
- exit(1);
+ _mesa_exit(1);
}
if (bit > p->program->Base.NumTemporaries)
@@ -378,16 +378,16 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p )
* ~p->temps_output isn't necessary, but will keep it there for
* now:
*/
- bit = ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output );
+ bit = _mesa_ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output );
/* Then any unused temporary:
*/
if (!bit)
- bit = ffs( ~p->temp_in_use );
+ bit = _mesa_ffs( ~p->temp_in_use );
if (!bit) {
_mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
- exit(1);
+ _mesa_exit(1);
}
if (bit > p->program->Base.NumTemporaries)