Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src Pull up the following, requested by he in ticket #217:
details: https://anonhg.NetBSD.org/src/rev/b9406df98bf0
branches: netbsd-8
changeset: 434243:b9406df98bf0
user: martin <martin%NetBSD.org@localhost>
date: Tue Aug 29 11:58:26 2017 +0000
description:
Pull up the following, requested by he in ticket #217:
lib/libm/Makefile 1.197-1.201
tests/lib/libm/t_fe_round.c 1.7
Ensure nexttowardf() is included on all IEEE targets.
Add rintl() for aarch64 and mips, and nexttoward() for m68k.
Add a test which verifies that nextafter() and nexttoward() are
present in the implementation.
diffstat:
lib/libm/Makefile | 16 ++++---
tests/lib/libm/t_fe_round.c | 91 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 99 insertions(+), 8 deletions(-)
diffs (204 lines):
diff -r aab41f8d7074 -r b9406df98bf0 lib/libm/Makefile
--- a/lib/libm/Makefile Tue Aug 29 11:51:50 2017 +0000
+++ b/lib/libm/Makefile Tue Aug 29 11:58:26 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.191.2.1 2017/08/29 11:45:18 martin Exp $
+# $NetBSD: Makefile,v 1.191.2.2 2017/08/29 11:58:26 martin Exp $
#
# @(#)Makefile 5.1beta 93/09/24
#
@@ -60,6 +60,7 @@
.if ${MKSOFTFLOAT} == "no"
COMMON_SRCS+= fenv.c
.endif
+COMMON_SRCS+= s_rintl.c
COMMON_SRCS+= e_sqrtl.c
COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
@@ -74,7 +75,7 @@
.if ${MKSOFTFLOAT} == "no"
COMMON_SRCS+= fenv.c
.endif
-COMMON_SRCS+= s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= s_rintl.c
.for f in fenv.c lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
COPTS.$f += -mfpu=vfp
.endfor
@@ -90,7 +91,7 @@
.elif (${LIBC_MACHINE_ARCH} == "hppa")
.PATH.c: ${.CURDIR}/arch/hppa
-COMMON_SRCS+= fenv.c s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= fenv.c s_rintl.c
.elif (${LIBC_MACHINE_ARCH} == "sparc")
.PATH: ${.CURDIR}/arch/sparc
@@ -100,7 +101,7 @@
.elif (${LIBC_MACHINE_ARCH} == "sparc64")
.PATH: ${.CURDIR}/arch/sparc64
COMMON_SRCS+= fenv.c
-COMMON_SRCS+= s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= s_rintl.c
.ifndef _COMPAT_M32_MK_
COMMON_SRCS+= s_nexttoward.c
.endif
@@ -114,7 +115,7 @@
.endif
.PATH: ${.CURDIR}/arch/i387
-COMMON_SRCS+= fenv.c s_nexttoward.c s_nexttowardf.c s_rintl.c
+COMMON_SRCS+= fenv.c s_nexttoward.c s_rintl.c
COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
@@ -153,7 +154,7 @@
e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
-COMMON_SRCS += fenv.c s_rintl.c
+COMMON_SRCS += fenv.c s_nexttoward.c s_rintl.c
.endif
.endif
# end of m68k
@@ -193,6 +194,7 @@
.if ${MKSOFTFLOAT} == "no"
COMMON_SRCS += fenv.c
.endif
+COMMON_SRCS+= s_rintl.c
.elif (${LIBC_MACHINE_CPU} == "sh3")
.PATH: ${.CURDIR}/arch/sh3
@@ -267,7 +269,7 @@
s_lround.c s_lroundf.c s_lroundl.c \
s_log1pf.c s_logb.c s_logbf.c s_logbl.c \
s_matherr.c s_modff.c s_modfl.c s_nearbyint.c s_nextafter.c s_nextafterl.c \
- s_nextafterf.c s_remquo.c s_remquof.c s_rint.c s_rintf.c \
+ s_nextafterf.c s_nexttowardf.c s_remquo.c s_remquof.c s_rint.c s_rintf.c \
s_round.c s_roundf.c s_roundl.c s_scalbn.c \
s_scalbnf.c s_scalbnl.c s_signgam.c s_significand.c s_significandf.c s_sin.c \
s_sinf.c s_tan.c s_tanf.c s_tanh.c s_tanhf.c s_tgammaf.c \
diff -r aab41f8d7074 -r b9406df98bf0 tests/lib/libm/t_fe_round.c
--- a/tests/lib/libm/t_fe_round.c Tue Aug 29 11:51:50 2017 +0000
+++ b/tests/lib/libm/t_fe_round.c Tue Aug 29 11:58:26 2017 +0000
@@ -122,11 +122,74 @@
}
}
+static const struct {
+ double input;
+ double toward;
+ double expected;
+} values2[] = {
+ { 10.0, 11.0, 10.0 },
+ { -5.0, -6.0, -5.0 },
+};
+
+ATF_TC(fe_nextafter);
+ATF_TC_HEAD(fe_nextafter, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checking IEEE 754 rounding using nextafter()");
+}
+
+ATF_TC_BODY(fe_nextafter, tc)
+{
+ double received;
+ int res;
+
+ for (unsigned int i = 0; i < __arraycount(values2); i++) {
+ received = nextafter(values2[i].input, values2[i].toward);
+ if (values2[i].input < values2[i].toward) {
+ res = (received > values2[i].input);
+ } else {
+ res = (received < values2[i].input);
+ }
+ ATF_CHECK_MSG(
+ res && (fabs(received - values2[i].expected) < EPSILON),
+ "nextafter() rounding wrong, difference too large\n"
+ "input: %f (index %d): got %f, expected %f, res %d\n",
+ values2[i].input, i, received, values2[i].expected, res);
+ }
+}
+
+ATF_TC(fe_nexttoward);
+ATF_TC_HEAD(fe_nexttoward, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checking IEEE 754 rounding using nexttoward()");
+}
+
+ATF_TC_BODY(fe_nexttoward, tc)
+{
+ double received;
+ int res;
+
+ for (unsigned int i = 0; i < __arraycount(values2); i++) {
+ received = nexttoward(values2[i].input, values2[i].toward);
+ if (values2[i].input < values2[i].toward) {
+ res = (received > values2[i].input);
+ } else {
+ res = (received < values2[i].input);
+ }
+ ATF_CHECK_MSG(
+ res && (fabs(received - values2[i].expected) < EPSILON),
+ "nexttoward() rounding wrong, difference too large\n"
+ "input: %f (index %d): got %f, expected %f, res %d\n",
+ values2[i].input, i, received, values2[i].expected, res);
+ }
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, fe_round);
ATF_TP_ADD_TC(tp, fe_nearbyint);
+ ATF_TP_ADD_TC(tp, fe_nextafter);
+ ATF_TP_ADD_TC(tp, fe_nexttoward);
return atf_no_error();
}
@@ -139,7 +202,6 @@
"dummy test case - no fenv.h support");
}
-
ATF_TC_BODY(t_nofe_round, tc)
{
atf_tc_skip("no fenv.h support on this architecture");
@@ -158,11 +220,38 @@
atf_tc_skip("no fenv.h support on this architecture");
}
+ATF_TC(t_nofe_nextafter);
+
+ATF_TC_HEAD(t_nofe_nextafter, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "dummy test case - no fenv.h support");
+}
+
+ATF_TC_BODY(t_nofe_nextafter, tc)
+{
+ atf_tc_skip("no fenv.h support on this architecture");
+}
+
+ATF_TC(t_nofe_nexttoward);
+
+ATF_TC_HEAD(t_nofe_nexttoward, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "dummy test case - no fenv.h support");
+}
+
+ATF_TC_BODY(t_nofe_nexttoward, tc)
+{
+ atf_tc_skip("no fenv.h support on this architecture");
+}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, t_nofe_round);
ATF_TP_ADD_TC(tp, t_nofe_nearbyint);
+ ATF_TP_ADD_TC(tp, t_nofe_nextafter);
+ ATF_TP_ADD_TC(tp, t_nofe_nexttoward);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index