EDuke32-specific libdivide customizations

git-svn-id: https://svn.eduke32.com/eduke32@7716 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-06-25 11:29:55 +00:00 committed by Christoph Oelckers
parent db7a2bd0db
commit d3f93fc00f

View file

@ -25,6 +25,14 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
#if defined(__x86_64__) || defined(_M_X64)
#define LIBDIVIDE_X86_64
#endif
#if defined LIBDIVIDE_X86_64 || defined __SSE2__ || (defined _M_IX86_FP && _M_IX86_FP == 2)
#define LIBDIVIDE_SSE2 1
#endif
#if defined(LIBDIVIDE_AVX512) #if defined(LIBDIVIDE_AVX512)
#include <immintrin.h> #include <immintrin.h>
#elif defined(LIBDIVIDE_AVX2) #elif defined(LIBDIVIDE_AVX2)
@ -54,10 +62,6 @@
#endif #endif
#endif #endif
#if defined(__x86_64__) || defined(_M_X64)
#define LIBDIVIDE_X86_64
#endif
#if defined(__i386__) #if defined(__i386__)
#define LIBDIVIDE_i386 #define LIBDIVIDE_i386
#endif #endif
@ -72,12 +76,16 @@
#define LIBDIVIDE_FUNCTION __func__ #define LIBDIVIDE_FUNCTION __func__
#endif #endif
#define LIBDIVIDE_ERROR(msg) \ #if 0
do { \ #define LIBDIVIDE_ERROR(msg) \
fprintf(stderr, "libdivide.h:%d: %s(): Error: %s\n", \ do { \
__LINE__, LIBDIVIDE_FUNCTION, msg); \ fprintf(stderr, "libdivide.h:%d: %s(): Error: %s\n", \
exit(-1); \ __LINE__, LIBDIVIDE_FUNCTION, msg); \
} while (0) exit(-1); \
} while (0)
#else
#define LIBDIVIDE_ERROR(msg)
#endif
#if defined(LIBDIVIDE_ASSERTIONS_ON) #if defined(LIBDIVIDE_ASSERTIONS_ON)
#define LIBDIVIDE_ASSERT(x) \ #define LIBDIVIDE_ASSERT(x) \
@ -372,7 +380,7 @@ static uint64_t libdivide_128_div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v,
// If overflow, set rem. to an impossible value, // If overflow, set rem. to an impossible value,
// and return the largest possible quotient // and return the largest possible quotient
if (u1 >= v) { if (EDUKE32_PREDICT_FALSE(u1 >= v)) {
*r = (uint64_t) -1; *r = (uint64_t) -1;
return (uint64_t) -1; return (uint64_t) -1;
} }