Skip to content

Commit 1a958b1

Browse files
committedJun 13, 2023
Fix issues uncovered by newer version of GCC
1 parent c7451ac commit 1a958b1

19 files changed

+50
-39
lines changed
 

‎am_main.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,7 @@ static void AM_Drawer_ (int c)
649649
{
650650
int* p = (int*)(fb + 320 * ((miny + 1)&~1));
651651
int* p_end = (int*)(fb + 320 * ((maxy + 1) & ~1));
652-
while (p < p_end)
653-
*p++ = 0;
652+
D_memset(p, 0, (p_end-p)*sizeof(*p));
654653
}
655654

656655
for (i=0 ; i<numlines ; i++,line++)

‎comnnew.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ char* D_strchr(const char* str, char chr)
8181

8282
int mystrlen(const char* string)
8383
{
84-
int rc = 0;
84+
volatile int rc = 0;
8585

8686
while (*(string++))
8787
rc++;

‎doomdef.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ typedef struct mobj_s
254254
} mobj_t
255255
;
256256

257-
typedef struct
257+
typedef struct degenmobj_s
258258
{
259259
fixed_t x, y, z;
260-
struct mobj_s* prev, * next;
260+
void *prev, *next;
261261
} degenmobj_t
262262
;
263263

‎in_main.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,15 @@ void IN_Start (void)
338338
else if (gamemapinfo.next)
339339
G_FindMapinfo(gamemapinfo.next, interm->nextmapinfo, NULL);
340340

341+
D_memset(interm->killvalue, 0, sizeof(*interm->killvalue)*MAXPLAYERS);
342+
D_memset(interm->itemvalue, 0, sizeof(*interm->itemvalue)*MAXPLAYERS);
343+
D_memset(interm->secretvalue, 0, sizeof(*interm->secretvalue)*MAXPLAYERS);
344+
D_memset(interm->fragvalue, 0, sizeof(*interm->fragvalue)*MAXPLAYERS);
345+
341346
for (i = 0; i < MAXPLAYERS; i++)
342347
{
343348
pstats_t *pstats = interm->pstats;
344349

345-
interm->killvalue[i] = interm->itemvalue[i] = interm->secretvalue[i] = interm->fragvalue[i] = 0;
346350
if (totalkills)
347351
pstats[i].killpercent = (players[i].killcount * 100) / totalkills;
348352
else

‎mars.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ enum
5454
MARS_SECCMD_NUMCMDS
5555
};
5656

57-
void Mars_Secondary(void) ATTR_DATA_CACHE_ALIGN;
57+
void Mars_Secondary(void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
5858

5959
void Mars_Sec_R_Setup(void) ATTR_DATA_CACHE_ALIGN;
6060
void Mars_Sec_R_WallPrep(void) ATTR_DATA_CACHE_ALIGN;

‎p_local.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage);
134134
void P_SpawnMissile (mobj_t *source, mobj_t *dest, mobjtype_t type);
135135
void P_SpawnPlayerMissile (mobj_t *source, mobjtype_t type);
136136

