This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: [PATCH] Remove __isinf uses that rely on signed return value
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Wilco Dijkstra <wdijkstr at arm dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 3 Jun 2015 11:49:06 +0000
- Subject: RE: [PATCH] Remove __isinf uses that rely on signed return value
- Authentication-results: sourceware.org; auth=none
- References: <001301d09d57$c0bfdf60$423f9e20$ at com> <alpine dot DEB dot 2 dot 10 dot 1506021739210 dot 21592 at digraph dot polyomino dot org dot uk> <000001d09df1$771af940$6550ebc0$ at com>
On Wed, 3 Jun 2015, Wilco Dijkstra wrote:
> > Joseph Myers wrote:
> > On Tue, 2 Jun 2015, Wilco Dijkstra wrote:
> >
> > > The printf code contains a few uses of __isinf where the sign is used -
> > > replace these with separate isinf and signbit.
> >
> > Why? Isn't the point of glibc's isinf returning a signed value that you
> > can do such combined operations?
>
> We discussed this a while back (and I thought it was agreed on going forward
> like this) - to recap, it is not required by any standard (so no standard
I don't recall any such discussion or agreement. The discussion in bug
15367 is on the basis of using __builtin_isinf_sign to implement the
header macro, not of changing the requirements and sometimes using
__builtin_isinf.
> compliant software may rely on this GLIBC specific behaviour), and is
> actually incompatible with C++ which requires a boolean to be returned.
C++ is the responsibility of libstdc++ (and defines overloaded functions,
not type-generic macros; libstdc++ needs to override things done in the C
header anyway).
> So the idea is to only support the old behaviour in GNUC mode for backwards
> compatibility, but not in C99/C++.
glibc is built with _GNU_SOURCE and can freely use all GNU features
(subject to link-time namespace issues). I see no need to change the
interface to this macro in glibc. Presumably the aim should be to make
the GCC __builtin_isinf / __builtin_isinf_sign at least as efficient as
the out-of-line functions, and safe for all inputs, make the isinf macro
use __builtin_isinf_sign, and make GCC optimize __builtin_isinf_sign calls
so it's as efficient as __builtin_isinf if the sign isn't used, and as
efficient as __builtin_isinf + __builtin_signbit if the sign is used.
--
Joseph S. Myers
joseph@codesourcery.com