--- BasiliskII/src/uae_cpu/fpu/mathlib.h 2002/09/15 18:21:13 1.2 +++ BasiliskII/src/uae_cpu/fpu/mathlib.h 2002/09/19 16:02:13 1.5 @@ -103,32 +103,30 @@ union fpu_single_shape { /* This is the IEEE 754 single-precision format. */ struct { -#if UAE_BYTE_ORDER == UAE_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned int negative:1; unsigned int exponent:8; unsigned int mantissa:23; -#endif /* Big endian. */ -#if UAE_BYTE_ORDER == UAE_LITTLE_ENDIAN +#else unsigned int mantissa:23; unsigned int exponent:8; unsigned int negative:1; -#endif /* Little endian. */ +#endif } ieee; /* This format makes it easier to see if a NaN is a signalling NaN. */ struct { -#if UAE_BYTE_ORDER == UAE_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned int negative:1; unsigned int exponent:8; unsigned int quiet_nan:1; unsigned int mantissa:22; -#endif /* Big endian. */ -#if UAE_BYTE_ORDER == UAE_LITTLE_ENDIAN +#else unsigned int mantissa:22; unsigned int quiet_nan:1; unsigned int exponent:8; unsigned int negative:1; -#endif /* Little endian. */ +#endif } ieee_nan; }; @@ -138,15 +136,14 @@ union fpu_double_shape { /* This is the IEEE 754 double-precision format. */ struct { -#if UAE_BYTE_ORDER == UAE_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned int negative:1; unsigned int exponent:11; /* Together these comprise the mantissa. */ unsigned int mantissa0:20; unsigned int mantissa1:32; -#endif /* Big endian. */ -#if UAE_BYTE_ORDER == UAE_LITTLE_ENDIAN -# if UAE_FLOAT_WORD_ORDER == UAE_BIG_ENDIAN +#else +# if HOST_FLOAT_WORDS_BIG_ENDIAN unsigned int mantissa0:20; unsigned int exponent:11; unsigned int negative:1; @@ -158,12 +155,12 @@ union fpu_double_shape { unsigned int exponent:11; unsigned int negative:1; # endif -#endif /* Little endian. */ +#endif } ieee; /* This format makes it easier to see if a NaN is a signalling NaN. */ struct { -#if UAE_BYTE_ORDER == UAE_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned int negative:1; unsigned int exponent:11; unsigned int quiet_nan:1; @@ -171,7 +168,7 @@ union fpu_double_shape { unsigned int mantissa0:19; unsigned int mantissa1:32; #else -# if UAE_FLOAT_WORD_ORDER == UAE_BIG_ENDIAN +# if HOST_FLOAT_WORDS_BIG_ENDIAN unsigned int mantissa0:19; unsigned int quiet_nan:1; unsigned int exponent:11; @@ -190,7 +187,7 @@ union fpu_double_shape { /* This format is used to extract the sign_exponent and mantissa parts only */ struct { -#if UAE_FLOAT_WORD_ORDER == UAE_BIG_ENDIAN +#if HOST_FLOAT_WORDS_BIG_ENDIAN unsigned int msw:32; unsigned int lsw:32; #else @@ -207,15 +204,14 @@ union fpu_extended_shape { /* This is the IEEE 854 double-extended-precision format. */ struct { -#if UAE_BYTE_ORDER == UAE_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned int negative:1; unsigned int exponent:15; unsigned int empty:16; unsigned int mantissa0:32; unsigned int mantissa1:32; -#endif -#if UAE_BYTE_ORDER == UAE_LITTLE_ENDIAN -# if UAE_FLOAT_WORD_ORDER == UAE_BIG_ENDIAN +#else +# if HOST_FLOAT_WORDS_BIG_ENDIAN unsigned int exponent:15; unsigned int negative:1; unsigned int empty:16; @@ -233,7 +229,7 @@ union fpu_extended_shape { /* This is for NaNs in the IEEE 854 double-extended-precision format. */ struct { -#if UAE_BYTE_ORDER == UAE_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned int negative:1; unsigned int exponent:15; unsigned int empty:16; @@ -241,9 +237,8 @@ union fpu_extended_shape { unsigned int quiet_nan:1; unsigned int mantissa0:30; unsigned int mantissa1:32; -#endif -#if UAE_BYTE_ORDER == UAE_LITTLE_ENDIAN -# if UAE_FLOAT_WORD_ORDER == UAE_BIG_ENDIAN +#else +# if HOST_FLOAT_WORDS_BIG_ENDIAN unsigned int exponent:15; unsigned int negative:1; unsigned int empty:16; @@ -265,7 +260,7 @@ union fpu_extended_shape { /* This format is used to extract the sign_exponent and mantissa parts only */ struct { -#if UAE_FLOAT_WORD_ORDER == UAE_BIG_ENDIAN +#if HOST_FLOAT_WORDS_BIG_ENDIAN unsigned int sign_exponent:16; unsigned int empty:16; unsigned int msw:32; @@ -287,7 +282,7 @@ union fpu_extended_shape { /* This is the IEEE 854 quad-precision format. */ struct { -#if UAE_BYTE_ORDER == UAE_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned int negative:1; unsigned int exponent:15; unsigned int mantissa0:16; @@ -306,7 +301,7 @@ union fpu_extended_shape { /* This is for NaNs in the IEEE 854 quad-precision format. */ struct { -#if UAE_BYTE_ORDER == UAE_BIG_ENDIAN +#ifdef WORDS_BIGENDIAN unsigned int negative:1; unsigned int exponent:15; unsigned int quiet_nan:1; @@ -326,7 +321,7 @@ union fpu_extended_shape { } ieee_nan; /* This format is used to extract the sign_exponent and mantissa parts only */ -#if UAE_FLOAT_WORD_ORDER == UAE_BIG_ENDIAN +#if HOST_FLOAT_WORDS_BIG_ENDIAN struct { uae_u64 msw; uae_u64 lsw; @@ -400,12 +395,12 @@ PRIVATE inline bool FFPU fp_do_isnan(fpu return (int)(((uae_u32)(se)) >> 16); #endif #else -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); - return (sxp->ieee_nan.exponent == FP_DOUBLE_EXP_MAX) -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); return (sxp->ieee_nan.exponent == FP_EXTENDED_EXP_MAX) +#else + fp_declare_init_shape(sxp, r, double); + return (sxp->ieee_nan.exponent == FP_DOUBLE_EXP_MAX) #endif && (sxp->ieee_nan.mantissa0 != 0) && (sxp->ieee_nan.mantissa1 != 0) @@ -459,12 +454,12 @@ PRIVATE inline bool FFPU fp_do_isinf(fpu return ~(lx >> 31) & (1 - (se >> 14)); #endif #else -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); - return (sxp->ieee_nan.exponent == FP_DOUBLE_EXP_MAX) -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); return (sxp->ieee_nan.exponent == FP_EXTENDED_EXP_MAX) +#else + fp_declare_init_shape(sxp, r, double); + return (sxp->ieee_nan.exponent == FP_DOUBLE_EXP_MAX) #endif && (sxp->ieee_nan.mantissa0 == 0) && (sxp->ieee_nan.mantissa1 == 0) @@ -481,10 +476,10 @@ PRIVATE inline bool FFPU fp_do_isinf(fpu PRIVATE inline bool FFPU fp_do_isneg(fpu_register const & r) { -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); +#else + fp_declare_init_shape(sxp, r, double); #endif return sxp->ieee.negative; } @@ -495,10 +490,10 @@ PRIVATE inline bool FFPU fp_do_isneg(fpu PRIVATE inline bool FFPU fp_do_iszero(fpu_register const & r) { // TODO: BRANCHES_ARE_EXPENSIVE -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); +#else + fp_declare_init_shape(sxp, r, double); #endif return (sxp->ieee.exponent == 0) && (sxp->ieee.mantissa0 == 0) @@ -531,14 +526,14 @@ PRIVATE inline void FFPU get_source_flag PRIVATE inline void FFPU make_nan(fpu_register & r) { // FIXME: is that correct ? -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); - sxp->ieee.exponent = FP_DOUBLE_EXP_MAX; - sxp->ieee.mantissa0 = 0xfffff; -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); sxp->ieee.exponent = FP_EXTENDED_EXP_MAX; sxp->ieee.mantissa0 = 0xffffffff; +#else + fp_declare_init_shape(sxp, r, double); + sxp->ieee.exponent = FP_DOUBLE_EXP_MAX; + sxp->ieee.mantissa0 = 0xfffff; #endif sxp->ieee.mantissa1 = 0xffffffff; #ifdef USE_QUAD_DOUBLE @@ -552,10 +547,10 @@ PRIVATE inline void FFPU make_zero_posit #if 1 r = +0.0; #else -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); +#else + fp_declare_init_shape(sxp, r, double); #endif sxp->ieee.negative = 0; sxp->ieee.exponent = 0; @@ -573,10 +568,10 @@ PRIVATE inline void FFPU make_zero_negat #if 1 r = -0.0; #else -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); +#else + fp_declare_init_shape(sxp, r, double); #endif sxp->ieee.negative = 1; sxp->ieee.exponent = 0; @@ -591,12 +586,12 @@ PRIVATE inline void FFPU make_zero_negat PRIVATE inline void FFPU make_inf_positive(fpu_register & r) { -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); - sxp->ieee_nan.exponent = FP_DOUBLE_EXP_MAX; -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); sxp->ieee_nan.exponent = FP_EXTENDED_EXP_MAX; +#else + fp_declare_init_shape(sxp, r, double); + sxp->ieee_nan.exponent = FP_DOUBLE_EXP_MAX; #endif sxp->ieee_nan.negative = 0; sxp->ieee_nan.mantissa0 = 0; @@ -609,12 +604,12 @@ PRIVATE inline void FFPU make_inf_positi PRIVATE inline void FFPU make_inf_negative(fpu_register & r) { -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); - sxp->ieee_nan.exponent = FP_DOUBLE_EXP_MAX; -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); sxp->ieee_nan.exponent = FP_EXTENDED_EXP_MAX; +#else + fp_declare_init_shape(sxp, r, double); + sxp->ieee_nan.exponent = FP_DOUBLE_EXP_MAX; #endif sxp->ieee_nan.negative = 1; sxp->ieee_nan.mantissa0 = 0; @@ -627,24 +622,24 @@ PRIVATE inline void FFPU make_inf_negati PRIVATE inline fpu_register FFPU fast_fgetexp(fpu_register const & r) { -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); - return (sxp->ieee.exponent - FP_DOUBLE_EXP_BIAS); -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); return (sxp->ieee.exponent - FP_EXTENDED_EXP_BIAS); +#else + fp_declare_init_shape(sxp, r, double); + return (sxp->ieee.exponent - FP_DOUBLE_EXP_BIAS); #endif } // Normalize to range 1..2 PRIVATE inline void FFPU fast_remove_exponent(fpu_register & r) { -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sxp, r, double); - sxp->ieee.exponent = FP_DOUBLE_EXP_BIAS; -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sxp, r, extended); sxp->ieee.exponent = FP_EXTENDED_EXP_BIAS; +#else + fp_declare_init_shape(sxp, r, double); + sxp->ieee.exponent = FP_DOUBLE_EXP_BIAS; #endif } @@ -652,12 +647,12 @@ PRIVATE inline void FFPU fast_remove_exp // of the source and destination operands. PRIVATE inline uae_u32 FFPU get_quotient_sign(fpu_register const & ra, fpu_register const & rb) { -#ifndef USE_LONG_DOUBLE - fp_declare_init_shape(sap, ra, double); - fp_declare_init_shape(sbp, rb, double); -#else +#if USE_LONG_DOUBLE || USE_QUAD_DOUBLE fp_declare_init_shape(sap, ra, extended); fp_declare_init_shape(sbp, rb, extended); +#else + fp_declare_init_shape(sap, ra, double); + fp_declare_init_shape(sbp, rb, double); #endif return ((sap->ieee.negative ^ sbp->ieee.negative) ? FPSR_QUOTIENT_SIGN : 0); } @@ -666,47 +661,127 @@ PRIVATE inline uae_u32 FFPU get_quotient /* --- Math functions --- */ /* -------------------------------------------------------------------------- */ -#if FPU_USE_ISO_C99 && USE_LONG_DOUBLE -# define fp_log logl -# define fp_log10 log10l -# define fp_exp expl -# define fp_pow powl -# define fp_fabs fabsl -# define fp_sqrt sqrtl -# define fp_sin sinl -# define fp_cos cosl -# define fp_tan tanl -# define fp_sinh sinhl -# define fp_cosh coshl -# define fp_tanh tanhl -# define fp_asin asinl -# define fp_acos acosl -# define fp_atan atanl -# define fp_asinh asinhl -# define fp_acosh acoshl -# define fp_atanh atanhl -# define fp_floor floorl -# define fp_ceil ceill -#else +#if FPU_USE_ISO_C99 && (USE_LONG_DOUBLE || USE_QUAD_DOUBLE) +# ifdef HAVE_LOGL +# define fp_log logl +# endif +# ifdef HAVE_LOG10L +# define fp_log10 log10l +# endif +# ifdef HAVE_EXPL +# define fp_exp expl +# endif +# ifdef HAVE_POWL +# define fp_pow powl +# endif +# ifdef HAVE_FABSL +# define fp_fabs fabsl +# endif +# ifdef HAVE_SQRTL +# define fp_sqrt sqrtl +# endif +# ifdef HAVE_SINL +# define fp_sin sinl +# endif +# ifdef HAVE_COSL +# define fp_cos cosl +# endif +# ifdef HAVE_TANL +# define fp_tan tanl +# endif +# ifdef HAVE_SINHL +# define fp_sinh sinhl +# endif +# ifdef HAVE_COSHL +# define fp_cosh coshl +# endif +# ifdef HAVE_TANHL +# define fp_tanh tanhl +# endif +# ifdef HAVE_ASINL +# define fp_asin asinl +# endif +# ifdef HAVE_ACOSL +# define fp_acos acosl +# endif +# ifdef HAVE_ATANL +# define fp_atan atanl +# endif +# ifdef HAVE_ASINHL +# define fp_asinh asinhl +# endif +# ifdef HAVE_ACOSHL +# define fp_acosh acoshl +# endif +# ifdef HAVE_ATANHL +# define fp_atanh atanhl +# endif +# ifdef HAVE_FLOORL +# define fp_floor floorl +# endif +# ifdef HAVE_CEILL +# define fp_ceil ceill +# endif +#endif + +#ifndef fp_log # define fp_log log +#endif +#ifndef fp_log10 # define fp_log10 log10 +#endif +#ifndef fp_exp # define fp_exp exp +#endif +#ifndef fp_pow # define fp_pow pow +#endif +#ifndef fp_fabs # define fp_fabs fabs +#endif +#ifndef fp_sqrt # define fp_sqrt sqrt +#endif +#ifndef fp_sin # define fp_sin sin +#endif +#ifndef fp_cos # define fp_cos cos +#endif +#ifndef fp_tan # define fp_tan tan +#endif +#ifndef fp_sinh # define fp_sinh sinh +#endif +#ifndef fp_cosh # define fp_cosh cosh +#endif +#ifndef fp_tanh # define fp_tanh tanh +#endif +#ifndef fp_asin # define fp_asin asin +#endif +#ifndef fp_acos # define fp_acos acos +#endif +#ifndef fp_atan # define fp_atan atan +#endif +#ifndef fp_asinh # define fp_asinh asinh +#endif +#ifndef fp_acosh # define fp_acosh acosh +#endif +#ifndef fp_atanh # define fp_atanh atanh +#endif +#ifndef fp_floor # define fp_floor floor +#endif +#ifndef fp_ceil # define fp_ceil ceil #endif