diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 7b05de62a..06b54e94d 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.3: +- MinGW compilation fixes - SvdB+Mika - Bilinear scaler is now faster, has 24bpp mode and uses regions -Alex - Accept CRLF line endings in .txt and .ts files - SvdB - Fixed overflow problem with 32bpp bilinear,biadapt,biadv scalers -Mika diff --git a/sc2/src/port.h b/sc2/src/port.h index 7ca488191..c61f5f306 100644 --- a/sc2/src/port.h +++ b/sc2/src/port.h @@ -3,43 +3,70 @@ #include "config.h" -#ifdef _MSC_VER -#define alloca _alloca -#define snprintf _snprintf +#ifdef WIN32 +# include +#else +# include #endif #ifndef HAVE_STRICMP -#define stricmp strcasecmp +# define stricmp strcasecmp #endif #ifndef HAVE_STRUPR char *strupr (char *str); #endif + +// Compilation related +#ifdef _MSC_VER +# define inline __inline +#else +# define inline __inline__ +#endif + +// Directories #ifdef WIN32 # include # define PATH_MAX _MAX_PATH # define NAME_MAX _MAX_FNAME // _MAX_DIR and FILENAME_MAX could also be candidates. // If anyone can tell me which one matches NAME_MAX, please - // tell me. - SvdB + // let me know. - SvdB #else - /* PATH_MAX is per POSIX defined in */ # include + /* PATH_MAX is per POSIX defined in */ +#endif + +// Some types +#ifdef WIN32 +typedef int ssize_t; #endif #ifdef _MSC_VER -# include -typedef int ssize_t; typedef unsigned short mode_t; +#endif + +// Directories +#include +#ifdef WIN32 +# ifdef _MSC_VER +# define MKDIR(name, mode) ((void) mode, _mkdir(name)) +# else +# define MKDIR(name, mode) ((void) mode, mkdir(name)) +# endif +#else +# define MKDIR mkdir +#endif +#ifdef _MSC_VER +# include +# define chdir _chdir +# define getcwd _getcwd # define access _access # define F_OK 0 # define W_OK 2 # define R_OK 4 -# include # define open _open -# define mkdir _mkdir # define read _read -# define rmdir _rmdir //# define fstat _fstat # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) # define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC) @@ -51,15 +78,24 @@ typedef unsigned short mode_t; //# define stat _stat # define unlink _unlink #elif defined (__MINGW32__) -typedef int ssize_t; -typedef unsigned short mode_t; -# define S_IRWXU (S_IREAD | S_IWRITE | S_IEXEC) # define S_IRWXG 0 # define S_IRWXO 0 -# define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR) -# define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG) -#else -# include +#endif + +// Memory +#ifdef WIN32 +# ifdef __MINGW32__ +# include +# elif defined (_MSC_VER) +# define alloca _alloca +# endif +#elif defined (__linux__) +# include +#endif + +// Printf +#ifdef _MSC_VER +#define snprintf _snprintf #endif #endif /* _PORT_H */ diff --git a/sc2/src/sc2code/libs/file/dirs.c b/sc2/src/sc2code/libs/file/dirs.c index d4a8b70dd..ef9e1148c 100644 --- a/sc2/src/sc2code/libs/file/dirs.c +++ b/sc2/src/sc2code/libs/file/dirs.c @@ -41,11 +41,7 @@ int createDirectory(const char *dir, int mode) { -#ifdef WIN32 - return mkdir (dir); -#else - return mkdir (dir, (mode_t) mode); -#endif + return MKDIR(dir, mode); } // make all components of the path if they don't exist already diff --git a/sc2/src/sc2code/libs/graphics/sdl/opengl.h b/sc2/src/sc2code/libs/graphics/sdl/opengl.h index 438c07d0c..2087865f6 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/opengl.h +++ b/sc2/src/sc2code/libs/graphics/sdl/opengl.h @@ -30,8 +30,10 @@ SDL_Surface* TFB_GL_DisplayFormatAlpha (SDL_Surface *surface); #ifdef HAVE_OPENGL #ifdef WIN32 +#ifdef _MSC_VER #pragma comment (lib, "opengl32.lib") #pragma comment (lib, "glu32.lib") +#endif /* To avoid including windows.h, Win32's needs APIENTRY and WINGDIAPI defined properly. */ diff --git a/sc2/src/sc2code/libs/sound/decoders/decoder.h b/sc2/src/sc2code/libs/sound/decoders/decoder.h index 6cb3ed633..0363c1f2c 100644 --- a/sc2/src/sc2code/libs/sound/decoders/decoder.h +++ b/sc2/src/sc2code/libs/sound/decoders/decoder.h @@ -25,8 +25,8 @@ #include "types.h" #include "uio.h" -#ifdef WIN32 -#pragma comment (lib, "vorbisfile.lib") +#ifdef _MSC_VER +# pragma comment (lib, "vorbisfile.lib") #endif typedef struct tfb_decoderformats diff --git a/sc2/src/sc2code/libs/sound/decoders/mikmod/mikmod_internals.h b/sc2/src/sc2code/libs/sound/decoders/mikmod/mikmod_internals.h index 7b8062b84..a348467c2 100644 --- a/sc2/src/sc2code/libs/sound/decoders/mikmod/mikmod_internals.h +++ b/sc2/src/sc2code/libs/sound/decoders/mikmod/mikmod_internals.h @@ -58,10 +58,12 @@ static char *strdup(const char *str) #endif #ifdef WIN32 -#ifndef __STDC__ -#define __STDC__ -#endif -#pragma warning(disable:4761) +# ifndef __STDC__ +# define __STDC__ +# endif +# ifdef _MSC_VER +# pragma warning(disable:4761) +# endif #endif #ifdef __cplusplus diff --git a/sc2/src/sc2code/libs/sound/sound_chooser.h b/sc2/src/sc2code/libs/sound/sound_chooser.h index a4f6adfac..ddd8a281d 100644 --- a/sc2/src/sc2code/libs/sound/sound_chooser.h +++ b/sc2/src/sc2code/libs/sound/sound_chooser.h @@ -18,14 +18,16 @@ */ #ifndef SOUNDCHOOSER_H -#define SOUNDCHOOSER_H -#ifdef WIN32 -#include -#include -#pragma comment (lib, "OpenAL32.lib") +# define SOUNDCHOOSER_H +# ifdef WIN32 +# include +# include +# ifdef _MSC_VER +# pragma comment (lib, "OpenAL32.lib") +# endif #else -#include -#include +# include +# include #endif #include "mixsdl/mixer.h" diff --git a/sc2/src/sc2code/libs/uio/mem.h b/sc2/src/sc2code/libs/uio/mem.h index 887de1669..4bf264e40 100644 --- a/sc2/src/sc2code/libs/uio/mem.h +++ b/sc2/src/sc2code/libs/uio/mem.h @@ -23,12 +23,6 @@ #include #include -#ifdef WIN32 -# include -# define alloca _alloca -#elif defined (__linux__) -# include -#endif #include "uioport.h" #define uio_malloc malloc diff --git a/sc2/src/sc2code/libs/uio/uioport.h b/sc2/src/sc2code/libs/uio/uioport.h index 3733fccaf..cae14280a 100644 --- a/sc2/src/sc2code/libs/uio/uioport.h +++ b/sc2/src/sc2code/libs/uio/uioport.h @@ -21,6 +21,21 @@ #ifndef _UIOPORT_H #define _UIOPORT_H +#ifdef WIN32 +# include +#else +# include +#endif + + +// Compilation related +#ifdef _MSC_VER +# define inline __inline +#else +# define inline __inline__ +#endif + +// Paths #ifdef WIN32 # include # define PATH_MAX _MAX_PATH @@ -28,33 +43,42 @@ // _MAX_DIR and FILENAME_MAX could also be candidates. // If anyone can tell me which one matches NAME_MAX, please // let me know. -# define inline __inline -typedef short uid_t; -typedef short gid_t; #else # include /* PATH_MAX is per POSIX defined in */ -# define inline __inline__ #endif + +// User ids +#ifdef WIN32 +typedef short uid_t; +typedef short gid_t; +#endif + +// Some types #ifdef WIN32 -# include -# define mkdir MS_INSANE_MKDIR - // direct.h would give a bad definition of mkdir(). Now it gives - // a bad definition of MS_INSANE_MKDIR(), which we won't use. - // Yes, it's a hack, but this way the hack will stay local to - // the MS-specific stuff. -# include -# undef mkdir -typedef unsigned short mode_t; -static inline int -mkdir(const char *pathname, mode_t mode) { - (void) mode; - return _mkdir(pathname); -} -#endif /* WIN32 */ -#ifdef _MSC_VER -# include typedef int ssize_t; +#endif +#ifdef _MSC_VER +typedef unsigned short mode_t; +#endif + +// Directories +#include +#ifdef WIN32 +# ifdef _MSC_VER +# define MKDIR(name, mode) ((void) mode, _mkdir(name)) +# else +# define MKDIR(name, mode) ((void) mode, mkdir(name)) +# endif +#else +# define MKDIR mkdir +#endif +#ifdef _MSC_VER +# include +# define chdir _chdir +# define getcwd _getcwd +# define chdir _chdir +# define getcwd _getcwd # define access _access # define F_OK 0 # define W_OK 2 @@ -90,12 +114,6 @@ typedef int ssize_t; # define stat _stat # define unlink _unlink #elif defined (__MINGW32__) -typedef int ssize_t; -typedef unsigned short mode_t; -# define S_IRUSR S_IREAD -# define S_IWUSR S_IWRITE -# define S_IXUSR S_IEXEC -# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) # define S_IRGRP 0 # define S_IWGRP 0 # define S_IXGRP 0 @@ -110,12 +128,19 @@ typedef unsigned short mode_t; # define S_IFREG _S_IFREG # define S_IFCHR _S_IFCHR # define S_IFDIR _S_IFDIR -# define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR) -# define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG) -#else -# include #endif +// Memory related: +#ifdef WIN32 +# ifdef __MINGW32__ +# include +# elif defined (_MSC_VER) +# define alloca _alloca +# endif +#elif defined (__linux__) +# include +#endif #endif /* _UIOPORT_H */ +