This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] math: support platforms with limited FP rounding or exception support


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."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]