Clean up doomtype.h a bit, add indenting and comments to make some preprocessor code more readable

This commit is contained in:
Monster Iestyn 2018-11-08 16:31:20 +00:00
parent 0bdbdd1b1e
commit 5c61c40551

View file

@ -44,12 +44,13 @@
typedef long ssize_t; typedef long ssize_t;
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ /* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) #if (_MSC_VER <= 1200)
#define DWORD_PTR DWORD #ifndef DWORD_PTR
#endif #define DWORD_PTR DWORD
#endif
#if ((_MSC_VER <= 1200) && (!defined(PDWORD_PTR))) #ifndef PDWORD_PTR
#define PDWORD_PTR PDWORD #define PDWORD_PTR PDWORD
#endif
#endif #endif
#elif defined (_arch_dreamcast) // KOS Dreamcast #elif defined (_arch_dreamcast) // KOS Dreamcast
#include <arch/types.h> #include <arch/types.h>
@ -102,7 +103,7 @@ typedef long ssize_t;
#ifdef _MSC_VER #ifdef _MSC_VER
#if (_MSC_VER <= 1800) // MSVC 2013 and back #if (_MSC_VER <= 1800) // MSVC 2013 and back
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER <= 1200) // MSVC 2012 and back #if (_MSC_VER <= 1200) // MSVC 6.0 and back
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #endif
#endif #endif
@ -185,7 +186,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
//faB: clean that up !! //faB: clean that up !!
#if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward #if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward
#include "stdbool.h" #include "stdbool.h"
#elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX) #elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX)
#define false FALSE // use windows types #define false FALSE // use windows types
#define true TRUE #define true TRUE
@ -275,58 +276,68 @@ typedef UINT32 tic_t;
#endif #endif
#ifdef __GNUC__ // __attribute__ ((X)) #ifdef __GNUC__ // __attribute__ ((X))
#define FUNCNORETURN __attribute__ ((noreturn)) #define FUNCNORETURN __attribute__ ((noreturn))
#if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && defined (__MINGW32__)
#include "inttypes.h" #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && defined (__MINGW32__) // MinGW, >= GCC 4.1
#if 0 //defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO > 0 #include "inttypes.h"
#define FUNCPRINTF __attribute__ ((format(gnu_printf, 1, 2))) #if 0 //defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO > 0
#define FUNCDEBUG __attribute__ ((format(gnu_printf, 2, 3))) #define FUNCPRINTF __attribute__ ((format(gnu_printf, 1, 2)))
#define FUNCIERROR __attribute__ ((format(gnu_printf, 1, 2),noreturn)) #define FUNCDEBUG __attribute__ ((format(gnu_printf, 2, 3)))
#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) #define FUNCIERROR __attribute__ ((format(gnu_printf, 1, 2),noreturn))
#define FUNCPRINTF __attribute__ ((format(ms_printf, 1, 2))) #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) // >= GCC 4.4
#define FUNCDEBUG __attribute__ ((format(ms_printf, 2, 3))) #define FUNCPRINTF __attribute__ ((format(ms_printf, 1, 2)))
#define FUNCIERROR __attribute__ ((format(ms_printf, 1, 2),noreturn)) #define FUNCDEBUG __attribute__ ((format(ms_printf, 2, 3)))
#else #define FUNCIERROR __attribute__ ((format(ms_printf, 1, 2),noreturn))
#define FUNCPRINTF __attribute__ ((format(printf, 1, 2))) #else
#define FUNCDEBUG __attribute__ ((format(printf, 2, 3))) #define FUNCPRINTF __attribute__ ((format(printf, 1, 2)))
#define FUNCIERROR __attribute__ ((format(printf, 1, 2),noreturn)) #define FUNCDEBUG __attribute__ ((format(printf, 2, 3)))
#endif #define FUNCIERROR __attribute__ ((format(printf, 1, 2),noreturn))
#else #endif
#define FUNCPRINTF __attribute__ ((format(printf, 1, 2))) #else
#define FUNCDEBUG __attribute__ ((format(printf, 2, 3))) #define FUNCPRINTF __attribute__ ((format(printf, 1, 2)))
#define FUNCIERROR __attribute__ ((format(printf, 1, 2),noreturn)) #define FUNCDEBUG __attribute__ ((format(printf, 2, 3)))
#endif #define FUNCIERROR __attribute__ ((format(printf, 1, 2),noreturn))
#ifndef FUNCIERROR #endif
#define FUNCIERROR __attribute__ ((noreturn))
#endif #ifndef FUNCIERROR
#define FUNCMATH __attribute__((const)) #define FUNCIERROR __attribute__ ((noreturn))
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) #endif
#define FUNCDEAD __attribute__ ((deprecated))
#define FUNCINLINE __attribute__((always_inline)) #define FUNCMATH __attribute__((const))
#define FUNCNONNULL __attribute__((nonnull))
#endif #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) // >= GCC 3.1
#define FUNCNOINLINE __attribute__((noinline)) #define FUNCDEAD __attribute__ ((deprecated))
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) #define FUNCINLINE __attribute__((always_inline))
#ifdef __i386__ // i386 only #define FUNCNONNULL __attribute__((nonnull))
#define FUNCTARGET(X) __attribute__ ((__target__ (X))) #endif
#endif
#endif #define FUNCNOINLINE __attribute__((noinline))
#if defined (__MINGW32__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#define ATTRPACK __attribute__((packed, gcc_struct)) #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) // >= GCC 4.4
#else #ifdef __i386__ // i386 only
#define ATTRPACK __attribute__((packed)) #define FUNCTARGET(X) __attribute__ ((__target__ (X)))
#endif #endif
#define ATTRUNUSED __attribute__((unused)) #endif
#ifdef _XBOX
#define FILESTAMP I_OutputMsg("%s:%d\n",__FILE__,__LINE__); #if defined (__MINGW32__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) // MinGW, >= GCC 3.4
#define XBOXSTATIC static #define ATTRPACK __attribute__((packed, gcc_struct))
#endif #else
#define ATTRPACK __attribute__((packed))
#endif
#define ATTRUNUSED __attribute__((unused))
// Xbox-only macros
#ifdef _XBOX
#define FILESTAMP I_OutputMsg("%s:%d\n",__FILE__,__LINE__);
#define XBOXSTATIC static
#endif
#elif defined (_MSC_VER) #elif defined (_MSC_VER)
#define ATTRNORETURN __declspec(noreturn) #define ATTRNORETURN __declspec(noreturn)
#define ATTRINLINE __forceinline #define ATTRINLINE __forceinline
#if _MSC_VER > 1200 #if _MSC_VER > 1200 // >= MSVC 6.0
#define ATTRNOINLINE __declspec(noinline) #define ATTRNOINLINE __declspec(noinline)
#endif #endif
#endif #endif
#ifndef FUNCPRINTF #ifndef FUNCPRINTF