[PATCH] Remove __isinf uses that rely on signed return value
Joseph Myers
joseph@codesourcery.com
Wed Jun 3 12:59:00 GMT 2015
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
More information about the Libc-alpha
mailing list