mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
[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.
This commit is contained in:
100
math/test-fenv.c
100
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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user