Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libc/gen return from an SIGFPE handler is not defi...



details:   https://anonhg.NetBSD.org/src/rev/1f98499179ce
branches:  trunk
changeset: 760229:1f98499179ce
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Fri Dec 31 14:54:55 2010 +0000

description:
return from an SIGFPE handler is not defined when the hardware
caused the exception. Use sigsetjmp/siglongjmp to resume the
test function instead.

diffstat:

 tests/lib/libc/gen/t_siginfo.c |  35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diffs (88 lines):

diff -r ecd32f1de578 -r 1f98499179ce tests/lib/libc/gen/t_siginfo.c
--- a/tests/lib/libc/gen/t_siginfo.c    Fri Dec 31 14:37:37 2010 +0000
+++ b/tests/lib/libc/gen/t_siginfo.c    Fri Dec 31 14:54:55 2010 +0000
@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <setjmp.h>
 
 #ifndef __vax__
 #include <ieeefp.h>
@@ -264,6 +265,7 @@
        }
 }
 
+static sigjmp_buf sigfpe_flt_env;
 static void
 sigfpe_flt_action(int signo, siginfo_t *info, void *ptr)
 {
@@ -276,6 +278,8 @@
        ATF_REQUIRE_EQ(info->si_signo, SIGFPE);
        ATF_REQUIRE_EQ(info->si_code, FPE_FLTDIV);
        ATF_REQUIRE_EQ(info->si_errno, 0);
+
+       siglongjmp(sigfpe_flt_env, 1);
 }
 
 ATF_TC(sigfpe_flt);
@@ -292,18 +296,21 @@
        struct sigaction sa;
        double d = strtod("0", NULL);
 
-       sa.sa_flags = SA_SIGINFO;
-       sa.sa_sigaction = sigfpe_flt_action;
-       sigemptyset(&sa.sa_mask);
-       sigaction(SIGFPE, &sa, NULL);
+       if (sigsetjmp(sigfpe_flt_env, 0) == 0) {
+               sa.sa_flags = SA_SIGINFO;
+               sa.sa_sigaction = sigfpe_flt_action;
+               sigemptyset(&sa.sa_mask);
+               sigaction(SIGFPE, &sa, NULL);
 #ifndef __vax__
-       fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
+               fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
 #endif
-       printf("%g\n", 1 / d);
+               printf("%g\n", 1 / d);
+       }
        if (fltdiv_signalled == 0)
                atf_tc_fail("FPE signal handler was not invoked");
 }
 
+static sigjmp_buf sigfpe_int_env;
 static void
 sigfpe_int_action(int signo, siginfo_t *info, void *ptr)
 {
@@ -319,6 +326,8 @@
                    "reports FPE_FLTDIV instead of FPE_INTDIV");
        ATF_REQUIRE_EQ(info->si_code, FPE_INTDIV);
        ATF_REQUIRE_EQ(info->si_errno, 0);
+
+       siglongjmp(sigfpe_int_env, 1);
 }
 
 ATF_TC(sigfpe_int);
@@ -335,14 +344,16 @@
        struct sigaction sa;
        long l = strtol("0", NULL, 10);
 
-       sa.sa_flags = SA_SIGINFO;
-       sa.sa_sigaction = sigfpe_int_action;
-       sigemptyset(&sa.sa_mask);
-       sigaction(SIGFPE, &sa, NULL);
+       if (sigsetjmp(sigfpe_int_env, 0) == 0) {
+               sa.sa_flags = SA_SIGINFO;
+               sa.sa_sigaction = sigfpe_int_action;
+               sigemptyset(&sa.sa_mask);
+               sigaction(SIGFPE, &sa, NULL);
 #ifndef __vax__
-       fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
+               fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
 #endif
-       printf("%ld\n", 1 / l);
+               printf("%ld\n", 1 / l);
+       }
        if (intdiv_signalled == 0)
                atf_tc_fail("FPE signal handler was not invoked");
 }



Home | Main Index | Thread Index | Old Index