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 #212:



details:   https://anonhg.NetBSD.org/src/rev/8f9acf968a20
branches:  netbsd-8
changeset: 850965:8f9acf968a20
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Aug 29 11:45:18 2017 +0000

description:
Pull up the following, requested by he in ticket #212:

        lib/libm/Makefile               1.192-1.196
        tests/lib/libm/t_fe_round.c     1.3-1.6

Ensure that nearbyint() is included in all targets except for vax,
and add a test case for nearbyint(), stubbed out for non-IEEE (vax).

diffstat:

 lib/libm/Makefile           |  29 ++++++++++++++++++++-------
 tests/lib/libm/t_fe_round.c |  47 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 9 deletions(-)

diffs (211 lines):

diff -r 6bb19ebc7f94 -r 8f9acf968a20 lib/libm/Makefile
--- a/lib/libm/Makefile Tue Aug 29 11:25:50 2017 +0000
+++ b/lib/libm/Makefile Tue Aug 29 11:45:18 2017 +0000
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.191 2017/05/06 18:03:24 christos Exp $
+#  $NetBSD: Makefile,v 1.191.2.1 2017/08/29 11:45:18 martin Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -62,17 +62,19 @@
 .endif
 COMMON_SRCS+= e_sqrtl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
+
 .elif (${LIBC_MACHINE_ARCH} == "alpha")
 .PATH: ${.CURDIR}/arch/alpha
 ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
 COMMON_SRCS+= fenv.c
 COPTS+=        -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
+
 .elif (${LIBC_MACHINE_CPU} == "arm")
 .PATH.c: ${.CURDIR}/arch/arm
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS+= fenv.c
 .endif
-COMMON_SRCS+= s_nexttowardf.c s_nearbyint.c s_rintl.c
+COMMON_SRCS+= s_nexttowardf.c 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
@@ -81,24 +83,29 @@
 .PATH.S: ${.CURDIR}/arch/arm
 ARCH_SRCS = e_sqrt.S e_sqrtf.S lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
 .endif
+
 .elif (${LIBC_MACHINE_ARCH} == "ia64")
 .PATH: ${.CURDIR}/arch/ia64
 COMMON_SRCS += fenv.c
+
 .elif (${LIBC_MACHINE_ARCH} == "hppa")
 .PATH.c: ${.CURDIR}/arch/hppa
-COMMON_SRCS+= fenv.c s_nexttowardf.c s_nearbyint.c s_rintl.c
+COMMON_SRCS+= fenv.c s_nexttowardf.c s_rintl.c
+
 .elif (${LIBC_MACHINE_ARCH} == "sparc")
 .PATH: ${.CURDIR}/arch/sparc
 COMMON_SRCS+= fenv.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
+
 .elif (${LIBC_MACHINE_ARCH} == "sparc64")
 .PATH: ${.CURDIR}/arch/sparc64
 COMMON_SRCS+= fenv.c
-COMMON_SRCS+= s_nexttowardf.c s_nearbyint.c s_rintl.c
+COMMON_SRCS+= s_nexttowardf.c s_rintl.c
 .ifndef _COMPAT_M32_MK_
 COMMON_SRCS+= s_nexttoward.c
 .endif
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
+
 .elif ((${MACHINE_ARCH} == "i386") || (${MACHINE_ARCH} == "x86_64"))
 
 # XXX consider making this LIBC_MACHINE_ARCH?
@@ -107,8 +114,7 @@
 .endif
 .PATH: ${.CURDIR}/arch/i387
 
-COMMON_SRCS+= fenv.c s_nexttoward.c s_nexttowardf.c \
-       s_nearbyint.c s_rintl.c
+COMMON_SRCS+= fenv.c s_nexttoward.c s_nexttowardf.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 \
@@ -128,6 +134,7 @@
 .if (${MACHINE_ARCH} == "i386")
 SUBDIR=arch/i387
 .endif
