From patchwork Mon Oct 16 21:21:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Naour X-Patchwork-Id: 23626 Received: (qmail 101400 invoked by alias); 16 Oct 2017 21:22:08 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 101088 invoked by uid 89); 16 Oct 2017 21:22:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f175.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XTugMlNaVLukHaDanTfztKGOwSmKgcRd1uPhmDgm2S4=; b=dkIbOG2ixyVtbObYBZxKw/FL2+xMGvBytCJ4xzgwQ4LKteVmwcbbbqIRyILMD95p5c f3oHVH1VdHUZunaHN1OSVU9e/9rAORUlMBJV3A5PshjdGXXYhqQ0IOgaNp3eduxsTXNe LNe6k+lT8J0mTSgiTutdHb1pkIS0kVPMgt7oEzDCoc1x2i6nVS3NFk58z91Du1LVtEyN 6RVTcPOYVtccx1NHRzsUP2EJIwypbu/loBAAUbDYAvi0uEKxdx6fQ+5OnvrsZcjhWNQM a7/0YRpca4O+gaMuwAaozXU01+EyjPMDUjBYcl7auBp1ocVWNOzJbmm9Tahyr/tcEgMp iy+w== X-Gm-Message-State: AMCzsaVbiDqPJqLsMXcJ3bDTp1Sgw5CzFAghjlU+ZeFQc0TkffZzx+kt QZBzMhbvNqn6CHYaocWiFo0scfOQ X-Google-Smtp-Source: ABhQp+RVD/yfr+IOq4YW5plGRgT+iPuCa8iQWu0V1A+/DUf3qV7n4hAHiOQV7LGmlg8zAc4BJTTyNA== X-Received: by 10.223.136.14 with SMTP id d14mr1581275wrd.215.1508188923267; Mon, 16 Oct 2017 14:22:03 -0700 (PDT) From: Romain Naour To: libc-alpha@sourceware.org Cc: Romain Naour , "Gabriel F . T . Gomes" , Joseph Myers Subject: [PATCH v2] Let signbit use the builtin in C++ mode with gcc < 6.x (bug 22146) Date: Mon, 16 Oct 2017 23:21:56 +0200 Message-Id: <20171016212156.20947-1-romain.naour@gmail.com> 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, when libstdc++ is configured with optimization for size enabled, its 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 Cc: Joseph Myers --- v2 Rework the patch following the review: https://sourceware.org/ml/libc-alpha/2017-09/msg00787.html --- ChangeLog | 5 +++++ math/math.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index f3b5e8c..de87072 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-10-16 Romain Naour (tiny change) + + [BZ #22296] + math/math.h: Let signbit use the builtin in C++ mode with gcc + < 6.x 2017-10-16 Florian Weimer * version.h (VERSION): Switch to ".9000" as the development diff --git a/math/math.h b/math/math.h index faa24817..5ad8156 100644 --- a/math/math.h +++ b/math/math.h @@ -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