diff options
Diffstat (limited to 'contrib/compiler-rt/lib/ppc')
-rw-r--r-- | contrib/compiler-rt/lib/ppc/DD.h | 2 | ||||
-rw-r--r-- | contrib/compiler-rt/lib/ppc/divtc3.c | 59 | ||||
-rw-r--r-- | contrib/compiler-rt/lib/ppc/fixtfdi.c | 4 | ||||
-rw-r--r-- | contrib/compiler-rt/lib/ppc/fixunstfdi.c | 1 | ||||
-rw-r--r-- | contrib/compiler-rt/lib/ppc/floatditf.c | 1 | ||||
-rw-r--r-- | contrib/compiler-rt/lib/ppc/floatunditf.c | 1 | ||||
-rw-r--r-- | contrib/compiler-rt/lib/ppc/multc3.c | 39 |
7 files changed, 52 insertions, 55 deletions
diff --git a/contrib/compiler-rt/lib/ppc/DD.h b/contrib/compiler-rt/lib/ppc/DD.h index 9ecd1f5..13862dc 100644 --- a/contrib/compiler-rt/lib/ppc/DD.h +++ b/contrib/compiler-rt/lib/ppc/DD.h @@ -1,7 +1,7 @@ #ifndef __DD_HEADER #define __DD_HEADER -#include <stdint.h> +#include "../int_lib.h" typedef union { long double ld; diff --git a/contrib/compiler-rt/lib/ppc/divtc3.c b/contrib/compiler-rt/lib/ppc/divtc3.c index d41f621..2991281 100644 --- a/contrib/compiler-rt/lib/ppc/divtc3.c +++ b/contrib/compiler-rt/lib/ppc/divtc3.c @@ -3,16 +3,16 @@ */ #include "DD.h" -#include <math.h> +#include "../int_math.h" -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif /* INFINITY */ +#if !defined(CRT_INFINITY) && defined(HUGE_VAL) +#define CRT_INFINITY HUGE_VAL +#endif /* CRT_INFINITY */ -#define makeFinite(x) { \ - (x).s.hi = __builtin_copysign(isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ - (x).s.lo = 0.0; \ - } +#define makeFinite(x) { \ + (x).s.hi = crt_copysign(crt_isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ + (x).s.lo = 0.0; \ + } long double __gcc_qadd(long double, long double); long double __gcc_qsub(long double, long double); @@ -26,16 +26,16 @@ __divtc3(long double a, long double b, long double c, long double d) DD dDD = { .ld = d }; int ilogbw = 0; - const double logbw = logb(__builtin_fmax( __builtin_fabs(cDD.s.hi), __builtin_fabs(dDD.s.hi) )); + const double logbw = crt_logb(crt_fmax(crt_fabs(cDD.s.hi), crt_fabs(dDD.s.hi) )); - if (isfinite(logbw)) + if (crt_isfinite(logbw)) { ilogbw = (int)logbw; - cDD.s.hi = scalbn(cDD.s.hi, -ilogbw); - cDD.s.lo = scalbn(cDD.s.lo, -ilogbw); - dDD.s.hi = scalbn(dDD.s.hi, -ilogbw); - dDD.s.lo = scalbn(dDD.s.lo, -ilogbw); + cDD.s.hi = crt_scalbn(cDD.s.hi, -ilogbw); + cDD.s.lo = crt_scalbn(cDD.s.lo, -ilogbw); + dDD.s.hi = crt_scalbn(dDD.s.hi, -ilogbw); + dDD.s.lo = crt_scalbn(dDD.s.lo, -ilogbw); } const long double denom = __gcc_qadd(__gcc_qmul(cDD.ld, cDD.ld), __gcc_qmul(dDD.ld, dDD.ld)); @@ -45,42 +45,45 @@ __divtc3(long double a, long double b, long double c, long double d) DD real = { .ld = __gcc_qdiv(realNumerator, denom) }; DD imag = { .ld = __gcc_qdiv(imagNumerator, denom) }; - real.s.hi = scalbn(real.s.hi, -ilogbw); - real.s.lo = scalbn(real.s.lo, -ilogbw); - imag.s.hi = scalbn(imag.s.hi, -ilogbw); - imag.s.lo = scalbn(imag.s.lo, -ilogbw); + real.s.hi = crt_scalbn(real.s.hi, -ilogbw); + real.s.lo = crt_scalbn(real.s.lo, -ilogbw); + imag.s.hi = crt_scalbn(imag.s.hi, -ilogbw); + imag.s.lo = crt_scalbn(imag.s.lo, -ilogbw); - if (isnan(real.s.hi) && isnan(imag.s.hi)) + if (crt_isnan(real.s.hi) && crt_isnan(imag.s.hi)) { DD aDD = { .ld = a }; DD bDD = { .ld = b }; DD rDD = { .ld = denom }; - if ((rDD.s.hi == 0.0) && (!isnan(aDD.s.hi) || !isnan(bDD.s.hi))) + if ((rDD.s.hi == 0.0) && (!crt_isnan(aDD.s.hi) || + !crt_isnan(bDD.s.hi))) { - real.s.hi = __builtin_copysign(INFINITY,cDD.s.hi) * aDD.s.hi; + real.s.hi = crt_copysign(CRT_INFINITY,cDD.s.hi) * aDD.s.hi; real.s.lo = 0.0; - imag.s.hi = __builtin_copysign(INFINITY,cDD.s.hi) * bDD.s.hi; + imag.s.hi = crt_copysign(CRT_INFINITY,cDD.s.hi) * bDD.s.hi; imag.s.lo = 0.0; } - else if ((isinf(aDD.s.hi) || isinf(bDD.s.hi)) && isfinite(cDD.s.hi) && isfinite(dDD.s.hi)) + else if ((crt_isinf(aDD.s.hi) || crt_isinf(bDD.s.hi)) && + crt_isfinite(cDD.s.hi) && crt_isfinite(dDD.s.hi)) { makeFinite(aDD); makeFinite(bDD); - real.s.hi = INFINITY * (aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi); + real.s.hi = CRT_INFINITY * (aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi); real.s.lo = 0.0; - imag.s.hi = INFINITY * (bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi); + imag.s.hi = CRT_INFINITY * (bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi); imag.s.lo = 0.0; } - else if ((isinf(cDD.s.hi) || isinf(dDD.s.hi)) && isfinite(aDD.s.hi) && isfinite(bDD.s.hi)) + else if ((crt_isinf(cDD.s.hi) || crt_isinf(dDD.s.hi)) && + crt_isfinite(aDD.s.hi) && crt_isfinite(bDD.s.hi)) { makeFinite(cDD); makeFinite(dDD); - real.s.hi = __builtin_copysign(0.0,(aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi)); + real.s.hi = crt_copysign(0.0,(aDD.s.hi*cDD.s.hi + bDD.s.hi*dDD.s.hi)); real.s.lo = 0.0; - imag.s.hi = __builtin_copysign(0.0,(bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi)); + imag.s.hi = crt_copysign(0.0,(bDD.s.hi*cDD.s.hi - aDD.s.hi*dDD.s.hi)); imag.s.lo = 0.0; } } diff --git a/contrib/compiler-rt/lib/ppc/fixtfdi.c b/contrib/compiler-rt/lib/ppc/fixtfdi.c index fa113a0..56e7b3f 100644 --- a/contrib/compiler-rt/lib/ppc/fixtfdi.c +++ b/contrib/compiler-rt/lib/ppc/fixtfdi.c @@ -7,7 +7,7 @@ */ #include "DD.h" -#include <stdint.h> +#include "../int_math.h" uint64_t __fixtfdi(long double input) { @@ -65,7 +65,7 @@ uint64_t __fixtfdi(long double input) /* Edge cases handled here: */ /* |x| < 1, result is zero. */ - if (1.0 > __builtin_fabs(x.s.hi)) + if (1.0 > crt_fabs(x.s.hi)) return INT64_C(0); /* x very close to INT64_MIN, care must be taken to see which side we are on. */ diff --git a/contrib/compiler-rt/lib/ppc/fixunstfdi.c b/contrib/compiler-rt/lib/ppc/fixunstfdi.c index 1fb5248..5e6e2ce 100644 --- a/contrib/compiler-rt/lib/ppc/fixunstfdi.c +++ b/contrib/compiler-rt/lib/ppc/fixunstfdi.c @@ -6,7 +6,6 @@ /* This file implements the PowerPC 128-bit double-double -> uint64_t conversion */ #include "DD.h" -#include <stdint.h> uint64_t __fixunstfdi(long double input) { diff --git a/contrib/compiler-rt/lib/ppc/floatditf.c b/contrib/compiler-rt/lib/ppc/floatditf.c index ed23dc8..beabdd0 100644 --- a/contrib/compiler-rt/lib/ppc/floatditf.c +++ b/contrib/compiler-rt/lib/ppc/floatditf.c @@ -6,7 +6,6 @@ /* This file implements the PowerPC long long -> long double conversion */ #include "DD.h" -#include <stdint.h> long double __floatditf(int64_t a) { diff --git a/contrib/compiler-rt/lib/ppc/floatunditf.c b/contrib/compiler-rt/lib/ppc/floatunditf.c index 20a3b71..b12e1e7 100644 --- a/contrib/compiler-rt/lib/ppc/floatunditf.c +++ b/contrib/compiler-rt/lib/ppc/floatunditf.c @@ -6,7 +6,6 @@ /* This file implements the PowerPC unsigned long long -> long double conversion */ #include "DD.h" -#include <stdint.h> long double __floatunditf(uint64_t a) { diff --git a/contrib/compiler-rt/lib/ppc/multc3.c b/contrib/compiler-rt/lib/ppc/multc3.c index 9d17a2c..738b65a 100644 --- a/contrib/compiler-rt/lib/ppc/multc3.c +++ b/contrib/compiler-rt/lib/ppc/multc3.c @@ -3,23 +3,19 @@ */ #include "DD.h" -#include <math.h> +#include "../int_math.h" -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif /* INFINITY */ +#define makeFinite(x) { \ + (x).s.hi = crt_copysign(crt_isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ + (x).s.lo = 0.0; \ + } -#define makeFinite(x) { \ - (x).s.hi = __builtin_copysign(isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \ - (x).s.lo = 0.0; \ - } - -#define zeroNaN(x) { \ - if (isnan((x).s.hi)) { \ - (x).s.hi = __builtin_copysign(0.0, (x).s.hi); \ - (x).s.lo = 0.0; \ - } \ - } +#define zeroNaN(x) { \ + if (crt_isnan((x).s.hi)) { \ + (x).s.hi = crt_copysign(0.0, (x).s.hi); \ + (x).s.lo = 0.0; \ + } \ + } long double __gcc_qadd(long double, long double); long double __gcc_qsub(long double, long double); @@ -36,7 +32,7 @@ __multc3(long double a, long double b, long double c, long double d) DD real = { .ld = __gcc_qsub(ac,bd) }; DD imag = { .ld = __gcc_qadd(ad,bc) }; - if (isnan(real.s.hi) && isnan(imag.s.hi)) + if (crt_isnan(real.s.hi) && crt_isnan(imag.s.hi)) { int recalc = 0; @@ -45,7 +41,7 @@ __multc3(long double a, long double b, long double c, long double d) DD cDD = { .ld = c }; DD dDD = { .ld = d }; - if (isinf(aDD.s.hi) || isinf(bDD.s.hi)) + if (crt_isinf(aDD.s.hi) || crt_isinf(bDD.s.hi)) { makeFinite(aDD); makeFinite(bDD); @@ -54,7 +50,7 @@ __multc3(long double a, long double b, long double c, long double d) recalc = 1; } - if (isinf(cDD.s.hi) || isinf(dDD.s.hi)) + if (crt_isinf(cDD.s.hi) || crt_isinf(dDD.s.hi)) { makeFinite(cDD); makeFinite(dDD); @@ -70,7 +66,8 @@ __multc3(long double a, long double b, long double c, long double d) DD adDD = { .ld = ad }; DD bcDD = { .ld = bc }; - if (isinf(acDD.s.hi) || isinf(bdDD.s.hi) || isinf(adDD.s.hi) || isinf(bcDD.s.hi)) + if (crt_isinf(acDD.s.hi) || crt_isinf(bdDD.s.hi) || + crt_isinf(adDD.s.hi) || crt_isinf(bcDD.s.hi)) { zeroNaN(aDD); zeroNaN(bDD); @@ -82,9 +79,9 @@ __multc3(long double a, long double b, long double c, long double d) if (recalc) { - real.s.hi = INFINITY * (aDD.s.hi*cDD.s.hi - bDD.s.hi*dDD.s.hi); + real.s.hi = CRT_INFINITY * (aDD.s.hi*cDD.s.hi - bDD.s.hi*dDD.s.hi); real.s.lo = 0.0; - imag.s.hi = INFINITY * (aDD.s.hi*dDD.s.hi + bDD.s.hi*cDD.s.hi); + imag.s.hi = CRT_INFINITY * (aDD.s.hi*dDD.s.hi + bDD.s.hi*cDD.s.hi); imag.s.lo = 0.0; } } |