137-
void P_RunMobjBase2 (void) ATTR_DATA_CACHE_ALIGN;
137+
void P_RunMobjBase2 (void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
138138
void P_RunMobjLate(void) ATTR_DATA_CACHE_ALIGN;
139139

140140
void L_SkullBash (mobj_t *mo);

‎p_map.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef struct
2121

2222
static fixed_t P_InterceptVector(divline_t* v2, divline_t* v1) ATTR_DATA_CACHE_ALIGN;
2323
boolean PIT_UseLines(line_t* li, plineuse_t *lu) ATTR_DATA_CACHE_ALIGN;
24-
void P_UseLines(player_t* player) ATTR_DATA_CACHE_ALIGN;
24+
void P_UseLines(player_t* player) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
2525
boolean PIT_RadiusAttack(mobj_t* thing, pradiusattack_t *ra) ATTR_DATA_CACHE_ALIGN;
2626
void P_RadiusAttack(mobj_t* spot, mobj_t* source, int damage) ATTR_DATA_CACHE_ALIGN;
2727
fixed_t P_AimLineAttack(lineattack_t *la, mobj_t* t1, angle_t angle, fixed_t distance) ATTR_DATA_CACHE_ALIGN;

‎p_mobj.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ int iquehead, iquetail;
1717
=
1818
===============
1919
*/
20-
static void P_AddMobjToList (mobj_t *mobj, mobj_t *head)
20+
static void P_AddMobjToList (mobj_t *mobj_, mobj_t *head_)
2121
{
22-
head->prev->next = mobj;
22+
degenmobj_t *mobj = (void*)mobj_, *head = (void *)head_;
23+
((degenmobj_t *)head->prev)->next = mobj;
2324
mobj->next = head;
2425
mobj->prev = head->prev;
2526
head->prev = mobj;
2627
}
2728

28-
static void P_RemoveMobjFromCurrList (mobj_t *mobj)
29+
static void P_RemoveMobjFromCurrList (mobj_t *mobj_)
2930
{
30-
mobj->next->prev = mobj->prev;
31-
mobj->prev->next = mobj->next;
31+
degenmobj_t *mobj = (void*)mobj_;
32+
((degenmobj_t *)mobj->next)->prev = mobj->prev;
33+
((degenmobj_t *)mobj->prev)->next = mobj->next;
3234
}
3335

3436
/*

‎p_sight.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static boolean PS_CrossBSPNode(sightWork_t* sw, int bspnum) ATTR_DATA_CACHE_ALIG
4646
static boolean PS_RejectCheckSight(mobj_t* t1, mobj_t* t2) ATTR_DATA_CACHE_ALIGN;
4747
static boolean P_MobjCanSightCheck(mobj_t *mobj) ATTR_DATA_CACHE_ALIGN;
4848
static boolean PS_CheckSight2(mobj_t* t1, mobj_t* t2) ATTR_DATA_CACHE_ALIGN;
49-
void P_CheckSights2(void) ATTR_DATA_CACHE_ALIGN;
49+
void P_CheckSights2(void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
5050

5151
//
5252
// Returns side 0 (front), 1 (back), or 2 (on).

‎p_spec.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -891,10 +891,14 @@ int EV_DoDonut(line_t *line)
891891
rtn = 1;
892892
line = lines + s1->lines[0];
893893
s2 = getNextSector(line,s1);
894+
if (!s2)
895+
continue;
894896
for (i = 0;i < s2->linecount;i++)
895897
{
896898
line = lines + s2->lines[i];
897899
s3 = LD_BACKSECTOR(line);
900+
if (!s3)
901+
continue;
898902
if (!(line->flags & ML_TWOSIDED) ||
899903
(s3 == s1))
900904
continue;
@@ -1024,10 +1028,8 @@ void P_SpawnSpecials (void)
10241028
/* */
10251029
/* Init other misc stuff */
10261030
/* */
1027-
for (i = 0;i < MAXCEILINGS;i++)
1028-
activeceilings[i] = NULL;
1029-
for (i = 0;i < MAXPLATS;i++)
1030-
activeplats[i] = NULL;
1031+
D_memset(activeceilings, 0, sizeof(*activeceilings)*MAXCEILINGS);
1032+
D_memset(activeplats, 0, sizeof(*activeplats)*MAXCEILINGS);
10311033
for (i = 0;i < MAXBUTTONS;i++)
10321034
D_memset(&buttonlist[i],0,sizeof(button_t));
10331035
}

‎r_main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ void R_BSP (void) __attribute__((noinline));
844844
void R_WallPrep (void) __attribute__((noinline));
845845
void R_SpritePrep (void) __attribute__((noinline));
846846
boolean R_LatePrep (void) __attribute__((noinline));
847-
void R_Cache (void); __attribute__((noinline))
847+
void R_Cache (void) __attribute__((noinline));
848848
void R_SegCommands (void) __attribute__((noinline));
849849
void R_DrawPlanes (void) __attribute__((noinline));
850850
void R_Sprites (void) __attribute__((noinline));

‎r_phase1.c

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ static boolean R_CheckBBox(rbspWork_t *rbsp, fixed_t bspcoord[4]) ATTR_DATA_CACH
3636
static void R_Subsector(rbspWork_t *rbsp, int num) ATTR_DATA_CACHE_ALIGN;
3737
static void R_StoreWallRange(rbspWork_t *rbsp, int start, int stop) ATTR_DATA_CACHE_ALIGN;
3838
static void R_RenderBSPNode(rbspWork_t *rbsp, int bspnum) ATTR_DATA_CACHE_ALIGN;
39-
void R_BSP(void) ATTR_DATA_CACHE_ALIGN;
4039

4140
void R_WallEarlyPrep(viswall_t* segl, fixed_t *floorheight,
4241
fixed_t *floornewheight, fixed_t *ceilingnewheight);

