From aa2069586d434dd0487b0daa2b583efe801a0d51 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 16 Sep 2005 18:14:24 +0000 Subject: use mesa import wrappers, bug 4468 --- src/mesa/main/imports.c | 13 +++++++++++++ src/mesa/main/imports.h | 2 ++ src/mesa/main/texcompress_fxt1.c | 4 ++-- src/mesa/main/texenvprogram.c | 8 ++++---- src/mesa/main/texobj.c | 2 +- src/mesa/math/m_matrix.c | 4 ++-- src/mesa/shader/arbprogparse.c | 2 +- src/mesa/shader/nvfragparse.c | 4 ++-- src/mesa/shader/program.c | 2 +- src/mesa/shader/slang/slang_compile.c | 4 ++-- src/mesa/shader/slang/slang_execute.c | 2 +- src/mesa/swrast/s_nvfragprog.c | 4 ++-- src/mesa/tnl/t_context.c | 2 +- src/mesa/tnl/t_vb_arbprogram.c | 2 +- src/mesa/tnl/t_vb_arbprogram_sse.c | 2 +- src/mesa/tnl/t_vertex_sse.c | 2 +- src/mesa/tnl/t_vp_build.c | 2 +- src/mesa/tnl/t_vtx_api.c | 2 +- src/mesa/tnl/t_vtx_x86.c | 6 +++--- src/mesa/x86/rtasm/x86sse.c | 5 +++-- 20 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index fec0d33844..8d39f77b41 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -259,6 +259,19 @@ _mesa_bzero( void *dst, size_t n ) #endif } +/** Wrapper around either memcmp() or xf86memcmp() */ +int +_mesa_memcmp( const void *s1, const void *s2, size_t n ) +{ +#if defined(XFree86LOADER) && defined(IN_MODULE) + return xf86memcmp( s1, s2, n ); +#elif defined(SUNOS4) + return memcmp( (char *) s1, (char *) s2, (int) n ); +#else + return memcmp(s1, s2, n); +#endif +} + /*@}*/ diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 27cc1a57f7..134eff84b3 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -613,6 +613,8 @@ _mesa_memset16( unsigned short *dst, unsigned short val, size_t n ); extern void _mesa_bzero( void *dst, size_t n ); +extern int +_mesa_memcmp( const void *s1, const void *s2, size_t n ); extern double _mesa_sin(double a); diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 748824194c..5fc41fa6bc 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -474,7 +474,7 @@ fxt1_choose (GLfloat vec[][MAX_COMP], GLint nv, } hist[N_TEXELS]; GLint lenh = 0; - memset(hist, 0, sizeof(hist)); + _mesa_memset(hist, 0, sizeof(hist)); for (k = 0; k < n; k++) { GLint l; @@ -1268,7 +1268,7 @@ fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint comps) if (comps == 3) { /* make the whole block opaque */ - memset(input, -1, sizeof(input)); + _mesa_memset(input, -1, sizeof(input)); } /* 8 texels each line */ diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 68dcc51b4c..2ffb1774a3 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -480,7 +480,7 @@ emit_op(struct texenv_fragment_program *p, GLuint nr = p->program->Base.NumInstructions++; struct fp_instruction *inst = &p->program->Instructions[nr]; - memset(inst, 0, sizeof(*inst)); + _mesa_memset(inst, 0, sizeof(*inst)); inst->Opcode = op; emit_arg( &inst->SrcReg[0], src0 ); @@ -792,7 +792,7 @@ static struct ureg emit_combine( struct texenv_fragment_program *p, emit_arith( p, FP_OPCODE_MAD, tmp0, WRITEMASK_XYZW, 0, two, src[0], neg1); - if (memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0) + if (_mesa_memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0) tmp1 = tmp0; else emit_arith( p, FP_OPCODE_MAD, tmp1, WRITEMASK_XYZW, 0, @@ -1039,7 +1039,7 @@ static void create_new_program(struct state_key *key, GLcontext *ctx, emit_arith( &p, FP_OPCODE_ADD, out, WRITEMASK_XYZ, 0, cf, s, undef ); emit_arith( &p, FP_OPCODE_MOV, out, WRITEMASK_W, 0, cf, undef, undef ); } - else if (memcmp(&cf, &out, sizeof(cf)) != 0) { + else if (_mesa_memcmp(&cf, &out, sizeof(cf)) != 0) { /* Will wind up in here if no texture enabled or a couple of * other scenarios (GL_REPLACE for instance). */ @@ -1093,7 +1093,7 @@ static void *search_cache( struct texenvprog_cache *cache, struct texenvprog_cache *c; for (c = cache; c; c = c->next) { - if (c->hash == hash && memcmp(c->key, key, keysize) == 0) + if (c->hash == hash && _mesa_memcmp(c->key, key, keysize) == 0) return c->data; } diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 5594cd9382..3c74e74872 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -246,7 +246,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, /* Always need the base level image */ if (!t->Image[0][baseLevel]) { char s[100]; - sprintf(s, "obj %p (%d) Image[baseLevel=%d] == NULL", + _mesa_sprintf(s, "obj %p (%d) Image[baseLevel=%d] == NULL", (void *) t, t->Name, baseLevel); incomplete(t, s); t->Complete = GL_FALSE; diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c index 408db9b963..ff32e3d94b 100644 --- a/src/mesa/math/m_matrix.c +++ b/src/mesa/math/m_matrix.c @@ -804,8 +804,8 @@ _math_matrix_rotate( GLmatrix *mat, GLfloat m[16]; GLboolean optimized; - s = (GLfloat) sin( angle * DEG2RAD ); - c = (GLfloat) cos( angle * DEG2RAD ); + s = (GLfloat) _mesa_sin( angle * DEG2RAD ); + c = (GLfloat) _mesa_cos( angle * DEG2RAD ); MEMCPY(m, Identity, sizeof(GLfloat)*16); optimized = GL_FALSE; diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 3c62a1f486..23cb46637c 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -560,7 +560,7 @@ var_cache_find (struct var_cache *va, GLubyte * name) /*struct var_cache *first = va;*/ while (va) { - if (!strcmp ( (const char*) name, (const char*) va->name)) { + if (!_mesa_strcmp ( (const char*) name, (const char*) va->name)) { if (va->type == vt_alias) return va->alias_binding; return va; diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index 17dd42bbf8..4f27a96eeb 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -1588,7 +1588,7 @@ PrintSrcReg(const struct fragment_program *program, } if (src->File == PROGRAM_NAMED_PARAM) { if (program->Parameters->Parameters[src->Index].Type == CONSTANT) { - printf("{%g, %g, %g, %g}", + _mesa_printf("{%g, %g, %g, %g}", program->Parameters->ParameterValues[src->Index][0], program->Parameters->ParameterValues[src->Index][1], program->Parameters->ParameterValues[src->Index][2], @@ -1597,7 +1597,7 @@ PrintSrcReg(const struct fragment_program *program, else { ASSERT(program->Parameters->Parameters[src->Index].Type == NAMED_PARAMETER); - printf("%s", program->Parameters->Parameters[src->Index].Name); + _mesa_printf("%s", program->Parameters->Parameters[src->Index].Name); } } else if (src->File == PROGRAM_OUTPUT) { diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index e721198136..70a9ced7a6 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -1304,7 +1304,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target, for (i = 0; i < ctx->Const.MaxVertexProgramAttribs; i++) { const char *name = _mesa_nv_vertex_input_register_name(i); char number[10]; - sprintf(number, "%d", i); + _mesa_sprintf(number, "%d", i); if (_mesa_strncmp(reg + 2, name, 4) == 0 || _mesa_strncmp(reg + 2, number, _mesa_strlen(number)) == 0) { COPY_4V(v, ctx->VertexProgram.Inputs[i]); diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 2377173cf0..0ff450ca91 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); - vsprintf (buf, msg, va); + _mesa_sprintf (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); - vsprintf (buf, msg, va); + _mesa_sprintf (buf, msg, va); if (slang_info_log_message (log, "warning", buf)) return 1; slang_info_log_memory (log); diff --git a/src/mesa/shader/slang/slang_execute.c b/src/mesa/shader/slang/slang_execute.c index d47f3eaca2..78a638b444 100644 --- a/src/mesa/shader/slang/slang_execute.c +++ b/src/mesa/shader/slang/slang_execute.c @@ -169,7 +169,7 @@ static void dump (const slang_assembly_file *file) char filename[256]; counter++; - sprintf (filename, "~mesa-slang-assembly-dump-(%u).txt", counter); + _mesa_sprintf (filename, "~mesa-slang-assembly-dump-(%u).txt", counter); f = fopen (filename, "w"); if (f == NULL) return; diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c index 1f9ec448c2..931bf64f92 100644 --- a/src/mesa/swrast/s_nvfragprog.c +++ b/src/mesa/swrast/s_nvfragprog.c @@ -1034,8 +1034,8 @@ execute_program( GLcontext *ctx, { GLfloat a[4], result[4]; fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a ); - result[0] = (GLfloat)cos(a[0]); - result[1] = (GLfloat)sin(a[0]); + result[0] = (GLfloat)_mesa_cos(a[0]); + result[1] = (GLfloat)_mesa_sin(a[0]); result[2] = 0.0; /* undefined! */ result[3] = 0.0; /* undefined! */ store_vector4( inst, machine, result ); diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 472b97bfe5..cda4cf2cbd 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -73,7 +73,7 @@ _tnl_CreateContext( GLcontext *ctx ) return GL_FALSE; } - if (getenv("MESA_CODEGEN")) + if (_mesa_getenv("MESA_CODEGEN")) tnl->AllowCodegen = GL_TRUE; /* Initialize the VB. diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 5cee3d78dc..9fc49a2cee 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -1031,7 +1031,7 @@ static void compile_vertex_program( struct vertex_program *program, /* Initialize cp. Note that ctx and VB aren't used in compilation * so we don't have to worry about statechanges: */ - memset(&cp, 0, sizeof(cp)); + _mesa_memset(&cp, 0, sizeof(cp)); cp.csr = p->instructions; /* Compile instructions: diff --git a/src/mesa/tnl/t_vb_arbprogram_sse.c b/src/mesa/tnl/t_vb_arbprogram_sse.c index 330d30efb9..c5da430dd3 100644 --- a/src/mesa/tnl/t_vb_arbprogram_sse.c +++ b/src/mesa/tnl/t_vb_arbprogram_sse.c @@ -1181,7 +1181,7 @@ _tnl_sse_codegen_vertex_program(struct tnl_compiled_program *p) { struct compilation cp; - memset(&cp, 0, sizeof(cp)); + _mesa_memset(&cp, 0, sizeof(cp)); cp.p = p; cp.have_sse2 = 1; diff --git a/src/mesa/tnl/t_vertex_sse.c b/src/mesa/tnl/t_vertex_sse.c index 13dc2f4d53..ad4cc62d5f 100644 --- a/src/mesa/tnl/t_vertex_sse.c +++ b/src/mesa/tnl/t_vertex_sse.c @@ -637,7 +637,7 @@ void _tnl_generate_sse_emit( GLcontext *ctx ) return; } - memset(&p, 0, sizeof(p)); + _mesa_memset(&p, 0, sizeof(p)); p.ctx = ctx; p.inputs_safe = 0; /* for now */ diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index e62c5b374c..3e77758edb 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1406,7 +1406,7 @@ static void *search_cache( struct tnl_cache *cache, struct tnl_cache *c; for (c = cache; c; c = c->next) { - if (c->hash == hash && memcmp(c->key, key, keysize) == 0) + if (c->hash == hash && _mesa_memcmp(c->key, key, keysize) == 0) return c->data; } diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c index fa9e04ad33..ae2056971e 100644 --- a/src/mesa/tnl/t_vtx_api.c +++ b/src/mesa/tnl/t_vtx_api.c @@ -943,7 +943,7 @@ void _tnl_vtx_init( GLcontext *ctx ) _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt ); - memcpy( tnl->vtx.tabfv, choose, sizeof(choose) ); + _mesa_memcpy( tnl->vtx.tabfv, choose, sizeof(choose) ); for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++) tnl->vtx.attrsz[i] = 0; diff --git a/src/mesa/tnl/t_vtx_x86.c b/src/mesa/tnl/t_vtx_x86.c index 38cdad451c..1812cfa471 100644 --- a/src/mesa/tnl/t_vtx_x86.c +++ b/src/mesa/tnl/t_vtx_x86.c @@ -90,7 +90,7 @@ EXTERN( _tnl_x86_choose_fv ); insert_at_head( &CACHE, dfn ); \ dfn->key = KEY; \ dfn->code = ALIGN_MALLOC( end - start, 16 ); \ - memcpy (dfn->code, start, end - start) + _mesa_memcpy (dfn->code, start, end - start) @@ -277,7 +277,7 @@ do { \ const char *end = WARP##_end; \ int offset = 0; \ code = ALIGN_MALLOC( end - start, 16 ); \ - memcpy (code, start, end - start); \ + _mesa_memcpy (code, start, end - start); \ FIXUP(code, 0, 0, (int)&(TNL_CONTEXT(ctx)->vtx.tabfv[ATTR][SIZE-1]));\ *(void **)&vfmt->FUNC = code; \ } while (0) @@ -351,7 +351,7 @@ void _tnl_x86choosers( tnl_attrfv_func (*choose)[4], const char *end = _tnl_x86_choose_fv_end; int offset = 0; code = ALIGN_MALLOC( end - start, 16 ); - memcpy (code, start, end - start); + _mesa_memcpy (code, start, end - start); FIXUP(code, 0, 0, attr); FIXUP(code, 0, 1, size + 1); FIXUPREL(code, 0, 2, do_choose); diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c index adc7126801..40ffc03204 100644 --- a/src/mesa/x86/rtasm/x86sse.c +++ b/src/mesa/x86/rtasm/x86sse.c @@ -1,5 +1,6 @@ #if defined(USE_X86_ASM) +#include "imports.h" #include "x86sse.h" #define DISASSEM 0 @@ -970,13 +971,13 @@ struct x86_reg x86_fn_arg( struct x86_function *p, void x86_init_func( struct x86_function *p ) { - p->store = malloc(1024); + p->store = _mesa_malloc(1024); p->csr = p->store; } void x86_release_func( struct x86_function *p ) { - free(p->store); + _mesa_free(p->store); } -- cgit v1.2.3