Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Let trigger_fpe() cause floating-point di...



details:   https://anonhg.NetBSD.org/src/rev/22efe8d74ae6
branches:  trunk
changeset: 973049:22efe8d74ae6
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Jun 17 08:42:16 2020 +0000

description:
Let trigger_fpe() cause floating-point divide by zero exception, instead of
integer one, which is not trapped for powerpc and aarch64.

Note that it is checked in lib/libc/gen/t_siginfo whether integer divide by
zero is interpreted as SIGFPE or not.

Now, all *_crash_fpe tests pass for powerpc, and nothing changes for amd64
at least.

diffstat:

 tests/lib/libc/sys/t_ptrace_signal_wait.h |  10 +++++-----
 tests/lib/libc/sys/t_ptrace_wait.h        |   9 ++++-----
 2 files changed, 9 insertions(+), 10 deletions(-)

diffs (73 lines):

diff -r ada944d47a16 -r 22efe8d74ae6 tests/lib/libc/sys/t_ptrace_signal_wait.h
--- a/tests/lib/libc/sys/t_ptrace_signal_wait.h Wed Jun 17 08:23:18 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_signal_wait.h Wed Jun 17 08:42:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_signal_wait.h,v 1.1 2020/05/04 23:49:31 kamil Exp $   */
+/*     $NetBSD: t_ptrace_signal_wait.h,v 1.2 2020/06/17 08:42:16 rin Exp $     */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -423,7 +423,7 @@
                            info.psi_siginfo.si_code <= ILL_BADSTK);
                break;
        case SIGFPE:
-               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
                break;
        case SIGBUS:
                ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -603,7 +603,7 @@
                            info.psi_siginfo.si_code <= ILL_BADSTK);
                break;
        case SIGFPE:
-               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
                break;
        case SIGBUS:
                ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -786,7 +786,7 @@
                            info.psi_siginfo.si_code <= ILL_BADSTK);
                break;
        case SIGFPE:
-               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+               ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
                break;
        case SIGBUS:
                ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -1890,7 +1890,7 @@
                                    info.psi_siginfo.si_code <= ILL_BADSTK);
                        break;
                case SIGFPE:
-                       FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+                       FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
                        break;
                case SIGBUS:
                        FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
diff -r ada944d47a16 -r 22efe8d74ae6 tests/lib/libc/sys/t_ptrace_wait.h
--- a/tests/lib/libc/sys/t_ptrace_wait.h        Wed Jun 17 08:23:18 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.h        Wed Jun 17 08:42:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.h,v 1.29 2020/06/17 08:23:18 rin Exp $   */
+/*     $NetBSD: t_ptrace_wait.h,v 1.30 2020/06/17 08:42:16 rin Exp $   */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -678,15 +678,14 @@
 static void __used
 trigger_fpe(void)
 {
-       volatile int a = getpid();
-       volatile int b = atoi("0");
+       volatile double a = getpid();
+       volatile double b = atoi("0");
 
 #ifdef __HAVE_FENV
        feenableexcept(FE_ALL_EXCEPT);
 #endif
 
-       /* Division by zero causes CPU trap, translated to SIGFPE */
-       usleep(a / b);
+       usleep((int)(a / b));
 }
 
 static void __used



Home | Main Index | Thread Index | Old Index