diff --git a/sys/platform.h b/sys/platform.h index d9a9a5b..1beb68b 100644 --- a/sys/platform.h +++ b/sys/platform.h @@ -32,6 +32,16 @@ If you have questions concerning this license or the applicable additional terms #include "config.h" #include "framework/BuildDefines.h" +#ifdef _WIN32 +#include // _alloca() +#endif + +// NOTE: By default Win32 uses a 1MB stack. Doom3 1.3.1 uses 4MB (probably set after compiling with EDITBIN /STACK +// dhewm3 now uses a 8MB stack, set with a linker flag in CMakeLists.txt (/STACK:8388608 for MSVC, -Wl,--stack,8388608 for mingw) +// Linux has a 8MB stack by default, and so does macOS, at least for the main thread +// anyway, a 2MB limit alloca should be safe even when using it multiple times in the same function +#define ID_MAX_ALLOCA_SIZE 2097152 // 2MB + /* =============================================================================== @@ -40,7 +50,7 @@ If you have questions concerning this license or the applicable additional terms =============================================================================== */ -// Win32 +// AROS #if defined(__AROS__) #define _alloca alloca @@ -71,7 +81,14 @@ If you have questions concerning this license or the applicable additional terms // Win32 #if defined(WIN32) || defined(_WIN32) -#define _alloca16( x ) ((void *)((((uintptr_t)_alloca( (x)+15 )) + 15) & ~15)) +#ifdef __MINGW32__ + #undef _alloca // in mingw _alloca is a #define + #define _alloca16( x ) ( (assert((x)= 1.28 + #define _alloca16( x ) ( ({assert((x) #endif -#if defined(__MINGW32__) - #include -#endif #include #include #include @@ -200,6 +250,18 @@ If you have questions concerning this license or the applicable additional terms #undef FindText // stupid namespace poluting Microsoft monkeys #endif +// Apple legacy +#ifdef __APPLE__ +#include +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1040 +#define OSX_TIGER +#elif __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 +#define OSX_LEOPARD +#endif +#endif +#endif + #define ID_TIME_T time_t typedef unsigned char byte; // 8 bits