From 0a036507374004156ba6dfd5db9d0c8efa70e78a Mon Sep 17 00:00:00 2001 From: nsz Date: Sun, 11 Mar 2012 15:38:39 +0100 Subject: [PATCH] long double math fixes for LD64 --- src/math/expl.c | 2 +- src/math/fdiml.c | 8 ++++++++ src/math/fmaxl.c | 8 ++++++++ src/math/fminl.c | 8 ++++++++ src/math/ilogbl.c | 1 + src/math/ldexp.c | 1 + src/math/ldexpf.c | 1 + src/math/ldexpl.c | 1 + src/math/nexttowardl.c | 1 + src/math/powl.c | 7 ++++++- src/math/remainderl.c | 1 + src/math/remquol.c | 1 + src/math/scalblnl.c | 8 ++++++++ 13 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/math/expl.c b/src/math/expl.c index ed794fb..898cf1a 100644 --- a/src/math/expl.c +++ b/src/math/expl.c @@ -70,7 +70,7 @@ #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 long double expl(long double x) { - return x; + return exp(x); } #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 diff --git a/src/math/fdiml.c b/src/math/fdiml.c index 5bb950c..cda3022 100644 --- a/src/math/fdiml.c +++ b/src/math/fdiml.c @@ -1,4 +1,11 @@ #include "libm.h" + +#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +long double fdiml(long double x, long double y) +{ + return fdim(x, y); +} +#else long double fdiml(long double x, long double y) { if (isnan(x)) @@ -7,3 +14,4 @@ long double fdiml(long double x, long double y) return y; return x > y ? x - y : 0; } +#endif diff --git a/src/math/fmaxl.c b/src/math/fmaxl.c index 7020ed4..8a1e365 100644 --- a/src/math/fmaxl.c +++ b/src/math/fmaxl.c @@ -1,4 +1,11 @@ #include "libm.h" + +#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +long double fmaxl(long double x, long double y) +{ + return fmax(x, y); +} +#else long double fmaxl(long double x, long double y) { if (isnan(x)) @@ -10,3 +17,4 @@ long double fmaxl(long double x, long double y) return signbit(x) ? y : x; return x < y ? y : x; } +#endif diff --git a/src/math/fminl.c b/src/math/fminl.c index 9ee0285..ae7159a 100644 --- a/src/math/fminl.c +++ b/src/math/fminl.c @@ -1,4 +1,11 @@ #include "libm.h" + +#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +long double fminl(long double x, long double y) +{ + return fmin(x, y); +} +#else long double fminl(long double x, long double y) { if (isnan(x)) @@ -10,3 +17,4 @@ long double fminl(long double x, long double y) return signbit(x) ? x : y; return x < y ? x : y; } +#endif diff --git a/src/math/ilogbl.c b/src/math/ilogbl.c index 3b42c4d..ed9ddcb 100644 --- a/src/math/ilogbl.c +++ b/src/math/ilogbl.c @@ -1,5 +1,6 @@ #include #include "libm.h" + #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 int ilogbl(long double x) { diff --git a/src/math/ldexp.c b/src/math/ldexp.c index bbf13e6..36835db 100644 --- a/src/math/ldexp.c +++ b/src/math/ldexp.c @@ -1,4 +1,5 @@ #include "libm.h" + double ldexp(double x, int n) { return scalbn(x, n); diff --git a/src/math/ldexpf.c b/src/math/ldexpf.c index fe684ff..f0981ae 100644 --- a/src/math/ldexpf.c +++ b/src/math/ldexpf.c @@ -1,4 +1,5 @@ #include "libm.h" + float ldexpf(float x, int n) { return scalbnf(x, n); diff --git a/src/math/ldexpl.c b/src/math/ldexpl.c index 79b3e86..885ff6e 100644 --- a/src/math/ldexpl.c +++ b/src/math/ldexpl.c @@ -1,4 +1,5 @@ #include "libm.h" + long double ldexpl(long double x, int n) { return scalbnl(x, n); diff --git a/src/math/nexttowardl.c b/src/math/nexttowardl.c index 48ce417..c393ce9 100644 --- a/src/math/nexttowardl.c +++ b/src/math/nexttowardl.c @@ -1,4 +1,5 @@ #include "libm.h" + long double nexttowardl(long double x, long double y) { return nextafterl(x, y); diff --git a/src/math/powl.c b/src/math/powl.c index 0f0d894..690f294 100644 --- a/src/math/powl.c +++ b/src/math/powl.c @@ -69,7 +69,12 @@ #include "libm.h" -#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 +#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +long double powl(long double x, long double y) +{ + return pow(x, y); +} +#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 /* Table size */ #define NXT 32 diff --git a/src/math/remainderl.c b/src/math/remainderl.c index 7794560..b99f938 100644 --- a/src/math/remainderl.c +++ b/src/math/remainderl.c @@ -1,4 +1,5 @@ #include "libm.h" + #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 long double remainderl(long double x, long double y) { diff --git a/src/math/remquol.c b/src/math/remquol.c index cacc5ba..dd18f35 100644 --- a/src/math/remquol.c +++ b/src/math/remquol.c @@ -11,6 +11,7 @@ */ #include "libm.h" + #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 long double remquol(long double x, long double y, int *quo) { diff --git a/src/math/scalblnl.c b/src/math/scalblnl.c index 4199e44..82ebbed 100644 --- a/src/math/scalblnl.c +++ b/src/math/scalblnl.c @@ -1,5 +1,12 @@ #include #include "libm.h" + +#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +long double scalblnl(long double x, long n) +{ + return scalbln(x, n); +} +#else long double scalblnl(long double x, long n) { if (n > INT_MAX) @@ -8,3 +15,4 @@ long double scalblnl(long double x, long n) n = INT_MIN; return scalbnl(x, n); } +#endif -- 2.20.1