summaryrefslogtreecommitdiffstats
path: root/libm/upstream-freebsd/lib/msun
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-04-17 18:17:32 +0100
committerCalin Juravle <calin@google.com>2014-04-23 19:03:06 +0100
commit1abc9ff6a5b5f8a9925f1b8d9d333bc5bc7d407f (patch)
tree3ea8e2f0f7288d7019004b397847228678d29843 /libm/upstream-freebsd/lib/msun
parent4ff967f3301087ea6ccaa17cfb1f04a034448a68 (diff)
downloadbionic-1abc9ff6a5b5f8a9925f1b8d9d333bc5bc7d407f.zip
bionic-1abc9ff6a5b5f8a9925f1b8d9d333bc5bc7d407f.tar.gz
bionic-1abc9ff6a5b5f8a9925f1b8d9d333bc5bc7d407f.tar.bz2
Clean-up _fpmath and fake_long_doubles
- promoted IEEEld2bits to fpmath since most of the where the same for diffrent archs - removed _fpmath - reinstated weak_references - moved isfinite and isnormal to libc - clean up fake_long_doubles - clean up some useless ifdefs - added missing nexttoward* tests Bug: 14134235 Change-Id: I95639c4885653fe47fd7dc0570ee5bb3389bbc6b
Diffstat (limited to 'libm/upstream-freebsd/lib/msun')
-rw-r--r--libm/upstream-freebsd/lib/msun/src/imprecise.c (renamed from libm/upstream-freebsd/lib/msun/src/s_isfinite.c)57
-rw-r--r--libm/upstream-freebsd/lib/msun/src/s_isnormal.c58
-rw-r--r--libm/upstream-freebsd/lib/msun/src/s_signbit.c58
3 files changed, 34 insertions, 139 deletions
diff --git a/libm/upstream-freebsd/lib/msun/src/s_isfinite.c b/libm/upstream-freebsd/lib/msun/src/imprecise.c
index c9d1bd7..a7503bf 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_isfinite.c
+++ b/libm/upstream-freebsd/lib/msun/src/imprecise.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * Copyright (c) 2013 David Chisnall
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,33 +26,44 @@
* $FreeBSD$
*/
+#include <float.h>
#include <math.h>
-#include "fpmath.h"
-
-int
-__isfinite(double d)
-{
- union IEEEd2bits u;
-
- u.d = d;
- return (u.bits.exp != 2047);
-}
+/*
+ * If long double is not the same size as double, then these will lose
+ * precision and we should emit a warning whenever something links against
+ * them.
+ */
+#if (LDBL_MANT_DIG > 53)
+#define WARN_IMPRECISE(x) \
+ __warn_references(x, # x " has lower than advertised precision");
+#else
+#define WARN_IMPRECISE(x)
+#endif
+/*
+ * Declare the functions as weak variants so that other libraries providing
+ * real versions can override them.
+ */
+#define DECLARE_WEAK(x)\
+ __weak_reference(imprecise_## x, x);\
+ WARN_IMPRECISE(x)
-int
-__isfinitef(float f)
+long double
+imprecise_powl(long double x, long double y)
{
- union IEEEf2bits u;
- u.f = f;
- return (u.bits.exp != 255);
+ return pow(x, y);
}
+DECLARE_WEAK(powl);
-int
-__isfinitel(long double e)
-{
- union IEEEl2bits u;
+#define DECLARE_IMPRECISE(f) \
+ long double imprecise_ ## f ## l(long double v) { return f(v); }\
+ DECLARE_WEAK(f ## l)
- u.e = e;
- return (u.bits.exp != 32767);
-}
+DECLARE_IMPRECISE(cosh);
+DECLARE_IMPRECISE(erfc);
+DECLARE_IMPRECISE(erf);
+DECLARE_IMPRECISE(lgamma);
+DECLARE_IMPRECISE(sinh);
+DECLARE_IMPRECISE(tanh);
+DECLARE_IMPRECISE(tgamma);
diff --git a/libm/upstream-freebsd/lib/msun/src/s_isnormal.c b/libm/upstream-freebsd/lib/msun/src/s_isnormal.c
deleted file mode 100644
index 49f2a74..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_isnormal.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-int
-__isnormal(double d)
-{
- union IEEEd2bits u;
-
- u.d = d;
- return (u.bits.exp != 0 && u.bits.exp != 2047);
-}
-
-int
-__isnormalf(float f)
-{
- union IEEEf2bits u;
-
- u.f = f;
- return (u.bits.exp != 0 && u.bits.exp != 255);
-}
-
-int
-__isnormall(long double e)
-{
- union IEEEl2bits u;
-
- u.e = e;
- return (u.bits.exp != 0 && u.bits.exp != 32767);
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_signbit.c b/libm/upstream-freebsd/lib/msun/src/s_signbit.c
deleted file mode 100644
index 01eb3ab..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_signbit.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-int
-__signbit(double d)
-{
- union IEEEd2bits u;
-
- u.d = d;
- return (u.bits.sign);
-}
-
-int
-__signbitf(float f)
-{
- union IEEEf2bits u;
-
- u.f = f;
- return (u.bits.sign);
-}
-
-int
-__signbitl(long double e)
-{
- union IEEEl2bits u;
-
- u.e = e;
- return (u.bits.sign);
-}