Skip to content

Commit 62617b3

Browse files
committed
Merge branch 'int_to_int32_t'
2 parents f19f7ef + 7e4ab5e commit 62617b3

17 files changed

+68
-50
lines changed

linuxdoom-1.10/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#
77
CC= gcc # gcc or g++
88

9-
CFLAGS=-ansi -g -Wall -DNORMALUNIX -DLINUX -I/opt/homebrew/opt/libx11/include/ -I/opt/homebrew/opt/xorgproto/include/ -I/opt/homebrew/opt/libxext/include/ # -DUSEASM
10-
LDFLAGS=-L/opt/homebrew/opt/libx11/lib -L/opt/homebrew/opt/libxcomposite/lib -L/opt/homebrew/opt/libxext/lib
9+
CFLAGS=-ansi -g -Wall -DNORMALUNIX -DLINUX -I/opt/X11/include -include stdint.h # -DUSEASM
10+
LDFLAGS=-L/usr/X11R6/lib
1111
LIBS=-lXext -lX11 -lm
1212

1313
# subdirectory for objects

linuxdoom-1.10/d_net.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ typedef struct
7979
typedef struct
8080
{
8181
// Supposed to be DOOMCOM_ID?
82-
long id;
82+
int32_t id;
8383

8484
// DOOM executes an int to execute commands.
8585
short intnum;

linuxdoom-1.10/doom.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pushd linux || exit
2+
xephyr :2 -ac -screen 320x200x8 &
3+
sleep 2
4+
./linuxxdoom -disp :2
5+
popd

linuxdoom-1.10/doomtype.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ typedef unsigned char byte;
4747

4848
// Max pos 32-bit int.
4949
#define MAXINT ((int)0x7fffffff)
50-
#define MAXLONG ((long)0x7fffffff)
50+
#define MAXLONG ((int32_t)0x7fffffff)
5151
#define MINCHAR ((char)0x80)
5252
#define MINSHORT ((short)0x8000)
5353

5454
// Max negative 32-bit integer.
5555
#define MININT ((int)0x80000000)
56-
#define MINLONG ((long)0x80000000)
56+
#define MINLONG ((int32_t)0x80000000)
5757
#endif
5858

5959

linuxdoom-1.10/i_net.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";
5353

5454
// For some odd reason...
5555
#define ntohl(x) \
56-
((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
57-
(((unsigned long int)(x) & 0x0000ff00U) << 8) | \
58-
(((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
59-
(((unsigned long int)(x) & 0xff000000U) >> 24)))
56+
((uint32_t)((((uint32_t)(x) & 0x000000ffU) << 24) | \
57+
(((uint32_t)(x) & 0x0000ff00U) << 8) | \
58+
(((uint32_t)(x) & 0x00ff0000U) >> 8) | \
59+
(((uint32_t)(x) & 0xff000000U) >> 24)))
6060

6161
#define ntohs(x) \
6262
((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \

linuxdoom-1.10/i_video.c

+12-10
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ void grabsharedmemory(int size)
686686
image->data = X_shminfo.shmaddr = shmat(id, 0, 0);
687687

688688
fprintf(stderr, "shared memory id=%d, addr=0x%x\n", id,
689-
(int) (image->data));
689+
(uintptr_t) (image->data));
690690
}
691691

692692
void I_InitGraphics(void)
@@ -704,7 +704,7 @@ void I_InitGraphics(void)
704704
char ysign=' ';
705705

706706
int oktodraw;
707-
unsigned long attribmask;
707+
uint32_t attribmask;
708708
XSetWindowAttributes attribs;
709709
XGCValues xgcvalues;
710710
int valuemask;
@@ -794,6 +794,8 @@ void I_InitGraphics(void)
794794
X_cmap = XCreateColormap(X_display, RootWindow(X_display,
795795
X_screen), X_visual, AllocAll);
796796

797+
XInstallColormap(X_display, X_cmap);
798+
797799
// setup attributes for main window
798800
attribmask = CWEventMask | CWColormap | CWBorderPixel;
799801
attribs.event_mask =
@@ -987,55 +989,55 @@ Expand4
987989
{
988990
fourpixels = lineptr[0];
989991

990-
dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) );
992+
dpixel = *(double *)( (uintptr_t)exp + ( (fourpixels&0xffff0000)>>13) );
991993
xline[0] = dpixel;
992994
xline[160] = dpixel;
993995
xline[320] = dpixel;
994996
xline[480] = dpixel;
995997

996-
dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) );
998+
dpixel = *(double *)( (uintptr_t)exp + ( (fourpixels&0xffff)<<3 ) );
997999
xline[1] = dpixel;
9981000
xline[161] = dpixel;
9991001
xline[321] = dpixel;
10001002
xline[481] = dpixel;
10011003

10021004
fourpixels = lineptr[1];
10031005

1004-
dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) );
1006+
dpixel = *(double *)( (uintptr_t)exp + ( (fourpixels&0xffff0000)>>13) );
10051007
xline[2] = dpixel;
10061008
xline[162] = dpixel;
10071009
xline[322] = dpixel;
10081010
xline[482] = dpixel;
10091011

