diff options
Diffstat (limited to 'libm')
-rw-r--r-- | libm/Android.mk | 8 | ||||
-rw-r--r-- | libm/fake_long_double.c | 8 | ||||
-rw-r--r-- | libm/fpclassify.c | 94 | ||||
-rw-r--r-- | libm/isinf.c | 68 | ||||
-rw-r--r-- | libm/upstream-freebsd/lib/msun/src/s_isnan.c | 65 |
5 files changed, 4 insertions, 239 deletions
diff --git a/libm/Android.mk b/libm/Android.mk index aea4662..1bd428d 100644 --- a/libm/Android.mk +++ b/libm/Android.mk @@ -1,10 +1,10 @@ LOCAL_PATH:= $(call my-dir) -# TODO: these come from from upstream's libc, not libm! +# TODO: this comes from from upstream's libc, not libm, but it's an +# implementation detail that should have hidden visibility, so it needs +# to be in whatever library the math code is in. libm_common_src_files := \ digittoint.c \ - fpclassify.c \ - isinf.c \ # TODO: this is not in the BSDs. libm_common_src_files += \ @@ -129,7 +129,6 @@ libm_common_src_files += \ upstream-freebsd/lib/msun/src/s_ilogb.c \ upstream-freebsd/lib/msun/src/s_ilogbf.c \ upstream-freebsd/lib/msun/src/s_isfinite.c \ - upstream-freebsd/lib/msun/src/s_isnan.c \ upstream-freebsd/lib/msun/src/s_isnormal.c \ upstream-freebsd/lib/msun/src/s_llrint.c \ upstream-freebsd/lib/msun/src/s_llrintf.c \ @@ -237,6 +236,7 @@ libm_common_cflags := \ -include $(LOCAL_PATH)/freebsd-compat.h \ libm_common_includes := $(LOCAL_PATH)/upstream-freebsd/lib/msun/src/ + libm_ld_includes := $(LOCAL_PATH)/upstream-freebsd/lib/msun/ld128/ # diff --git a/libm/fake_long_double.c b/libm/fake_long_double.c index b5b264b..611512a 100644 --- a/libm/fake_long_double.c +++ b/libm/fake_long_double.c @@ -17,11 +17,6 @@ #include <float.h> #include <math.h> -extern int __isinf(double); /* isinf.c */ -int (isinf)(double a1) { return __isinf(a1); } - -int (isnanf)(float a1) { return __isnanf(a1); } - /* * On LP64 sizeof(long double) > sizeof(double) so functions which fall back * to their double variants lose precision. Emit a warning whenever something @@ -58,10 +53,7 @@ WARN_IMPRECISE(powl) * that call the regular "double" function. */ -int __fpclassifyl(long double a1) { return __fpclassifyd(a1); } int __isfinitel(long double a1) { return __isfinite(a1); } -int __isinfl(long double a1) { return __isinf(a1); } -int __isnanl(long double a1) { return (isnan)(a1); } int __isnormall(long double a1) { return __isnormal(a1); } int __signbitl(long double a1) { return __signbit(a1); } diff --git a/libm/fpclassify.c b/libm/fpclassify.c deleted file mode 100644 index a039138..0000000 --- a/libm/fpclassify.c +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org> - * Copyright (c) 2002, 2003 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: src/lib/libc/gen/fpclassify.c,v 1.2 2005/02/06 03:23:31 das Exp $ - */ - -#include <sys/endian.h> - -#include <math.h> -#include <stdint.h> - -#include "fpmath.h" - -int -__fpclassifyf(float f) -{ - union IEEEf2bits u; - - u.f = f; - if (u.bits.exp == 0) { - if (u.bits.man == 0) - return (FP_ZERO); - return (FP_SUBNORMAL); - } - if (u.bits.exp == 255) { - if (u.bits.man == 0) - return (FP_INFINITE); - return (FP_NAN); - } - return (FP_NORMAL); -} - -int -__fpclassifyd(double d) -{ - union IEEEd2bits u; - - u.d = d; - if (u.bits.exp == 0) { - if ((u.bits.manl | u.bits.manh) == 0) - return (FP_ZERO); - return (FP_SUBNORMAL); - } - if (u.bits.exp == 2047) { - if ((u.bits.manl | u.bits.manh) == 0) - return (FP_INFINITE); - return (FP_NAN); - } - return (FP_NORMAL); -} - -int -__fpclassifyl(long double e) -{ - union IEEEl2bits u; - - u.e = e; - if (u.bits.exp == 0) { - if ((u.bits.manl | u.bits.manh) == 0) - return (FP_ZERO); - return (FP_SUBNORMAL); - } - mask_nbit_l(u); /* Mask normalization bit if applicable. */ - if (u.bits.exp == 32767) { - if ((u.bits.manl | u.bits.manh) == 0) - return (FP_INFINITE); - return (FP_NAN); - } - return (FP_NORMAL); -} - diff --git a/libm/isinf.c b/libm/isinf.c deleted file mode 100644 index c917f16..0000000 --- a/libm/isinf.c +++ /dev/null @@ -1,68 +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 <sys/cdefs.h> -#include "fpmath.h" - -/* - * XXX These routines belong in libm, but they must remain in libc for - * binary compat until we can bump libm's major version number. - */ - -int -__isinf(double d) -{ - union IEEEd2bits u; - - u.d = d; - return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0); -} - -int -__isinff(float f) -{ - union IEEEf2bits u; - - u.f = f; - return (u.bits.exp == 255 && u.bits.man == 0); -} - -int -__isinfl(long double e) -{ - union IEEEl2bits u; - - u.e = e; - mask_nbit_l(u); -#ifndef __alpha__ - return (u.bits.exp == 32767 && u.bits.manl == 0 && u.bits.manh == 0); -#else - return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0); -#endif -} diff --git a/libm/upstream-freebsd/lib/msun/src/s_isnan.c b/libm/upstream-freebsd/lib/msun/src/s_isnan.c deleted file mode 100644 index a54ded3..0000000 --- a/libm/upstream-freebsd/lib/msun/src/s_isnan.c +++ /dev/null @@ -1,65 +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" - -/* Provided by libc.so */ -#ifndef PIC -#undef isnan -int -isnan(double d) -{ - union IEEEd2bits u; - - u.d = d; - return (u.bits.exp == 2047 && (u.bits.manl != 0 || u.bits.manh != 0)); -} -#endif /* !PIC */ - -int -__isnanf(float f) -{ - union IEEEf2bits u; - - u.f = f; - return (u.bits.exp == 255 && u.bits.man != 0); -} - -int -__isnanl(long double e) -{ - union IEEEl2bits u; - - u.e = e; - mask_nbit_l(u); - return (u.bits.exp == 32767 && (u.bits.manl != 0 || u.bits.manh != 0)); -} - -__weak_reference(__isnanf, isnanf); |