]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Let fpclassify use the builtin when optimizing for size in C++ mode (bug 22146)
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Wed, 20 Sep 2017 18:10:26 +0000 (15:10 -0300)
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Fri, 22 Sep 2017 20:31:09 +0000 (17:31 -0300)
When optimization for size is on (-Os), fpclassify does not use the
type-generic __builtin_fpclassify 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 fpclassify, 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, when libstdc++ is configured with optimization for size
enabled, its configure tests include math.h and get the definition of
fpclassify 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 fpclassify use the builtin in C++ mode, even when
optimization for size is on.  This allows the configure test in
libstdc++ to work.

Tested for powerpc64le and x86_64.

[BZ #22146]
math/math.h: Let fpclassify use the builtin in C++ mode, even
when optimazing for size.

(cherry picked from commit c5c4a626098ec884b8527356abdf2a4bb7b6bf27)

ChangeLog
NEWS
math/math.h

index 6b09c61d5a3d94322598e012e6f5d8a627757620..382674d5a3306685f5bb0766d80b5e0b7ffe567a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-22  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
+
+       [BZ #22146]
+       math/math.h: Let fpclassify use the builtin in C++ mode, even
+       when optimazing for size.
+
 2017-08-22  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
 
        * include/libc-symbols.h: [!defined HAVE_GCC_IFUNC] (__ifunc):
diff --git a/NEWS b/NEWS
index 9bcb1761717dc0c35c575db6cc81b14797c091f9..48e206438092404f0baf27fe1b32e48d0f9b5fb8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ The following bugs are resolved with this release:
   [21972] assert macro requires operator== (int) for its argument type
   [22095] resolv: Fix memory leak with OOM during resolv.conf parsing
   [22096] resolv: __resolv_conf_attach must not free passed conf object
+  [22146] Let fpclassify use the builtin when optimizing for size in C++ mode
 \f
 Version 2.26
 
index 7c0fc6dbb3eea54d63f475fe9076a03c54a0ecae..f9348ec3ea43ca9f157b4f5df01d416e75e2dfc8 100644 (file)
@@ -402,7 +402,13 @@ enum
 
 /* Return number of classification appropriate for X.  */
 # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__                        \
-     && !defined __OPTIMIZE_SIZE__
+     && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
+     /* The check for __cplusplus allows the use of the builtin, even
+       when optimization for size is on.  This is provided for
+       libstdc++, only to let its configure test work when it is built
+       with -Os.  No further use of this definition of fpclassify is
+       expected in C++ mode, since libstdc++ provides its own version
+       of fpclassify in cmath (which undefines fpclassify).  */
 #  define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE,           \
      FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
 # else