This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] math: support platforms with limited FP rounding or exception support
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: Chris Metcalf <cmetcalf at tilera dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Bruno Haible <bruno at clisp dot org>, <libc-alpha at sourceware dot org>
- Date: Mon, 16 Jul 2012 18:54:28 +0200
- Subject: Re: [PATCH] math: support platforms with limited FP rounding or exception support
- References: <Pine.LNX.4.64.1205131001470.23868@digraph.polyomino.org.uk><4FAFA5D6.4020704@tilera.com><Pine.LNX.4.64.1205151043180.31080@digraph.polyomino.org.uk><201205151641.q4FGflm6003865@gx-1.internal.tilera.com>
Chris Metcalf <cmetcalf@tilera.com> writes:
> diff --git a/stdlib/bug-getcontext.c b/stdlib/bug-getcontext.c
> index 745aa1f..7db49c8 100644
> --- a/stdlib/bug-getcontext.c
> +++ b/stdlib/bug-getcontext.c
> @@ -9,6 +9,9 @@
> static int
> do_test (void)
> {
> +#if FE_ALL_EXCEPT == 0
That doesn't work. The macro is not required to be suitable for
preprocessor expressions, and this effectively disables the test for
everyone. Fixed as attached.
Andreas.
* stdlib/bug-getcontext.c (do_test): Don't test FE_ALL_EXCEPT in
preprocessor. Test for each exception mask separately.
diff --git a/stdlib/bug-getcontext.c b/stdlib/bug-getcontext.c
index 7db49c8..133ee91 100644
--- a/stdlib/bug-getcontext.c
+++ b/stdlib/bug-getcontext.c
@@ -9,10 +9,25 @@
static int
do_test (void)
{
-#if FE_ALL_EXCEPT == 0
- printf("Skipping test; no support for FP exceptions.\n");
-#else
- int except_mask = FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW;
+ if (FE_ALL_EXCEPT == 0)
+ {
+ printf("Skipping test; no support for FP exceptions.\n");
+ return 0;
+ }
+
+ int except_mask = 0;
+#ifdef FE_DIVBYZERO
+ except_mask |= FE_DIVBYZERO;
+#endif
+#ifdef FE_INVALID
+ except_mask |= FE_INVALID;
+#endif
+#ifdef FE_OVERFLOW
+ except_mask |= FE_OVERFLOW;
+#endif
+#ifdef FE_UNDERFLOW
+ except_mask |= FE_UNDERFLOW;
+#endif
int status = feenableexcept (except_mask);
except_mask = fegetexcept ();
@@ -44,7 +59,7 @@ do_test (void)
printf("\nAt end fegetexcept() returned %d, expected: %d.\n",
mask, except_mask);
-#endif
+
return 0;
}
--
1.7.11.2
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."