summaryrefslogtreecommitdiff
path: root/src
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
parenta01cb26a90aaa8f631c94d741617715dff89168c (diff)
additional wrapper updates, bug 4468
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/windows/gldirect/dglwgl.h25
-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
-rw-r--r--src/mesa/math/m_debug_norm.c8
-rw-r--r--src/mesa/math/m_debug_xform.c2
-rw-r--r--src/mesa/math/m_matrix.c14
-rw-r--r--src/mesa/shader/arbprogparse.c20
-rw-r--r--src/mesa/shader/nvvertexec.c8
-rw-r--r--src/mesa/shader/slang/slang_compile.c15
-rw-r--r--src/mesa/shader/slang/slang_execute.c14
-rw-r--r--src/mesa/swrast/s_aaline.c2
-rw-r--r--src/mesa/swrast/s_fog.c12
-rw-r--r--src/mesa/swrast/s_nvfragprog.c2
-rw-r--r--src/mesa/swrast/s_texfilter.c12
-rw-r--r--src/mesa/tnl/t_vb_arbprogram.c2
-rw-r--r--src/mesa/tnl/t_vb_fog.c2
-rw-r--r--src/mesa/tnl/t_vertex_generic.c2
-rw-r--r--src/mesa/tnl/t_vp_build.c6
-rw-r--r--src/mesa/tnl/t_vtx_exec.c6
-rw-r--r--src/mesa/tnl/t_vtx_x86.c17
-rw-r--r--src/mesa/x86-64/x86-64.c4
-rw-r--r--src/mesa/x86/common_x86.c2
26 files changed, 227 insertions, 109 deletions
diff --git a/src/mesa/drivers/windows/gldirect/dglwgl.h b/src/mesa/drivers/windows/gldirect/dglwgl.h
index c488ff9e65..aac0410333 100644
--- a/src/mesa/drivers/windows/gldirect/dglwgl.h
+++ b/src/mesa/drivers/windows/gldirect/dglwgl.h
@@ -60,6 +60,31 @@ typedef struct {
char *name;
} DGL_extension;
+#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__ */
+
/*------------------------- Function Prototypes ---------------------------*/
#ifdef __cplusplus
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)
diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c
index e403998550..9bb4659815 100644
--- a/src/mesa/math/m_debug_norm.c
+++ b/src/mesa/math/m_debug_norm.c
@@ -165,7 +165,7 @@ static void ref_norm_transform_normalize( const GLmatrix *mat,
/* Hmmm, don't know how we could test the precalculated
* length case...
*/
- scale = 1.0 / sqrt( len );
+ scale = 1.0 / SQRTF( len );
SCALE_SCALAR_3V( out[i], scale, t );
} else {
out[i][0] = out[i][1] = out[i][2] = 0;
@@ -230,7 +230,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
case VAR:
break;
default:
- abort();
+ _mesa_exit(1);
}
}
}
@@ -241,7 +241,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles )
ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
for ( j = 0 ; j < 3 ; j++ )
s[i][j] = rnd();
- length[i] = 1 / sqrt( LEN_SQUARED_3FV( s[i] ) );
+ length[i] = 1 / SQRTF( LEN_SQUARED_3FV( s[i] ) );
}
source->data = (GLfloat(*)[4]) s;
@@ -339,7 +339,7 @@ void _math_test_all_normal_transform_functions( char *description )
if ( first_time ) {
first_time = 0;
- mesa_profile = getenv( "MESA_PROFILE" );
+ mesa_profile = _mesa_getenv( "MESA_PROFILE" );
}
#ifdef RUN_DEBUG_BENCHMARK
diff --git a/src/mesa/math/m_debug_xform.c b/src/mesa/math/m_debug_xform.c
index d8250f246e..feed539eac 100644
--- a/src/mesa/math/m_debug_xform.c
+++ b/src/mesa/math/m_debug_xform.c
@@ -284,7 +284,7 @@ void _math_test_all_transform_functions( char *description )
if ( first_time ) {
first_time = 0;
- mesa_profile = getenv( "MESA_PROFILE" );
+ mesa_profile = _mesa_getenv( "MESA_PROFILE" );
}
#ifdef RUN_DEBUG_BENCHMARK
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index ff32e3d94b..b4ba1bc2a0 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -382,9 +382,9 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
/* choose pivot - or die */
- if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
- if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
- if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
+ if (FABSF(r3[0])>FABSF(r2[0])) SWAP_ROWS(r3, r2);
+ if (FABSF(r2[0])>FABSF(r1[0])) SWAP_ROWS(r2, r1);
+ if (FABSF(r1[0])>FABSF(r0[0])) SWAP_ROWS(r1, r0);
if (0.0 == r0[0]) return GL_FALSE;
/* eliminate first variable */
@@ -402,8 +402,8 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
- if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
- if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
+ if (FABSF(r3[1])>FABSF(r2[1])) SWAP_ROWS(r3, r2);
+ if (FABSF(r2[1])>FABSF(r1[1])) SWAP_ROWS(r2, r1);
if (0.0 == r1[1]) return GL_FALSE;
/* eliminate second variable */
@@ -416,7 +416,7 @@ static GLboolean invert_matrix_general( GLmatrix *mat )
s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
/* choose pivot - or die */
- if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
+ if (FABSF(r3[2])>FABSF(r2[2])) SWAP_ROWS(r3, r2);
if (0.0 == r2[2]) return GL_FALSE;
/* eliminate third variable */
@@ -1075,7 +1075,7 @@ _math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
m[2] *= x; m[6] *= y; m[10] *= z;
m[3] *= x; m[7] *= y; m[11] *= z;
- if (fabs(x - y) < 1e-8 && fabs(x - z) < 1e-8)
+ if (FABSF(x - y) < 1e-8 && FABSF(x - z) < 1e-8)
mat->flags |= MAT_FLAG_UNIFORM_SCALE;
else
mat->flags |= MAT_FLAG_GENERAL_SCALE;
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index e8992c6d8b..dba8280c27 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -3886,7 +3886,7 @@ static int extension_is_supported (const GLubyte *ext)
while (extensions < end)
{
- const GLubyte *name_end = (const GLubyte *) strchr ((const char *) extensions, ' ');
+ const GLubyte *name_end = (const GLubyte *) _mesa_strstr ((const char *) extensions, " ");
if (name_end == NULL)
name_end = end;
if (name_end - extensions == ext_len && _mesa_strncmp ((const char *) ext,
@@ -4037,7 +4037,7 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
strz[len] = '\0';
#if DEBUG_PARSING
- printf ("Checking Grammar!\n");
+ fprintf (stderr, "Checking Grammar!\n");
#endif
/* do a fast check on program string - initial production buffer is 4K */
err = grammar_fast_check (arbprogram_syn_id, strz, &parsed, &parsed_len, 0x1000);
@@ -4050,21 +4050,23 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
_mesa_error (ctx, GL_INVALID_OPERATION, "glProgramStringARB(syntax error)");
/* useful for debugging */
- if (0) {
+#if DEBUG_PARSING
+ do {
int line, col;
char *s;
- printf("Program: %s\n", (char *) strz);
- printf("Error Pos: %d\n", ctx->Program.ErrorPos);
+ fprintf(stderr, "Program: %s\n", (char *) strz);
+ fprintf(stderr, "Error Pos: %d\n", ctx->Program.ErrorPos);
s = (char *) _mesa_find_line_column(strz, strz+ctx->Program.ErrorPos, &line, &col);
- printf("line %d col %d: %s\n", line, col, s);
- }
+ fprintf(stderr, "line %d col %d: %s\n", line, col, s);
+ } while (0)
+#endif
grammar_destroy (arbprogram_syn_id);
return 1;
}
#if DEBUG_PARSING
- printf ("Destroying grammer dict [parse retval: %d]\n", err);
+ fprintf (stderr, "Destroying grammer dict [parse retval: %d]\n", err);
#endif
grammar_destroy (arbprogram_syn_id);
@@ -4120,7 +4122,7 @@ _mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
_mesa_free (parsed);
#if DEBUG_PARSING
- printf ("_mesa_parse_arb_program() done\n");
+ fprintf (stderr, "_mesa_parse_arb_program() done\n");
#endif
return err;
}
diff --git a/src/mesa/shader/nvvertexec.c b/src/mesa/shader/nvvertexec.c
index 725e3ec9cd..f99c4dfac1 100644
--- a/src/mesa/shader/nvvertexec.c
+++ b/src/mesa/shader/nvvertexec.c
@@ -452,7 +452,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{
GLfloat t[4], q[4], floor_t0;
fetch_vector1( &inst->SrcReg[0], state, t );
- floor_t0 = (float) floor(t[0]);
+ floor_t0 = FLOORF(t[0]);
if (floor_t0 > FLT_MAX_EXP) {
SET_POS_INFINITY(q[0]);
SET_POS_INFINITY(q[2]);
@@ -481,7 +481,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{
GLfloat t[4], q[4], abs_t0;
fetch_vector1( &inst->SrcReg[0], state, t );
- abs_t0 = (GLfloat) fabs(t[0]);
+ abs_t0 = FABSF(t[0]);
if (abs_t0 != 0.0F) {
/* Since we really can't handle infinite values on VMS
* like other OSes we'll use __MAXFLOAT to represent
@@ -499,7 +499,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
}
else {
int exponent;
- double mantissa = frexp(t[0], &exponent);
+ GLfloat mantissa = FREXPF(t[0], &exponent);
q[0] = (GLfloat) (exponent - 1);
q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */
q[2] = (GLfloat) (q[0] + LOG2(q[1]));
@@ -635,7 +635,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
{
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
- state->AddressReg[0] = (GLint) floor(t[0]);
+ state->AddressReg[0] = (GLint) FLOORF(t[0]);
}
break;
case VP_OPCODE_DPH:
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index 0ff450ca91..688eac33c7 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -635,7 +635,7 @@ int slang_info_log_error (slang_info_log *log, const char *msg, ...)
char buf[1024];
va_start (va, msg);
- _mesa_sprintf (buf, msg, va);
+ _mesa_vsprintf (buf, msg, va);
if (slang_info_log_message (log, "error", buf))
return 1;
slang_info_log_memory (log);
@@ -649,7 +649,7 @@ int slang_info_log_warning (slang_info_log *log, const char *msg, ...)
char buf[1024];
va_start (va, msg);
- _mesa_sprintf (buf, msg, va);
+ _mesa_vsprintf (buf, msg, va);
if (slang_info_log_message (log, "warning", buf))
return 1;
slang_info_log_memory (log);
@@ -685,7 +685,7 @@ static int parse_identifier (slang_parse_ctx *C, char **id)
slang_info_log_memory (C->L);
return 0;
}
- C->I += strlen ((const char *) C->I) + 1;
+ C->I += _mesa_strlen ((const char *) C->I) + 1;
return 1;
}
@@ -734,8 +734,9 @@ static int parse_float (slang_parse_ctx *C, float *number)
return 0;
}
- whole = (char *) (slang_alloc_malloc ((strlen (integral) + strlen (fractional) + strlen (
- exponent) + 3) * sizeof (char)));
+ whole = (char *) (slang_alloc_malloc ((_mesa_strlen (integral) +
+ _mesa_strlen (fractional) + _mesa_strlen (exponent) + 3) *
+ sizeof (char)));
if (whole == NULL)
{
slang_alloc_free (exponent);
@@ -751,7 +752,7 @@ static int parse_float (slang_parse_ctx *C, float *number)
slang_string_concat (whole, "E");
slang_string_concat (whole, exponent);
- *number = (float) (atof (whole));
+ *number = (float) (_mesa_strtod(whole, (char **)NULL));
slang_alloc_free (whole);
slang_alloc_free (exponent);
@@ -2115,7 +2116,7 @@ if (slang_string_compare ("main", (**parsed_func_ret).header.name) == 0)
xxx_prolog (&file, (**parsed_func_ret).address);
_slang_execute (&file);
slang_assembly_file_destruct (&file);
-exit (0);
+_mesa_exit (0);
}
}
return 1;
diff --git a/src/mesa/shader/slang/slang_execute.c b/src/mesa/shader/slang/slang_execute.c
index 78a638b444..5b1d6d3940 100644
--- a/src/mesa/shader/slang/slang_execute.c
+++ b/src/mesa/shader/slang/slang_execute.c
@@ -34,6 +34,9 @@
#include "slang_storage.h"
#include "slang_execute.h"
+#define DEBUG_SLANG
+
+#ifdef DEBUG_SLANG
static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i)
{
fprintf (f, "%.5u:\t", i);
@@ -179,11 +182,14 @@ static void dump (const slang_assembly_file *file)
fclose (f);
}
+#endif
int _slang_execute (const slang_assembly_file *file)
{
slang_machine mach;
+#ifdef DEBUG_SLANG
FILE *f;
+#endif
mach.ip = 0;
mach.sp = SLANG_MACHINE_STACK_SIZE;
@@ -200,13 +206,18 @@ int _slang_execute (const slang_assembly_file *file)
static_assert(sizeof (GLuint) == 4);
/*static_assert(sizeof (GLuint *) == 4);*/
+#ifdef DEBUG_SLANG
dump (file);
+#endif
+#ifdef DEBUG_SLANG
f = fopen ("~mesa-slang-assembly-execution.txt", "w");
+#endif
while (!mach.exit)
{
slang_assembly *a = file->code + mach.ip;
+#ifdef DEBUG_SLANG
if (f != NULL)
{
unsigned int i;
@@ -216,6 +227,7 @@ int _slang_execute (const slang_assembly_file *file)
fprintf (f, "\t%.5u\t%6f\t%u\n", i, mach.stack._float[i], mach.stack._addr[i]);
fflush (f);
}
+#endif
mach.ip++;
switch (a->type)
@@ -344,8 +356,10 @@ int _slang_execute (const slang_assembly_file *file)
}
}
+#ifdef DEBUG_SLANG
if (f != NULL)
fclose (f);
+#endif
return 0;
}
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index 39c51a50f7..b8c214f689 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -210,7 +210,7 @@ compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4],
if (rho2 == 0.0F)
return 0.0;
else
- return (GLfloat) (log(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */
+ return (GLfloat) (LOGF(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */
}
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 0af9cd8f28..e3d6274b3f 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -51,12 +51,12 @@ _swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z)
return CLAMP(f, 0.0F, 1.0F);
case GL_EXP:
d = ctx->Fog.Density;
- f = (GLfloat) exp(-d * z);
+ f = EXPF(-d * z);
f = CLAMP(f, 0.0F, 1.0F);
return f;
case GL_EXP2:
d = ctx->Fog.Density;
- f = (GLfloat) exp(-(d * d * z * z));
+ f = EXPF(-(d * d * z * z));
f = CLAMP(f, 0.0F, 1.0F);
return f;
default:
@@ -130,7 +130,7 @@ _swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span )
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f, oneMinusF;
- f = (GLfloat) exp(density * FABSF(fogCoord) / w);
+ f = EXPF(density * FABSF(fogCoord) / w);
f = CLAMP(f, 0.0F, 1.0F);
oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
@@ -158,7 +158,7 @@ _swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span )
if (tmp < FLT_MIN_10_EXP)
tmp = FLT_MIN_10_EXP;
#endif
- f = (GLfloat) exp(tmp);
+ f = EXPF(tmp);
f = CLAMP(f, 0.0F, 1.0F);
oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
@@ -259,7 +259,7 @@ _swrast_fog_ci_span( const GLcontext *ctx, struct sw_span *span )
GLfloat w = haveW ? span->w : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
- GLfloat f = (GLfloat) exp(density * fogCoord / w);
+ GLfloat f = EXPF(density * fogCoord / w);
f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep;
@@ -284,7 +284,7 @@ _swrast_fog_ci_span( const GLcontext *ctx, struct sw_span *span )
if (tmp < FLT_MIN_10_EXP)
tmp = FLT_MIN_10_EXP;
#endif
- f = (GLfloat) exp(tmp);
+ f = EXPF(tmp);
f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep;
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 931bf64f92..1e18120152 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -821,7 +821,7 @@ execute_program( GLcontext *ctx,
result[0] = 1.0F;
result[1] = a[0];
/* XXX we could probably just use pow() here */
- result[2] = (a[0] > 0.0F) ? (GLfloat) exp(a[3] * log(a[1])) : 0.0F;
+ result[2] = (a[0] > 0.0F) ? EXPF(a[3] * LOGF(a[1])) : 0.0F;
result[3] = 1.0F;
store_vector4( inst, machine, result );
}
diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index 59673bb978..0597947f51 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -297,7 +297,7 @@ repeat_remainder(GLint a, GLint b)
} \
break; \
case GL_MIRROR_CLAMP_EXT: \
- U = (GLfloat) fabs(S); \
+ U = FABSF(S); \
if (U >= 1.0F) \
U = (GLfloat) SIZE; \
else \
@@ -307,7 +307,7 @@ repeat_remainder(GLint a, GLint b)
I1 = I0 + 1; \
break; \
case GL_MIRROR_CLAMP_TO_EDGE_EXT: \
- U = (GLfloat) fabs(S); \
+ U = FABSF(S); \
if (U >= 1.0F) \
U = (GLfloat) SIZE; \
else \
@@ -324,7 +324,7 @@ repeat_remainder(GLint a, GLint b)
{ \
const GLfloat min = -1.0F / (2.0F * SIZE); \
const GLfloat max = 1.0F - min; \
- U = (GLfloat) fabs(S); \
+ U = FABSF(S); \
if (U <= min) \
U = min * SIZE; \
else if (U >= max) \
@@ -418,7 +418,7 @@ repeat_remainder(GLint a, GLint b)
{ \
/* s limited to [0,1] */ \
/* i limited to [0,size-1] */ \
- const GLfloat u = (GLfloat) fabs(S); \
+ const GLfloat u = FABSF(S); \
if (u <= 0.0F) \
I = 0; \
else if (u >= 1.0F) \
@@ -433,7 +433,7 @@ repeat_remainder(GLint a, GLint b)
/* i limited to [0, size-1] */ \
const GLfloat min = 1.0F / (2.0F * SIZE); \
const GLfloat max = 1.0F - min; \
- const GLfloat u = (GLfloat) fabs(S); \
+ const GLfloat u = FABSF(S); \
if (u < min) \
I = 0; \
else if (u > max) \
@@ -448,7 +448,7 @@ repeat_remainder(GLint a, GLint b)
/* i limited to [0, size-1] */ \
const GLfloat min = -1.0F / (2.0F * SIZE); \
const GLfloat max = 1.0F - min; \
- const GLfloat u = (GLfloat) fabs(S); \
+ const GLfloat u = FABSF(S); \
if (u < min) \
I = -1; \
else if (u > max) \
diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c
index 9fc49a2cee..08b9ffc889 100644
--- a/src/mesa/tnl/t_vb_arbprogram.c
+++ b/src/mesa/tnl/t_vb_arbprogram.c
@@ -97,7 +97,7 @@ static GLfloat RoughApproxPower(GLfloat x, GLfloat y)
*/
static GLfloat ApproxLog2(GLfloat t)
{
- return (GLfloat) (log(t) * 1.442695F);
+ return (GLfloat) (LOGF(t) * 1.442695F);
}
static GLfloat ApproxExp2(GLfloat t)
diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
index 91c3591f5b..ddf849a658 100644
--- a/src/mesa/tnl/t_vb_fog.c
+++ b/src/mesa/tnl/t_vb_fog.c
@@ -80,7 +80,7 @@ init_static_data( void )
GLfloat f = 0.0F;
GLint i = 0;
for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
- exp_table[i] = (GLfloat) exp(-f);
+ exp_table[i] = EXPF(-f);
}
inited = 1;
}
diff --git a/src/mesa/tnl/t_vertex_generic.c b/src/mesa/tnl/t_vertex_generic.c
index 3f94458053..236a5bedc8 100644
--- a/src/mesa/tnl/t_vertex_generic.c
+++ b/src/mesa/tnl/t_vertex_generic.c
@@ -203,7 +203,7 @@ static INLINE void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte
static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
{
(void) a; (void) v; (void) in;
- abort();
+ _mesa_exit(1);
}
static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
index 3e77758edb..68bd7b7a9a 100644
--- a/src/mesa/tnl/t_vp_build.c
+++ b/src/mesa/tnl/t_vp_build.c
@@ -326,10 +326,10 @@ static struct ureg swizzle1( struct ureg reg, int x )
static struct ureg get_temp( struct tnl_program *p )
{
- int bit = ffs( ~p->temp_in_use );
+ int bit = _mesa_ffs( ~p->temp_in_use );
if (!bit) {
- fprintf(stderr, "%s: out of temporaries\n", __FILE__);
- exit(1);
+ _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
+ _mesa_exit(1);
}
p->temp_in_use |= 1<<(bit-1);
diff --git a/src/mesa/tnl/t_vtx_exec.c b/src/mesa/tnl/t_vtx_exec.c
index ef609781c5..b296e439d2 100644
--- a/src/mesa/tnl/t_vtx_exec.c
+++ b/src/mesa/tnl/t_vtx_exec.c
@@ -113,8 +113,12 @@ static void _tnl_vb_bind_vtx( GLcontext *ctx )
GLuint count = tnl->vtx.initial_counter - tnl->vtx.counter;
GLuint attr, i;
- if (0) fprintf(stderr, "_tnl_vb_bind_vtx(): %d verts %d vertsize\n",
+#undef DEBUG_VTX
+
+#ifdef DEBUG_VTX
+ fprintf(stderr, "_tnl_vb_bind_vtx(): %d verts %d vertsize\n",
count, tnl->vtx.vertex_size);
+#endif
/* Setup constant data in the VB.
diff --git a/src/mesa/tnl/t_vtx_x86.c b/src/mesa/tnl/t_vtx_x86.c
index 1812cfa471..99a0550932 100644
--- a/src/mesa/tnl/t_vtx_x86.c
+++ b/src/mesa/tnl/t_vtx_x86.c
@@ -44,7 +44,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "t_vtx_api.h"
#include "simple_list.h"
-
#if defined(USE_X86_ASM) && !defined(HAVE_NONSTANDARD_GLAPIENTRY)
#define EXTERN( FUNC ) \
@@ -94,6 +93,18 @@ EXTERN( _tnl_x86_choose_fv );
+#undef DEBUG_VTX
+
+#ifdef DEBUG_VTX
+#define FIXUP_PRINTF( offset, NEWVAL ) \
+ fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL))
+#define FIXUPREL_PRINTF( offset, NEWVAL, CODE ) \
+ fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL) - ((int)(CODE)+offset) - 4)
+#else
+#define FIXUP_PRINTF( offset, NEWVAL )
+#define FIXUPREL_PRINTF( offset, NEWVAL, CODE )
+#endif
+
#define FIXUP( CODE, KNOWN_OFFSET, CHECKVAL, NEWVAL ) \
do { \
GLint subst = 0x10101010 + CHECKVAL; \
@@ -101,7 +112,7 @@ do { \
if (DONT_KNOW_OFFSETS) { \
while (*(int *)(CODE+offset) != subst) offset++; \
*(int *)(CODE+offset) = (int)(NEWVAL); \
- if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL)); \
+ FIXUP_PRINTF(offset, NEWVAL); \
offset += 4; \
} \
else { \
@@ -120,7 +131,7 @@ do { \
if (DONT_KNOW_OFFSETS) { \
while (*(int *)(CODE+offset) != subst) offset++; \
*(int *)(CODE+offset) = (int)(NEWVAL) - ((int)(CODE)+offset) - 4; \
- if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL) - ((int)(CODE)+offset) - 4); \
+ FIXUPREL_PRINTF(offset, NEWVAL, CODE); \
offset += 4; \
} \
else { \
diff --git a/src/mesa/x86-64/x86-64.c b/src/mesa/x86-64/x86-64.c
index e70bc66274..21d978b06e 100644
--- a/src/mesa/x86-64/x86-64.c
+++ b/src/mesa/x86-64/x86-64.c
@@ -1,4 +1,4 @@
-/* $Id: x86-64.c,v 1.1 2005/05/07 16:59:59 brianp Exp $ */
+/* $Id: x86-64.c,v 1.2 2005/09/19 20:12:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -70,7 +70,7 @@ static void message( const char *msg )
}
#endif
if ( debug ) {
- fprintf( stderr, "%s", msg );
+ _mesa_debug( NULL, "%s", msg );
}
}
#endif
diff --git a/src/mesa/x86/common_x86.c b/src/mesa/x86/common_x86.c
index 0ff7fd51a6..eece7c1c84 100644
--- a/src/mesa/x86/common_x86.c
+++ b/src/mesa/x86/common_x86.c
@@ -71,7 +71,7 @@ static void message( const char *msg )
}
#endif
if ( debug ) {
- fprintf( stderr, "%s", msg );
+ _mesa_debug( NULL, "%s", msg );
}
}