[ARM] Add fenv test support for targets which don't have FP traps
Commit Message
See attachment.
Wilco
-----Original Message-----
From: Marcus Shawcroft [mailto:marcus.shawcroft@gmail.com]
Sent: 15 April 2014 18:12
To: Wilco Dijkstra
Cc: GNU C Library
Subject: Re: [PATCH] [ARM] Add fenv test support for targets which don't have FP traps
On 15 April 2014 14:17, Wilco <wdijkstr@arm.com> wrote:
> Marcus,
>
> Given there have been no further comments on this, could you check this in please?
>
> Wilco
Sure, but like the last patch you posted, this one has also been
munged by your mail agent, please re-post as an attachment and I'll
apply it.
Cheers
/Marcus
---
math/test-fenv.c | 25 +++++++++++++++----------
sysdeps/arm/math-tests.h | 3 +++
sysdeps/generic/math-tests.h | 11 +++++++++++
3 files changed, 29 insertions(+), 10 deletions(-)
Comments
On 15 April 2014 18:56, Wilco <wdijkstr@arm.com> wrote:
> See attachment.
>
> Wilco
Thanks, committed.
/Marcus
@@ -36,6 +36,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <sys/resource.h>
+#include <math-tests.h>
/*
Since not all architectures might define all exceptions, we define
@@ -233,14 +234,9 @@ feenv_nomask_test (const char *flag_name, int fe_exc)
#if defined FE_NOMASK_ENV
int status;
pid_t pid;
- fenv_t saved;
- fegetenv (&saved);
- errno = 0;
- fesetenv (FE_NOMASK_ENV);
- status = errno;
- fesetenv (&saved);
- if (status == ENOSYS)
+ if (!EXCEPTION_ENABLE_SUPPORTED (FE_ALL_EXCEPT)
+ && fesetenv (FE_NOMASK_ENV) != 0)
{
printf ("Test: not testing FE_NOMASK_ENV, it isn't implemented.\n");
return;
@@ -349,7 +345,13 @@ feexcp_nomask_test (const char *flag_name, int fe_exc)
int status;
pid_t pid;
- printf ("Test: after fedisableexcept (%s) processes will abort\n",
+ if (!EXCEPTION_ENABLE_SUPPORTED (fe_exc) && feenableexcept (fe_exc) == -1)
+ {
+ printf ("Test: not testing feenableexcept, it isn't implemented.\n");
+ return;
+ }
+
+ printf ("Test: after feenableexcept (%s) processes will abort\n",
flag_name);
printf (" when feraiseexcept (%s) is called.\n", flag_name);
pid = fork ();
@@ -470,7 +472,6 @@ feenable_test (const char *flag_name, int fe_exc)
{
int excepts;
-
printf ("Tests for feenableexcepts etc. with flag %s\n", flag_name);
/* First disable all exceptions. */
@@ -488,8 +489,12 @@ feenable_test (const char *flag_name, int fe_exc)
flag_name, excepts);
++count_errors;
}
-
excepts = feenableexcept (fe_exc);
+ if (!EXCEPTION_ENABLE_SUPPORTED (fe_exc) && excepts == -1)
+ {
+ printf ("Test: not testing feenableexcept, it isn't implemented.\n");
+ return;
+ }
if (excepts == -1)
{
printf ("Test: feenableexcept (%s) failed\n", flag_name);
@@ -29,4 +29,7 @@
# define EXCEPTION_TESTS_long_double 0
#endif
+/* Not all VFP implementations support trapping exceptions. */
+#define EXCEPTION_ENABLE_SUPPORTED(EXCEPT) ((EXCEPT) == 0)
+
#include_next <math-tests.h>
@@ -76,3 +76,14 @@
(sizeof (TYPE) == sizeof (float) ? EXCEPTION_TESTS_float \
: sizeof (TYPE) == sizeof (double) ? EXCEPTION_TESTS_double \
: EXCEPTION_TESTS_long_double)
+
+/* Indicate whether the given exception trap(s) can be enabled
+ in feenableexcept. If non-zero, the traps are always supported.
+ If zero, traps may or may not be supported depending on the
+ target (this can be determined by checking the return value
+ of feenableexcept). This enables skipping of tests which use
+ traps. By default traps are supported unless overridden. */
+#ifndef EXCEPTION_ENABLE_SUPPORTED
+# define EXCEPTION_ENABLE_SUPPORTED(EXCEPT) \
+ (EXCEPTION_TESTS_float || EXCEPTION_TESTS_double)
+#endif