diff options
author | Brian Paul <[email protected]> | 2002-10-25 21:06:26 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-10-25 21:06:26 +0000 |
commit | 367d308b8267ad86cd7623590b7bfd4737b5fbf5 (patch) | |
tree | 0ff79c1667eb62f514e6ac5acd4211927256fb88 /src/mesa/main | |
parent | e781aec85d30182eea1b6dab5fb9dd06594f5671 (diff) |
wrapped a few more C library functions
Diffstat (limited to 'src/mesa/main')
-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 |
6 files changed, 159 insertions, 18 deletions
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) |