This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Provide a C++ version of signbit that does not use __MATH_TG (bug 22296)


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.

[1] https://sourceware.org/ml/libc-alpha/2017-09/msg00787.html

Adding a check for the standard in use (__cpluplus < 201103L) would
probably be safer and it would solve the problem with mesa, as described
in bug 22296.  However, it would not help with the configure check in
libstdc++ ("checking for ISO C99 support in <math.h> for C++11").

Moreover, I'm not sure if defining signbit as a function in math.h is
correct, even if it's only for C++11.  So, I suggest we wait for comments
from other, more experienced developers.  :)

>+inline int signbit (long double __val) { return __signbitl (__val); }

If defining signbit as a function in math.h is actually OK, then you need
to check for __NO_LONG_DOUBLE_MATH before calling __signbitl, since it is
only defined when long double is not the same as double.  Otherwise, call
__signbit.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]