diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index 189da6cc5..d7128be00 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -21,6 +21,27 @@ #endif #endif +#ifdef __GNUC__ +# define EDUKE32_GCC_PREREQ(major, minor) (major > __GNUC__ || (major == __GNUC__ && minor >= __GNUC_MINOR__)) +#else +# define EDUKE32_GCC_PREREQ(major, minor) 0 +#endif + +#ifdef __clang__ +# define EDUKE32_CLANG_PREREQ(major, minor) (major > __clang_major__ || (major == __clang_major__ && minor >= __clang_minor__)) +#else +# define EDUKE32_CLANG_PREREQ(major, minor) 0 +#endif +#ifndef __has_builtin +# define __has_builtin(x) 0 // Compatibility with non-clang compilers. +#endif +#ifndef __has_feature +# define __has_feature(x) 0 // Compatibility with non-clang compilers. +#endif +#ifndef __has_extension +# define __has_extension __has_feature // Compatibility with pre-3.0 compilers. +#endif + #ifndef UNREFERENCED_PARAMETER #define UNREFERENCED_PARAMETER(x) x=x #endif @@ -37,17 +58,19 @@ # define ATTRIBUTE_OPTIMIZE(str) #endif -#if defined __GNUC__ || defined __clang__ +#if defined __GNUC__ || __has_builtin(__builtin_expect) #define EDUKE32_PREDICT_TRUE(x) __builtin_expect(!!(x),1) #define EDUKE32_PREDICT_FALSE(x) __builtin_expect(!!(x),0) +#else +#define EDUKE32_PREDICT_TRUE(x) (x) +#define EDUKE32_PREDICT_FALSE(x) (x) +#endif + +#if EDUKE32_GCC_PREREQ(4,5) || __has_builtin(__builtin_unreachable) #define EDUKE32_UNREACHABLE_SECTION(...) __builtin_unreachable() #elif _MSC_VER -#define EDUKE32_PREDICT_TRUE(x) (x) -#define EDUKE32_PREDICT_FALSE(x) (x) #define EDUKE32_UNREACHABLE_SECTION(...) __assume(0) -#else -#define EDUKE32_PREDICT_TRUE(x) (x) -#define EDUKE32_PREDICT_FALSE(x) (x) +#else #define EDUKE32_UNREACHABLE_SECTION(...) __VA_ARGS__ #endif @@ -377,6 +400,7 @@ static inline int32_t Blrintf(const float x) return n; } #else +#include #define Blrintf lrintf #endif diff --git a/polymer/eduke32/build/src/a-c.c b/polymer/eduke32/build/src/a-c.c index eceb6b120..a87fcb782 100644 --- a/polymer/eduke32/build/src/a-c.c +++ b/polymer/eduke32/build/src/a-c.c @@ -191,14 +191,8 @@ extern uint32_t vplce[4]; extern int32_t vince[4]; extern intptr_t bufplce[4]; -#if !defined __has_extension -# define __has_extension(x) 0 -#endif - -#if (defined __GNUC__ && __GNUC_MINOR__ >= 7) || (defined __clang__ && __has_extension(attribute_ext_vector_type)) -# if defined _WIN64 || defined __amd64 || defined __x86_64 || defined __x86_64__ -# define USE_VECTOR_EXT -# endif +#if (EDUKE32_GCC_PREREQ(4,7) || __has_extension(attribute_ext_vector_type)) && defined BITNESS64 +# define USE_VECTOR_EXT #endif #ifdef USE_VECTOR_EXT diff --git a/polymer/eduke32/build/src/kplib.c b/polymer/eduke32/build/src/kplib.c index 073a565a6..f46552d17 100644 --- a/polymer/eduke32/build/src/kplib.c +++ b/polymer/eduke32/build/src/kplib.c @@ -87,7 +87,7 @@ static __inline int32_t _lrotl(int32_t i, int sh) #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif -#if defined __clang__ && __clang_major__==3 +#if defined __clang__ && __clang_major__==3 && __clang_minor__==1 // clang 3.1 SVN r149129, assertion failure with inline asm # define NOASM 1 #endif diff --git a/polymer/eduke32/build/src/winbits.c b/polymer/eduke32/build/src/winbits.c index 8952eff07..38c709933 100644 --- a/polymer/eduke32/build/src/winbits.c +++ b/polymer/eduke32/build/src/winbits.c @@ -10,7 +10,7 @@ #include "winbits.h" -#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__) +#ifdef BITNESS64 # define EBACKTRACEDLL "ebacktrace1-64.dll" #else # define EBACKTRACEDLL "ebacktrace1.dll" @@ -291,6 +291,6 @@ int32_t addsearchpath_ProgramFiles(const char *p) // Workaround for a bug in mingwrt-4.0.0 and up where a function named main() in misc/src/libcrt/gdtoa/qnan.c takes precedence over the proper one in src/libcrt/crt/main.c. -#if (defined __MINGW32__ && __GNUC__ == 4 && __GNUC_MINOR__ >= 8) || (defined __clang__ && __clang_major__ == 3 && __clang_minor__ >= 4) +#if (defined __MINGW32__ && EDUKE32_GCC_PREREQ(4,8)) || EDUKE32_CLANG_PREREQ(3,4) # include "mingw_main.c" #endif