mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-30 05:50:09 +00:00
Use ISO C functions for MSVC.
This commit is contained in:
parent
f066f5a4fd
commit
2d2e721437
@ -51,14 +51,18 @@
|
|||||||
|
|
||||||
// NOTE: this is irrelevant on Win32 platforms since the MS libraries
|
// NOTE: this is irrelevant on Win32 platforms since the MS libraries
|
||||||
// don't support extended-precision floating-point computations
|
// don't support extended-precision floating-point computations
|
||||||
#ifdef WIN32
|
#if defined(WIN32) && USE_LONG_DOUBLE
|
||||||
#undef FPU_USE_ISO_C99
|
#undef FPU_USE_ISO_C99
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use faster implementation of math functions, but this could cause
|
// Use faster implementation of math functions, but this could cause
|
||||||
// some incorrect results (?)
|
// some incorrect results (?)
|
||||||
// TODO: actually implement the slower but safer versions
|
#ifdef _MSC_VER
|
||||||
|
// MSVC uses intrinsics for all of the math functions, so it should still be fast
|
||||||
|
#define FPU_FAST_MATH 0
|
||||||
|
#else
|
||||||
#define FPU_FAST_MATH 1
|
#define FPU_FAST_MATH 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#if FPU_USE_ISO_C99
|
#if FPU_USE_ISO_C99
|
||||||
// NOTE: no prior <math.h> shall be included at this point
|
// NOTE: no prior <math.h> shall be included at this point
|
||||||
@ -373,7 +377,7 @@ PRIVATE inline bool FFPU fp_do_isnan(fpu_register const & r)
|
|||||||
hx &= 0x7fffffff;
|
hx &= 0x7fffffff;
|
||||||
hx |= (uae_u32)(lx | (-lx)) >> 31;
|
hx |= (uae_u32)(lx | (-lx)) >> 31;
|
||||||
hx = 0x7ff00000 - hx;
|
hx = 0x7ff00000 - hx;
|
||||||
return (int)(((uae_u32)hx) >> 31);
|
return (((uae_u32)hx) >> 31) != 0;
|
||||||
#elif USE_QUAD_DOUBLE
|
#elif USE_QUAD_DOUBLE
|
||||||
fp_declare_init_shape(sxp, r, extended);
|
fp_declare_init_shape(sxp, r, extended);
|
||||||
uae_s64 hx = sxp->parts64.msw;
|
uae_s64 hx = sxp->parts64.msw;
|
||||||
@ -381,7 +385,7 @@ PRIVATE inline bool FFPU fp_do_isnan(fpu_register const & r)
|
|||||||
hx &= 0x7fffffffffffffffLL;
|
hx &= 0x7fffffffffffffffLL;
|
||||||
hx |= (uae_u64)(lx | (-lx)) >> 63;
|
hx |= (uae_u64)(lx | (-lx)) >> 63;
|
||||||
hx = 0x7fff000000000000LL - hx;
|
hx = 0x7fff000000000000LL - hx;
|
||||||
return (int)((uae_u64)hx >> 63);
|
return ((uae_u64)hx >> 63) != 0;
|
||||||
#else
|
#else
|
||||||
fp_declare_init_shape(sxp, r, extended);
|
fp_declare_init_shape(sxp, r, extended);
|
||||||
uae_s32 se = sxp->parts.sign_exponent;
|
uae_s32 se = sxp->parts.sign_exponent;
|
||||||
@ -392,7 +396,7 @@ PRIVATE inline bool FFPU fp_do_isnan(fpu_register const & r)
|
|||||||
se |= (uae_u32)(lx | (-lx)) >> 31;
|
se |= (uae_u32)(lx | (-lx)) >> 31;
|
||||||
se = 0xfffe - se;
|
se = 0xfffe - se;
|
||||||
// TODO: check whether rshift count is 16 or 31
|
// TODO: check whether rshift count is 16 or 31
|
||||||
return (int)(((uae_u32)(se)) >> 16);
|
return (((uae_u32)(se)) >> 16) != 0;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE
|
#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE
|
||||||
@ -428,14 +432,14 @@ PRIVATE inline bool FFPU fp_do_isinf(fpu_register const & r)
|
|||||||
uae_s32 lx = sxp->parts.lsw;
|
uae_s32 lx = sxp->parts.lsw;
|
||||||
lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
|
lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
|
||||||
lx |= -lx;
|
lx |= -lx;
|
||||||
return ~(lx >> 31) & (hx >> 30);
|
return (~(lx >> 31) & (hx >> 30)) != 0;
|
||||||
#elif USE_QUAD_DOUBLE
|
#elif USE_QUAD_DOUBLE
|
||||||
fp_declare_init_shape(sxp, r, extended);
|
fp_declare_init_shape(sxp, r, extended);
|
||||||
uae_s64 hx = sxp->parts64.msw;
|
uae_s64 hx = sxp->parts64.msw;
|
||||||
uae_s64 lx = sxp->parts64.lsw;
|
uae_s64 lx = sxp->parts64.lsw;
|
||||||
lx |= (hx & 0x7fffffffffffffffLL) ^ 0x7fff000000000000LL;
|
lx |= (hx & 0x7fffffffffffffffLL) ^ 0x7fff000000000000LL;
|
||||||
lx |= -lx;
|
lx |= -lx;
|
||||||
return ~(lx >> 63) & (hx >> 62);
|
return (~(lx >> 63) & (hx >> 62)) != 0;
|
||||||
#else
|
#else
|
||||||
fp_declare_init_shape(sxp, r, extended);
|
fp_declare_init_shape(sxp, r, extended);
|
||||||
uae_s32 se = sxp->parts.sign_exponent;
|
uae_s32 se = sxp->parts.sign_exponent;
|
||||||
@ -451,7 +455,7 @@ PRIVATE inline bool FFPU fp_do_isinf(fpu_register const & r)
|
|||||||
#endif
|
#endif
|
||||||
lx |= -lx;
|
lx |= -lx;
|
||||||
se &= 0x8000;
|
se &= 0x8000;
|
||||||
return ~(lx >> 31) & (1 - (se >> 14));
|
return (~(lx >> 31) & (1 - (se >> 14))) != 0;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE
|
#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE
|
||||||
@ -661,7 +665,8 @@ PRIVATE inline uae_u32 FFPU get_quotient_sign(fpu_register const & ra, fpu_regis
|
|||||||
/* --- Math functions --- */
|
/* --- Math functions --- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#if FPU_USE_ISO_C99 && (USE_LONG_DOUBLE || USE_QUAD_DOUBLE)
|
#if FPU_USE_ISO_C99
|
||||||
|
#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE
|
||||||
# ifdef HAVE_LOGL
|
# ifdef HAVE_LOGL
|
||||||
# define fp_log logl
|
# define fp_log logl
|
||||||
# endif
|
# endif
|
||||||
@ -785,14 +790,13 @@ PRIVATE inline uae_u32 FFPU get_quotient_sign(fpu_register const & ra, fpu_regis
|
|||||||
# define fp_ceil ceil
|
# define fp_ceil ceil
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FPU_IEEE) && defined(USE_X87_ASSEMBLY)
|
#elif defined(FPU_IEEE) && defined(USE_X87_ASSEMBLY)
|
||||||
// Assembly optimized support functions. Taken from glibc 2.2.2
|
// Assembly optimized support functions. Taken from glibc 2.2.2
|
||||||
|
|
||||||
#undef fp_log
|
#undef fp_log
|
||||||
#define fp_log fp_do_log
|
#define fp_log fp_do_log
|
||||||
|
|
||||||
#ifndef FPU_FAST_MATH
|
#if !FPU_FAST_MATH
|
||||||
// FIXME: unimplemented
|
|
||||||
PRIVATE fpu_extended fp_do_log(fpu_extended x);
|
PRIVATE fpu_extended fp_do_log(fpu_extended x);
|
||||||
#else
|
#else
|
||||||
PRIVATE inline fpu_extended fp_do_log(fpu_extended x)
|
PRIVATE inline fpu_extended fp_do_log(fpu_extended x)
|
||||||
@ -806,7 +810,7 @@ PRIVATE inline fpu_extended fp_do_log(fpu_extended x)
|
|||||||
#undef fp_log10
|
#undef fp_log10
|
||||||
#define fp_log10 fp_do_log10
|
#define fp_log10 fp_do_log10
|
||||||
|
|
||||||
#ifndef FPU_FAST_MATH
|
#if !FPU_FAST_MATH
|
||||||
// FIXME: unimplemented
|
// FIXME: unimplemented
|
||||||
PRIVATE fpu_extended fp_do_log10(fpu_extended x);
|
PRIVATE fpu_extended fp_do_log10(fpu_extended x);
|
||||||
#else
|
#else
|
||||||
@ -821,7 +825,7 @@ PRIVATE inline fpu_extended fp_do_log10(fpu_extended x)
|
|||||||
#undef fp_exp
|
#undef fp_exp
|
||||||
#define fp_exp fp_do_exp
|
#define fp_exp fp_do_exp
|
||||||
|
|
||||||
#ifndef FPU_FAST_MATH
|
#if !FPU_FAST_MATH
|
||||||
// FIXME: unimplemented
|
// FIXME: unimplemented
|
||||||
PRIVATE fpu_extended fp_do_exp(fpu_extended x);
|
PRIVATE fpu_extended fp_do_exp(fpu_extended x);
|
||||||
#else
|
#else
|
||||||
@ -940,7 +944,7 @@ PRIVATE inline fpu_extended fp_do_sgn1(fpu_extended x)
|
|||||||
#undef fp_sinh
|
#undef fp_sinh
|
||||||
#define fp_sinh fp_do_sinh
|
#define fp_sinh fp_do_sinh
|
||||||
|
|
||||||
#ifndef FPU_FAST_MATH
|
#if !FPU_FAST_MATH
|
||||||
// FIXME: unimplemented
|
// FIXME: unimplemented
|
||||||
PRIVATE fpu_extended fp_do_sinh(fpu_extended x);
|
PRIVATE fpu_extended fp_do_sinh(fpu_extended x);
|
||||||
#else
|
#else
|
||||||
@ -954,7 +958,7 @@ PRIVATE inline fpu_extended fp_do_sinh(fpu_extended x)
|
|||||||
#undef fp_cosh
|
#undef fp_cosh
|
||||||
#define fp_cosh fp_do_cosh
|
#define fp_cosh fp_do_cosh
|
||||||
|
|
||||||
#ifndef FPU_FAST_MATH
|
#if !FPU_FAST_MATH
|
||||||
// FIXME: unimplemented
|
// FIXME: unimplemented
|
||||||
PRIVATE fpu_extended fp_do_cosh(fpu_extended x);
|
PRIVATE fpu_extended fp_do_cosh(fpu_extended x);
|
||||||
#else
|
#else
|
||||||
@ -968,7 +972,7 @@ PRIVATE inline fpu_extended fp_do_cosh(fpu_extended x)
|
|||||||
#undef fp_tanh
|
#undef fp_tanh
|
||||||
#define fp_tanh fp_do_tanh
|
#define fp_tanh fp_do_tanh
|
||||||
|
|
||||||
#ifndef FPU_FAST_MATH
|
#if !FPU_FAST_MATH
|
||||||
// FIXME: unimplemented
|
// FIXME: unimplemented
|
||||||
PRIVATE fpu_extended fp_do_tanh(fpu_extended x);
|
PRIVATE fpu_extended fp_do_tanh(fpu_extended x);
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user