[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: float, math: Fix 'int' to 'long double' conversion on Linux/SPARC64
From: |
Jim Meyering |
Subject: |
Re: float, math: Fix 'int' to 'long double' conversion on Linux/SPARC64 |
Date: |
Sat, 01 Oct 2011 14:41:50 +0200 |
Bruno Haible wrote:
> It started as a test failure on Linux/SPARC64:
>
> test-logl.c:42: assertion failed
> FAIL: test-logl
>
> I tried to fix it by activating the gnulib replacement code for logl(). But
> the bug persisted.
>
> Debugging it in detail, it turned out to be a bug in the 'int' to 'long
> double'
> conversion. The glibc provided function, that is invoked by the GCC generated
> code, actually performs an 'unsigned int' to 'long double' conversion.
>
> I've reported it at
> <http://sources.redhat.com/bugzilla/show_bug.cgi?id=13240>.
> Here's the workaround for gnulib.
>
>
> 2011-09-30 Bruno Haible <address@hidden>
>
> float, math: Fix 'int' to 'long double' conversion on Linux/SPARC64.
> * m4/float_h.m4 (gl_FLOAT_H): Test conversion from 'int' to
> 'long double'. Set REPLACE_ITOLD.
> * lib/float.in.h (_Qp_itoq, _gl_float_fix_itold): New declarations.
> * lib/math.in.h (_Qp_itoq, _gl_math_fix_itold): New declarations.
> * lib/itold.c: New file.
> * modules/float (Files): Add lib/itold.c.
> (configure.ac): When REPLACE_ITOLD is 1, arrange to compile itold.c.
> (Makefile.am): Substitute REPLACE_ITOLD.
> * modules/math (Depends-on): Add float.
> (Makefile.am): Substitute REPLACE_ITOLD.
> * doc/posix-headers/float.texi: Mention problem on Linux/SPARC64.
> * doc/posix-headers/math.texi: Likewise.
> * doc/posix-functions/logl.texi: Likewise.
>
> ================================= lib/itold.c
> =================================
> /* Replacement for 'int' to 'long double' conversion routine.
> Copyright (C) 2011 Free Software Foundation, Inc.
> Written by Bruno Haible <address@hidden>, 2011.
>
> This program is free software: you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 3 of the License, or
> (at your option) any later version.
>
> This program 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 General Public License for more details.
>
> You should have received a copy of the GNU General Public License
> along with this program. If not, see <http://www.gnu.org/licenses/>. */
>
> #include <config.h>
>
> /* Specification. */
> #include <float.h>
>
> void
> _Qp_itoq (long double *result, int a)
> {
> /* Convert from 'int' to 'double', then from 'double' to 'long double'. */
> *result = (double) a;
> }
Hi Bruno,
Thanks for all of this work.
I've taken the liberty of adding the above file.
Without it, any use of gnulib with affected modules fails like this:
gnulib/gnulib-tool: *** file /h/j/w/co/cu/gnulib/lib/itold.c not found
gnulib/gnulib-tool: *** Stop.
E.g.,
http://hydra.nixos.org/jobset/gnu/gzip-master
>From 0041d0b4ff6c590ea87c21bdeabc22d00133c184 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 1 Oct 2011 14:34:09 +0200
Subject: [PATCH] float, math: add omitted file
* lib/itold.c: Add file, required for yesterday's float change.
---
ChangeLog | 5 +++++
lib/itold.c | 28 ++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
create mode 100644 lib/itold.c
diff --git a/ChangeLog b/ChangeLog
index d60071b..779e00d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-10-01 Jim Meyering <address@hidden>
+
+ float, math: add omitted file
+ * lib/itold.c: Add file, required for yesterday's float change.
+
2011-10-01 Bruno Haible <address@hidden>
isinf: Fix for OpenBSD/x86.
diff --git a/lib/itold.c b/lib/itold.c
new file mode 100644
index 0000000..0236f33
--- /dev/null
+++ b/lib/itold.c
@@ -0,0 +1,28 @@
+/* Replacement for 'int' to 'long double' conversion routine.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ Written by Bruno Haible <address@hidden>, 2011.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <float.h>
+
+void
+_Qp_itoq (long double *result, int a)
+{
+ /* Convert from 'int' to 'double', then from 'double' to 'long double'. */
+ *result = (double) a;
+}
--
1.7.7.rc0.362.g5a14
- Re: float, math: Fix 'int' to 'long double' conversion on Linux/SPARC64,
Jim Meyering <=