Index: src/mesa/drivers/windows/gldirect/dglwgl.h =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/windows/gldirect/dglwgl.h,v retrieving revision 1.1 diff -u -r1.1 dglwgl.h --- src/mesa/drivers/windows/gldirect/dglwgl.h 20 Apr 2004 11:13:11 -0000 1.1 +++ src/mesa/drivers/windows/gldirect/dglwgl.h 18 Sep 2005 15:34:28 -0000 @@ -60,6 +60,31 @@ 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 +#endif +#endif +#endif /* !__MINGW32__ */ + /*------------------------- Function Prototypes ---------------------------*/ #ifdef __cplusplus Index: src/mesa/main/enums.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/main/enums.c,v retrieving revision 1.40 diff -u -r1.40 enums.c --- src/mesa/main/enums.c 26 Aug 2005 17:50:39 -0000 1.40 +++ src/mesa/main/enums.c 18 Sep 2005 15:35:01 -0000 @@ -4542,7 +4542,7 @@ { 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 @@ 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 ); } Index: src/mesa/main/glheader.h =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/main/glheader.h,v retrieving revision 1.64 diff -u -r1.64 glheader.h --- src/mesa/main/glheader.h 16 Jul 2005 00:56:20 -0000 1.64 +++ src/mesa/main/glheader.h 18 Sep 2005 15:35:02 -0000 @@ -118,32 +118,6 @@ #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 -#endif -#endif -#endif /* !__MINGW32__ */ - - /* * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN. * Do not use them unless absolutely necessary! @@ -173,7 +147,6 @@ #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP) #define CAPI _cdecl #endif -#include /* This is a macro on IRIX */ @@ -267,20 +240,6 @@ # 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. Index: src/mesa/main/imports.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/main/imports.c,v retrieving revision 1.51 diff -u -r1.51 imports.c --- src/mesa/main/imports.c 16 Sep 2005 18:14:24 -0000 1.51 +++ src/mesa/main/imports.c 18 Sep 2005 15:35:05 -0000 @@ -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 @@ } +/* 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 @@ /**********************************************************************/ +/** \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 @@ #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 @@ /**********************************************************************/ +/** \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 */ /*@{*/ Index: src/mesa/main/imports.h =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/main/imports.h,v retrieving revision 1.56 diff -u -r1.56 imports.h --- src/mesa/main/imports.h 16 Sep 2005 18:14:24 -0000 1.56 +++ src/mesa/main/imports.h 18 Sep 2005 15:35:07 -0000 @@ -39,6 +39,7 @@ /* XXX some of the stuff in glheader.h should be moved into this file. */ #include "glheader.h" +#include #ifdef __cplusplus @@ -274,6 +275,8 @@ *** 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 @@ #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 @@ #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 @@ extern float _mesa_log2(float x); +extern int +_mesa_ffs(int i); + extern unsigned int _mesa_bitcount(unsigned int n); @@ -647,6 +659,10 @@ _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 @@ 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 @@ 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 ); Index: src/mesa/main/mtypes.h =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/main/mtypes.h,v retrieving revision 1.226 diff -u -r1.226 mtypes.h --- src/mesa/main/mtypes.h 15 Sep 2005 05:00:45 -0000 1.226 +++ src/mesa/main/mtypes.h 18 Sep 2005 15:35:17 -0000 @@ -36,6 +36,7 @@ #include "glheader.h" +#include /* GLimports/GLexports/GLcontextModes */ #include "config.h" /* Hardwired parameters */ #include "glapitable.h" #include "glthread.h" Index: src/mesa/main/texenvprogram.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/main/texenvprogram.c,v retrieving revision 1.23 diff -u -r1.23 texenvprogram.c --- src/mesa/main/texenvprogram.c 16 Sep 2005 18:14:24 -0000 1.23 +++ src/mesa/main/texenvprogram.c 18 Sep 2005 15:35:20 -0000 @@ -350,16 +350,16 @@ /* 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 @@ * ~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) Index: src/mesa/math/m_debug_norm.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/math/m_debug_norm.c,v retrieving revision 1.15 diff -u -r1.15 m_debug_norm.c --- src/mesa/math/m_debug_norm.c 26 Apr 2004 10:10:24 -0000 1.15 +++ src/mesa/math/m_debug_norm.c 18 Sep 2005 15:35:21 -0000 @@ -165,7 +165,7 @@ /* 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 @@ case VAR: break; default: - abort(); + _mesa_exit(1); } } } @@ -241,7 +241,7 @@ 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 @@ if ( first_time ) { first_time = 0; - mesa_profile = getenv( "MESA_PROFILE" ); + mesa_profile = _mesa_getenv( "MESA_PROFILE" ); } #ifdef RUN_DEBUG_BENCHMARK Index: src/mesa/math/m_debug_xform.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/math/m_debug_xform.c,v retrieving revision 1.17 diff -u -r1.17 m_debug_xform.c --- src/mesa/math/m_debug_xform.c 7 May 2005 16:59:58 -0000 1.17 +++ src/mesa/math/m_debug_xform.c 18 Sep 2005 15:35:21 -0000 @@ -284,7 +284,7 @@ if ( first_time ) { first_time = 0; - mesa_profile = getenv( "MESA_PROFILE" ); + mesa_profile = _mesa_getenv( "MESA_PROFILE" ); } #ifdef RUN_DEBUG_BENCHMARK Index: src/mesa/math/m_matrix.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/math/m_matrix.c,v retrieving revision 1.23 diff -u -r1.23 m_matrix.c --- src/mesa/math/m_matrix.c 16 Sep 2005 18:14:24 -0000 1.23 +++ src/mesa/math/m_matrix.c 18 Sep 2005 15:35:26 -0000 @@ -382,9 +382,9 @@ 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 @@ 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 @@ 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 @@ 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; Index: src/mesa/shader/arbprogparse.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/shader/arbprogparse.c,v retrieving revision 1.34 diff -u -r1.34 arbprogparse.c --- src/mesa/shader/arbprogparse.c 16 Sep 2005 18:18:47 -0000 1.34 +++ src/mesa/shader/arbprogparse.c 18 Sep 2005 15:35:34 -0000 @@ -3886,7 +3886,7 @@ 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 @@ 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_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_free (parsed); #if DEBUG_PARSING - printf ("_mesa_parse_arb_program() done\n"); + fprintf (stderr, "_mesa_parse_arb_program() done\n"); #endif return err; } Index: src/mesa/shader/nvvertexec.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/shader/nvvertexec.c,v retrieving revision 1.12 diff -u -r1.12 nvvertexec.c --- src/mesa/shader/nvvertexec.c 1 Jul 2005 01:30:03 -0000 1.12 +++ src/mesa/shader/nvvertexec.c 18 Sep 2005 15:35:36 -0000 @@ -452,7 +452,7 @@ { 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 @@ { 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 @@ } 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 @@ { 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: Index: src/mesa/shader/slang/slang_compile.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/shader/slang/slang_compile.c,v retrieving revision 1.10 diff -u -r1.10 slang_compile.c --- src/mesa/shader/slang/slang_compile.c 16 Sep 2005 18:14:25 -0000 1.10 +++ src/mesa/shader/slang/slang_compile.c 18 Sep 2005 15:35:39 -0000 @@ -635,7 +635,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ xxx_prolog (&file, (**parsed_func_ret).address); _slang_execute (&file); slang_assembly_file_destruct (&file); -exit (0); +_mesa_exit (0); } } return 1; Index: src/mesa/shader/slang/slang_execute.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/shader/slang/slang_execute.c,v retrieving revision 1.6 diff -u -r1.6 slang_execute.c --- src/mesa/shader/slang/slang_execute.c 16 Sep 2005 18:14:25 -0000 1.6 +++ src/mesa/shader/slang/slang_execute.c 18 Sep 2005 15:35:40 -0000 @@ -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 @@ 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 @@ 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 @@ 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 @@ } } +#ifdef DEBUG_SLANG if (f != NULL) fclose (f); +#endif return 0; } Index: src/mesa/swrast/s_aaline.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/swrast/s_aaline.c,v retrieving revision 1.23 diff -u -r1.23 s_aaline.c --- src/mesa/swrast/s_aaline.c 9 Mar 2004 16:58:26 -0000 1.23 +++ src/mesa/swrast/s_aaline.c 18 Sep 2005 15:35:42 -0000 @@ -210,7 +210,7 @@ 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) */ } Index: src/mesa/swrast/s_fog.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/swrast/s_fog.c,v retrieving revision 1.30 diff -u -r1.30 s_fog.c --- src/mesa/swrast/s_fog.c 17 Jan 2005 16:16:35 -0000 1.30 +++ src/mesa/swrast/s_fog.c 18 Sep 2005 15:35:43 -0000 @@ -51,12 +51,12 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; Index: src/mesa/swrast/s_nvfragprog.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/swrast/s_nvfragprog.c,v retrieving revision 1.56 diff -u -r1.56 s_nvfragprog.c --- src/mesa/swrast/s_nvfragprog.c 16 Sep 2005 18:14:25 -0000 1.56 +++ src/mesa/swrast/s_nvfragprog.c 18 Sep 2005 15:35:46 -0000 @@ -821,7 +821,7 @@ 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 ); } Index: src/mesa/swrast/s_texfilter.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/swrast/s_texfilter.c,v retrieving revision 1.4 diff -u -r1.4 s_texfilter.c --- src/mesa/swrast/s_texfilter.c 16 Sep 2005 04:16:48 -0000 1.4 +++ src/mesa/swrast/s_texfilter.c 18 Sep 2005 15:35:50 -0000 @@ -297,7 +297,7 @@ } \ 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 @@ 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 @@ { \ 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 @@ { \ /* 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 @@ /* 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 @@ /* 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) \ Index: src/mesa/tnl/t_vb_arbprogram.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/tnl/t_vb_arbprogram.c,v retrieving revision 1.25 diff -u -r1.25 t_vb_arbprogram.c --- src/mesa/tnl/t_vb_arbprogram.c 16 Sep 2005 18:14:25 -0000 1.25 +++ src/mesa/tnl/t_vb_arbprogram.c 18 Sep 2005 15:35:54 -0000 @@ -97,7 +97,7 @@ */ static GLfloat ApproxLog2(GLfloat t) { - return (GLfloat) (log(t) * 1.442695F); + return (GLfloat) (LOGF(t) * 1.442695F); } static GLfloat ApproxExp2(GLfloat t) Index: src/mesa/tnl/t_vb_fog.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/tnl/t_vb_fog.c,v retrieving revision 1.31 diff -u -r1.31 t_vb_fog.c --- src/mesa/tnl/t_vb_fog.c 22 Apr 2005 12:51:19 -0000 1.31 +++ src/mesa/tnl/t_vb_fog.c 18 Sep 2005 15:35:55 -0000 @@ -80,7 +80,7 @@ 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; } Index: src/mesa/tnl/t_vertex_generic.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/tnl/t_vertex_generic.c,v retrieving revision 1.1 diff -u -r1.1 t_vertex_generic.c --- src/mesa/tnl/t_vertex_generic.c 18 May 2005 15:26:48 -0000 1.1 +++ src/mesa/tnl/t_vertex_generic.c 18 Sep 2005 15:35:56 -0000 @@ -203,7 +203,7 @@ 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 ) Index: src/mesa/tnl/t_vp_build.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/tnl/t_vp_build.c,v retrieving revision 1.27 diff -u -r1.27 t_vp_build.c --- src/mesa/tnl/t_vp_build.c 16 Sep 2005 18:14:25 -0000 1.27 +++ src/mesa/tnl/t_vp_build.c 18 Sep 2005 15:36:00 -0000 @@ -326,10 +326,10 @@ 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); Index: src/mesa/tnl/t_vtx_exec.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/tnl/t_vtx_exec.c,v retrieving revision 1.15 diff -u -r1.15 t_vtx_exec.c --- src/mesa/tnl/t_vtx_exec.c 22 Apr 2005 12:51:19 -0000 1.15 +++ src/mesa/tnl/t_vtx_exec.c 18 Sep 2005 15:36:01 -0000 @@ -113,8 +113,12 @@ 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. Index: src/mesa/tnl/t_vtx_x86.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/tnl/t_vtx_x86.c,v retrieving revision 1.20 diff -u -r1.20 t_vtx_x86.c --- src/mesa/tnl/t_vtx_x86.c 16 Sep 2005 18:14:25 -0000 1.20 +++ src/mesa/tnl/t_vtx_x86.c 18 Sep 2005 15:36:01 -0000 @@ -44,7 +44,6 @@ #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 @@ +#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 @@ 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 @@ 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 { \ Index: src/mesa/x86/common_x86.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/x86/common_x86.c,v retrieving revision 1.36 diff -u -r1.36 common_x86.c --- src/mesa/x86/common_x86.c 24 Jul 2005 06:29:16 -0000 1.36 +++ src/mesa/x86/common_x86.c 18 Sep 2005 15:36:03 -0000 @@ -71,7 +71,7 @@ } #endif if ( debug ) { - fprintf( stderr, "%s", msg ); + _mesa_debug( NULL, "%s", msg ); } } Index: src/mesa/x86-64/x86-64.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/x86-64/x86-64.c,v retrieving revision 1.1 diff -u -r1.1 x86-64.c --- src/mesa/x86-64/x86-64.c 7 May 2005 16:59:59 -0000 1.1 +++ src/mesa/x86-64/x86-64.c 18 Sep 2005 15:36:10 -0000 @@ -70,7 +70,7 @@ } #endif if ( debug ) { - fprintf( stderr, "%s", msg ); + _mesa_debug( NULL, "%s", msg ); } } #endif