+
 .elif (${LIBC_MACHINE_ARCH} == "m68k")
 .if defined(M68060)
 .PATH: ${.CURDIR}/arch/m68060
@@ -146,10 +153,11 @@
            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
+COMMON_SRCS += fenv.c s_rintl.c
 .endif
 .endif
 # end of m68k
+
 .elif (${LIBC_MACHINE_ARCH} == "vax")
 .PATH: ${.CURDIR}/arch/vax
 
@@ -160,6 +168,7 @@
 # and emulation code isn't written yet.
 ARCH_SRCS = n_scalbn.S
 WARNS?=5
+
 .elif (${LIBC_MACHINE_CPU} == "riscv")
 .PATH: ${.CURDIR}/arch/riscv
 
@@ -172,22 +181,26 @@
 ARCH_SRCS += s_fmax.S s_fmaxf.S
 ARCH_SRCS += s_fmin.S s_fminf.S
 .endif
+
 .elif (${LIBC_MACHINE_ARCH} == "powerpc")
 .PATH: ${.CURDIR}/arch/powerpc
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
+
 .elif (${LIBC_MACHINE_CPU} == "mips")
 .PATH: ${.CURDIR}/arch/mips
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
+
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH: ${.CURDIR}/arch/sh3
 .if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
 .endif
+# End of list of CPU tests
 
 WARNS?=5
 
@@ -253,7 +266,7 @@
        s_lrint.c s_lrintf.c s_lrintl.c \
        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_nextafter.c s_nextafterl.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_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 \
diff -r 6bb19ebc7f94 -r 8f9acf968a20 tests/lib/libm/t_fe_round.c
--- a/tests/lib/libm/t_fe_round.c       Tue Aug 29 11:25:50 2017 +0000
+++ b/tests/lib/libm/t_fe_round.c       Tue Aug 29 11:45:18 2017 +0000
@@ -89,7 +89,36 @@
                    (fegetround() == values[i].round_mode),
                    "Didn't get the same rounding mode out!\n"
                    "(index %d) fed in %d rounding mode, got %d out\n",
-                   i, fegetround(), values[i].round_mode);
+                   i, values[i].round_mode, fegetround());
+       }
+}
+
+ATF_TC(fe_nearbyint);
+ATF_TC_HEAD(fe_nearbyint, tc)
+{
+       atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using nearbyint");
+}
+
+ATF_TC_BODY(fe_nearbyint, tc)
+{
+       double received;
+
+       for (unsigned int i = 0; i < __arraycount(values); i++) {
+               fesetround(values[i].round_mode);
+
+               received = nearbyint(values[i].input);
+               ATF_CHECK_MSG(
+                   (fabs(received - values[i].expected) < EPSILON),
+                   "nearbyint rounding wrong, difference too large\n"
+                   "input: %f (index %d): got %f, expected %ld\n",
+                   values[i].input, i, received, values[i].expected);
+
+               /* Do we get the same rounding mode out? */
+               ATF_CHECK_MSG(
+                   (fegetround() == values[i].round_mode),
+                   "Didn't get the same rounding mode out!\n"
+                   "(index %d) fed in %d rounding mode, got %d out\n",
+                   i, values[i].round_mode, fegetround());
        }
 }
 
@@ -97,6 +126,7 @@
 {
 
        ATF_TP_ADD_TC(tp, fe_round);
+       ATF_TP_ADD_TC(tp, fe_nearbyint);
 
        return atf_no_error();
 }
@@ -115,9 +145,24 @@
        atf_tc_skip("no fenv.h support on this architecture");
 }
 
+ATF_TC(t_nofe_nearbyint);
+
+ATF_TC_HEAD(t_nofe_nearbyint, tc)
+{
+       atf_tc_set_md_var(tc, "descr",
+           "dummy test case - no fenv.h support");
+}
+
+ATF_TC_BODY(t_nofe_nearbyint, 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);
        return atf_no_error();
 }
 



Home | Main Index | Thread Index | Old Index