1010-
dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) );
1012+
dpixel = *(double *)( (uintptr_t)exp + ( (fourpixels&0xffff)<<3 ) );
10111013
xline[3] = dpixel;
10121014
xline[163] = dpixel;
10131015
xline[323] = dpixel;
10141016
xline[483] = dpixel;
10151017

10161018
fourpixels = lineptr[2];
10171019

1018-
dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) );
1020+
dpixel = *(double *)( (uintptr_t)exp + ( (fourpixels&0xffff0000)>>13) );
10191021
xline[4] = dpixel;
10201022
xline[164] = dpixel;
10211023
xline[324] = dpixel;
10221024
xline[484] = dpixel;
10231025

1024-
dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) );
1026+
dpixel = *(double *)( (uintptr_t)exp + ( (fourpixels&0xffff)<<3 ) );
10251027
xline[5] = dpixel;
10261028
xline[165] = dpixel;
10271029
xline[325] = dpixel;
10281030
xline[485] = dpixel;
10291031

10301032
fourpixels = lineptr[3];
10311033

1032-
dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) );
1034+
dpixel = *(double *)( (uintptr_t)exp + ( (fourpixels&0xffff0000)>>13) );
10331035
xline[6] = dpixel;
10341036
xline[166] = dpixel;
10351037
xline[326] = dpixel;
10361038
xline[486] = dpixel;
10371039

1038-
dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) );
1040+
dpixel = *(double *)( (uintptr_t)exp + ( (fourpixels&0xffff)<<3 ) );
10391041
xline[7] = dpixel;
10401042
xline[167] = dpixel;
10411043
xline[327] = dpixel;

linuxdoom-1.10/info.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1147,12 +1147,12 @@ typedef enum
11471147
typedef struct
11481148
{
11491149
spritenum_t sprite;
1150-
long frame;
1151-
long tics;
1150+
int32_t frame;
1151+
int32_t tics;
11521152
// void (*action) ();
11531153
actionf_t action;
11541154
statenum_t nextstate;
1155-
long misc1, misc2;
1155+
int32_t misc1, misc2;
11561156
} state_t;
11571157

11581158
extern state_t states[NUMSTATES];

linuxdoom-1.10/m_misc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void M_LoadDefaults (void)
392392
*defaults[i].location = parm;
393393
else
394394
*defaults[i].location =
395-
(int) newstring;
395+
(uintptr_t) newstring;
396396
break;
397397
}
398398
}

linuxdoom-1.10/m_swap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ unsigned short SwapSHORT(unsigned short x)
4242
}
4343

4444
// Swapping 32bit.
45-
unsigned long SwapLONG( unsigned long x)
45+
uint32_t SwapLONG( uint32_t x)
4646
{
4747
return
4848
(x>>24)

linuxdoom-1.10/m_swap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
// WAD files are stored little endian.
3434
#ifdef __BIG_ENDIAN__
3535
short SwapSHORT(short);
36-
long SwapLONG(long);
36+
int32_t SwapLONG(int32_t);
3737
#define SHORT(x) ((short)SwapSHORT((unsigned short) (x)))
38-
#define LONG(x) ((long)SwapLONG((unsigned long) (x)))
38+
#define LONG(x) ((int32_t)SwapLONG((uint32_t) (x)))
3939
#else
4040
#define SHORT(x) (x)
4141
#define LONG(x) (x)

linuxdoom-1.10/p_saveg.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ byte* save_p;
3737

3838
// Pads save_p to a 4-byte boundary
3939
// so that the load/save works on SGI&Gecko.
40-
#define PADSAVEP() save_p += (4 - ((int) save_p & 3)) & 3
40+
#define PADSAVEP() save_p += (4 - ((uintptr_t) save_p & 3)) & 3
4141

4242

4343

@@ -101,7 +101,7 @@ void P_UnArchivePlayers (void)
101101
if (players[i]. psprites[j].state)
102102
{
103103
players[i]. psprites[j].state
104-
= &states[ (int)players[i].psprites[j].state ];
104+
= &states[ (uintptr_t)players[i].psprites[j].state ];
105105
}
106106
}
107107
}
@@ -299,11 +299,11 @@ void P_UnArchiveThinkers (void)
299299
mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL);
300300
memcpy (mobj, save_p, sizeof(*mobj));
301301
save_p += sizeof(*mobj);
302-
mobj->state = &states[(int)mobj->state];
302+
mobj->state = &states[(uintptr_t)mobj->state];
303303
mobj->target = NULL;
304304
if (mobj->player)
305305
{
306-
mobj->player = &players[(int)mobj->player-1];
306+
mobj->player = &players[(uintptr_t)mobj->player-1];
307307
mobj->player->mo = mobj;
308308
}
309309
P_SetThingPosition (mobj);
@@ -498,7 +498,7 @@ void P_UnArchiveSpecials (void)
498498
ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL);
499499
memcpy (ceiling, save_p, sizeof(*ceiling));
500500
save_p += sizeof(*ceiling);
501-
ceiling->sector = &sectors[(int)ceiling->sector];
501+
ceiling->sector = &sectors[(uintptr_t)ceiling->sector];
502502
ceiling->sector->specialdata = ceiling;
503503

