Module Name: src
Committed By: martin
Date: Sat Jan 26 16:44:30 UTC 2019
Modified Files:
src/tests/kernel: h_segv.c t_trapsignal.sh
Log Message:
Some arm CPUs do not implement traps on floating point exceptions.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/kernel/h_segv.c
cvs rdiff -u -r1.4 -r1.5 src/tests/kernel/t_trapsignal.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/kernel/h_segv.c
diff -u src/tests/kernel/h_segv.c:1.10 src/tests/kernel/h_segv.c:1.11
--- src/tests/kernel/h_segv.c:1.10 Mon Nov 12 05:02:00 2018
+++ src/tests/kernel/h_segv.c Sat Jan 26 16:44:30 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: h_segv.c,v 1.10 2018/11/12 05:02:00 riastradh Exp $ */
+/* $NetBSD: h_segv.c,v 1.11 2019/01/26 16:44:30 martin Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: h_segv.c,v 1.10 2018/11/12 05:02:00 riastradh Exp $");
+__RCSID("$NetBSD: h_segv.c,v 1.11 2019/01/26 16:44:30 martin Exp $");
#define __TEST_FENV
@@ -39,6 +39,7 @@ __RCSID("$NetBSD: h_segv.c,v 1.10 2018/1
#include <err.h>
#include <fenv.h>
+#include <ieeefp.h> /* only need for ARM Cortex/Neon hack */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -50,6 +51,7 @@ static int flags;
#define F_HANDLE 2
#define F_MASK 4
#define F_IGNORE 8
+#define F_CHECK 16
static struct {
const char *n;
@@ -58,7 +60,8 @@ static struct {
{ "recurse", F_RECURSE },
{ "handle", F_HANDLE },
{ "mask", F_MASK },
- { "ignore", F_IGNORE }
+ { "ignore", F_IGNORE },
+ { "check", F_CHECK }
};
static int sig;
@@ -104,6 +107,23 @@ trigger_ill(void)
}
static void
+check_fpe(void)
+{
+#if (__arm__ && !__SOFTFP__) || __aarch64__
+ /*
+ * Some NEON fpus do not implement IEEE exception handling,
+ * skip these tests if running on them and compiled for
+ * hard float.
+ */
+ if (0 == fpsetmask(fpsetmask(FP_X_INV))) {
+ printf("FPU does not implement exception handling\n");
+ exit(EXIT_FAILURE);
+ }
+#endif
+ exit(EXIT_SUCCESS);
+}
+
+static void
trigger_fpe(void)
{
volatile double a = getpid();
@@ -185,7 +205,7 @@ usage(void)
const char *pname = getprogname();
fprintf(stderr, "Usage: %s segv|trap|ill|fpe|bus "
- "[recurse|mask|handle|ignore] ...\n", pname);
+ "[recurse|mask|handle|ignore|check] ...\n", pname);
exit(EXIT_FAILURE);
}
@@ -221,6 +241,13 @@ main(int argc, char *argv[])
if (flags == 0 || sig == 0)
usage();
+ if (flags & F_CHECK && sig != SIGFPE) {
+ fprintf(stderr, "can only check for fpe support\n");
+ return 1;
+ }
+ if (flags & F_CHECK)
+ check_fpe();
+
if (flags & F_HANDLE) {
struct sigaction sa;
Index: src/tests/kernel/t_trapsignal.sh
diff -u src/tests/kernel/t_trapsignal.sh:1.4 src/tests/kernel/t_trapsignal.sh:1.5
--- src/tests/kernel/t_trapsignal.sh:1.4 Sun May 27 17:04:45 2018
+++ src/tests/kernel/t_trapsignal.sh Sat Jan 26 16:44:30 2019
@@ -1,4 +1,4 @@
-# $NetBSD: t_trapsignal.sh,v 1.4 2018/05/27 17:04:45 kamil Exp $
+# $NetBSD: t_trapsignal.sh,v 1.5 2019/01/26 16:44:30 martin Exp $
#
# Copyright (c) 2017 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -172,6 +172,18 @@ trap_ignore_body()
# SIGFPE
+fpe_available()
+{
+ if ${HELPER} fpe check > msg.$$
+ then
+ rm -f msg.$$
+ else
+ msg=$( cat msg.$$ )
+ rm -f msg.$$
+ atf_skip "$msg"
+ fi
+}
+
atf_test_case fpe_simple
fpe_simple()
{
@@ -179,6 +191,7 @@ fpe_simple()
}
fpe_simple_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:" \
${HELPER} fpe recurse
}
@@ -190,6 +203,7 @@ fpe_handle()
}
fpe_handle_body()
{
+ fpe_available
atf_check -s exit:0 -o "inline:" -e "inline:got 8\n" \
${HELPER} fpe handle
}
@@ -201,6 +215,7 @@ fpe_mask()
}
fpe_mask_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:" \
${HELPER} fpe mask
}
@@ -212,6 +227,7 @@ fpe_handle_mask()
}
fpe_handle_mask_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:" \
${HELPER} fpe mask handle
}
@@ -224,6 +240,7 @@ fpe_handle_recurse()
fpe_handle_recurse_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:got 8\n" \
${HELPER} fpe handle recurse
}
@@ -236,6 +253,7 @@ fpe_ignore()
fpe_ignore_body()
{
+ fpe_available
atf_check -s signal:8 -o "inline:" -e "inline:" \
${HELPER} fpe ignore
}