0001-Do-not-use-__builtin_types_compatible_p-in-C-mode-bu.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From f7439f9b1089e17b6721f28e228682831a2f0135 Mon Sep 17 00:00:00 2001
  2. From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
  3. Date: Mon, 21 Aug 2017 14:23:27 +0200
  4. Subject: [PATCH] Do not use __builtin_types_compatible_p in C++ mode (bug
  5. 21930)
  6. The logic to define isinf for float128 depends on the availability of
  7. __builtin_types_compatible_p, which is only available in C mode,
  8. however, the conditionals do not check for C or C++ mode. This lead to
  9. an error in libstdc++ configure, as reported by bug 21930.
  10. This patch adds a conditional for C mode in the definition of isinf for
  11. float128. No definition is provided in C++ mode, since libstdc++
  12. headers undefine isinf.
  13. Tested for powerpc64le (glibc test suite and libstdc++-v3 configure).
  14. [BZ #21930]
  15. * math/math.h (isinf): Check if in C or C++ mode before using
  16. __builtin_types_compatible_p, since this is a C mode feature.
  17. (cherry picked from commit 47a67213a9f51c5f8816d240500b10db605d8b77)
  18. [Romain rebase on glibc 2.26]
  19. Signed-off-by: Romain Naour <romain.naour@gmail.com>
  20. ---
  21. math/math.h | 8 ++++++--
  22. 1 file changed, 6 insertions(+), 2 deletions(-)
  23. diff --git a/math/math.h b/math/math.h
  24. index e217080..dea8dbe 100644
  25. --- a/math/math.h
  26. +++ b/math/math.h
  27. @@ -442,8 +442,12 @@ enum
  28. /* Return nonzero value if X is positive or negative infinity. */
  29. # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
  30. - && !defined __SUPPORT_SNAN__
  31. - /* __builtin_isinf_sign is broken for float128 only before GCC 7.0. */
  32. + && !defined __SUPPORT_SNAN__ && !defined __cplusplus
  33. + /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
  34. + use the helper function, __isinff128, with older compilers. This is
  35. + only provided for C mode, because in C++ mode, GCC has no support
  36. + for __builtin_types_compatible_p (and when in C++ mode, this macro is
  37. + not used anyway, because libstdc++ headers undefine it). */
  38. # define isinf(x) \
  39. (__builtin_types_compatible_p (__typeof (x), _Float128) \
  40. ? __isinff128 (x) : __builtin_isinf_sign (x))
  41. --
  42. 2.9.5