This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix fenv.h fallback returns
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 7 Jan 2011 01:55:13 +0000 (UTC)
- Subject: Fix fenv.h fallback returns
C99(+TC1) explicitly says that feclearexcept, feraiseexcept and
fesetexceptflag return zero when their "excepts" operand is zero,
because nothing needs to be done in that case. This patch fixes the
fallback implementations - the ones for when no exceptions are
supported, when no target-specific implementation is used - to do so;
to conform to C99(+TC1), these operations should always be considered
supported and successful when applied to the empty set of exceptions,
even when no exceptions are supported.
(I noticed this issue in the course of going through the C1X draft to
prepare the UK comments on it; the same wording appears in both
C99+TCs and C1X here. I haven't tried to list changes that will be
needed to glibc for implementing C1X, though certainly there will be
quite a few; I do have a list of C1X features needing implementing in
GCC.)
2011-01-07 Joseph Myers <joseph@codesourcery.com>
* math/fclrexcpt.c (__feclearexcept): Return zero if nothing needs
to be done.
* math/fraiseexcpt.c (__feraiseexcept): Likewise.
* math/fsetexcptflg.c (__fesetexceptflag): Likewise.
diff --git a/math/fclrexcpt.c b/math/fclrexcpt.c
index 560e326..fb6ef16 100644
--- a/math/fclrexcpt.c
+++ b/math/fclrexcpt.c
@@ -1,5 +1,5 @@
/* Clear given exceptions in current floating-point environment.
- Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1999, 2000, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -24,8 +24,8 @@
int
__feclearexcept (int excepts)
{
- /* This always fails. */
- return 1;
+ /* This always fails unless nothing needs to be done. */
+ return (excepts != 0);
}
#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
strong_alias (__feclearexcept, __old_feclearexcept)
diff --git a/math/fraiseexcpt.c b/math/fraiseexcpt.c
index 764634a..d4f5f03 100644
--- a/math/fraiseexcpt.c
+++ b/math/fraiseexcpt.c
@@ -1,5 +1,5 @@
/* Raise given exceptions.
- Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1999, 2000, 2002, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -24,8 +24,8 @@
int
__feraiseexcept (int excepts)
{
- /* This always fails. */
- return 1;
+ /* This always fails unless nothing needs to be done. */
+ return (excepts != 0);
}
#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
strong_alias (__feraiseexcept, __old_feraiseexcept)
diff --git a/math/fsetexcptflg.c b/math/fsetexcptflg.c
index 8d0f0ff..ef8060b 100644
--- a/math/fsetexcptflg.c
+++ b/math/fsetexcptflg.c
@@ -1,5 +1,5 @@
/* Set floating-point environment exception handling.
- Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1999, 2000, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -24,8 +24,8 @@
int
__fesetexceptflag (const fexcept_t *flagp, int excepts)
{
- /* This always fails. */
- return 1;
+ /* This always fails unless nothing needs to be done. */
+ return (excepts != 0);
}
#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
strong_alias (__fesetexceptflag, __old_fesetexceptflag)
--
Joseph S. Myers
joseph@codesourcery.com