504504
if (ceiling->thinker.function.acp1)
@@ -513,7 +513,7 @@ void P_UnArchiveSpecials (void)
513513
door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL);
514514
memcpy (door, save_p, sizeof(*door));
515515
save_p += sizeof(*door);
516-
door->sector = &sectors[(int)door->sector];
516+
door->sector = &sectors[(uintptr_t)door->sector];
517517
door->sector->specialdata = door;
518518
door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor;
519519
P_AddThinker (&door->thinker);
@@ -524,7 +524,7 @@ void P_UnArchiveSpecials (void)
524524
floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL);
525525
memcpy (floor, save_p, sizeof(*floor));
526526
save_p += sizeof(*floor);
527-
floor->sector = &sectors[(int)floor->sector];
527+
floor->sector = &sectors[(uintptr_t)floor->sector];
528528
floor->sector->specialdata = floor;
529529
floor->thinker.function.acp1 = (actionf_p1)T_MoveFloor;
530530
P_AddThinker (&floor->thinker);
@@ -535,7 +535,7 @@ void P_UnArchiveSpecials (void)
535535
plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL);
536536
memcpy (plat, save_p, sizeof(*plat));
537537
save_p += sizeof(*plat);
538-
plat->sector = &sectors[(int)plat->sector];
538+
plat->sector = &sectors[(uintptr_t)plat->sector];
539539
plat->sector->specialdata = plat;
540540

541541
if (plat->thinker.function.acp1)
@@ -550,7 +550,7 @@ void P_UnArchiveSpecials (void)
550550
flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL);
551551
memcpy (flash, save_p, sizeof(*flash));
552552
save_p += sizeof(*flash);
553-
flash->sector = &sectors[(int)flash->sector];
553+
flash->sector = &sectors[(uintptr_t)flash->sector];
554554
flash->thinker.function.acp1 = (actionf_p1)T_LightFlash;
555555
P_AddThinker (&flash->thinker);
556556
break;
@@ -560,7 +560,7 @@ void P_UnArchiveSpecials (void)
560560
strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL);
561561
memcpy (strobe, save_p, sizeof(*strobe));
562562
save_p += sizeof(*strobe);
563-
strobe->sector = &sectors[(int)strobe->sector];
563+
strobe->sector = &sectors[(uintptr_t)strobe->sector];
564564
strobe->thinker.function.acp1 = (actionf_p1)T_StrobeFlash;
565565
P_AddThinker (&strobe->thinker);
566566
break;
@@ -570,7 +570,7 @@ void P_UnArchiveSpecials (void)
570570
glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL);
571571
memcpy (glow, save_p, sizeof(*glow));
572572
save_p += sizeof(*glow);
573-
glow->sector = &sectors[(int)glow->sector];
573+
glow->sector = &sectors[(uintptr_t)glow->sector];
574574
glow->thinker.function.acp1 = (actionf_p1)T_Glow;
575575
P_AddThinker (&glow->thinker);
576576
break;

linuxdoom-1.10/p_setup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ void P_GroupLines (void)
533533
}
534534

