diff options
-rw-r--r-- | src/mesa/drivers/osmesa/osmesa.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/x11/fakeglx.c | 32 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 38 | ||||
-rw-r--r-- | src/mesa/main/enums.c | 4 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 16 | ||||
-rw-r--r-- | src/mesa/main/imports.c | 112 | ||||
-rw-r--r-- | src/mesa/main/imports.h | 33 | ||||
-rw-r--r-- | src/mesa/main/light.c | 8 | ||||
-rw-r--r-- | src/mesa/main/light.h | 4 |
9 files changed, 196 insertions, 55 deletions
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 5efb52391b6..f67047a1cd4 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.93 2002/10/24 23:57:23 brianp Exp $ */ +/* $Id: osmesa.c,v 1.94 2002/10/25 21:06:34 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -653,7 +653,7 @@ OSMesaGetProcAddress( const char *funcName ) { int i; for (i = 0; functions[i].Name; i++) { - if (strcmp(functions[i].Name, funcName) == 0) + if (_mesa_strcmp(functions[i].Name, funcName) == 0) return (void *) functions[i].Address; } return (void *) _glapi_get_proc_address(funcName); diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 99361b4d1a0..2cb45df70aa 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -1,4 +1,4 @@ -/* $Id: fakeglx.c,v 1.70 2002/10/24 23:57:23 brianp Exp $ */ +/* $Id: fakeglx.c,v 1.71 2002/10/25 21:06:34 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -271,7 +271,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, if (dbFlag) { /* Check if the MESA_BACK_BUFFER env var is set */ - char *backbuffer = getenv("MESA_BACK_BUFFER"); + char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER"); if (backbuffer) { if (backbuffer[0]=='p' || backbuffer[0]=='P') { ximageFlag = GL_FALSE; @@ -287,7 +287,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, /* Comparing IDs uses less memory but sometimes fails. */ /* XXX revisit this after 3.0 is finished. */ - if (getenv("MESA_GLX_VISUAL_HACK")) + if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) comparePointers = GL_TRUE; else comparePointers = GL_FALSE; @@ -366,7 +366,7 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo ) ); } else if (is_usable_visual( visinfo )) { - if (getenv("MESA_GLX_FORCE_CI")) { + if (_mesa_getenv("MESA_GLX_FORCE_CI")) { /* Configure this visual as a COLOR INDEX visual. */ return save_glx_visual( dpy, visinfo, GL_FALSE, /* rgb */ @@ -565,21 +565,21 @@ static XVisualInfo *get_env_visual(Display *dpy, int scr, const char *varname) int depth, xclass = -1; XVisualInfo *vis; - if (!getenv( varname )) { + if (!_mesa_getenv( varname )) { return NULL; } - strncpy( value, getenv(varname), 100 ); + _mesa_strncpy( value, _mesa_getenv(varname), 100 ); value[99] = 0; sscanf( value, "%s %d", type, &depth ); - if (strcmp(type,"TrueColor")==0) xclass = TrueColor; - else if (strcmp(type,"DirectColor")==0) xclass = DirectColor; - else if (strcmp(type,"PseudoColor")==0) xclass = PseudoColor; - else if (strcmp(type,"StaticColor")==0) xclass = StaticColor; - else if (strcmp(type,"GrayScale")==0) xclass = GrayScale; - else if (strcmp(type,"StaticGray")==0) xclass = StaticGray; + if (_mesa_strcmp(type,"TrueColor")==0) xclass = TrueColor; + else if (_mesa_strcmp(type,"DirectColor")==0) xclass = DirectColor; + else if (_mesa_strcmp(type,"PseudoColor")==0) xclass = PseudoColor; + else if (_mesa_strcmp(type,"StaticColor")==0) xclass = StaticColor; + else if (_mesa_strcmp(type,"GrayScale")==0) xclass = GrayScale; + else if (_mesa_strcmp(type,"StaticGray")==0) xclass = StaticGray; if (xclass>-1 && depth>0) { vis = get_visual( dpy, scr, depth, xclass ); @@ -1383,7 +1383,7 @@ Fake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap ) if (b) { XMesaDestroyBuffer(b); } - else if (getenv("MESA_DEBUG")) { + else if (_mesa_getenv("MESA_DEBUG")) { _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n"); } } @@ -1457,7 +1457,7 @@ Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable ) if (buffer) { XMesaSwapBuffers(buffer); } - else if (getenv("MESA_DEBUG")) { + else if (_mesa_getenv("MESA_DEBUG")) { _mesa_warning(NULL, "Mesa: glXSwapBuffers: invalid drawable\n"); } } @@ -1474,7 +1474,7 @@ Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, if (buffer) { XMesaCopySubBuffer(buffer, x, y, width, height); } - else if (getenv("MESA_DEBUG")) { + else if (_mesa_getenv("MESA_DEBUG")) { _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n"); } } @@ -1742,7 +1742,7 @@ static const char * get_extensions( void ) { #ifdef FX - const char *fx = getenv("MESA_GLX_FX"); + const char *fx = _mesa_getenv("MESA_GLX_FX"); if (fx && fx[0] != 'd') { return EXTENSIONS; } diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 9ea50fb8bc7..c9917794333 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1,4 +1,4 @@ -/* $Id: xm_api.c,v 1.46 2002/10/24 23:57:23 brianp Exp $ */ +/* $Id: xm_api.c,v 1.47 2002/10/25 21:06:34 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -167,7 +167,7 @@ static void error( const char *msg ) { (void)DitherValues; /* Muffle compiler */ - if (getenv("MESA_DEBUG")) + if (_mesa_getenv("MESA_DEBUG")) fprintf( stderr, "X/Mesa error: %s\n", msg ); } @@ -266,7 +266,7 @@ static GLint gamma_adjust( GLfloat gamma, GLint value, GLint max ) } else { double x = (double) value / (double) max; - return IROUND_POS((GLfloat) max * pow(x, 1.0F/gamma)); + return IROUND_POS((GLfloat) max * _mesa_pow(x, 1.0F/gamma)); } } @@ -504,7 +504,7 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b ) b->shminfo.shmid = shmget( IPC_PRIVATE, b->backimage->bytes_per_line * b->backimage->height, IPC_CREAT|0777 ); if (b->shminfo.shmid < 0) { - if (getenv("MESA_DEBUG")) + if (_mesa_getenv("MESA_DEBUG")) perror("alloc_back_buffer"); XDestroyImage( b->backimage ); b->backimage = NULL; @@ -516,7 +516,7 @@ static GLboolean alloc_shm_back_buffer( XMesaBuffer b ) b->shminfo.shmaddr = b->backimage->data = (char*)shmat( b->shminfo.shmid, 0, 0 ); if (b->shminfo.shmaddr == (char *) -1) { - if (getenv("MESA_DEBUG")) + if (_mesa_getenv("MESA_DEBUG")) perror("alloc_back_buffer"); XDestroyImage( b->backimage ); shmctl( b->shminfo.shmid, IPC_RMID, 0 ); @@ -872,7 +872,7 @@ static GLboolean setup_grayscale( int client, XMesaVisual v, buffer->pixel_to_b[xcol.pixel] = gray; } - if (colorsfailed && getenv("MESA_DEBUG")) { + if (colorsfailed && _mesa_getenv("MESA_DEBUG")) { fprintf( stderr, "Note: %d out of 256 needed colors do not match exactly.\n", colorsfailed ); @@ -952,7 +952,7 @@ static GLboolean setup_dithered_color( int client, XMesaVisual v, } } - if (colorsfailed && getenv("MESA_DEBUG")) { + if (colorsfailed && _mesa_getenv("MESA_DEBUG")) { fprintf( stderr, "Note: %d out of %d needed colors do not match exactly.\n", colorsfailed, _R*_G*_B ); @@ -986,19 +986,19 @@ static void setup_8bit_hpcr( XMesaVisual v ) g = 1.0 / v->RedGamma; for (i=0; i<256; i++) { - GLint red = IROUND_POS(255.0 * pow( hpcr_rgbTbl[0][i]/255.0, g )); + GLint red = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[0][i]/255.0, g )); v->hpcr_rgbTbl[0][i] = CLAMP( red, 16, 239 ); } g = 1.0 / v->GreenGamma; for (i=0; i<256; i++) { - GLint green = IROUND_POS(255.0 * pow( hpcr_rgbTbl[1][i]/255.0, g )); + GLint green = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[1][i]/255.0, g )); v->hpcr_rgbTbl[1][i] = CLAMP( green, 16, 239 ); } g = 1.0 / v->BlueGamma; for (i=0; i<256; i++) { - GLint blue = IROUND_POS(255.0 * pow( hpcr_rgbTbl[2][i]/255.0, g )); + GLint blue = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[2][i]/255.0, g )); v->hpcr_rgbTbl[2][i] = CLAMP( blue, 32, 223 ); } v->undithered_pf = PF_HPCR; /* can't really disable dithering for now */ @@ -1007,7 +1007,7 @@ static void setup_8bit_hpcr( XMesaVisual v ) /* which method should I use to clear */ /* GL_FALSE: keep the ordinary method */ /* GL_TRUE : clear with dither pattern */ - v->hpcr_clear_flag = getenv("MESA_HPCR_CLEAR") ? GL_TRUE : GL_FALSE; + v->hpcr_clear_flag = _mesa_getenv("MESA_HPCR_CLEAR") ? GL_TRUE : GL_FALSE; if (v->hpcr_clear_flag) { v->hpcr_clear_pixmap = XMesaCreatePixmap(v->display, @@ -1242,7 +1242,7 @@ static GLboolean initialize_visual_and_buffer( int client, } v->index_bits = 0; - if (getenv("MESA_NO_DITHER")) { + if (_mesa_getenv("MESA_NO_DITHER")) { v->dithered_pf = v->undithered_pf; } } @@ -1253,7 +1253,7 @@ static GLboolean initialize_visual_and_buffer( int client, * which can help Brian figure out what's going on when a user * reports bugs. */ - if (getenv("MESA_INFO")) { + if (_mesa_getenv("MESA_INFO")) { fprintf(stderr, "X/Mesa visual = %p\n", (void *) v); fprintf(stderr, "X/Mesa dithered pf = %u\n", v->dithered_pf); fprintf(stderr, "X/Mesa undithered pf = %u\n", v->undithered_pf); @@ -1471,7 +1471,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, GLint red_bits, green_bits, blue_bits, alpha_bits; /* For debugging only */ - if (getenv("MESA_XSYNC")) { + if (_mesa_getenv("MESA_XSYNC")) { /* This makes debugging X easier. * In your debugger, set a breakpoint on _XError to stop when an * X protocol error is generated. @@ -1529,7 +1529,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, #endif /* check for MESA_GAMMA environment variable */ - gamma = getenv("MESA_GAMMA"); + gamma = _mesa_getenv("MESA_GAMMA"); if (gamma) { v->RedGamma = v->GreenGamma = v->BlueGamma = 0.0; sscanf( gamma, "%f %f %f", &v->RedGamma, &v->GreenGamma, &v->BlueGamma ); @@ -1732,7 +1732,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w, if (GET_VISUAL_DEPTH(v) != attr.depth) { #endif - if (getenv("MESA_DEBUG")) { + if (_mesa_getenv("MESA_DEBUG")) { fprintf(stderr, "XMesaCreateWindowBuffer: depth mismatch between visual and window!\n"); } return NULL; @@ -1748,7 +1748,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w, b->cmap = attr.colormap; } else { - if (getenv("MESA_DEBUG")) { + if (_mesa_getenv("MESA_DEBUG")) { fprintf(stderr, "Window %u has no colormap!\n", (unsigned int) w); } /* this is weird, a window w/out a colormap!? */ @@ -1784,7 +1784,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w, } #ifdef FX - fxEnvVar = getenv("MESA_GLX_FX"); + fxEnvVar = _mesa_getenv("MESA_GLX_FX"); if (fxEnvVar) { if (fxEnvVar[0]!='d') { int attribs[100]; @@ -2181,7 +2181,7 @@ GLboolean XMesaLoseCurrent(XMesaContext c) GLboolean XMesaSetFXmode( GLint mode ) { #ifdef FX - const char *fx = getenv("MESA_GLX_FX"); + const char *fx = _mesa_getenv("MESA_GLX_FX"); if (fx && fx[0] != 'd') { GET_CURRENT_CONTEXT(ctx); GrHwConfiguration hw; diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index f7a3e439ab8..dfa739f4067 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -1,4 +1,4 @@ -/* $Id: enums.c,v 1.22 2002/10/24 23:57:20 brianp Exp $ */ +/* $Id: enums.c,v 1.23 2002/10/25 21:06:26 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -853,7 +853,7 @@ static int sorted = 0; static int compar_name( const enum_elt *a, const enum_elt *b ) { - return strcmp(a->c, b->c); + return _mesa_strcmp(a->c, b->c); } diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 88868b9633f..f387fb2c212 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,4 +1,4 @@ -/* $Id: extensions.c,v 1.84 2002/10/24 23:57:20 brianp Exp $ */ +/* $Id: extensions.c,v 1.85 2002/10/25 21:06:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -315,7 +315,7 @@ _mesa_add_extension( GLcontext *ctx, { struct extension *t = MALLOC_STRUCT(extension); t->enabled = enabled; - strncpy(t->name, name, MAX_EXT_NAMELEN); + _mesa_strncpy(t->name, name, MAX_EXT_NAMELEN); t->name[MAX_EXT_NAMELEN] = 0; t->flag = flag_ptr; if (t->flag) @@ -337,7 +337,7 @@ set_extension( GLcontext *ctx, const char *name, GLint state ) */ struct extension *i; foreach( i, ctx->Extensions.ext_list ) - if (strncmp(i->name, name, MAX_EXT_NAMELEN) == 0) + if (_mesa_strncmp(i->name, name, MAX_EXT_NAMELEN) == 0) break; if (i == ctx->Extensions.ext_list) { @@ -379,7 +379,7 @@ _mesa_extension_is_enabled( GLcontext *ctx, const char *name) { struct extension *i; foreach( i, ctx->Extensions.ext_list ) - if (strncmp(i->name, name, MAX_EXT_NAMELEN) == 0) { + if (_mesa_strncmp(i->name, name, MAX_EXT_NAMELEN) == 0) { if (i->enabled) return GL_TRUE; else @@ -446,18 +446,18 @@ _mesa_extensions_get_string( GLcontext *ctx ) GLuint len = 0; foreach (i, ctx->Extensions.ext_list) if (i->enabled) - len += strlen(i->name) + 1; + len += _mesa_strlen(i->name) + 1; if (len == 0) return ""; - str = (char *)MALLOC(len * sizeof(char)); + str = (char *) _mesa_malloc(len * sizeof(char)); ctx->Extensions.ext_string = str; foreach (i, ctx->Extensions.ext_list) if (i->enabled) { - strcpy(str, i->name); - str += strlen(str); + _mesa_strcpy(str, i->name); + str += _mesa_strlen(str); *str++ = ' '; } diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 3b88009edd5..f9c69863ab3 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -1,4 +1,4 @@ -/* $Id: imports.c,v 1.21 2002/10/24 23:57:21 brianp Exp $ */ +/* $Id: imports.c,v 1.22 2002/10/25 21:06:28 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -208,6 +208,50 @@ _mesa_bzero( void *dst, size_t n ) } +double +_mesa_sin(double a) +{ +#ifdef XFree86LOADER + return xf86sin(a); +#else + return sin(a); +#endif +} + + +double +_mesa_cos(double a) +{ +#ifdef XFree86LOADER + return xf86cos(a); +#else + return cos(a); +#endif +} + + +double +_mesa_sqrt(double x) +{ +#ifdef XFree86LOADER + return xf86sqrt(x); +#else + return sqrt(x); +#endif +} + + +double +_mesa_pow(double x, double y) +{ +#ifdef XFree86LOADER + return xf86pow(x, y); +#else + return pow(x, y); +#endif +} + + char * _mesa_getenv( const char *var ) { @@ -230,6 +274,72 @@ _mesa_strstr( const char *haystack, const char *needle ) } +char * +_mesa_strncat( char *dest, const char *src, size_t n ) +{ +#ifdef XFree86LOADER + return xf86strncat(dest, src, n); +#else + return strncat(dest, src, n); +#endif +} + + +char * +_mesa_strcpy( char *dest, const char *src ) +{ +#ifdef XFree86LOADER + return xf86strcpy(dest, src); +#else + return strcpy(dest, src); +#endif +} + + +char * +_mesa_strncpy( char *dest, const char *src, size_t n ) +{ +#ifdef XFree86LOADER + return xf86strncpy(dest, src, n); +#else + return strncpy(dest, src, n); +#endif +} + + +size_t +_mesa_strlen( const char *s ) +{ +#ifdef XFree86LOADER + return xf86strlen(s); +#else + return strlen(s); +#endif +} + + +int +_mesa_strcmp( const char *s1, const char *s2 ) +{ +#ifdef XFree86LOADER + return xf86strcmp(s1, s2); +#else + return strcmp(s1, s2); +#endif +} + + +int +_mesa_strncmp( const char *s1, const char *s2, size_t n ) +{ +#ifdef XFree86LOADER + return xf86strncmp(s1, s2, n); +#else + return strncmp(s1, s2, n); +#endif +} + + int _mesa_atoi(const char *s) { diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 4054ed0c941..463b9cafb9c 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -1,4 +1,4 @@ -/* $Id: imports.h,v 1.6 2002/10/24 23:57:21 brianp Exp $ */ +/* $Id: imports.h,v 1.7 2002/10/25 21:06:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -127,12 +127,43 @@ extern void _mesa_bzero( void *dst, size_t n ); +extern double +_mesa_sin(double a); + +extern double +_mesa_cos(double a); + +extern double +_mesa_sqrt(double x); + +extern double +_mesa_pow(double x, double y); + + extern char * _mesa_getenv( const char *var ); extern char * _mesa_strstr( const char *haystack, const char *needle ); +extern char * +_mesa_strncat( char *dest, const char *src, size_t n ); + +extern char * +_mesa_strcpy( char *dest, const char *src ); + +extern char * +_mesa_strncpy( char *dest, const char *src, size_t n ); + +extern size_t +_mesa_strlen( const char *s ); + +extern int +_mesa_strcmp( const char *s1, const char *s2 ); + +extern int +_mesa_strncmp( const char *s1, const char *s2, size_t n ); + extern int _mesa_atoi( const char *s ); diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 638be5e8353..201938d4aa7 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,4 +1,4 @@ -/* $Id: light.c,v 1.53 2002/10/24 23:57:21 brianp Exp $ */ +/* $Id: light.c,v 1.54 2002/10/25 21:06:29 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -156,7 +156,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); l->SpotCutoff = params[0]; - l->_CosCutoff = (GLfloat) cos(params[0]*DEG2RAD); + l->_CosCutoff = (GLfloat) _mesa_cos(params[0]*DEG2RAD); if (l->_CosCutoff < 0) l->_CosCutoff = 0; if (l->SpotCutoff != 180.0F) @@ -1038,7 +1038,7 @@ static void validate_spot_exp_table( struct gl_light *l ) for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) { if (clamp == 0) { - tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent); + tmp = _mesa_pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent); if (tmp < FLT_MIN * 100.0) { tmp = 0.0; clamp = 1; @@ -1096,7 +1096,7 @@ static void validate_shine_table( GLcontext *ctx, GLuint i, GLfloat shininess ) GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1); if (x < 0.005) /* underflow check */ x = 0.005; - t = pow(x, shininess); + t = _mesa_pow(x, shininess); if (t > 1e-20) m[j] = (GLfloat) t; else diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h index 5cd24e83ff4..63c40f87975 100644 --- a/src/mesa/main/light.h +++ b/src/mesa/main/light.h @@ -1,4 +1,4 @@ -/* $Id: light.h,v 1.14 2001/09/14 21:36:43 brianp Exp $ */ +/* $Id: light.h,v 1.15 2002/10/25 21:06:30 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -86,7 +86,7 @@ do { \ float f = (dp * (SHINE_TABLE_SIZE-1)); \ int k = (int) f; \ if (k > SHINE_TABLE_SIZE-2) \ - result = (GLfloat) pow( dp, _tab->shininess ); \ + result = (GLfloat) _mesa_pow( dp, _tab->shininess ); \ else \ result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \ } while (0) |