diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2005-12-06 15:41:43 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2005-12-06 15:41:43 +0000 |
commit | 9580179dfb42d5b81ff6ec9704b82a556c7f1229 (patch) | |
tree | ae2a55aa82c4efc43ae832abcf316e1773c228bb /src | |
parent | d5179613d5302173471a6a910fa9ec235c9ff046 (diff) |
C++ fixes, mostly casts (Stephane Conversy)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/x11/fakeglx.c | 2 | ||||
-rw-r--r-- | src/mesa/main/texenvprogram.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/arbprogparse.c | 10 | ||||
-rw-r--r-- | src/mesa/shader/nvfragparse.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/nvvertparse.c | 2 | ||||
-rw-r--r-- | src/mesa/shader/program.c | 28 | ||||
-rw-r--r-- | src/mesa/swrast/s_depth.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_stencil.c | 10 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 2 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_arbprogram.c | 8 | ||||
-rw-r--r-- | src/mesa/tnl/t_vertex.c | 5 | ||||
-rw-r--r-- | src/mesa/tnl/t_vp_build.c | 8 |
13 files changed, 45 insertions, 44 deletions
diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 1933fed067..24fc6fe6ab 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -345,7 +345,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, */ xmvis->vishandle = vinfo; /* Allocate more space for additional visual */ - VisualTable = _mesa_realloc( VisualTable, + VisualTable = (XMesaVisual *) _mesa_realloc( VisualTable, sizeof(XMesaVisual) * NumVisuals, sizeof(XMesaVisual) * (NumVisuals + 1)); /* add xmvis to the list */ diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index a92db42bfd..711464aab2 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -998,7 +998,7 @@ create_new_program(struct state_key *key, GLcontext *ctx, p.program = program; p.program->Base.Instructions = - _mesa_malloc(sizeof(struct prog_instruction) * MAX_INSTRUCTIONS); + (struct prog_instruction*) _mesa_malloc(sizeof(struct prog_instruction) * MAX_INSTRUCTIONS); p.program->Base.NumInstructions = 0; p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB; p.program->NumTexIndirections = 1; /* correct? */ diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 09b1caeaae..a64360adbe 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -2488,7 +2488,7 @@ parse_src_reg (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head, return 1; } - *File = src->param_binding_type; + *File = (enum register_file) src->param_binding_type; switch (*(*inst)++) { case ARRAY_INDEX_ABSOLUTE: @@ -2536,7 +2536,7 @@ parse_src_reg (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head, if (parse_param_use (ctx, inst, vc_head, Program, &src)) return 1; - *File = src->param_binding_type; + *File = (enum register_file) src->param_binding_type; *Index = src->param_binding_begin; break; } @@ -2563,7 +2563,7 @@ parse_src_reg (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head, /* XXX: We have to handle offsets someplace in here! -- or are those above? */ case vt_param: - *File = src->param_binding_type; + *File = (enum register_file) src->param_binding_type; *Index = src->param_binding_begin; break; @@ -4056,7 +4056,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, GLuint i; ASSERT(target == GL_FRAGMENT_PROGRAM_ARB); - if (!_mesa_parse_arb_program(ctx, target, str, len, &ap)) { + if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, &ap)) { /* Error in the program. Just return. */ return; } @@ -4108,7 +4108,7 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target, ASSERT(target == GL_VERTEX_PROGRAM_ARB); - if (!_mesa_parse_arb_program(ctx, target, str, len, &ap)) { + if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, &ap)) { /* Error in the program. Just return. */ return; } diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index e56bf589fb..95d3e42ef7 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -1213,7 +1213,7 @@ Parse_PrintInstruction(struct parse_state *parseState, for (len = 0; str[len] != '\''; len++) /* find closing quote */ ; parseState->pos += len + 1; - msg = _mesa_malloc(len + 1); + msg = (GLubyte*) _mesa_malloc(len + 1); _mesa_memcpy(msg, str, len); msg[len] = 0; diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index fc44a49d4c..7aac631934 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -1048,7 +1048,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction * for (len = 0; str[len] != '\''; len++) /* find closing quote */ ; parseState->pos += len + 1; - msg = _mesa_malloc(len + 1); + msg = (GLubyte*) _mesa_malloc(len + 1); _mesa_memcpy(msg, str, len); msg[len] = 0; diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index c668ce8a5a..4e8dacea7e 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -369,7 +369,7 @@ add_parameter(struct program_parameter_list *paramList, paramList->Size * sizeof(struct program_parameter)); tmp = paramList->ParameterValues; - paramList->ParameterValues = ALIGN_MALLOC(paramList->Size * 4 * sizeof(GLfloat), 16); + paramList->ParameterValues = (GLfloat(*)[4]) ALIGN_MALLOC(paramList->Size * 4 * sizeof(GLfloat), 16); if (tmp) { _mesa_memcpy(paramList->ParameterValues, tmp, n * 4 * sizeof(GLfloat)); @@ -1153,17 +1153,17 @@ make_state_string(const GLint state[6]) char tmp[30]; append(str, "state."); - append_token(str, state[0]); + append_token(str, (enum state_index) state[0]); switch (state[0]) { case STATE_MATERIAL: append_face(str, state[1]); - append_token(str, state[2]); + append_token(str, (enum state_index) state[2]); break; case STATE_LIGHT: append(str, "light"); append_index(str, state[1]); /* light number [i]. */ - append_token(str, state[2]); /* coefficients */ + append_token(str, (enum state_index) state[2]); /* coefficients */ break; case STATE_LIGHTMODEL_AMBIENT: append(str, "lightmodel.ambient"); @@ -1179,11 +1179,11 @@ make_state_string(const GLint state[6]) case STATE_LIGHTPROD: append_index(str, state[1]); /* light number [i]. */ append_face(str, state[2]); - append_token(str, state[3]); + append_token(str, (enum state_index) state[3]); break; case STATE_TEXGEN: append_index(str, state[1]); /* tex unit [i] */ - append_token(str, state[2]); /* plane coef */ + append_token(str, (enum state_index) state[2]); /* plane coef */ break; case STATE_TEXENV_COLOR: append_index(str, state[1]); /* tex unit [i] */ @@ -1206,11 +1206,11 @@ make_state_string(const GLint state[6]) /* state[3] = first column to fetch */ /* state[4] = last column to fetch */ /* state[5] = transpose, inverse or invtrans */ - const enum state_index mat = state[1]; + const enum state_index mat = (enum state_index) state[1]; const GLuint index = (GLuint) state[2]; const GLuint first = (GLuint) state[3]; const GLuint last = (GLuint) state[4]; - const enum state_index modifier = state[5]; + const enum state_index modifier = (enum state_index) state[5]; append_token(str, mat); if (index) append_index(str, index); @@ -1229,7 +1229,7 @@ make_state_string(const GLint state[6]) case STATE_VERTEX_PROGRAM: /* state[1] = {STATE_ENV, STATE_LOCAL} */ /* state[2] = parameter index */ - append_token(str, state[1]); + append_token(str, (enum state_index) state[1]); append_index(str, state[2]); break; case STATE_INTERNAL: @@ -1523,7 +1523,7 @@ static void print_dst_reg(const struct prog_dst_register *dstReg) { _mesa_printf(" %s[%d]%s", - program_file_string(dstReg->File), + program_file_string((enum register_file) dstReg->File), dstReg->Index, writemask_string(dstReg->WriteMask)); } @@ -1532,7 +1532,7 @@ static void print_src_reg(const struct prog_src_register *srcReg) { _mesa_printf("%s[%d]%s", - program_file_string(srcReg->File), + program_file_string((enum register_file) srcReg->File), srcReg->Index, swizzle_string(srcReg->Swizzle, srcReg->NegateBase, GL_FALSE)); @@ -1551,7 +1551,7 @@ _mesa_print_instruction(const struct prog_instruction *inst) if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { _mesa_printf(", "); _mesa_printf("%s[%d]%s", - program_file_string(inst->SrcReg[0].File), + program_file_string((enum register_file) inst->SrcReg[0].File), inst->SrcReg[0].Index, swizzle_string(inst->SrcReg[0].Swizzle, inst->SrcReg[0].NegateBase, GL_FALSE)); @@ -1564,7 +1564,7 @@ _mesa_print_instruction(const struct prog_instruction *inst) _mesa_printf("_SAT"); print_dst_reg(&inst->DstReg); _mesa_printf("%s[%d], %s;\n", - program_file_string(inst->SrcReg[0].File), + program_file_string((enum register_file) inst->SrcReg[0].File), inst->SrcReg[0].Index, swizzle_string(inst->SrcReg[0].Swizzle, inst->SrcReg[0].NegateBase, GL_TRUE)); @@ -1611,7 +1611,7 @@ _mesa_print_instruction(const struct prog_instruction *inst) if (inst->DstReg.File != PROGRAM_UNDEFINED) { _mesa_printf(" %s[%d]%s", - program_file_string(inst->DstReg.File), + program_file_string((enum register_file) inst->DstReg.File), inst->DstReg.Index, writemask_string(inst->DstReg.WriteMask)); } diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 27a77b14af..8a2d08b58e 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -1136,7 +1136,7 @@ _swrast_depth_bounds_test( GLcontext *ctx, struct sw_span *span ) zbuffer = zbuffer16; } else { - zbuffer = rb->GetPointer(ctx, rb, span->x, span->y); + zbuffer = (GLushort*) rb->GetPointer(ctx, rb, span->x, span->y); if (!zbuffer) { rb->GetRow(ctx, rb, count, span->x, span->y, zbuffer16); zbuffer = zbuffer16; @@ -1163,7 +1163,7 @@ _swrast_depth_bounds_test( GLcontext *ctx, struct sw_span *span ) zbuffer = zbuffer32; } else { - zbuffer = rb->GetPointer(ctx, rb, span->x, span->y); + zbuffer = (GLuint*) rb->GetPointer(ctx, rb, span->x, span->y); if (!zbuffer) { rb->GetRow(ctx, rb, count, span->x, span->y, zbuffer32); zbuffer = zbuffer32; diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index effe4a6a52..1c78f848e1 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -426,7 +426,7 @@ stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face) } #endif - stencil = rb->GetPointer(ctx, rb, x, y); + stencil = (GLstencil *) rb->GetPointer(ctx, rb, x, y); if (!stencil) { rb->GetRow(ctx, rb, n, x, y, stencilRow); stencil = stencilRow; @@ -1173,7 +1173,7 @@ _swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) if (rb->DataType == GL_UNSIGNED_BYTE) { GLint i, j; for (i = 0; i < height; i++) { - GLubyte *stencil = rb->GetPointer(ctx, rb, x, y + i); + GLubyte *stencil = (GLubyte*) rb->GetPointer(ctx, rb, x, y + i); for (j = 0; j < width; j++) { stencil[j] = (stencil[j] & invMask) | clearVal; } @@ -1182,7 +1182,7 @@ _swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) else { GLint i, j; for (i = 0; i < height; i++) { - GLushort *stencil = rb->GetPointer(ctx, rb, x, y + i); + GLushort *stencil = (GLushort*) rb->GetPointer(ctx, rb, x, y + i); for (j = 0; j < width; j++) { stencil[j] = (stencil[j] & invMask) | clearVal; } @@ -1194,7 +1194,7 @@ _swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) if (width == rb->Width && rb->DataType == GL_UNSIGNED_BYTE) { /* optimized case */ /* Note: bottom-to-top raster assumed! */ - GLubyte *stencil = rb->GetPointer(ctx, rb, x, y); + GLubyte *stencil = (GLubyte *) rb->GetPointer(ctx, rb, x, y); GLuint len = width * height * sizeof(GLubyte); _mesa_memset(stencil, clearVal, len); } @@ -1207,7 +1207,7 @@ _swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) _mesa_memset(stencil, clearVal, width); } else { - _mesa_memset16(stencil, clearVal, width); + _mesa_memset16((short unsigned int*) stencil, clearVal, width); } } } diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 30b2947323..d9777bfe6d 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -87,11 +87,11 @@ _tnl_CreateContext( GLcontext *ctx ) _tnl_vtx_init( ctx ); if (ctx->_MaintainTnlProgram) { - tnl->vp_cache = MALLOC(sizeof(*tnl->vp_cache)); + tnl->vp_cache = (struct tnl_cache *) MALLOC(sizeof(*tnl->vp_cache)); tnl->vp_cache->size = 5; tnl->vp_cache->n_items = 0; - tnl->vp_cache->items = MALLOC(tnl->vp_cache->size * - sizeof(*tnl->vp_cache->items)); + tnl->vp_cache->items = (struct tnl_cache_item**) + _mesa_malloc(tnl->vp_cache->size * sizeof(*tnl->vp_cache->items)); _mesa_memset(tnl->vp_cache->items, 0, tnl->vp_cache->size * sizeof(*tnl->vp_cache->items)); diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index da225b518e..753f59257a 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -563,7 +563,7 @@ struct tnl_clipspace_fastpath { GLuint attr_count; GLboolean match_strides; - struct { + struct attr_type { GLuint format; GLuint size; GLuint stride; diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 4aa2e80d55..38182c1ba1 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -582,11 +582,11 @@ static void print_RSW( union instruction op ) static void print_ALU( union instruction op ) { - _mesa_printf("%s ", _mesa_opcode_string(op.alu.opcode)); + _mesa_printf("%s ", _mesa_opcode_string((enum prog_opcode) op.alu.opcode)); print_reg(0, op.alu.dst); _mesa_printf(", "); print_reg(op.alu.file0, op.alu.idx0); - if (_mesa_num_inst_src_regs(op.alu.opcode) > 1) { + if (_mesa_num_inst_src_regs((enum prog_opcode) op.alu.opcode) > 1) { _mesa_printf(", "); print_reg(op.alu.file1, op.alu.idx1); } @@ -1082,7 +1082,7 @@ static void cvp_emit_inst( struct compilation *cp, static void free_tnl_data( struct vertex_program *program ) { - struct tnl_compiled_program *p = program->TnlData; + struct tnl_compiled_program *p = (struct tnl_compiled_program *) program->TnlData; if (p->compiled_func) _mesa_free((void *)p->compiled_func); _mesa_free(p); @@ -1460,7 +1460,7 @@ static GLboolean init_vertex_program( GLcontext *ctx, */ m->VB = VB; - m->File[0] = ALIGN_MALLOC(REG_MAX * sizeof(GLfloat) * 4, 16); + m->File[0] = (GLfloat(*)[4])ALIGN_MALLOC(REG_MAX * sizeof(GLfloat) * 4, 16); /* Initialize regs where necessary: */ diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index ca3aad1404..b532a20142 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -87,7 +87,8 @@ void _tnl_register_fastpath( struct tnl_clipspace *vtx, fastpath->attr_count = vtx->attr_count; fastpath->match_strides = match_strides; fastpath->func = vtx->emit; - fastpath->attr = MALLOC(vtx->attr_count * sizeof(fastpath->attr[0])); + fastpath->attr = (struct attr_type *) + _mesa_malloc(vtx->attr_count * sizeof(fastpath->attr[0])); for (i = 0; i < vtx->attr_count; i++) { fastpath->attr[i].format = vtx->attr[i].format; @@ -425,7 +426,7 @@ void *_tnl_emit_vertices_to_buffer( GLcontext *ctx, /* Note: dest should not be adjusted for non-zero 'start' values: */ - vtx->emit( ctx, end - start, dest ); + vtx->emit( ctx, end - start, (GLubyte*) dest ); return (void *)((GLubyte *)dest + vtx->vertex_size * (end - start)); } diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 77e105115c..7e28bbbc3c 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -514,7 +514,7 @@ static void emit_op3fn(struct tnl_program *p, return; } - inst->Opcode = op; + inst->Opcode = (enum prog_opcode) op; inst->StringPos = 0; inst->Data = 0; @@ -1406,7 +1406,7 @@ create_new_program( const struct state_key *key, p.temp_reserved = ~((1<<max_temps)-1); p.program->Base.Instructions - = MALLOC(sizeof(struct prog_instruction) * MAX_INSN); + = (struct prog_instruction*) MALLOC(sizeof(struct prog_instruction) * MAX_INSN); p.program->Base.String = 0; p.program->Base.NumInstructions = p.program->Base.NumTemporaries = @@ -1441,7 +1441,7 @@ static void rehash( struct tnl_cache *cache ) GLuint size, i; size = cache->size * 3; - items = MALLOC(size * sizeof(*items)); + items = (struct tnl_cache_item**) _mesa_malloc(size * sizeof(*items)); _mesa_memset(items, 0, size * sizeof(*items)); for (i = 0; i < cache->size; i++) @@ -1461,7 +1461,7 @@ static void cache_item( struct tnl_cache *cache, void *key, void *data ) { - struct tnl_cache_item *c = MALLOC(sizeof(*c)); + struct tnl_cache_item *c = (struct tnl_cache_item*) _mesa_malloc(sizeof(*c)); c->hash = hash; c->key = key; c->data = data; |