[PATCH] Provide a C++ version of signbit that does not use __MATH_TG (bug 22296)
Joseph Myers
joseph@codesourcery.com
Mon Oct 16 17:19:00 GMT 2017
On Mon, 16 Oct 2017, Gabriel F. T. Gomes wrote:
> On Sun, 15 Oct 2017, Romain Naour wrote:
>
> >--- a/math/math.h
> >+++ b/math/math.h
> >@@ -448,6 +448,21 @@ enum
> > /* Return nonzero value if sign of X is negative. */
> > # if __GNUC_PREREQ (6,0)
> > # define signbit(x) __builtin_signbit (x)
> >+# elif defined __cplusplus
>
> I believe that the comment [1] about fpclassify applies to signbit, too,
> because it is also the job of libstdc++ to provide it in C++11.
Yes, this case is like isinf and fpclassify: it's the job of libstdc++ to
undefine these macros, and redefine as functions if necessary. None of
the C99 type-generic macros should be defined by glibc as functions for
C++, because that's libstdc++'s job; the glibc definitions should only
ever be used for C++ when running the libstdc++ configure test. The TS
18661 macros like issignaling are different because they aren't in
standard C++ and libstdc++ doesn't provide its own versions of them.
My suggestion for signbit would be just to call __builtin_signbitl for the
case of (C++, !__GNUC_PREREQ (6,0)), which may involve unnecessary
conversions to long double when called at runtime (which shouldn't happen
anyway) but should be sufficient for the configure test.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list