535535
// build line tables for each sector
536-
linebuffer = Z_Malloc (total*4, PU_LEVEL, 0);
536+
linebuffer = Z_Malloc (total*sizeof(line_t*), PU_LEVEL, 0);
537537
sector = sectors;
538538
for (i=0 ; i<numsectors ; i++, sector++)
539539
{

linuxdoom-1.10/r_data.c

+19-9
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,17 @@ typedef struct
8787
boolean masked;
8888
short width;
8989
short height;
90-
void **columndirectory; // OBSOLETE
90+
/*
91+
* NOTE: WAD files were originally authored on 32-bit systems, where the
92+
* columndirectory field is expected to be 32 bits wide. On 64-bit systems,
93+
* this field expands to 64 bits, causing misalignment and breaking things.
94+
* To maintain the correct behavior, we enforce a 32-bit width for this
95+
* field by replacing the void** type with int32_t. Since this field is not
96+
* used elsewhere in the code, this change should not introduce any issues.
97+
*
98+
* - eben ([email protected])
99+
*/
100+
int32_t columndirectory; // OBSOLETE
91101
short patchcount;
92102
mappatch_t patches[1];
93103
} maptexture_t;
@@ -479,13 +489,13 @@ void R_InitTextures (void)
479489
}
480490
numtextures = numtextures1 + numtextures2;
481491

482-
textures = Z_Malloc (numtextures*4, PU_STATIC, 0);
483-
texturecolumnlump = Z_Malloc (numtextures*4, PU_STATIC, 0);
484-
texturecolumnofs = Z_Malloc (numtextures*4, PU_STATIC, 0);
485-
texturecomposite = Z_Malloc (numtextures*4, PU_STATIC, 0);
486-
texturecompositesize = Z_Malloc (numtextures*4, PU_STATIC, 0);
487-
texturewidthmask = Z_Malloc (numtextures*4, PU_STATIC, 0);
488-
textureheight = Z_Malloc (numtextures*4, PU_STATIC, 0);
492+
textures = Z_Malloc (numtextures*sizeof(texture_t*), PU_STATIC, 0);
493+
texturecolumnlump = Z_Malloc (numtextures*sizeof(short*), PU_STATIC, 0);
494+
texturecolumnofs = Z_Malloc (numtextures*sizeof(unsigned short*), PU_STATIC, 0);
495+
texturecomposite = Z_Malloc (numtextures*sizeof(byte*), PU_STATIC, 0);
496+
texturecompositesize = Z_Malloc (numtextures*sizeof(int), PU_STATIC, 0);
497+
texturewidthmask = Z_Malloc (numtextures*sizeof(int), PU_STATIC, 0);
498+
textureheight = Z_Malloc (numtextures*sizeof(fixed_t), PU_STATIC, 0);
489499

490500
totalwidth = 0;
491501

@@ -639,7 +649,7 @@ void R_InitColormaps (void)
639649
lump = W_GetNumForName("COLORMAP");
640650
length = W_LumpLength (lump) + 255;
641651
colormaps = Z_Malloc (length, PU_STATIC, 0);
642-
colormaps = (byte *)( ((int)colormaps + 255)&~0xff);
652+
colormaps = (byte *)( ((uintptr_t)colormaps + 255)&~0xff);
643653
W_ReadLump (lump,colormaps);
644654
}
645655

linuxdoom-1.10/r_draw.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ void R_InitTranslationTables (void)
461461
int i;
462462

463463
translationtables = Z_Malloc (256*3+255, PU_STATIC, 0);
464-
translationtables = (byte *)(( (int)translationtables + 255 )& ~255);
464+
translationtables = (byte *)(( (uintptr_t)translationtables + 255 )& ~255);
465465

466466
// translate just the 16 green colors
467467
for (i=0 ; i<256 ; i++)

linuxdoom-1.10/r_main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void R_InitPointToAngle (void)
428428
// UNUSED - now getting from tables.c
429429
#if 0
430430
int i;
431-
long t;
431+
int32_t t;
432432
float f;
433433
//
434434
// slope (tangent) to angle lookup

linuxdoom-1.10/xephyr.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xephyr :2 -ac -screen 320x200x8 &

linuxdoom-1.10/z_zone.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ Z_ChangeTag2
437437
if (block->id != ZONEID)
438438
I_Error ("Z_ChangeTag: freed a pointer without ZONEID");
439439

440-
if (tag >= PU_PURGELEVEL && (unsigned)block->user < 0x100)
440+
if (tag >= PU_PURGELEVEL && (uintptr_t)block->user < 0x100)
441441
I_Error ("Z_ChangeTag: an owner is required for purgable blocks");
442442

443443
block->tag = tag;

0 commit comments

Comments
 (0)