From a8c79c4088e8c04e4297936efa0dee6c8e6e974d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 16 Apr 2007 20:15:57 +0000 Subject: [BZ #3427] 2007-03-22 Jakub Jelinek [BZ #3427] * sysdeps/x86_64/fpu/feholdexcpt.c (feholdexcept): Clear all exceptions both in SW and MXCSR. * sysdeps/x86_64/fpu/feupdateenv.c: New file. * sysdeps/x86_64/fpu/feenablxcpt.c (feenableexcept): Remove dead code. * sysdeps/x86_64/fpu/fedisblxcpt.c (fedisableexcept): Likewise. * sysdeps/i386/fpu/feholdexcpt.c (feholdexcept): Clear all exceptions in MXCSR if SSE is available. * sysdeps/i386/fpu/feupdateenv.c: Include unistd.h, dl-procinfo.h and ldsodefs.h. (__feupdateenv): Query exceptions also from MXCSR if SSE is available. Fix comment typo. * sysdeps/ia64/fpu/feholdexcpt.c (feholdexcept): Clear all exceptions. Return 0 rather than 1. * sysdeps/ia64/fpu/feupdateenv.c (feupdateenv): Fix comment typo. Remove incorrect part of a comment. Fix argument to feraiseexcept. * math/test-fenv.c (feholdexcept_tests): New function. (main): Call it. 2007-01-05 Richard B. Kreckel [BZ #3427] * sysdeps/i386/fpu/feholdexcpt.c (feholdexcept): Clear all exceptions in SW. --- math/test-fenv.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) (limited to 'math/test-fenv.c') diff --git a/math/test-fenv.c b/math/test-fenv.c index 78127c3..4b710d8 100644 --- a/math/test-fenv.c +++ b/math/test-fenv.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1997, 1998, 2000, 2001, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2000, 2001, 2003, 2007 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger and Ulrich Drepper , 1997. @@ -636,6 +637,102 @@ feenv_tests (void) } +static void +feholdexcept_tests (void) +{ + fenv_t saved, saved2; + int res; + + feclearexcept (FE_ALL_EXCEPT); + fedisableexcept (FE_ALL_EXCEPT); +#ifdef FE_DIVBYZERO + feraiseexcept (FE_DIVBYZERO); +#endif + test_exceptions ("feholdexcept_tests FE_DIVBYZERO test", + DIVBYZERO_EXC, 0); + res = feholdexcept (&saved); + if (res != 0) + { + printf ("feholdexcept failed: %d\n", res); + ++count_errors; + } +#if defined FE_TONEAREST && defined FE_TOWARDZERO + res = fesetround (FE_TOWARDZERO); + if (res != 0) + { + printf ("fesetround failed: %d\n", res); + ++count_errors; + } +#endif + test_exceptions ("feholdexcept_tests 0 test", NO_EXC, 0); + feraiseexcept (FE_INVALID); + test_exceptions ("feholdexcept_tests FE_INVALID test", + INVALID_EXC, 0); + res = feupdateenv (&saved); + if (res != 0) + { + printf ("feupdateenv failed: %d\n", res); + ++count_errors; + } +#if defined FE_TONEAREST && defined FE_TOWARDZERO + res = fegetround (); + if (res != FE_TONEAREST) + { + printf ("feupdateenv didn't restore rounding mode: %d\n", res); + ++count_errors; + } +#endif + test_exceptions ("feholdexcept_tests FE_DIVBYZERO|FE_INVALID test", + DIVBYZERO_EXC | INVALID_EXC, 0); + feclearexcept (FE_ALL_EXCEPT); + feraiseexcept (FE_INVALID); +#if defined FE_TONEAREST && defined FE_UPWARD + res = fesetround (FE_UPWARD); + if (res != 0) + { + printf ("fesetround failed: %d\n", res); + ++count_errors; + } +#endif + res = feholdexcept (&saved2); + if (res != 0) + { + printf ("feholdexcept failed: %d\n", res); + ++count_errors; + } +#if defined FE_TONEAREST && defined FE_UPWARD + res = fesetround (FE_TONEAREST); + if (res != 0) + { + printf ("fesetround failed: %d\n", res); + ++count_errors; + } +#endif + test_exceptions ("feholdexcept_tests 0 2nd test", NO_EXC, 0); + feraiseexcept (FE_INEXACT); + test_exceptions ("feholdexcept_tests FE_INEXACT test", + INEXACT_EXC, 0); + res = feupdateenv (&saved2); + if (res != 0) + { + printf ("feupdateenv failed: %d\n", res); + ++count_errors; + } +#if defined FE_TONEAREST && defined FE_UPWARD + res = fegetround (); + if (res != FE_UPWARD) + { + printf ("feupdateenv didn't restore rounding mode: %d\n", res); + ++count_errors; + } + fesetround (FE_TONEAREST); +#endif + test_exceptions ("feholdexcept_tests FE_INEXACT|FE_INVALID test", + INVALID_EXC | INEXACT_EXC, 0); + feclearexcept (FE_ALL_EXCEPT); +} + + /* IEC 559 and ISO C99 define a default startup environment */ static void initial_tests (void) @@ -654,6 +751,7 @@ main (void) initial_tests (); fe_tests (); feenv_tests (); + feholdexcept_tests (); if (count_errors) { -- cgit v1.1