‎r_phase2.c

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static void R_SetupCalc(viswall_t* wc, fixed_t hyp, angle_t normalangle, int ang
1818
void R_WallLatePrep(viswall_t* wc, vertex_t *verts) ATTR_DATA_CACHE_ALIGN;
1919
static void R_SegLoop(viswall_t* segl, unsigned short* clipbounds, fixed_t floorheight,
2020
fixed_t floornewheight, fixed_t ceilingnewheight) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
21+
void R_WallPrep(void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
2122

2223
void R_WallEarlyPrep(viswall_t* segl, fixed_t *floorheight,
2324
fixed_t *floornewheight, fixed_t *ceilingnewheight)

‎r_phase3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
static void R_PrepMobj(mobj_t* thing) ATTR_DATA_CACHE_ALIGN;
1111
static void R_PrepPSprite(pspdef_t* psp) ATTR_DATA_CACHE_ALIGN;
12-
void R_SpritePrep(void) ATTR_DATA_CACHE_ALIGN;
12+
void R_SpritePrep(void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
1313

1414
//
1515
// Project vissprite for potentially visible actor

‎r_phase6.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void R_DrawSeg(seglocal_t* lseg, unsigned short *clipbounds) ATTR_DATA_CA
4848

4949
static void R_LockSeg(void) ATTR_DATA_CACHE_ALIGN;
5050
static void R_UnlockSeg(void) ATTR_DATA_CACHE_ALIGN;
51-
void R_SegCommands(void) ATTR_DATA_CACHE_ALIGN;
51+
void R_SegCommands(void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
5252

5353
//
5454
// Render a wall texture as columns

‎r_phase7.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void R_UnlockPln(void) ATTR_DATA_CACHE_ALIGN;
4747
static visplane_t* R_GetNextPlane(uint16_t *sortedvisplanes) ATTR_DATA_CACHE_ALIGN;
4848

4949
void R_PreDrawPlanes(void) ATTR_DATA_CACHE_ALIGN;
50-
void R_DrawPlanes(void) ATTR_DATA_CACHE_ALIGN;
50+
void R_DrawPlanes(void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
5151

5252
static char pl_lock = 0;
5353
#ifdef MARS

‎r_phase8.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void R_DrawVisSprite(vissprite_t* vis, unsigned short* spropening, int *fuzzpos,
1717
void R_ClipVisSprite(vissprite_t *vis, unsigned short *spropening, int sprscreenhalf, int16_t *walls) ATTR_DATA_CACHE_ALIGN;
1818
static void R_DrawSortedSprites(int *fuzzpos, int* sortedsprites, int sprscreenhalf) ATTR_DATA_CACHE_ALIGN;
1919
static void R_DrawPSprites(int *fuzzpos, int sprscreenhalf) ATTR_DATA_CACHE_ALIGN;
20-
void R_Sprites(void) ATTR_DATA_CACHE_ALIGN;
20+
void R_Sprites(void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline));
2121

2222
void R_DrawVisSprite(vissprite_t *vis, unsigned short *spropening, int *fuzzpos, int sprscreenhalf)
2323
{

‎st_main.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,15 @@ void ST_InitEveryLevel(void)
104104
for (i = 0; i < MAXPLAYERS; i++)
105105
numplayers += playeringame[i] ? 1 : 0;
106106

107+
D_memset(stbar, 0, sizeof(stbar[0])*MAXPLAYERS);
108+
107109
for (p = 0; p < numplayers; p++)
108110
{
109111
stbar_t* sb = &stbar[p];
110112

111113
/* force everything to be updated on next ST_Update */
112114
sb->forcedraw = true;
113115
sb->drawface = -1;
114-
sb->facetics = 0;
115-
116-
sb->numstbarcmds = 0;
117116

118117
/* DRAW FRAG COUNTS INITIALLY */
119118
{
@@ -131,18 +130,11 @@ void ST_InitEveryLevel(void)
131130
sb->yourFragsCount = players[p].frags;
132131
sb->hisFragsCount = players[!p].frags;
133132
}
134-
135-
sb->gotgibbed = false;
136-
sb->gibdraw = false; /* DON'T DRAW GIBBED HEAD SEQUENCE */
137-
sb->gibframe = 0;
138133
sb->gibdelay = GIBTIME;
139-
sb->doSpclFace = false;
140134
sb->specialFace = f_none;
141135

142136
for (i = 0; i < NUMCARDS; i++)
143137
{
144-
sb->tryopen[i] = false;
145-
sb->flashCards[i].active = false;
146138
sb->flashCards[i].x = KEYX + (i > 2 ? 3 : 0);
147139
sb->flashCards[i].y = card_y[i];
148140
sb->flashCards[i].w = KEYW;

‎vsprintf.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,14 @@ int D_vsnprintf(char* string, size_t nmax, const char* format, va_list argptr)
8181
{
8282
str = (char*)va_arg(argptr, int);
8383
len = mystrlen(str);
84-
while (fieldsize-- > len) *(string++) = padchar; /* do field pad */
85-
while (*str) *(string++) = *(str++); /* copy string */
84+
while (fieldsize-- > len) {
85+
__asm volatile("");
86+
*(string++) = padchar; /* do field pad */
87+
}
88+
while (*str) {
89+
__asm volatile("");
90+
*(string++) = *(str++); /* copy string */
91+
}
8692
format++;
8793
}
8894
else
@@ -126,8 +132,14 @@ int D_vsnprintf(char* string, size_t nmax, const char* format, va_list argptr)
126132
len = 0;
127133
while (num || fieldsize || !len)
128134
{
129-
for (i = len; i; i--) string[i] = string[i - 1]; /* shift right */
130-
if (len && fieldsize && !num) *string = padchar; /* pad out */
135+
for (i = len; i; i--) {
136+
__asm volatile("");
137+
string[i] = string[i - 1]; /* shift right */
138+
}
139+
if (len && fieldsize && !num) {
140+
__asm volatile("");
141+
*string = padchar; /* pad out */
142+
}
131143
else
132144
{
133145
/* put in a hex or decimal digit */

0 commit comments

Comments
 (0)
Please sign in to comment.