From fe95805d860201f2cb8abfa990f2cb41216c786a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 19 Jul 2008 05:40:57 +0000 Subject: [PATCH] various gcc 4.3 fixes --- libs/gamecode/engine/pr_strings.c | 2 +- libs/net/nm/net_vcr.c | 13 +++++++++---- libs/video/renderer/gl/gl_lightmap.c | 4 ++-- libs/video/renderer/gl/gl_mod_alias.c | 4 ++-- libs/video/renderer/gl/gl_skin.c | 4 ++-- libs/video/targets/fbset_modes_l.l | 3 ++- libs/video/targets/vid_fbdev.c | 6 +++++- tools/bsp2img/bsp2img.c | 3 ++- tools/qfbsp/source/map.c | 2 +- tools/qfbsp/source/region.c | 4 ++-- tools/qfcc/source/expr.c | 2 +- tools/qfcc/source/qc-lex.l | 5 +++-- tools/qfmodelgen/source/trilib.c | 8 ++++---- 13 files changed, 36 insertions(+), 24 deletions(-) diff --git a/libs/gamecode/engine/pr_strings.c b/libs/gamecode/engine/pr_strings.c index cc03087ff..57d8c0293 100644 --- a/libs/gamecode/engine/pr_strings.c +++ b/libs/gamecode/engine/pr_strings.c @@ -340,7 +340,7 @@ PR_SetString (progs_t *pr, const char *s) s = ""; sr = Hash_Find (pr->strref_hash, s); - if (!sr) { + if (__builtin_expect (!sr, 1)) { sr = new_string_ref (pr); sr->type = str_static; sr->s.string = pr_strdup(pr, s); diff --git a/libs/net/nm/net_vcr.c b/libs/net/nm/net_vcr.c index 9eebb9edc..4fb42f24f 100644 --- a/libs/net/nm/net_vcr.c +++ b/libs/net/nm/net_vcr.c @@ -97,9 +97,10 @@ int VCR_GetMessage (qsocket_t * sock) { int ret; + long *driverdata = (long *) &sock->driverdata; if (host_time != next.time || next.op != VCR_OP_GETMESSAGE - || next.session != *(long *) (char *) (&sock->driverdata)) + || next.session != *driverdata) Sys_Error ("VCR missmatch"); Qread (vcrFile, &ret, sizeof (int)); @@ -124,9 +125,10 @@ int VCR_SendMessage (qsocket_t * sock, sizebuf_t *data) { int ret; + long *driverdata = (long *) &sock->driverdata; if (host_time != next.time || next.op != VCR_OP_SENDMESSAGE - || next.session != *(long *) (char *) (&sock->driverdata)) + || next.session != *driverdata) Sys_Error ("VCR missmatch"); Qread (vcrFile, &ret, sizeof (int)); @@ -141,9 +143,10 @@ qboolean VCR_CanSendMessage (qsocket_t * sock) { qboolean ret; + long *driverdata = (long *) &sock->driverdata; if (host_time != next.time || next.op != VCR_OP_CANSENDMESSAGE - || next.session != *(long *) (char *) (&sock->driverdata)) + || next.session != *driverdata) Sys_Error ("VCR missmatch"); Qread (vcrFile, &ret, sizeof (int)); @@ -177,6 +180,7 @@ qsocket_t * VCR_CheckNewConnections (void) { qsocket_t *sock; + long *driverdata; if (host_time != next.time || next.op != VCR_OP_CONNECT) Sys_Error ("VCR missmatch"); @@ -187,7 +191,8 @@ VCR_CheckNewConnections (void) } sock = NET_NewQSocket (); - *(long *) (char *) (&sock->driverdata) = next.session; + driverdata = (long *) &sock->driverdata; + *driverdata = next.session; Qread (vcrFile, sock->address, NET_NAMELEN); VCR_ReadNext (); diff --git a/libs/video/renderer/gl/gl_lightmap.c b/libs/video/renderer/gl/gl_lightmap.c index dcb2803f0..a2304e837 100644 --- a/libs/video/renderer/gl/gl_lightmap.c +++ b/libs/video/renderer/gl/gl_lightmap.c @@ -92,7 +92,7 @@ gl_lightmap_init (void) for (s = 1; s < 8192; s++) dlightdivtable[s] = 1048576 / (s << 7); } - +/* static void R_RecursiveLightUpdate (mnode_t *node) { @@ -108,7 +108,7 @@ R_RecursiveLightUpdate (mnode_t *node) c--, surf++) surf->cached_dlight = true; } - +*/ static inline void R_AddDynamicLights_1 (msurface_t *surf) { diff --git a/libs/video/renderer/gl/gl_mod_alias.c b/libs/video/renderer/gl/gl_mod_alias.c index f1cf89048..89f6afa1d 100644 --- a/libs/video/renderer/gl/gl_mod_alias.c +++ b/libs/video/renderer/gl/gl_mod_alias.c @@ -90,7 +90,7 @@ float r_avertexnormal_dots[SHADEDOT_QUANT][256] = { vec3_t shadevector; -static inline void +static void GL_DrawAliasFrameTri (vert_order_t *vo) { int count = vo->count; @@ -133,7 +133,7 @@ GL_DrawAliasFrameTriMulti (vert_order_t *vo) qfglEnd (); } -static inline void +static void GL_DrawAliasFrame (vert_order_t *vo) { int count; diff --git a/libs/video/renderer/gl/gl_skin.c b/libs/video/renderer/gl/gl_skin.c index 81d78f61e..174d49549 100644 --- a/libs/video/renderer/gl/gl_skin.c +++ b/libs/video/renderer/gl/gl_skin.c @@ -94,7 +94,7 @@ Skin_Set_Translate (int top, int bottom, void *_dest) } } -static inline void +static void build_skin_8 (byte * original, int tinwidth, int tinheight, unsigned int scaled_width, unsigned int scaled_height, int inwidth, qboolean alpha) @@ -121,7 +121,7 @@ build_skin_8 (byte * original, int tinwidth, int tinheight, alpha); } -static inline void +static void build_skin_32 (byte * original, int tinwidth, int tinheight, unsigned int scaled_width, unsigned int scaled_height, int inwidth, qboolean alpha) diff --git a/libs/video/targets/fbset_modes_l.l b/libs/video/targets/fbset_modes_l.l index f59ce7321..be70aa48c 100644 --- a/libs/video/targets/fbset_modes_l.l +++ b/libs/video/targets/fbset_modes_l.l @@ -159,5 +159,6 @@ junk . #ifdef YY_FLEX_REALLOC_HACK #else -static __attribute__ ((unused)) void (*yyunput_hack)(int, char*) = yyunput; +static __attribute__ ((used)) void (*yyunput_hack)(int, char*) = yyunput; +static __attribute__ ((used)) int (*input_hack)(void) = input; #endif diff --git a/libs/video/targets/vid_fbdev.c b/libs/video/targets/vid_fbdev.c index 87c79541e..33e366f1b 100644 --- a/libs/video/targets/vid_fbdev.c +++ b/libs/video/targets/vid_fbdev.c @@ -58,7 +58,6 @@ static __attribute__ ((used)) const char rcsid[] = #include #include #include -#include #include #include #include @@ -77,6 +76,11 @@ static __attribute__ ((used)) const char rcsid[] = #include "d_iface.h" #include "fbset.h" +#ifndef PAGE_SIZE +# define PAGE_SIZE (sysconf(_SC_PAGESIZE)) +# define PAGE_MASK (~(PAGE_SIZE-1)) +#endif + static struct VideoMode current_mode; static char current_name[32]; static int num_modes; diff --git a/tools/bsp2img/bsp2img.c b/tools/bsp2img/bsp2img.c index 9fb61617c..a72ed18bf 100644 --- a/tools/bsp2img/bsp2img.c +++ b/tools/bsp2img/bsp2img.c @@ -149,7 +149,8 @@ plotpoint (image_t *image, long xco, long yco, unsigned int color) { unsigned int bigcol = 0; - if (xco < 0 || xco > image->width || yco < 0 || yco > image->height) + if (image->width < 0 || image->height < 0 + || xco < 0 || xco > image->width || yco < 0 || yco > image->height) return; bigcol = (unsigned int) image->image[yco * image->width + xco]; diff --git a/tools/qfbsp/source/map.c b/tools/qfbsp/source/map.c index 4aefa434c..be3d1a9ac 100644 --- a/tools/qfbsp/source/map.c +++ b/tools/qfbsp/source/map.c @@ -116,7 +116,7 @@ FindTexinfo (texinfo_t *t) continue; for (j = 0; j < 8; j++) - if (t->vecs[0][j] != tex->vecs[0][j]) + if (t->vecs[j / 4][j % 4] != tex->vecs[j / 4][j % 4]) break; if (j != 8) continue; diff --git a/tools/qfbsp/source/region.c b/tools/qfbsp/source/region.c index e7d2ce4a6..82b9f5e7a 100644 --- a/tools/qfbsp/source/region.c +++ b/tools/qfbsp/source/region.c @@ -55,7 +55,7 @@ face to region mapping numbers int firstedge; vec3_t region_mins, region_maxs; - +/* static void AddPointToRegion (vec3_t p) { @@ -157,7 +157,7 @@ RecursiveGrowRegion (dface_t *r, face_t *f) } } - +*/ int edgemapping[MAX_MAP_EDGES]; typedef struct { diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 3752e27b1..503bb040a 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -2319,7 +2319,7 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t) return e; } -static inline int +static int is_indirect (expr_t *e) { if (e->type == ex_expr && e->e.expr.op == '.') diff --git a/tools/qfcc/source/qc-lex.l b/tools/qfcc/source/qc-lex.l index afb3ac527..f0ef60de6 100644 --- a/tools/qfcc/source/qc-lex.l +++ b/tools/qfcc/source/qc-lex.l @@ -695,7 +695,8 @@ line_info (char *text) } #ifdef YY_FLEX_REALLOC_HACK -static __attribute__ ((unused)) void *(*const yy_flex_realloc_hack)(void *,yy_size_t) = yy_flex_realloc; +static __attribute__ ((used)) void *(*const yy_flex_realloc_hack)(void *,yy_size_t) = yy_flex_realloc; #else -static __attribute__ ((unused)) void (*yyunput_hack)(int, char*) = yyunput; +static __attribute__ ((used)) void (*yyunput_hack)(int, char*) = yyunput; +static __attribute__ ((used)) int (*input_hack)(void) = input; #endif diff --git a/tools/qfmodelgen/source/trilib.c b/tools/qfmodelgen/source/trilib.c index 1527bf372..7c9bc28ec 100644 --- a/tools/qfmodelgen/source/trilib.c +++ b/tools/qfmodelgen/source/trilib.c @@ -74,8 +74,8 @@ LoadTriangleList (char *filename, triangle_t **pptri, int *numtriangles) { QFile *input; char name[256], tex[256]; - float start, t; - int count, exitpattern, iLevel, magic, i; + float start, exitpattern, t; + int count, iLevel, magic, i; tf_triangle tri; triangle_t *ptri; @@ -105,8 +105,8 @@ LoadTriangleList (char *filename, triangle_t **pptri, int *numtriangles) while (Qeof(input) == 0) { Qread(input, &start, sizeof (float)); - *(int *) (char *) &start = BigLong (*(int *) (char *) &start); - if (*(int *) (char *) &start != exitpattern) { + start = BigFloat (start); + if (start != exitpattern) { if (start == FLOAT_START) { // Start of an object or group of objects. i = -1;