]> sourceware.org Git - glibc.git/commitdiff
Let signbit use the builtin in C++ mode with gcc < 6.x (bug 22296)
authorRomain Naour <romain.naour@gmail.com>
Mon, 16 Oct 2017 21:21:56 +0000 (23:21 +0200)
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Tue, 17 Oct 2017 14:06:44 +0000 (12:06 -0200)
When using gcc < 6.x, signbit does not use the type-generic
__builtin_signbit builtin, instead it uses __MATH_TG.
However, when library support for float128 is available, __MATH_TG uses
__builtin_types_compatible_p, which is not available in C++ mode.

On the other hand, libstdc++ undefines (in cmath) many macros from
math.h, including signbit, so that it can provide its own functions.
However, during its configure tests, libstdc++ just tests for the
availability of the macros (it does not undefine them, nor does it
provide its own functions).

Finally, libstdc++ configure tests include math.h and get the definition
of signbit that uses __MATH_TG (and __builtin_types_compatible_p).
Since libstdc++ does not undefine the macros during its configure
tests, they fail.

This patch lets signbit use the builtin in C++ mode when gcc < 6.x is
used. This allows the configure test in libstdc++ to work.

Tested for x86_64.

[BZ #22296]
* math/math.h: Let signbit use the builtin in C++ mode with gcc
< 6.x

Cc: Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Cc: Joseph Myers <joseph@codesourcery.com>
ChangeLog
math/math.h

index 64f5ca7ff393fbde11d853e9113cd230f19a399e..e3f0faa3da7eadfeab892f684f7fe1cc037fdf32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-17  Romain Naour  <romain.naour@gmail.com>  (tiny change)
+
+       [BZ #22296]
+       * math/math.h: Let signbit use the builtin in C++ mode with gcc
+       < 6.x
+
 2017-10-17  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
        * scripts/build-many-glibcs.py (Context.add_all_configs):
index faa248173124446c005cf80f83350ff66a396fde..5ad8156555daf583514e214c2de0aca782871788 100644 (file)
@@ -448,6 +448,15 @@ enum
 /* Return nonzero value if sign of X is negative.  */
 # if __GNUC_PREREQ (6,0)
 #  define signbit(x) __builtin_signbit (x)
+# elif defined __cplusplus
+  /* In C++ mode, __MATH_TG cannot be used, because it relies on
+     __builtin_types_compatible_p, which is a C-only builtin.
+     The check for __cplusplus allows the use of the builtin instead of
+     __MATH_TG. This is provided for libstdc++, only to let its configure
+     test work. No further use of this definition of signbit is expected
+     in C++ mode, since libstdc++ provides its own version of signbit
+     in cmath (which undefines signbit). */
+#  define signbit(x) __builtin_signbitl (x)
 # elif __GNUC_PREREQ (4,0)
 #  define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
 # else
This page took 0.077108 seconds and 5 git commands to generate.