This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Avoid spurious failures from <fenv.h> fallback functions
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: joseph at codesourcery dot com
- Cc: libc-alpha at sourceware dot org, thomas at codesourcery dot com
- Date: Fri, 21 Jun 2013 08:46:19 +0900 (JST)
- Subject: Re: Avoid spurious failures from <fenv.h> fallback functions
- References: <Pine dot LNX dot 4 dot 64 dot 1306201045120 dot 4098 at digraph dot polyomino dot org dot uk>
"Joseph S. Myers" <joseph@codesourcery.com> wrote:
> Kaz, Thomas, note that there is no SH version of fgetexcptflg.c. This
> looks like an oversight, given that all the other <fenv.h> functions
> have SH implementations. Neither old nor new stub version would
> really be correct for SH; there should be a real implementation.
> Filed as bug 15655.
It's really an oversight. I'd like to commit the attached patch
if it's OK to Thomas.
Regards,
kaz
--
2013-06-21 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/sh/sh4/fpu/fgetexcptflg.c: New file.
diff --git a/sysdeps/sh/sh4/fpu/fgetexcptflg.c b/sysdeps/sh/sh4/fpu/fgetexcptflg.c
new file mode 100644
index 0000000..6a2a0c0
--- /dev/null
+++ b/sysdeps/sh/sh4/fpu/fgetexcptflg.c
@@ -0,0 +1,38 @@
+/* Store current representation for exceptions.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+ fpu_control_t temp;
+
+ /* Get the current exceptions. */
+ _FPU_GETCW (temp);
+
+ /* We only save the relevant bits here. In particular, care has to be
+ taken with the CAUSE bits, as an inadvertent restore later on could
+ generate unexpected exceptions. */
+
+ *flagp = temp & excepts & FE_ALL_EXCEPT;
+
+ /* Success. */
+ return 0;
+}