Fix compilation on *nix systems, e.g. Linux+GLibC+GCC

This commit is contained in:
Fabian Greffrath 2016-08-19 21:39:04 +02:00
parent 70a0d74de2
commit d858126b2c
8 changed files with 39 additions and 10 deletions

View File

@ -21,6 +21,13 @@
#ifndef D_IO_INCLUDED
#define D_IO_INCLUDED
#ifndef TRUE
#define TRUE true
#endif
#ifndef FALSE
#define FALSE false
#endif
#ifdef _MSC_VER
#include <direct.h>
#include <io.h>
@ -28,13 +35,28 @@
#define W_OK 2
#define R_OK 4
#define S_ISDIR(x) (((sbuf.st_mode & S_IFDIR)==S_IFDIR)?1:0)
#define TRUE true
#define FALSE false
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#ifndef PATH_MAX
#define PATH_MAX _MAX_PATH
#endif
#elif defined (__unix__)
#include <unistd.h>
#include <ctype.h> // tolower()
#ifndef O_BINARY
#define O_BINARY 0
#endif
#define stricmp strcasecmp
#define strnicmp strncasecmp
static inline char *strlwr (char *str) {
char *c = str;
while (*str != '\0')
{
*str = tolower (*str);
str++;
}
return c;
}
#else
#include <unistd.h>
#endif

View File

@ -1263,6 +1263,7 @@ void D_DoomMain(void)
if (devparm)
printf(D_DEVSTR);
#ifndef __unix__
if (M_CheckParm("-cdrom"))
{
printf(D_CDROM);
@ -1275,6 +1276,7 @@ void D_DoomMain(void)
// killough 10/98:
sprintf(basedefault, "c:/doomdata/%s.cfg", D_DoomExeName());
}
#endif
// turbo option
if ((p=M_CheckParm ("-turbo")))

View File

@ -1156,9 +1156,11 @@ void G_SaveGameName(char *name, int slot)
// Ty 05/04/98 - use savegamename variable (see d_deh.c)
// killough 12/98: add .7 to truncate savegamename
#ifndef __unix__
if (M_CheckParm("-cdrom"))
sprintf(name, "c:/doomdata/%.7s%d.dsg", savegamename, slot);
else
#endif
sprintf(name, "%s/%.7s%d.dsg", basesavegame, savegamename, slot);
}

View File

@ -257,7 +257,7 @@ void I_Quit (void)
G_CheckDemoStatus();
M_SaveDefaults();
#if defined(MY_SDL_VER)
#if defined(MY_SDL_VER) && defined(_MSC_VER)
// Under Visual C++, the console window likes to rudely slam
// shut -- this can stop it
if(*errmsg || waitAtExit)

View File

@ -36,6 +36,7 @@
#define __attribute__(x)
#endif
#include <stdlib.h> // abs()
#include "i_system.h"
//

View File

@ -717,8 +717,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
return mobj;
}
static mapthing_t itemrespawnque[ITEMQUESIZE];
static int itemrespawntime[ITEMQUESIZE];
mapthing_t itemrespawnque[ITEMQUESIZE];
int itemrespawntime[ITEMQUESIZE];
int iquehead, iquetail;
//

View File

@ -45,9 +45,9 @@ rcsid[] = "$Id: r_segs.c,v 1.16 1998/05/03 23:02:01 killough Exp $";
// killough 1/6/98: replaced globals with statics where appropriate
// True if any of the segs textures might be visible.
static boolean segtextured;
static boolean markfloor; // False if the back side is the same plane.
static boolean markceiling;
boolean segtextured;
boolean markfloor; // False if the back side is the same plane.
boolean markceiling;
static boolean maskedtexture;
static int toptexture;
static int bottomtexture;
@ -61,8 +61,8 @@ lighttable_t **walllights;
//
// regular wall
//
static int rw_x;
static int rw_stopx;
int rw_x;
int rw_stopx;
static angle_t rw_centerangle;
static fixed_t rw_offset;
static fixed_t rw_scale;

View File

@ -99,6 +99,8 @@ void Z_DumpHistory(char *);
#define calloc(n1,n2) Z_Calloc(n1,n2,PU_STATIC,0)
#define strdup(s) Z_Strdup(s,PU_STATIC,0)
// dprintf() is already declared in <stdio.h>, define it out of the way
#define dprintf doomprintf
// Doom-style printf
void dprintf(const char *, ...) __attribute__((format(printf,1,2)));