From patchwork Mon Dec 29 15:12:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 127185 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 494724BA2E24 for ; Mon, 29 Dec 2025 15:12:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 494724BA2E24 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=pGrvhV3K X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by sourceware.org (Postfix) with ESMTPS id DC8C64BA2E04 for ; Mon, 29 Dec 2025 15:12:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC8C64BA2E04 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC8C64BA2E04 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.216.65 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767021128; cv=none; b=NGc0V5nOM12FAkUQI21sc4BXqw5Idw8GEBjnO2vG2GHs469CWESj345SDpMSwfCUEEypKieXQxMHcb4KyqLBH/PbwpM3ajNfdiWqoDBWopfZGpbt8WtYc9BA4ZJHWg+tTtAasWwXXBLjIljPr4PXYDFzWir9rPlF3vjsfOSNcIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767021128; c=relaxed/simple; bh=iz1ASeuzkeY96+3m3EwQwmJZI2bdcitCKyesmbudVYY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=E2jckbnNTo3xhJ+oxnq7SKUiWBkvaA3OdbV4hl2ZpEBmW4uAB8KtHYIs3nCpctAIHzmy8akVe3q0XwEVscszYVw5urDWw71ZlmIe0dftBvWCcUCbVIu7dwyAT/ODrAadA6a/dzAvIp9+wQkAjy1jHWX5BDRlM3cIQDkxz54QpWc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC8C64BA2E04 Received: by mail-pj1-f65.google.com with SMTP id 98e67ed59e1d1-34c9edf63a7so9873642a91.1 for ; Mon, 29 Dec 2025 07:12:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767021126; x=1767625926; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LY0YffRTMROerbYiIfeBY8xZb/ooBt8RWdeGutL74HI=; b=pGrvhV3KqqDAS6GbqEtcF6S1nZveQn4kiiHsidWmT93U5BgT+Q3k+ZDxI6Ffm5QJYY rfRqrilLl3MuaEpG9GRqXyfdUWMFWLbzSMhCwSVWWHwq4NqQ2Wn2tUoVK0klxe+jDAsP T1EP57bcuBGC8rEwfJhNOYvXRNfBI5B9F3+YUt42ol0BJpGjpXyhIYeSbD7pECK9ijmg 4WFa0nPEMgdYeZGxjnHuHJK9WSHVrQ4wvB0byzFdSJJ3vjQS4edKG3fKG+LYtmq+w1Vl guP6C/kEeqp9jd80V47wzvQDT+s0zBsj0TpIUya7edPkXunu45MtLEoX9frPmNgptBdF rkUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767021126; x=1767625926; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LY0YffRTMROerbYiIfeBY8xZb/ooBt8RWdeGutL74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 2002:a05:7022:e80c:b0:11d:f44d:34db with SMTP id a92af1059eb24-121722ec1a5mr26315267c88.35.1767021126205; Mon, 29 Dec 2025 07:12:06 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:4c9f:b7c5:baa2:19f4:c869]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-121724ddc30sm120958388c88.6.2025.12.29.07.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Dec 2025 07:12:05 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" , Collin Funk , Sam James , Andreas Schwab Subject: [PATCH] math.h: Do use __MATH_TG_BUILTIN_CLASSIFY for C++ Date: Mon, 29 Dec 2025 12:12:00 -0300 Message-ID: <20251229151201.2453737-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The __MATH_TG_BUILTIN_CLASSIFY macro can not be used in C++ mode due it might use __builtin_types_compatible_p, which is a C-only builtin. Checked with bmg targetting x86_64-linux-gnu and on x86_64-linux-gnu and aarch64 with gcc-15 and clang-18. --- math/math.h | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/math/math.h b/math/math.h index 96b64379f7..49489293fc 100644 --- a/math/math.h +++ b/math/math.h @@ -1173,21 +1173,25 @@ enum /* Return number of classification appropriate for X. */ # if ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ - || __glibc_clang_prereq (2,8)) \ - && (!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) \ - __MATH_TG_BUILTIN_CLASSIFY ((x), \ - __builtin_fpclassify, (FP_NAN, FP_INFINITE, \ - FP_NORMAL, FP_SUBNORMAL, \ - FP_ZERO, x), \ - fpclassify, (x), \ - __FP_BUILTIN_FPCLASSIFY_DENORMAL) + || __glibc_clang_prereq (2,8)) \ + && !defined __cplusplus + /* The __MATH_TG_BUILTIN_CLASSIFY macro can not be used in C++ mode due + it might use __builtin_types_compatible_p, which is C-only builtin. */ +# define fpclassify(x) \ + __MATH_TG_BUILTIN_CLASSIFY ((x), \ + __builtin_fpclassify, (FP_NAN, FP_INFINITE, \ + FP_NORMAL, FP_SUBNORMAL, \ + FP_ZERO, x), \ + fpclassify, (x), \ + __FP_BUILTIN_FPCLASSIFY_DENORMAL) +# elif defined __cplusplus + /* The check for __cplusplus allows the use of the builtin, even + when optimization for size is on. This is provided for + libstdc++ and 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 # define fpclassify(x) __MATH_TG ((x), __fpclassify, (x)) # endif @@ -1247,12 +1251,17 @@ enum # define isinf(x) \ (__builtin_types_compatible_p (__typeof (x), _Float128) \ ? __isinff128 (x) : __builtin_isinf_sign (x)) -# elif (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ - || __glibc_clang_prereq (3,7) + /* The __MATH_TG_BUILTIN_CLASSIFY macro can not be used in C++ mode due + it might use __builtin_types_compatible_p, which is C-only builtin. */ +# elif ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ + || __glibc_clang_prereq (3,7)) \ + && !defined __cplusplus # define isinf(x) __MATH_TG_BUILTIN_CLASSIFY ((x), \ __builtin_isinf_sign, (x), \ isinf, (x), \ __FP_BUILTIN_ISINF_SIGN_DENORMAL) +# elif defined __cplusplus +# define isinf(x) __builtin_isinf_sign (x) # else # define isinf(x) __MATH_TG ((x), __isinf, (x)) # endif