Module Name:    src
Committed By:   mlelstv
Date:           Fri Dec 31 14:54:55 UTC 2010

Modified Files:
        src/tests/lib/libc/gen: t_siginfo.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_siginfo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/gen/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.4 src/tests/lib/libc/gen/t_siginfo.c:1.5
--- src/tests/lib/libc/gen/t_siginfo.c:1.4	Mon Dec 27 15:24:13 2010
+++ src/tests/lib/libc/gen/t_siginfo.c	Fri Dec 31 14:54:55 2010
@@ -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");
 }

Reply via email to