diff options
author | Ulrich Drepper <drepper@redhat.com> | 2007-04-16 20:15:57 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2007-04-16 20:15:57 +0000 |
commit | a8c79c4088e8c04e4297936efa0dee6c8e6e974d (patch) | |
tree | eff01fb1edcb8dbd7a3b40feeffc2137a5a9a00a /math | |
parent | 34317254127a027848079aabdd17efa1deb9279f (diff) | |
download | glibc-a8c79c4088e8c04e4297936efa0dee6c8e6e974d.tar.gz |
[BZ #3427]
2007-03-22 Jakub Jelinek <jakub@redhat.com>
[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 <kreckel@ginac.de>
[BZ #3427]
* sysdeps/i386/fpu/feholdexcpt.c (feholdexcept): Clear all exceptions
in SW.
Diffstat (limited to 'math')
-rw-r--r-- | math/test-fenv.c | 100 |
1 files changed, 99 insertions, 1 deletions
diff --git a/math/test-fenv.c b/math/test-fenv.c index 78127c338e..4b710d83f3 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 <aj@suse.de> and Ulrich Drepper <drepper@cygnus.com>, 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) { |