From patchwork Fri Oct 31 20:00:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123244 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 004F33860C36 for ; Fri, 31 Oct 2025 20:05:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 004F33860C36 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=Z+YJKjbO X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 79D683860C39 for ; Fri, 31 Oct 2025 20:03:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79D683860C39 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 79D683860C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761940989; cv=none; b=heiCwGmoY2qBEaHvhxuC7AFcMDFILd20rKoheikZm2erGXVJ9V5gEW94ZgrYznjdSlXHSJJiCsjJuw8tW95HlDEqT+SaexjlCC9CFtPIGakLRLisQ6Qv/7OzFY11PiiAdfJQ5Bet5oi8/UDGuspxxpWvn9pSe+EHiM8nwU2kTy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761940989; c=relaxed/simple; bh=CISaqLFhkOz+ndQ1dLFe+OGQ5962/nl71+mHb9FcjMU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t2tl2Ow+G1ooPG59EGK/GWp3pJbP0Hpt78zazXDTnbcUoxTb2/a3LxwfM+nJa8Av/UETXLaR6tFpjSMyp1udgTtYImhJTWipY+7iQg9Of9RBSpMwuNU21pczTWf9O4PxAl8RfgK11SF2hE64XVHj9tZ9Vj5RbXpHAvz7HS4qST4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79D683860C39 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2951a817541so19590905ad.2 for ; Fri, 31 Oct 2025 13:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761940988; x=1762545788; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8fIrIaPcnvKBR70rgQxRpJIrzjj1fw6u7gW54nZTaAU=; b=Z+YJKjbOZECK4vw0Plv1XYF9HxxhEcgYgBLD8kT3XbWA469mhLtlfFDOVnbPdHvWbU 5r4H3s8zH8EmY+5pqV9oY22FfdfyLMcWPC2ucbM6q026LErsRaqy0y0YJZWvKJWi/aJe /vudgNcO4k3gF+V0NX0KpPLGth05vCYIFotqvN9gCZsZB8gEGEh5XVctvUVWCMjpm9gK rG6RXND1RLcuJ+9+ofDxZ7zggD7ESFTsGX3jVT0lkPktXa+bQHyLJlSBT4PdCO1JLj+L dFXZg7ZxfX1XDNYKJNf8mNiZYn989BHFzrPvs3n71AnvqBhpTRqsiKOIqYrMjTOtXtHs 2M/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761940988; x=1762545788; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8fIrIaPcnvKBR70rgQxRpJIrzjj1fw6u7gW54nZTaAU=; b=HKPqSg5juCf1EaWTO0MtPJDg5KkPUm+NEPxy8k5KPjif5+oGzKoraDwcqCUh4kz4Vv 1CbRXGWhCGrn9QSgQ+peSqpHVTeyII68vOXKbnW5/Q2PpmDtcDXmOMnjhALuXgKtFr9R ZkDr5nFuJrRVFTabKH2avtSO5zEX4U5tadTSD3AT5/Ke/IpLTzgbbhkjn6G3Z49oG7PJ YqOeWOa1ANiAzhzmoA+YRM0y7tUfJYXCFYRP9LqQGKD0ZD8w2edGbPVOyQ8ZQOyQK52U M3zKfkaH9fnJ7VV8xWmA24zTiX59XkPtrSVhhU5VSfd90uYM17FfBAGnbp+lRvF7BzJY +OMw== X-Gm-Message-State: AOJu0YxMgVRdVL+xgWAiUlfDKxVIkS4BYOy1R2JG9rP0kaTgkpHrKJNs ZG2OqRTvTgnwmbgea/aIvCraPR8VHLyKtgDOaGutIqcZS7t5+31qFqqr40Y9l+bZ4Pu97zJ/pD2 vhy41ULk= X-Gm-Gg: ASbGncvtgkfbAyQ5npkr3q+Yn76zaazN2d7iYv6aDjAx1K0xi+iA7/7qCdqFTrGKacT oFiyBElfYZusV2AWpe7Mm/CJyvs7wLWCkRORSeIRy8a3xIjjcGbElUbQr1ZScSju77MVQkZnkOc /tFKOjiz9FeVTgP4prybLVbVwlkQ0oq8JXvm76S07fPQJQ3mn6V93jW8WzzMG2F2fwrj2mk7NBz YxjkUrAQKC53KHykeG2gCP04YHKtYW0TTjQnC4+QX0Y07OqYHxf1+dOrpWwEazBI6OB/sqHWBkr O4nqYYGDdzhO8BM2wt+XPjxQjspUgzQjWQpkWc4qHp0Q/MRwzIzXQm6zvxhX1sFfEkf+vC7eiVz Wx+RxBgsDkVo/yuviVbhW4zMrkJYULXngH08vV2er8BlrjSF3I+5BhO0lXaF3/Vf4qaVGmjU77B 1fXGXVq9wC6cbU X-Google-Smtp-Source: AGHT+IF0QEMY/LQWfIx689TM+I0/JEB7NQIDKdcO1rruNOcrZSvnGwsCfGzPv/U/ujmrmBft0tmkNw== X-Received: by 2002:a17:902:e78d:b0:24b:24dc:91a7 with SMTP id d9443c01a7336-2951a52a946mr55708445ad.45.1761940988072; Fri, 31 Oct 2025 13:03:08 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:07 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 01/19] stdlib: Remove mp_clz_tab.c Date: Fri, 31 Oct 2025 17:00:34 -0300 Message-ID: <20251031200300.3716090-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 count_leading_zeros is not used anymore, so there is no need to provide the table for possible usage. The hppa already provides the compat symbol on libgcc-compat.c. Reviewed-by: Collin Funk --- stdlib/Makefile | 1 - stdlib/mp_clz_tab.c | 36 ------------------------------------ sysdeps/hppa/mp_clz_tab.c | 1 - sysdeps/i386/mp_clz_tab.c | 1 - sysdeps/powerpc/mp_clz_tab.c | 1 - sysdeps/x86_64/mp_clz_tab.c | 1 - 6 files changed, 41 deletions(-) delete mode 100644 stdlib/mp_clz_tab.c delete mode 100644 sysdeps/hppa/mp_clz_tab.c delete mode 100644 sysdeps/i386/mp_clz_tab.c delete mode 100644 sysdeps/powerpc/mp_clz_tab.c delete mode 100644 sysdeps/x86_64/mp_clz_tab.c diff --git a/stdlib/Makefile b/stdlib/Makefile index e9319cf95da..176a79572b0 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -513,7 +513,6 @@ routines := \ # routines aux += \ fpioconst \ - mp_clz_tab \ # aux tests-extras += \ diff --git a/stdlib/mp_clz_tab.c b/stdlib/mp_clz_tab.c deleted file mode 100644 index 9084298803e..00000000000 --- a/stdlib/mp_clz_tab.c +++ /dev/null @@ -1,36 +0,0 @@ -/* __clz_tab -- support for longlong.h - Copyright (C) 1991-2025 Free Software Foundation, Inc. - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in the GNU MP Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#if 0 -#include -#include "gmp-impl.h" -#endif - -const -unsigned char __clz_tab[] = -{ - 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, -}; diff --git a/sysdeps/hppa/mp_clz_tab.c b/sysdeps/hppa/mp_clz_tab.c deleted file mode 100644 index 52d06383c19..00000000000 --- a/sysdeps/hppa/mp_clz_tab.c +++ /dev/null @@ -1 +0,0 @@ -/* __clz_tab not needed on hppa. */ diff --git a/sysdeps/i386/mp_clz_tab.c b/sysdeps/i386/mp_clz_tab.c deleted file mode 100644 index 860f98cc62a..00000000000 --- a/sysdeps/i386/mp_clz_tab.c +++ /dev/null @@ -1 +0,0 @@ -/* __clz_tab not needed on i386. */ diff --git a/sysdeps/powerpc/mp_clz_tab.c b/sysdeps/powerpc/mp_clz_tab.c deleted file mode 100644 index 4b5f29bfe5d..00000000000 --- a/sysdeps/powerpc/mp_clz_tab.c +++ /dev/null @@ -1 +0,0 @@ -/* __clz_tab not needed on powerpc. */ diff --git a/sysdeps/x86_64/mp_clz_tab.c b/sysdeps/x86_64/mp_clz_tab.c deleted file mode 100644 index 7b13a394da8..00000000000 --- a/sysdeps/x86_64/mp_clz_tab.c +++ /dev/null @@ -1 +0,0 @@ -/* __clz_tab not needed on x86-64. */ From patchwork Fri Oct 31 20:00:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123245 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B90D93850429 for ; Fri, 31 Oct 2025 20:05:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B90D93850429 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=sTFoi5X/ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id 72DC3386103B for ; Fri, 31 Oct 2025 20:03:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72DC3386103B 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 72DC3386103B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761940992; cv=none; b=cFP/qmN/TPo+Ukf3ChaYUrOhuXd+4Iqoydznr+MDw0CI/c9mwpw7BTtebfjVq/84gJWbAKyA3L18kd8aGA/C3T1l9uFG8VpFUz7A1tXjI++jXXrrHZgEuboOKE/U3BSGAHsN02FQZ+PhX6gvqF9+tnO+fu7apnvwc7MA1ozKkcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761940992; c=relaxed/simple; bh=P1Qi0JfrvjFIXzj7LnYaYEz5LOGUtG3ApYQpv+yqUM8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ApPKRZPVmVTNF1kRj5vOpTxj2jzjdQbiah5CDouFBvGO379NJ9MxaSB2mIdYYW8yiw1nEjOoHU0AQqp8HiRmUn6b5Cb5vTCqmfK3n3h/TVlYt8CGEn79UHOizIGd/G5J2m9doInJDQYMcPmwKqcJteUsCnf6XlzCn+I3WUZG4Qs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72DC3386103B Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-b55517e74e3so2545318a12.2 for ; Fri, 31 Oct 2025 13:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761940991; x=1762545791; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9b4SM9JxXxrgKJZHPmWlf+x4azTFvq+LscZyroZURbo=; b=sTFoi5X/NMXsfJAFabhIwzrdIEbzCd34njGcQQcE8xjLl4z+Q7gHE1LchOg2lt5SzT a8NQBCNfcWcen1hkA82A0Qbvko65jChYWn7x3mVWg8RE5tDn+Mv1vYOnEByDrNjGup+1 g4+Dm+Y0P0Q+M7qN+EOfA/nu2m/MtuatYgvKgU/zjvT/CZLr70ow7TW1pl3k9JI3GfF2 qVpT+pWqsWFQfkmejQ432V8urO63WB2R2t6Q7dFAgkA0wWp1jhZroBA7Sufh/BsyBU7N bF1H+WdOcENJ3xHrnVJ3S3EnOCfeu6RZemMHqEkycIxUg8mU9l+98Y7ycEgpe3hYYm09 qxpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761940991; x=1762545791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9b4SM9JxXxrgKJZHPmWlf+x4azTFvq+LscZyroZURbo=; b=CgGj4EiVAiz4wS9jJWC58CpPN69/uSBIwil3Lg+4onkcj+Dag2deocNmLADAzXBKqP 1xbRz8M5idCaV8kWCFqsNw+brbQbc9RJwZhL4DGgD8MW3SPxKK6wKlyRJ7UM76x8+aaN qk+lEFfzgywkTR87W8yz3koEEcp9KOdmllFxoOlPSdAJ9WftwhPGzRoyGQZfjmxxZyiT ncaI8ezj9T7hegSwjFrowGlkYeX80Yp/QFX+TBPN0xz2JEHNS0ayj43pyDWDdKerjuEk Y+gkimK+sEXRlptJVZyg4fl7AZvvNyn1JnHAO7OMvXIHjIu19z8xwAGs7edueMrOCdzF LL4w== X-Gm-Message-State: AOJu0Yw56TaBPuslJHn4E+BnzI8isgRH4ziebu4/iJmCHdpXh8jwPtVu WFkxAwnrj1heXDxdRb6aViSj5iDAqVYTHh2/FWnJiU8BVW30x0elo5gcUknoG0xC9NOFi4/uLGI EecIzM4Y= X-Gm-Gg: ASbGncvaFogCfTjx8xK/GHXzodX2gOX9mErCE9ZbRcyv3SbRZXsutDdlcJTJKfxxX45 8HFzokhmhrLvQSKJWnU3oJMOWUT7qphisqjSff9wwXc6mZqiQDrjImCkkl5d+/MUZDxBq++JZNu Oci2AwroNYu6E8L75mQHXTG/o2sMVp/gAImRx4xIkosuTQzr04MaLYoJKSVmtCxj0muKhMEJYBK z3E4qtKkjAQxa/aF4VIt3rizNLMjOi6SWq2tIjZ4IP9UxSffHjs4zAeBZzyeOdloiZrni9U6j4K OpJoV/N5CaJlkNBL9NyqMG9Jkfj1IhWpRSfgbTPNbarw+Y7da+nAwZkhNLFQL6zpBjaXK31kgIu aPPk/pBQdf7RlX5CH96J8zHBnhodS/TC7jsSaMkVUfMbS0XPctXlYu6sHQX2KoLf4VhRNm9ZQRb H6nSmNO6ZJcdOqUB1bFFfvCmY= X-Google-Smtp-Source: AGHT+IFr1av9KFxZig6W6dZ+d3W4ouS6kWGZ1zMRQcpylavukcPyMLLEWwiYBw9eoEAP9/kS1eo0Ww== X-Received: by 2002:a17:902:f605:b0:24b:4a9a:703a with SMTP id d9443c01a7336-2951a3d4644mr68110265ad.17.1761940990572; Fri, 31 Oct 2025 13:03:10 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:09 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 02/19] Add gmp-arch and udiv_qrnnd Date: Fri, 31 Oct 2025 17:00:35 -0300 Message-ID: <20251031200300.3716090-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SCC_10_SHORT_WORD_LINES, SCC_20_SHORT_WORD_LINES, SCC_35_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 To enable “longlong.h” removal, the udiv_qrnnd is moved to a gmp-arch.h file. It allows each architecture to implement its own arch-specific optimizations. The generic implementation now uses a static inline, which provides better type checking than the GNU extension to cast the asm constraint (and it works better with clang). Most of the architecture uses the generic implementation, which is expanded from a macro, except for alpha, x86, m68k, sh, and sparc. I kept that alpha, which uses out-of-the-line implementations and x86, where there is no easy way to use the div{q} instruction from C code. For the rest, the compiler generates good enough code. The hppa also provides arch-specific implementations, but they are not routed in “longlong.h” and thus never used. --- soft-fp/soft-fp.h | 19 +- stdio-common/_itoa.c | 7 +- stdio-common/_itowa.c | 7 +- stdlib/Makefile | 1 - stdlib/addmul_1.c | 1 + stdlib/divmod_1.c | 1 + stdlib/mod_1.c | 1 + stdlib/mul_1.c | 1 + stdlib/strtod_l.c | 1 + stdlib/submul_1.c | 1 + stdlib/udiv_qrnnd.c | 10 - sysdeps/alpha/Makefile | 4 + sysdeps/alpha/gmp-arch.h | 2 + sysdeps/generic/gmp-arch.h | 113 +++++++++++ sysdeps/hppa/hppa1.1/udiv_qrnnd.S | 77 -------- sysdeps/hppa/udiv_qrnnd.S | 285 ---------------------------- sysdeps/ieee754/dbl-64/dbl2mpn.c | 1 + sysdeps/ieee754/ldbl-128/ldbl2mpn.c | 1 + sysdeps/ieee754/ldbl-96/ldbl2mpn.c | 1 + sysdeps/wordsize-32/divdi3.c | 10 +- sysdeps/x86/gmp-arch.h | 50 +++++ sysdeps/x86/ldbl2mpn.c | 1 + 22 files changed, 193 insertions(+), 402 deletions(-) delete mode 100644 stdlib/udiv_qrnnd.c create mode 100644 sysdeps/alpha/gmp-arch.h create mode 100644 sysdeps/generic/gmp-arch.h delete mode 100644 sysdeps/hppa/hppa1.1/udiv_qrnnd.S delete mode 100644 sysdeps/hppa/udiv_qrnnd.S create mode 100644 sysdeps/x86/gmp-arch.h diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h index 1f087148318..4c0859fa068 100644 --- a/soft-fp/soft-fp.h +++ b/soft-fp/soft-fp.h @@ -316,22 +316,6 @@ #include "op-8.h" #include "op-common.h" -/* Sigh. Silly things longlong.h needs. */ -#define UWtype _FP_W_TYPE -#define W_TYPE_SIZE _FP_W_TYPE_SIZE - -typedef int QItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); -#if _FP_W_TYPE_SIZE == 32 -typedef unsigned int UHWtype __attribute__ ((mode (HI))); -#elif _FP_W_TYPE_SIZE == 64 -typedef USItype UHWtype; -#endif - #ifndef CMPtype # define CMPtype int #endif @@ -341,7 +325,10 @@ typedef USItype UHWtype; #ifndef umul_ppmm # ifdef _LIBC +# include +# include # include +# include # else # include "longlong.h" # endif diff --git a/stdio-common/_itoa.c b/stdio-common/_itoa.c index 08859f0dd08..e9cbcfab3b6 100644 --- a/stdio-common/_itoa.c +++ b/stdio-common/_itoa.c @@ -26,6 +26,7 @@ #include #include #include +#include #include <_itoa.h> @@ -308,8 +309,8 @@ _itoa (unsigned long long int value, char *buflim, unsigned int base, if (big_normalization_steps == 0) xh = 0; else - xh = (mp_limb_t) (value >> 64 - big_normalization_steps); - xl = (mp_limb_t) (value >> 32 - big_normalization_steps); + xh = (mp_limb_t) (value >> (64 - big_normalization_steps)); + xl = (mp_limb_t) (value >> (32 - big_normalization_steps)); udiv_qrnnd (x1hi, r, xh, xl, big_base_norm); xl = ((mp_limb_t) value) << big_normalization_steps; @@ -320,7 +321,7 @@ _itoa (unsigned long long int value, char *buflim, unsigned int base, xh = x1hi; else xh = ((x1hi << big_normalization_steps) - | (x1lo >> 32 - big_normalization_steps)); + | (x1lo >> (32 - big_normalization_steps))); xl = x1lo << big_normalization_steps; udiv_qrnnd (t[0], x, xh, xl, big_base_norm); t[1] = x >> big_normalization_steps; diff --git a/stdio-common/_itowa.c b/stdio-common/_itowa.c index 6443b293a48..2da7489502c 100644 --- a/stdio-common/_itowa.c +++ b/stdio-common/_itowa.c @@ -21,6 +21,7 @@ #include #include #include +#include #include <_itowa.h> @@ -228,8 +229,8 @@ _itowa (unsigned long long int value, wchar_t *buflim, unsigned int base, if (big_normalization_steps == 0) xh = 0; else - xh = (mp_limb_t) (value >> 64 - big_normalization_steps); - xl = (mp_limb_t) (value >> 32 - big_normalization_steps); + xh = (mp_limb_t) (value >> (64 - big_normalization_steps)); + xl = (mp_limb_t) (value >> (32 - big_normalization_steps)); udiv_qrnnd (x1hi, r, xh, xl, big_base_norm); xl = ((mp_limb_t) value) << big_normalization_steps; @@ -240,7 +241,7 @@ _itowa (unsigned long long int value, wchar_t *buflim, unsigned int base, xh = x1hi; else xh = ((x1hi << big_normalization_steps) - | (x1lo >> 32 - big_normalization_steps)); + | (x1lo >> (32 - big_normalization_steps))); xl = x1lo << big_normalization_steps; udiv_qrnnd (t[0], x, xh, xl, big_base_norm); t[1] = x >> big_normalization_steps; diff --git a/stdlib/Makefile b/stdlib/Makefile index 176a79572b0..a9a68c190c4 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -493,7 +493,6 @@ mpn-routines := \ rshift \ sub_n \ submul_1 \ - udiv_qrnnd \ # mpn-routines mpn-headers = \ asm-syntax.h \ diff --git a/stdlib/addmul_1.c b/stdlib/addmul_1.c index 52411c3d105..a5bf7fd37e4 100644 --- a/stdlib/addmul_1.c +++ b/stdlib/addmul_1.c @@ -24,6 +24,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" #include "longlong.h" +#include mp_limb_t mpn_addmul_1 (register mp_ptr res_ptr, register mp_srcptr s1_ptr, diff --git a/stdlib/divmod_1.c b/stdlib/divmod_1.c index b91ab9e5934..676145d7272 100644 --- a/stdlib/divmod_1.c +++ b/stdlib/divmod_1.c @@ -28,6 +28,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" #include "longlong.h" +#include #ifndef UMUL_TIME #define UMUL_TIME 1 diff --git a/stdlib/mod_1.c b/stdlib/mod_1.c index 74c1f6a5214..be3ae3d648f 100644 --- a/stdlib/mod_1.c +++ b/stdlib/mod_1.c @@ -25,6 +25,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" #include "longlong.h" +#include #ifndef UMUL_TIME #define UMUL_TIME 1 diff --git a/stdlib/mul_1.c b/stdlib/mul_1.c index 225b4917d98..0a04a8eb1e3 100644 --- a/stdlib/mul_1.c +++ b/stdlib/mul_1.c @@ -22,6 +22,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" #include "longlong.h" +#include mp_limb_t mpn_mul_1 (register mp_ptr res_ptr, register mp_srcptr s1_ptr, diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c index 5814475e405..7618adb2854 100644 --- a/stdlib/strtod_l.c +++ b/stdlib/strtod_l.c @@ -83,6 +83,7 @@ extern double ____strtod_l_internal (const char *, char **, int, locale_t); #include #include "gmp-impl.h" #include "longlong.h" +#include "gmp-arch.h" #include "fpioconst.h" #include diff --git a/stdlib/submul_1.c b/stdlib/submul_1.c index 3eb4d015f55..0005c2e04e6 100644 --- a/stdlib/submul_1.c +++ b/stdlib/submul_1.c @@ -24,6 +24,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" #include "longlong.h" +#include mp_limb_t mpn_submul_1 (register mp_ptr res_ptr, register mp_srcptr s1_ptr, diff --git a/stdlib/udiv_qrnnd.c b/stdlib/udiv_qrnnd.c deleted file mode 100644 index d32796c04d4..00000000000 --- a/stdlib/udiv_qrnnd.c +++ /dev/null @@ -1,10 +0,0 @@ -/* For some machines GNU MP needs to define an auxiliary function: - - udiv_qrnnd (quotient, remainder, high_numerator, low_numerator, denominator) - - Divides a two-word unsigned integer, composed by the integers - HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient - in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less - than DENOMINATOR for correct operation. If, in addition, the most - significant bit of DENOMINATOR must be 1, then the pre-processor symbol - UDIV_NEEDS_NORMALIZATION is defined to 1. */ diff --git a/sysdeps/alpha/Makefile b/sysdeps/alpha/Makefile index 39dea0d72cb..cae60186c82 100644 --- a/sysdeps/alpha/Makefile +++ b/sysdeps/alpha/Makefile @@ -32,6 +32,10 @@ ifeq ($(subdir),string) sysdep_routines += stxcpy stxncpy endif +ifeq ($(subdir),stdlib) +sysdep_routines += udiv_qrnnd +endif + ifeq ($(subdir),elf) # The ld.so startup code cannot use literals until it self-relocates. CFLAGS-rtld.c = -mbuild-constants diff --git a/sysdeps/alpha/gmp-arch.h b/sysdeps/alpha/gmp-arch.h new file mode 100644 index 00000000000..c6e4c8f498f --- /dev/null +++ b/sysdeps/alpha/gmp-arch.h @@ -0,0 +1,2 @@ +#define __EXTERNAL_QRNND 1 +#include diff --git a/sysdeps/generic/gmp-arch.h b/sysdeps/generic/gmp-arch.h new file mode 100644 index 00000000000..623b0ae968c --- /dev/null +++ b/sysdeps/generic/gmp-arch.h @@ -0,0 +1,113 @@ +/* Multiprecision generic functions. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __GMP_ARCH_H +#define __GMP_ARCH_H + +#include + +#define LL_B ((mp_limb_t) 1 << (BITS_PER_MP_LIMB / 2)) + +static __always_inline mp_limb_t +ll_lowpart (mp_limb_t t) +{ + return t & (LL_B - 1); +} + +static __always_inline mp_limb_t +ll_highpart (mp_limb_t t) +{ + return t >> (BITS_PER_MP_LIMB / 2); +} + +/* udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, + denominator) divides a UDWtype, composed by the UWtype integers + HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient + in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less + than DENOMINATOR for correct operation. If, in addition, the most + significant bit of DENOMINATOR must be 1, then the pre-processor symbol + UDIV_NEEDS_NORMALIZATION is defined to 1. */ +#ifndef __EXTERNAL_QRNND +static __always_inline void +udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, + mp_limb_t d) +{ + mp_limb_t d1 = ll_highpart (d), + d0 = ll_lowpart (d), + q1, q0; + mp_limb_t r1, r0, m; + + r1 = n1 % d1; + q1 = n1 / d1; + m = q1 * d0; + r1 = r1 * LL_B | ll_highpart (n0); + if (r1 < m) + { + q1--; + r1 += d; + if (r1 >= d) + if (r1 < m) + { + q1--; + r1 += d; + } + } + r1 -= m; + + r0 = r1 % d1; + q0 = r1 / d1; + m = q0 * d0; + r0 = r0 * LL_B | ll_lowpart (n0); + if (r0 < m) + { + q0--; + r0 += d; + if (r0 >= d) + if (r0 < m) + { + q0--; + r0 += d; + } + } + r0 -= m; + + *q = q1 * LL_B | q0; + *r = r0; +} +# undef UDIV_NEEDS_NORMALIZATION +# define UDIV_NEEDS_NORMALIZATION 1 +#else +extern mp_limb_t __udiv_qrnnd (mp_limb_t *, mp_limb_t, mp_limb_t, mp_limb_t) + attribute_hidden; + +static __always_inline void +udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, + mp_limb_t d) +{ + *q = __udiv_qrnnd (r, n1, n0, d); +} +# undef UDIV_NEEDS_NORMALIZATION +# define UDIV_NEEDS_NORMALIZATION 0 +#endif + +#undef udiv_qrnnd +#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ + udiv_qrnnd_generic (&__q, &__r, __n1, __n0, __d) + + +#endif /* __GMP_ARHC_H */ diff --git a/sysdeps/hppa/hppa1.1/udiv_qrnnd.S b/sysdeps/hppa/hppa1.1/udiv_qrnnd.S deleted file mode 100644 index 2f8101bbd2a..00000000000 --- a/sysdeps/hppa/hppa1.1/udiv_qrnnd.S +++ /dev/null @@ -1,77 +0,0 @@ -;! HP-PA __udiv_qrnnd division support, used from longlong.h. -;! This version runs fast on PA 7000 and later. - -;! Copyright (C) 1993-2025 Free Software Foundation, Inc. - -;! This file is part of the GNU MP Library. - -;! The GNU MP Library is free software; you can redistribute it and/or modify -;! it under the terms of the GNU Lesser General Public License as published by -;! the Free Software Foundation; either version 2.1 of the License, or (at your -;! option) any later version. - -;! The GNU MP Library is distributed in the hope that it will be useful, but -;! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -;! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -;! License for more details. - -;! You should have received a copy of the GNU Lesser General Public License -;! along with the GNU MP Library. If not, see -;! . - - -;! INPUT PARAMETERS -;! rem_ptr gr26 -;! n1 gr25 -;! n0 gr24 -;! d gr23 - - .text -L$0000: - .word 0x43f00000 - .word 0x0 - .export __udiv_qrnnd -__udiv_qrnnd: - .proc - .callinfo frame=64,no_calls - .entry - ldo 64(%r30),%r30 - - stws %r25,-16(%r30) ;! n_hi - stws %r24,-12(%r30) ;! n_lo - b,l L$0,%r1 - ldo L$0000-L$0(%r1),%r1 -L$0: - fldds -16(%r30),%fr5 - stws %r23,-12(%r30) - comib,<= 0,%r25,L$1 - fcnvxf,dbl,dbl %fr5,%fr5 - fldds 0(%r1),%fr4 - fadd,dbl %fr4,%fr5,%fr5 -L$1: - fcpy,sgl %fr0,%fr6L - fldws -12(%r30),%fr6R - fcnvxf,dbl,dbl %fr6,%fr4 - - fdiv,dbl %fr5,%fr4,%fr5 - - fcnvfx,dbl,dbl %fr5,%fr4 - fstws %fr4R,-16(%r30) - xmpyu %fr4R,%fr6R,%fr6 - ldws -16(%r30),%r28 - fstds %fr6,-16(%r30) - ldws -12(%r30),%r21 - ldws -16(%r30),%r20 - sub %r24,%r21,%r22 - subb %r25,%r20,%r1 - comib,= 0,%r1,L$2 - ldo -64(%r30),%r30 - - add %r22,%r23,%r22 - ldo -1(%r28),%r28 -L$2: - bv 0(%r2) - stws %r22,0(%r26) - - .exit - .procend diff --git a/sysdeps/hppa/udiv_qrnnd.S b/sysdeps/hppa/udiv_qrnnd.S deleted file mode 100644 index 317fcda7228..00000000000 --- a/sysdeps/hppa/udiv_qrnnd.S +++ /dev/null @@ -1,285 +0,0 @@ -;! HP-PA __udiv_qrnnd division support, used from longlong.h. -;! This version runs fast on pre-PA7000 CPUs. - -;! Copyright (C) 1993-2025 Free Software Foundation, Inc. - -;! This file is part of the GNU MP Library. - -;! The GNU MP Library is free software; you can redistribute it and/or modify -;! it under the terms of the GNU Lesser General Public License as published by -;! the Free Software Foundation; either version 2.1 of the License, or (at your -;! option) any later version. - -;! The GNU MP Library is distributed in the hope that it will be useful, but -;! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -;! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -;! License for more details. - -;! You should have received a copy of the GNU Lesser General Public License -;! along with the GNU MP Library. If not, see -;! . - - -;! INPUT PARAMETERS -;! rem_ptr gr26 -;! n1 gr25 -;! n0 gr24 -;! d gr23 - -;! The code size is a bit excessive. We could merge the last two ds;addc -;! sequences by simply moving the "bb,< Odd" instruction down. The only -;! trouble is the FFFFFFFF code that would need some hacking. - - .text - .export __udiv_qrnnd -__udiv_qrnnd: - .proc - .callinfo frame=0,no_calls - .entry - - comb,< %r23,%r0,L$largedivisor - sub %r0,%r23,%r1 ;! clear cy as side-effect - ds %r0,%r1,%r0 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r24 - ds %r25,%r23,%r25 - addc %r24,%r24,%r28 - ds %r25,%r23,%r25 - comclr,>= %r25,%r0,%r0 - addl %r25,%r23,%r25 - stws %r25,0(%r26) - bv 0(%r2) - addc %r28,%r28,%r28 - -L$largedivisor: - extru %r24,31,1,%r20 ;! r20 = n0 & 1 - bb,< %r23,31,L$odd - extru %r23,30,31,%r22 ;! r22 = d >> 1 - shd %r25,%r24,1,%r24 ;! r24 = new n0 - extru %r25,30,31,%r25 ;! r25 = new n1 - sub %r0,%r22,%r21 - ds %r0,%r21,%r0 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - comclr,>= %r25,%r0,%r0 - addl %r25,%r22,%r25 - sh1addl %r25,%r20,%r25 - stws %r25,0(%r26) - bv 0(%r2) - addc %r24,%r24,%r28 - -L$odd: addib,sv,n 1,%r22,L$FF.. ;! r22 = (d / 2 + 1) - shd %r25,%r24,1,%r24 ;! r24 = new n0 - extru %r25,30,31,%r25 ;! r25 = new n1 - sub %r0,%r22,%r21 - ds %r0,%r21,%r0 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r24 - ds %r25,%r22,%r25 - addc %r24,%r24,%r28 - comclr,>= %r25,%r0,%r0 - addl %r25,%r22,%r25 - sh1addl %r25,%r20,%r25 -;! We have computed (n1,,n0) / (d + 1), q' = r28, r' = r25 - add,nuv %r28,%r25,%r25 - addl %r25,%r1,%r25 - addc %r0,%r28,%r28 - sub,<< %r25,%r23,%r0 - addl %r25,%r1,%r25 - stws %r25,0(%r26) - bv 0(%r2) - addc %r0,%r28,%r28 - -;! This is just a special case of the code above. -;! We come here when d == 0xFFFFFFFF -L$FF..: add,uv %r25,%r24,%r24 - sub,<< %r24,%r23,%r0 - ldo 1(%r24),%r24 - stws %r24,0(%r26) - bv 0(%r2) - addc %r0,%r25,%r28 - - .exit - .procend diff --git a/sysdeps/ieee754/dbl-64/dbl2mpn.c b/sysdeps/ieee754/dbl-64/dbl2mpn.c index d69973419b7..cacf5da7d80 100644 --- a/sysdeps/ieee754/dbl-64/dbl2mpn.c +++ b/sysdeps/ieee754/dbl-64/dbl2mpn.c @@ -18,6 +18,7 @@ #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" +#include #include #include #include diff --git a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c index d3f3476d569..fd75db1271c 100644 --- a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c +++ b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c @@ -18,6 +18,7 @@ #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" +#include #include #include #include diff --git a/sysdeps/ieee754/ldbl-96/ldbl2mpn.c b/sysdeps/ieee754/ldbl-96/ldbl2mpn.c index 982f4273803..6c7aadbca2e 100644 --- a/sysdeps/ieee754/ldbl-96/ldbl2mpn.c +++ b/sysdeps/ieee754/ldbl-96/ldbl2mpn.c @@ -18,6 +18,7 @@ #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" +#include #include #include #include diff --git a/sysdeps/wordsize-32/divdi3.c b/sysdeps/wordsize-32/divdi3.c index 387022ab141..360094134f1 100644 --- a/sysdeps/wordsize-32/divdi3.c +++ b/sysdeps/wordsize-32/divdi3.c @@ -25,20 +25,16 @@ #error This is for 32-bit targets only #endif -typedef unsigned int UQItype __attribute__ ((mode (QI))); -typedef int SItype __attribute__ ((mode (SI))); -typedef unsigned int USItype __attribute__ ((mode (SI))); -typedef int DItype __attribute__ ((mode (DI))); -typedef unsigned int UDItype __attribute__ ((mode (DI))); #define Wtype SItype #define HWtype SItype #define DWtype DItype -#define UWtype USItype #define UHWtype USItype #define UDWtype UDItype -#define W_TYPE_SIZE 32 +#include +#include #include +#include #if __BYTE_ORDER == __BIG_ENDIAN struct DWstruct { Wtype high, low;}; diff --git a/sysdeps/x86/gmp-arch.h b/sysdeps/x86/gmp-arch.h new file mode 100644 index 00000000000..5c8b8830afa --- /dev/null +++ b/sysdeps/x86/gmp-arch.h @@ -0,0 +1,50 @@ +/* Multiprecision generic functions. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __GMP_ARCH_H +#define __GMP_ARCH_H + +#include + +static __always_inline void +udiv_qrnnd_x86 (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, + mp_limb_t d) +{ +#ifdef __x86_64__ + asm ("div{q} %4" + : "=a" (*q), + "=d" (*r) + : "0" (n0), + "1" (n1), + "rm" (d)); +#else + asm ("div{l} %4" + : "=a" (*q), + "=d" (*r) + : "0" (n0), + "1" (n1), + "rm" (d)); +#endif +} +#undef UDIV_NEEDS_NORMALIZATION +#define UDIV_NEEDS_NORMALIZATION 0 +#undef udiv_qrnnd +#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ + udiv_qrnnd_x86 (&__q, &__r, __n1, __n0, __d) + +#endif diff --git a/sysdeps/x86/ldbl2mpn.c b/sysdeps/x86/ldbl2mpn.c index c41fb8da147..593c472e8ab 100644 --- a/sysdeps/x86/ldbl2mpn.c +++ b/sysdeps/x86/ldbl2mpn.c @@ -18,6 +18,7 @@ #include "gmp.h" #include "gmp-impl.h" #include "longlong.h" +#include #include #include #include From patchwork Fri Oct 31 20:00:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123249 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EFCF5385043B for ; Fri, 31 Oct 2025 20:09:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFCF5385043B 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=PiCxFW26 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 50DBF385084D for ; Fri, 31 Oct 2025 20:03:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50DBF385084D 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 50DBF385084D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761940994; cv=none; b=J9dnxgfg6qjkGDijVwhVRqo0hNdJmEI2aMtEzpeZHYy6dy99iEQv7K+XEGRNhOsW35oWyoUuYlEhoTKqtG0HrmG1yF7Oo6otJLpSCxzTaYd9kyUke8KqThyZ3ePYCxBgtJBzHuKZg4jFjE1tMLqDsyxVVpHesHMtu0pvQC8urCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761940994; c=relaxed/simple; bh=GK7Sk+diM7xtPJBnqJL0ZLTkBOsWqw5SzZP5bIUuvZs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PjDy2AwW5pNKidBAij++JfDa3nDbHGuYPmQXFjvdPK3SfQt8tusxzhYmqztlBe1Pmy1b15qxc+bt5443CHzRfmUy2meTiC1kH1g9FtFHhNF4Jgw0ELzaPuJyLOwYOcCyF9rfrYcWdjs2rNQ+2MBr6VK39k3crYQGfYzKzCuvnM0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50DBF385084D Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-295247a814bso16047465ad.0 for ; Fri, 31 Oct 2025 13:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761940993; x=1762545793; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BYZnCcaytJpLKqYElDPSp9NgJTM61KymTKlo6t9tRHU=; b=PiCxFW26rfjqdXJmnoSEhmelGZB0GuN1g3fPVpTCfqdxeJrnQFLs3IsZ8TOX/n1nyH wAjYWUuONDCOC1yfXguMg4YmYQKdpLQVe1ZmdjPexDFtIHGKsH6SsbGOHSpZHib4p021 L29ec+ar1mCiwAmYF2FgFmywyKJpX1mE7Nh2H5+DcGIaVOw563pYxgWfHjlmPkEWRw9f i0WXiitPBQymYlNYKWO1HNrVkfnATf/kK8Lw1Bx/rl3Z5FLSboTcGvoUe+Q0+fTG+CMp LmeXKED6PDSYp+Um0KFcp4q7p85OXP8zYivdv0FcfHG7bDvzvbJv65tMbxsHcUwZdUU/ iLSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761940993; x=1762545793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BYZnCcaytJpLKqYElDPSp9NgJTM61KymTKlo6t9tRHU=; b=Tkp6IBIb1iuLEi1Ib0BxLmgiX289f1wfkDbi1PCkBMjy9JFB8ST5yauai6N97cm+6n d+p0ZxJ0Wgw/zWuGeU2GGQ2yInzN/n+kvdx9r0R2bj4oyKd07LqeD/tZ8DwMlXoKDjlB ikYqPfPcZ8HRoHwDEfoXchVQIK9wV1qUqck8Ru1pnPlWeFktFwuY8+aSrv9epikYo5Ha 2K6p79L0rPs0tl859AFklF01I6xnSOiS21YpG815OfdEeq8KVPi/s7FhFgZw87jDHEiV OvolKQu5mylI284IqNwCHv+CM/UkOHQqeyDQbV216Me1eWoVRS0Nw+etp9x9x6DLB5La VG0w== X-Gm-Message-State: AOJu0YyAxLPrtb002HgIE3Qm+pZkH+uXgrQhSEwneKcaKFXlCXyG7C8Z +m8/N2K2NW8ATiebtmt8ph1uuwxzWZ+c8GAjxpmv/dPfVOBY0M4Qywrya2QfZNyP67gxeHO8Iui f8t/w+0Y= X-Gm-Gg: ASbGnctKY+L5XFRI++VTbZJ+6ViiEzOMehXhqpWgokcrCZqosghGCrxglaRQBHc47jN zHeWsVRQVXlvurs4kp510pqyHIhyKgLA1ND2XQp5Xs5smCdZA/fP9vMJFCf15ZdruNkKGZImN+P 1hdkbezkP4in6iQDOVos9GV0wbN+hGkRrSEyNDckivwXP9s2oEFo4snN2FhE+UNpigW4H8+MDDn GkJly8zDvS3mF1BhpoGIS75xKRHf6f6UCCj57W4V7dO2ujCp6Aaa42qA/uOVAeRUwPHvap8d64I AxgkSHjaMWaS4cR6CiTZH1iJgS8PMG3Cm56Ht75lQ95UvT5q58hus+EFF+JkJKTWk1mgsXOIySc 5n61MZ7Gi3JH0M4WsRf90nitnlFVqWnoTkxxhOwULnESq7rvRuF+e8liYwWRyMbS2EL4dlVhtWW vP4PwkFnGDUagy X-Google-Smtp-Source: AGHT+IFya1nan2LXM7Hi6ng7yrNzgahNd6coUSZGXrCjZzOzA0h4kuNSpv9ncd6XCKx/E3Gb8jm4DQ== X-Received: by 2002:a17:902:cf06:b0:292:c97c:3569 with SMTP id d9443c01a7336-2951a4bec09mr56975355ad.48.1761940992824; Fri, 31 Oct 2025 13:03:12 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:12 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 03/19] Add add_ssaaaa and sub_ssaaaa to gmp-arch.h Date: Fri, 31 Oct 2025 17:00:36 -0300 Message-ID: <20251031200300.3716090-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 To enable “longlong.h” removal, add_ssaaaa and sub_ssaaaa are moved to gmp-arch.h. The generic implementation now uses a static inline. This provides better type checking than the GNU extension, which casts the asm constraint. It also works better with clang. Most architectures use the generic implementation. This is expanded from a macro. Exceptions are arc, arm, hppa, x86, m68k, powerpc, and sparc. I kept only the x86 optimization, as there is no easy way to emit add{q}. For all others, the compiler generates good enough code. The strongly typed implementation required some changes. I adjusted _FP_W_TYPE, _FP_WS_TYPE, and _FP_I_TYPE to use the same type as mp_limb_t on aarch64, powerpc64le, x86_64, and riscv64. This basically means using “long” instead of “long long.” --- sysdeps/aarch64/sfp-machine.h | 4 +- sysdeps/generic/gmp-arch.h | 35 ++++++++++++- sysdeps/loongarch/sfp-machine.h | 6 +-- .../powerpc/powerpc64/le/fpu/sfp-machine.h | 6 +-- sysdeps/riscv/sfp-machine.h | 6 +-- sysdeps/x86/fpu/sfp-machine.h | 18 ++++--- sysdeps/x86/gmp-arch.h | 52 +++++++++++++++++++ 7 files changed, 109 insertions(+), 18 deletions(-) diff --git a/sysdeps/aarch64/sfp-machine.h b/sysdeps/aarch64/sfp-machine.h index b41a9462dfa..3468e47db30 100644 --- a/sysdeps/aarch64/sfp-machine.h +++ b/sysdeps/aarch64/sfp-machine.h @@ -2,9 +2,9 @@ #include #define _FP_W_TYPE_SIZE 64 -#define _FP_W_TYPE unsigned long long +#define _FP_W_TYPE unsigned long #define _FP_WS_TYPE signed long long -#define _FP_I_TYPE long long +#define _FP_I_TYPE long #define _FP_MUL_MEAT_S(R,X,Y) \ _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y) diff --git a/sysdeps/generic/gmp-arch.h b/sysdeps/generic/gmp-arch.h index 623b0ae968c..3ec144562a7 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -110,4 +110,37 @@ udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, udiv_qrnnd_generic (&__q, &__r, __n1, __n0, __d) -#endif /* __GMP_ARHC_H */ +/* add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1, + high_addend_2, low_addend_2) adds two UWtype integers, composed by + HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2 + respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow + (i.e. carry out) is not stored anywhere, and is lost. */ +static __always_inline void +add_ssaaaa_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, + mp_limb_t al, mp_limb_t bh, mp_limb_t bl) +{ + *sl = al + bl; + *sh = (ah + bh) + (*sl < al); +} +#undef add_ssaaaa +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ + add_ssaaaa_generic (&sh, &sl, ah, al, bh, bl) + +/* sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend, + high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers, + composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and + LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE + and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere, + and is lost. */ +static __always_inline void +sub_ddmmss_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, + mp_limb_t al, mp_limb_t bh, mp_limb_t bl) +{ + *sl = al - bl; + *sh = (ah - bh) - (*sl > al); +} +#undef sub_ddmmss +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ + sub_ddmmss_generic (&sh, &sl, ah, al, bh, bl) + +#endif diff --git a/sysdeps/loongarch/sfp-machine.h b/sysdeps/loongarch/sfp-machine.h index 497b550f5ca..113d96651b6 100644 --- a/sysdeps/loongarch/sfp-machine.h +++ b/sysdeps/loongarch/sfp-machine.h @@ -21,9 +21,9 @@ #include #define _FP_W_TYPE_SIZE 64 -#define _FP_W_TYPE unsigned long long -#define _FP_WS_TYPE signed long long -#define _FP_I_TYPE long long +#define _FP_W_TYPE unsigned long +#define _FP_WS_TYPE signed long +#define _FP_I_TYPE long #define _FP_MUL_MEAT_S(R, X, Y) _FP_MUL_MEAT_1_imm (_FP_WFRACBITS_S, R, X, Y) #define _FP_MUL_MEAT_D(R, X, Y) \ diff --git a/sysdeps/powerpc/powerpc64/le/fpu/sfp-machine.h b/sysdeps/powerpc/powerpc64/le/fpu/sfp-machine.h index b4b27f95f4c..30b7fcf6edb 100644 --- a/sysdeps/powerpc/powerpc64/le/fpu/sfp-machine.h +++ b/sysdeps/powerpc/powerpc64/le/fpu/sfp-machine.h @@ -1,7 +1,7 @@ #define _FP_W_TYPE_SIZE 64 -#define _FP_W_TYPE unsigned long long -#define _FP_WS_TYPE signed long long -#define _FP_I_TYPE long long +#define _FP_W_TYPE unsigned long +#define _FP_WS_TYPE signed long +#define _FP_I_TYPE long typedef int TItype __attribute__ ((mode (TI))); typedef unsigned int UTItype __attribute__ ((mode (TI))); diff --git a/sysdeps/riscv/sfp-machine.h b/sysdeps/riscv/sfp-machine.h index 43b2ba10ab0..a38edd1e3c7 100644 --- a/sysdeps/riscv/sfp-machine.h +++ b/sysdeps/riscv/sfp-machine.h @@ -52,9 +52,9 @@ #else # define _FP_W_TYPE_SIZE 64 -# define _FP_W_TYPE unsigned long long -# define _FP_WS_TYPE signed long long -# define _FP_I_TYPE long long +# define _FP_W_TYPE unsigned long +# define _FP_WS_TYPE signed long +# define _FP_I_TYPE long # define _FP_MUL_MEAT_S(R, X, Y) \ _FP_MUL_MEAT_1_imm (_FP_WFRACBITS_S, R, X, Y) diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h index 5892f4f5fe5..cbcedb8621e 100644 --- a/sysdeps/x86/fpu/sfp-machine.h +++ b/sysdeps/x86/fpu/sfp-machine.h @@ -8,9 +8,15 @@ typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); #ifdef __x86_64__ # define _FP_W_TYPE_SIZE 64 -# define _FP_W_TYPE unsigned long long -# define _FP_WS_TYPE signed long long -# define _FP_I_TYPE long long +# ifndef __ILP32__ +# define _FP_W_TYPE unsigned long +# define _FP_WS_TYPE signed long +# define _FP_I_TYPE long +# else +# define _FP_W_TYPE unsigned long long +# define _FP_WS_TYPE signed long long +# define _FP_I_TYPE long long +# endif typedef int TItype __attribute__ ((mode (TI))); typedef unsigned int UTItype __attribute__ ((mode (TI))); @@ -45,9 +51,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); } while (0) #else # define _FP_W_TYPE_SIZE 32 -# define _FP_W_TYPE unsigned int -# define _FP_WS_TYPE signed int -# define _FP_I_TYPE int +# define _FP_W_TYPE unsigned long int +# define _FP_WS_TYPE signed long int +# define _FP_I_TYPE long int # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \ __asm__ ("add{l} {%11,%3|%3,%11}\n\t" \ diff --git a/sysdeps/x86/gmp-arch.h b/sysdeps/x86/gmp-arch.h index 5c8b8830afa..45f047e1b64 100644 --- a/sysdeps/x86/gmp-arch.h +++ b/sysdeps/x86/gmp-arch.h @@ -47,4 +47,56 @@ udiv_qrnnd_x86 (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, #define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ udiv_qrnnd_x86 (&__q, &__r, __n1, __n0, __d) +static __always_inline void +add_ssaaaa_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, + mp_limb_t al, mp_limb_t bh, mp_limb_t bl) +{ +#ifdef __x86_64__ + asm ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}" + : "=r" (*sh), + "=&r" (*sl) + : "%0" (ah), + "rme" (bh), + "%1" (al), + "rme" (bl)); +#else + asm ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}" + : "=r" (*sh), + "=&r" (*sl) + : "%0" (ah), + "g" (bh), + "%1" (al), + "g" (bl)); +#endif +} +#undef add_ssaaaa +#define add_ssaaaa(__sh, __sl, __ah, __al, __bh, __bl) \ + add_ssaaaa_x86 (&__sh, &__sl, __ah, __al, __bh, __bl) + +static __always_inline void +sub_ddmmss_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, + mp_limb_t al, mp_limb_t bh, mp_limb_t bl) +{ +#ifdef __x86_64__ + asm ("sub{q} {%5,%1|%1,%5}\n\tsbb{q} {%3,%0|%0,%3}" + : "=r" (*sh), + "=&r" (*sl) + : "0" (ah), + "rme" (bh), + "1" (al), + "rme" (bl)); +#else + asm ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}" + : "=r" (*sh), + "=&r" (*sl) + : "0" (ah), + "g" (bh), + "1" (al), + "g" (bl)); +#endif +} +#undef sub_ddmmss +#define sub_ddmmss(__sh, __sl, __ah, __al, __bh, __bl) \ + sub_ddmmss_x86 (&__sh, &__sl, __ah, __al, __bh, __bl) + #endif From patchwork Fri Oct 31 20:00:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123248 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4ED6E385040F for ; Fri, 31 Oct 2025 20:09:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4ED6E385040F 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=I/69/K5I X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 8C5D83850856 for ; Fri, 31 Oct 2025 20:03:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C5D83850856 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 8C5D83850856 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761940996; cv=none; b=nRUaLVWwoNrRZePj5BnkPMHpIA7LYS+TG9zcjKnExLOepH0MizOdTvbdzDBLfYOY5EMTb/HPD/gATAgl1WZgKArhXpzEPGZbMqRV7qK87/fQZ0QPYSBjdnfAknr9O2Umqotkco1S2x70P0cLI4u2a7UzhHLFzt/xahGLHod0LpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761940996; c=relaxed/simple; bh=Ry5dEshKCbSSxlklPrGcv6I+Nq/Ry1XooMVhDUnDk2o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=HxQWgnxuPYpnIjfgVjPYjSVOZ32Oll+8j0gnqYk4NL3Rtuc/1fKXnH/GBjG75Dpe0iOrb+/47rurpya1VxBaBvP8CiSKV5RvVSXmV/JFT2EJnaFJaCxRIibFH+9PJBYz3JPeJkz4dhzlyc6buIkqEzEfPQUvJ7u0TOCUTOSRpVs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C5D83850856 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-290aaff555eso24558865ad.2 for ; Fri, 31 Oct 2025 13:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761940995; x=1762545795; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bs7ftDougyCmA2KbUUbIV19DZRgAZhSp3sS8Din8htY=; b=I/69/K5IcWtWtJjyz7Mg+BbK5tl0vsEU7L5GduINNokK/sHGUo2XjCFPUR3HDv3ehP zUDLWmbKrIHNNzmidabnlzEA7+lKvPpNNoQosBp2a5MD/22sXgzOgpugHR+a9NT61JOp nYbM/qWvF2uBqH3BXRLpjBnflLmNCqE0Jz8FWNQRLnk0APuI2oYfcaCUpZfqfXimeKEt gxFueA/pT68ktY28DJRgUI/jLNK3fUnU/O/DqW283Z0gtpbKU+dCtLIX0Ub34nJFuY0C KIIPs51y9YLM7OdtOdv4uIs7MfL2KenrgUdQPrcOkX9sTmw/8SF7yOi/qQeIBX5Ynzn3 3hgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761940995; x=1762545795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bs7ftDougyCmA2KbUUbIV19DZRgAZhSp3sS8Din8htY=; b=Cobib7hyrR91jhq1cwnARtJDxBe/xu1H63IBxXXiDkWKnTZbp97Uh61oyrp6mF9K29 IpvuDbrQ0pqj8rdQLoq8hzZPtXfylgClCMNms0qgWc2m7T/KSQMv2Xj5ULPD7UaN4PUT LmgPZv9Vu2IVXAVgBac9IFZc5u/eKUe0bvX8lnfVLNQaQ5pB7KHOTtN+BY0jwarWAMQi J5u8s6LOGYcy3tYWyH6fGGKeeW3Ph1yb18OE9Bz0uUFPYsitcXPMhsSlK1A6ze7woc6s ne6g8E3XmdHxLg4p3S3vWcC02tDjwfnT9KTkpL4Zs7Tmia767uQDCl4xBnfAr49mf9sY mO4g== X-Gm-Message-State: AOJu0YwFHM/FdyivnKJMkh9UX0qiFPbAn664/LyhIdwW6aU2MQYtsaLl f622qi+Ha0eF3Irg0jA8a4Bc8Sfph/58bq+zKF0+IemTfP2MVWOTMhHdue4ZpcyCckTkBjRd3S+ hXyXyFK4= X-Gm-Gg: ASbGnctLv0gRuVcSm9yenKs1gmNQ2dkwFhLAcQGVY77MfFDX6Ij3QO8XtzUSyitZmbT j88B9cvVLPs0oygx669Y+F6dZEiaqkUcifDEaVSwyS8Nw5rHOdgLan4rGBU9qLQYSbpNrZB5BMA haiq3YAvdcvyQDepV5pR2pUwDHHhh6uDKbO4Bcyv0a62/G0bomVuzfA0yZ0GOyyqpjKvwse4mql L7H28JhBc+czZ+ZLnr0sTuslX0QCjdBW4I0ACO9fYCVMfEdM8RVOiVZP2HmeRjhB5qiDge5F2tE xraUPnNKmDP+IAnx9r9SvUCk9iw09l3L2dcj4OpKMsNKrns6BJjUCjZfwjHqhyM9GN4X4a3a819 espRaDD1++w8HKWwXpdIgyG4Q5BaNhdj62VJFZk/RVRqnlvzZ+3WwJefFkUMhv/WJD/Iu58daff Bw12fBwFkVQaMbpmn3PtE44gU= X-Google-Smtp-Source: AGHT+IEuQj6YgBPfPfLL4AD52siijC8whTNeTj41mo937bLnnI+nkBpv+iZS31ctcuWelGzG1ESlYA== X-Received: by 2002:a17:903:2c10:b0:294:ccc6:ccfd with SMTP id d9443c01a7336-2951a3a2fcbmr59939435ad.24.1761940995111; Fri, 31 Oct 2025 13:03:15 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:14 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 04/19] Add umul_ppmm to gmp-arch.hdoc Date: Fri, 31 Oct 2025 17:00:37 -0300 Message-ID: <20251031200300.3716090-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 To enable “longlong.h” removal, the umul_ppmm is moved to a gmp-arch.h. The generic implementation now uses a static inline, which provides better type checking than the GNU extension to cast the asm constraint (and it works better with clang). Most of the architecture uses the generic implementation, which is expanded from a macro, except for alpha, arm, hppa, x86, m68k, mips, powerpc, and sparc. I kept only x86 optimization, where there is no easy way to emit mul{q}. For the rest, the compiler generates good enough code. --- sysdeps/generic/gmp-arch.h | 40 ++++++++++++++++++++++++++++++++++++++ sysdeps/x86/gmp-arch.h | 21 ++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/sysdeps/generic/gmp-arch.h b/sysdeps/generic/gmp-arch.h index 3ec144562a7..f5d6495f2b4 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -35,6 +35,46 @@ ll_highpart (mp_limb_t t) return t >> (BITS_PER_MP_LIMB / 2); } +/* umul_ppmm(high_prod, low_prod, multiplier, multiplicand) multiplies two + UWtype integers MULTIPLIER and MULTIPLICAND, and generates a two UWtype + word product in HIGH_PROD and LOW_PROD. */ +static __always_inline void +umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) +{ +#if __WORDSIZE == 32 + uint64_t t0 = (uint64_t)u * v; + *w1 = t0 >> 32; + *w0 = t0; +#else + mp_limb_t ul = ll_lowpart (u); + mp_limb_t uh = ll_highpart (u); + mp_limb_t vl = ll_lowpart (v); + mp_limb_t vh = ll_highpart (v); + + mp_limb_t x0 = ul * vl; + mp_limb_t x1 = ul * vh; + mp_limb_t x2 = uh * vl; + mp_limb_t x3 = uh * vh; + + x1 += ll_highpart (x0); + x1 += x2; + if (x1 < x2) + x3 += LL_B; + + *w1 = x3 + ll_highpart (x1); + *w0 = ll_lowpart (x1) * LL_B + ll_lowpart (x0); +#endif +} +#undef umul_ppmm +#define umul_ppmm(__w1, __w0, __u, __v) \ + ({ \ + __typeof (__w0) __w0t; \ + __typeof (__w1) __w1t; \ + umul_ppmm_generic (&__w1t, &__w0t, __u, __v); \ + __w1 = __w1t; \ + __w0 = __w0t; \ + }) + /* udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, denominator) divides a UDWtype, composed by the UWtype integers HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient diff --git a/sysdeps/x86/gmp-arch.h b/sysdeps/x86/gmp-arch.h index 45f047e1b64..c3aa0f2e3b1 100644 --- a/sysdeps/x86/gmp-arch.h +++ b/sysdeps/x86/gmp-arch.h @@ -21,6 +21,27 @@ #include +static __always_inline void +umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) +{ +#ifdef __x86_64__ + asm ("mul{q} %3" + : "=a" (*w0), + "=d" (*w1) + : "%0" (u), + "rm" (v)); +#else + asm ("mul{l} %3" + : "=a" (*w0), + "=d" (*w1) + : "%0" (u), + "rm" (v)); +#endif +} +#undef umul_ppmm +#define umul_ppmm(__w1, __w0, __u, __v) \ + umul_ppmm_generic (&__w1, &__w0, __u, __v) + static __always_inline void udiv_qrnnd_x86 (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, mp_limb_t d) From patchwork Fri Oct 31 20:00:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123254 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 68030385087E for ; Fri, 31 Oct 2025 20:14:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 68030385087E 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=VG2m6gH8 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id E882A385087C for ; Fri, 31 Oct 2025 20:03:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E882A385087C 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 E882A385087C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941001; cv=none; b=YqDUsMyPJty20iP4dyIozVTlTXjbvWAPhsG0pJ7lRaFRZpuVPnbwY09WFqns8FFnA5xl8gEtnFh3/G4Dqh4YAbFifAcOTBLdrPrZWl7ZfXttsqHDwXOUcZIkKPjmUB+97UoBHmUDSE2YzH46PX1gtSiaJ95FVbe3/PZmO6IrGNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941001; c=relaxed/simple; bh=OtD9HJGZABXJTO1edhDbB4PkC2hjEk0vVmeOOQorC0A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jYPw0kB1+VX2sMpnbOEtWKg+cQyCLkRrK32IWR1D0CRuYJ6ZAesyNV8Kw2dCpyDSAQNtHSKSiYvaaYu4SikeqSaavnHL1J6k8SK7wObCIPiHn+Nr3yTQKgLycKTITcFqsnsKFkQi41AHsJB5ZzQmoGv9dNsWXIHbLw6jku4FC6I= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E882A385087C Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-7a27bf4fbcbso2733726b3a.1 for ; Fri, 31 Oct 2025 13:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941000; x=1762545800; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lJOBfoKbYRH1vap3lkaHeZlIVkBXN+ymcX1JcZxTFC0=; b=VG2m6gH8Up54q++DPKTxtWiIvO2lH+LgSe6KwHdk40RjHDoSyTf6CBy8XMEQ8ZoZeX bdxlwLUIci0CPQHw3zG/+zWCYw01FCbfS9uUhS/unUSQ/qmOX9oau4YGL/1TPqCSjemd nsewpvDtxXyEf8dl3ZCIwT+HXnw5zZiktlfKFD5dRhYJIHy9Pq9mwBjxl+WflSqIZJeW EsLPnxiACgRk4/7wGIyF08zE5GarTmjO96ciaCAes5Z9vweWQGj2xzoG+4R3GHOfQlgm s8AjAUXGRX1xzFpI5G32Cje7cxC4X8nbrn1qOhN58PZStVVXjeDMUx1hC1CgLUdzFB2A DOwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941000; x=1762545800; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lJOBfoKbYRH1vap3lkaHeZlIVkBXN+ymcX1JcZxTFC0=; b=OrQ7EHmotHt312uJhVmXD0RtOzRgHlxdm/UwctkhCUk5fxvgamTKZe7ETYt6zSxLVk lPOryg8e9+aScvvtGE3E4mddZYCnY/ssH+G/jvGUop1DdS7m2FvwcoWIENwp1H+uySRQ E52bBMqoL7eNoqYZMkMiIqo38M8lgFw1puiueOeAckCDpQRn0uQXPR68hF5+59tV/mx8 iV4PFusgpkAU5Z+0YCJG/veN2f8nCnKCNUJw4SI0n4aIBuZ94Wq9UKA6KetYANWc2hbT TmkT/gZCuQit3FpeyMOXsSLnggKHAM05Wak2jyOtc2YMr8obniwUeQ1QbDKT3iZisVlX oc4Q== X-Gm-Message-State: AOJu0Yw37WlV3NDUdfcF8+eHdbzF+JJIVw4RtFQFUgze4VYaFwmtaDvT acJLaG9kDGkgXDy6legxEP02bKImFNuuuIEDCjK7qlGcZVY6lYxRrQA0e+uRKN3GY9mFoblQFmH ZnS4c6Dw= X-Gm-Gg: ASbGncv/l05HjwHaOwxSbZIXXltrfrmNV4z8esZy4xokH66fMdBOX56CJ0OUTFSTkdC rGMIWifgFZppXNSntqSFMo14ZWwwdifrHeKp5O7/Jc6ioiqKS1Mt1mDgTmfWCR9x8o3xdAe7JLk 2MklKzdqiS9xxe2PKzsHsOBSamPYTFZLYrscjSoxDDhar0CQ1zUMXPmqbqVNqriG3IRfGy8amHq kro1DcPXRO/4+ai8aTcbaUviiGdV9MSVO46mVXn/gk5tHVVYR3x6aP399xXC2lOg3G/IlVDy3lO YyM05BimQ1z0n5SMvzdTU/qxPJvvZ/IInnESf9VPrDHpmGR1cubLIMMEH54mi2sDNRuJf/Flw/T fxydD2HlBPmvXxo2XQq7aKlL22kOYoqxTwIeQI7ck2DJ9ZEKRh/bcIOIwjqm7tCWmMZpNNZa/Vz 8eerqtJlrPK1DqXPxcV15VUgg= X-Google-Smtp-Source: AGHT+IFFCrBTY7VRBFYXLf4icHNU66+FTPfPJrJj8CGYJbMwDDzl9PwCeNaZSzuIQR0yo2Sl5oZxiw== X-Received: by 2002:a17:903:1ca:b0:295:105:c87d with SMTP id d9443c01a7336-2951a55b729mr57109765ad.32.1761940997648; Fri, 31 Oct 2025 13:03:17 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:17 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 05/19] stdlib: Remove longlong.h Date: Fri, 31 Oct 2025 17:00:38 -0300 Message-ID: <20251031200300.3716090-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 gmp-arch.h now provides all the required definitions. --- soft-fp/soft-fp.h | 2 - stdio-common/_itoa.c | 2 - stdio-common/_itowa.c | 2 - stdlib/Makefile | 1 - stdlib/addmul_1.c | 2 - stdlib/divmod_1.c | 2 - stdlib/divrem.c | 1 - stdlib/gmp-impl.h | 2 + stdlib/longlong.h | 1786 ------------------------ stdlib/mod_1.c | 2 - stdlib/mul_1.c | 2 - stdlib/strtod_l.c | 2 - stdlib/submul_1.c | 2 - sysdeps/generic/gmp-arch.h | 5 - sysdeps/ieee754/dbl-64/dbl2mpn.c | 2 - sysdeps/ieee754/ldbl-128/ldbl2mpn.c | 2 - sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c | 1 - sysdeps/ieee754/ldbl-96/ldbl2mpn.c | 2 - sysdeps/wordsize-32/divdi3.c | 2 - sysdeps/x86/gmp-arch.h | 5 - sysdeps/x86/ldbl2mpn.c | 2 - 21 files changed, 2 insertions(+), 1827 deletions(-) delete mode 100644 stdlib/longlong.h diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h index 4c0859fa068..a3a44f8a42b 100644 --- a/soft-fp/soft-fp.h +++ b/soft-fp/soft-fp.h @@ -327,8 +327,6 @@ # ifdef _LIBC # include # include -# include -# include # else # include "longlong.h" # endif diff --git a/stdio-common/_itoa.c b/stdio-common/_itoa.c index e9cbcfab3b6..dd9c5715a7f 100644 --- a/stdio-common/_itoa.c +++ b/stdio-common/_itoa.c @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include <_itoa.h> diff --git a/stdio-common/_itowa.c b/stdio-common/_itowa.c index 2da7489502c..5aaf1b9a1e5 100644 --- a/stdio-common/_itowa.c +++ b/stdio-common/_itowa.c @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include <_itowa.h> diff --git a/stdlib/Makefile b/stdlib/Makefile index a9a68c190c4..02ad6d17fb0 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -499,7 +499,6 @@ mpn-headers = \ gmp-impl.h \ gmp-mparam.h \ gmp.h \ - longlong.h \ # mpn-headers routines := \ diff --git a/stdlib/addmul_1.c b/stdlib/addmul_1.c index a5bf7fd37e4..95b4c60366b 100644 --- a/stdlib/addmul_1.c +++ b/stdlib/addmul_1.c @@ -23,8 +23,6 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" -#include "longlong.h" -#include mp_limb_t mpn_addmul_1 (register mp_ptr res_ptr, register mp_srcptr s1_ptr, diff --git a/stdlib/divmod_1.c b/stdlib/divmod_1.c index 676145d7272..7d833dfd5d9 100644 --- a/stdlib/divmod_1.c +++ b/stdlib/divmod_1.c @@ -27,8 +27,6 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include #include "gmp-impl.h" -#include "longlong.h" -#include #ifndef UMUL_TIME #define UMUL_TIME 1 diff --git a/stdlib/divrem.c b/stdlib/divrem.c index 889fe3da127..9f54c33e69d 100644 --- a/stdlib/divrem.c +++ b/stdlib/divrem.c @@ -21,7 +21,6 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" -#include "longlong.h" /* Divide num (NP/NSIZE) by den (DP/DSIZE) and write the NSIZE-DSIZE least significant quotient limbs at QP diff --git a/stdlib/gmp-impl.h b/stdlib/gmp-impl.h index dea739c44c2..3da6d0555ea 100644 --- a/stdlib/gmp-impl.h +++ b/stdlib/gmp-impl.h @@ -298,6 +298,8 @@ typedef unsigned int UHWtype; #define impn_sqr_n_basecase __MPN(impn_sqr_n_basecase) #define impn_sqr_n __MPN(impn_sqr_n) +#include + #ifndef _PROTO #if defined (__STDC__) || defined (__cplusplus) #define _PROTO(x) x diff --git a/stdlib/longlong.h b/stdlib/longlong.h deleted file mode 100644 index 4549f0a55f3..00000000000 --- a/stdlib/longlong.h +++ /dev/null @@ -1,1786 +0,0 @@ -/* longlong.h -- definitions for mixed size 32/64 bit arithmetic. - Copyright (C) 1991-2025 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - In addition to the permissions in the GNU Lesser General Public - License, the Free Software Foundation gives you unlimited - permission to link the compiled version of this file into - combinations with other programs, and to distribute those - combinations without any restriction coming from the use of this - file. (The Lesser General Public License restrictions do apply in - other respects; for example, they cover modification of the file, - and distribution when not linked into a combine executable.) - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* You have to define the following before including this file: - - UWtype -- An unsigned type, default type for operations (typically a "word") - UHWtype -- An unsigned type, at least half the size of UWtype. - UDWtype -- An unsigned type, at least twice as large a UWtype - W_TYPE_SIZE -- size in bits of UWtype - - UQItype -- Unsigned 8 bit type. - SItype, USItype -- Signed and unsigned 32 bit types. - DItype, UDItype -- Signed and unsigned 64 bit types. - - On a 32 bit machine UWtype should typically be USItype; - on a 64 bit machine, UWtype should typically be UDItype. */ - -#define __BITS4 (W_TYPE_SIZE / 4) -#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2)) -#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1)) -#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2)) - -#ifndef W_TYPE_SIZE -#define W_TYPE_SIZE 32 -#define UWtype USItype -#define UHWtype USItype -#define UDWtype UDItype -#endif - -/* Used in glibc only. */ -#ifndef attribute_hidden -#define attribute_hidden -#endif - -extern const UQItype __clz_tab[256] attribute_hidden; - -/* Define auxiliary asm macros. - - 1) umul_ppmm(high_prod, low_prod, multiplier, multiplicand) multiplies two - UWtype integers MULTIPLIER and MULTIPLICAND, and generates a two UWtype - word product in HIGH_PROD and LOW_PROD. - - 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a - UDWtype product. This is just a variant of umul_ppmm. - - 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, - denominator) divides a UDWtype, composed by the UWtype integers - HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient - in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less - than DENOMINATOR for correct operation. If, in addition, the most - significant bit of DENOMINATOR must be 1, then the pre-processor symbol - UDIV_NEEDS_NORMALIZATION is defined to 1. - - 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator, - denominator). Like udiv_qrnnd but the numbers are signed. The quotient - is rounded towards 0. - - 5) count_leading_zeros(count, x) counts the number of zero-bits from the - msb to the first nonzero bit in the UWtype X. This is the number of - steps X needs to be shifted left to set the msb. Undefined for X == 0, - unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value. - - 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts - from the least significant end. - - 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1, - high_addend_2, low_addend_2) adds two UWtype integers, composed by - HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2 - respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow - (i.e. carry out) is not stored anywhere, and is lost. - - 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend, - high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers, - composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and - LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE - and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere, - and is lost. - - If any of these macros are left undefined for a particular CPU, - C macros are used. */ - -/* The CPUs come in alphabetical order below. - - Please add support for more CPUs here, or improve the current support - for the CPUs below! - (E.g. WE32100, IBM360.) */ - -#if defined (__GNUC__) && !defined (NO_ASM) - -/* We sometimes need to clobber "cc" with gcc2, but that would not be - understood by gcc1. Use cpp to avoid major code duplication. */ -#if __GNUC__ < 2 -#define __CLOBBER_CC -#define __AND_CLOBBER_CC -#else /* __GNUC__ >= 2 */ -#define __CLOBBER_CC : "cc" -#define __AND_CLOBBER_CC , "cc" -#endif /* __GNUC__ < 2 */ - -#if defined (__aarch64__) - -#if W_TYPE_SIZE == 32 -#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X)) -#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X)) -#define COUNT_LEADING_ZEROS_0 32 -#endif /* W_TYPE_SIZE == 32 */ - -#if W_TYPE_SIZE == 64 -#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clzll (X)) -#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctzll (X)) -#define COUNT_LEADING_ZEROS_0 64 -#endif /* W_TYPE_SIZE == 64 */ - -#endif /* __aarch64__ */ - -#if defined (__alpha) && W_TYPE_SIZE == 64 -/* There is a bug in g++ before version 5 that - errors on __builtin_alpha_umulh. */ -#if !defined(__cplusplus) || __GNUC__ >= 5 -#define umul_ppmm(ph, pl, m0, m1) \ - do { \ - UDItype __m0 = (m0), __m1 = (m1); \ - (ph) = __builtin_alpha_umulh (__m0, __m1); \ - (pl) = __m0 * __m1; \ - } while (0) -#define UMUL_TIME 46 -#endif /* !c++ */ -#ifndef LONGLONG_STANDALONE -#define udiv_qrnnd(q, r, n1, n0, d) \ - do { UDItype __r; \ - (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \ - (r) = __r; \ - } while (0) -extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype); -#define UDIV_TIME 220 -#endif /* LONGLONG_STANDALONE */ -#ifdef __alpha_cix__ -#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzl (X)) -#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X)) -#define COUNT_LEADING_ZEROS_0 64 -#else -#define count_leading_zeros(COUNT,X) \ - do { \ - UDItype __xr = (X), __t, __a; \ - __t = __builtin_alpha_cmpbge (0, __xr); \ - __a = __clz_tab[__t ^ 0xff] - 1; \ - __t = __builtin_alpha_extbl (__xr, __a); \ - (COUNT) = 64 - (__clz_tab[__t] + __a*8); \ - } while (0) -#define count_trailing_zeros(COUNT,X) \ - do { \ - UDItype __xr = (X), __t, __a; \ - __t = __builtin_alpha_cmpbge (0, __xr); \ - __t = ~__t & -~__t; \ - __a = ((__t & 0xCC) != 0) * 2; \ - __a += ((__t & 0xF0) != 0) * 4; \ - __a += ((__t & 0xAA) != 0); \ - __t = __builtin_alpha_extbl (__xr, __a); \ - __a <<= 3; \ - __t &= -__t; \ - __a += ((__t & 0xCC) != 0) * 2; \ - __a += ((__t & 0xF0) != 0) * 4; \ - __a += ((__t & 0xAA) != 0); \ - (COUNT) = __a; \ - } while (0) -#endif /* __alpha_cix__ */ -#endif /* __alpha */ - -#if defined (__arc__) && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("add.f %1, %4, %5\n\tadc %0, %2, %3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "%r" ((USItype) (ah)), \ - "rICal" ((USItype) (bh)), \ - "%r" ((USItype) (al)), \ - "rICal" ((USItype) (bl)) \ - : "cc") -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "r" ((USItype) (ah)), \ - "rICal" ((USItype) (bh)), \ - "r" ((USItype) (al)), \ - "rICal" ((USItype) (bl)) \ - : "cc") - -#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v) -#ifdef __ARC_NORM__ -#define count_leading_zeros(count, x) \ - do \ - { \ - SItype c_; \ - \ - __asm__ ("norm.f\t%0,%1\n\tmov.mi\t%0,-1" : "=r" (c_) : "r" (x) : "cc");\ - (count) = c_ + 1; \ - } \ - while (0) -#define COUNT_LEADING_ZEROS_0 32 -#endif /* __ARC_NORM__ */ -#endif /* __arc__ */ - -#if defined (__arm__) && (defined (__thumb2__) || !defined (__thumb__)) \ - && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("adds %1, %4, %5\n\tadc %0, %2, %3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "%r" ((USItype) (ah)), \ - "rI" ((USItype) (bh)), \ - "%r" ((USItype) (al)), \ - "rI" ((USItype) (bl)) __CLOBBER_CC) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("subs %1, %4, %5\n\tsbc %0, %2, %3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "r" ((USItype) (ah)), \ - "rI" ((USItype) (bh)), \ - "r" ((USItype) (al)), \ - "rI" ((USItype) (bl)) __CLOBBER_CC) -# if defined(__ARM_ARCH_2__) || defined(__ARM_ARCH_2A__) \ - || defined(__ARM_ARCH_3__) -# define umul_ppmm(xh, xl, a, b) \ - do { \ - register USItype __t0, __t1, __t2; \ - __asm__ ("%@ Inlined umul_ppmm\n" \ - " mov %2, %5, lsr #16\n" \ - " mov %0, %6, lsr #16\n" \ - " bic %3, %5, %2, lsl #16\n" \ - " bic %4, %6, %0, lsl #16\n" \ - " mul %1, %3, %4\n" \ - " mul %4, %2, %4\n" \ - " mul %3, %0, %3\n" \ - " mul %0, %2, %0\n" \ - " adds %3, %4, %3\n" \ - " addcs %0, %0, #65536\n" \ - " adds %1, %1, %3, lsl #16\n" \ - " adc %0, %0, %3, lsr #16" \ - : "=&r" ((USItype) (xh)), \ - "=r" ((USItype) (xl)), \ - "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \ - : "r" ((USItype) (a)), \ - "r" ((USItype) (b)) __CLOBBER_CC ); \ - } while (0) -# define UMUL_TIME 20 -# else -# define umul_ppmm(xh, xl, a, b) \ - do { \ - /* Generate umull, under compiler control. */ \ - register UDItype __t0 = (UDItype)(USItype)(a) * (USItype)(b); \ - (xl) = (USItype)__t0; \ - (xh) = (USItype)(__t0 >> 32); \ - } while (0) -# define UMUL_TIME 3 -# endif -# define UDIV_TIME 100 -#endif /* __arm__ */ - -#if defined(__arm__) -/* Let gcc decide how best to implement count_leading_zeros. */ -#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X)) -#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctz (X)) -#define COUNT_LEADING_ZEROS_0 32 -#endif - -#if defined (__AVR__) - -#if W_TYPE_SIZE == 16 -#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X)) -#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctz (X)) -#define COUNT_LEADING_ZEROS_0 16 -#endif /* W_TYPE_SIZE == 16 */ - -#if W_TYPE_SIZE == 32 -#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzl (X)) -#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X)) -#define COUNT_LEADING_ZEROS_0 32 -#endif /* W_TYPE_SIZE == 32 */ - -#if W_TYPE_SIZE == 64 -#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzll (X)) -#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzll (X)) -#define COUNT_LEADING_ZEROS_0 64 -#endif /* W_TYPE_SIZE == 64 */ - -#endif /* defined (__AVR__) */ - -#if defined (__CRIS__) - -#if __CRIS_arch_version >= 3 -#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X)) -#define COUNT_LEADING_ZEROS_0 32 -#endif /* __CRIS_arch_version >= 3 */ - -#if __CRIS_arch_version >= 8 -#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X)) -#endif /* __CRIS_arch_version >= 8 */ - -#if __CRIS_arch_version >= 10 -#define __umulsidi3(u,v) ((UDItype)(USItype) (u) * (UDItype)(USItype) (v)) -#else -#define __umulsidi3 __umulsidi3 -extern UDItype __umulsidi3 (USItype, USItype); -#endif /* __CRIS_arch_version >= 10 */ - -#define umul_ppmm(w1, w0, u, v) \ - do { \ - UDItype __x = __umulsidi3 (u, v); \ - (w0) = (USItype) (__x); \ - (w1) = (USItype) (__x >> 32); \ - } while (0) - -/* FIXME: defining add_ssaaaa and sub_ddmmss should be advantageous for - DFmode ("double" intrinsics, avoiding two of the three insns handling - carry), but defining them as open-code C composing and doing the - operation in DImode (UDImode) shows that the DImode needs work: - register pressure from requiring neighboring registers and the - traffic to and from them come to dominate, in the 4.7 series. */ - -#endif /* defined (__CRIS__) */ - -#if defined (__hppa) && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "%rM" ((USItype) (ah)), \ - "rM" ((USItype) (bh)), \ - "%rM" ((USItype) (al)), \ - "rM" ((USItype) (bl))) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("sub %4,%5,%1\n\tsubb %2,%3,%0" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "rM" ((USItype) (ah)), \ - "rM" ((USItype) (bh)), \ - "rM" ((USItype) (al)), \ - "rM" ((USItype) (bl))) -#if defined (_PA_RISC1_1) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - union \ - { \ - UDItype __f; \ - struct {USItype __w1, __w0;} __w1w0; \ - } __t; \ - __asm__ ("xmpyu %1,%2,%0" \ - : "=x" (__t.__f) \ - : "x" ((USItype) (u)), \ - "x" ((USItype) (v))); \ - (w1) = __t.__w1w0.__w1; \ - (w0) = __t.__w1w0.__w0; \ - } while (0) -#define UMUL_TIME 8 -#else -#define UMUL_TIME 30 -#endif -#define UDIV_TIME 40 -#define count_leading_zeros(count, x) \ - do { \ - USItype __tmp; \ - __asm__ ( \ - "ldi 1,%0\n" \ -" extru,= %1,15,16,%%r0 ; Bits 31..16 zero?\n" \ -" extru,tr %1,15,16,%1 ; No. Shift down, skip add.\n"\ -" ldo 16(%0),%0 ; Yes. Perform add.\n" \ -" extru,= %1,23,8,%%r0 ; Bits 15..8 zero?\n" \ -" extru,tr %1,23,8,%1 ; No. Shift down, skip add.\n"\ -" ldo 8(%0),%0 ; Yes. Perform add.\n" \ -" extru,= %1,27,4,%%r0 ; Bits 7..4 zero?\n" \ -" extru,tr %1,27,4,%1 ; No. Shift down, skip add.\n"\ -" ldo 4(%0),%0 ; Yes. Perform add.\n" \ -" extru,= %1,29,2,%%r0 ; Bits 3..2 zero?\n" \ -" extru,tr %1,29,2,%1 ; No. Shift down, skip add.\n"\ -" ldo 2(%0),%0 ; Yes. Perform add.\n" \ -" extru %1,30,1,%1 ; Extract bit 1.\n" \ -" sub %0,%1,%0 ; Subtract it.\n" \ - : "=r" (count), "=r" (__tmp) : "1" (x)); \ - } while (0) -#endif - -#if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32 -#if !defined (__zarch__) -#define smul_ppmm(xh, xl, m0, m1) \ - do { \ - union {DItype __ll; \ - struct {USItype __h, __l;} __i; \ - } __x; \ - __asm__ ("lr %N0,%1\n\tmr %0,%2" \ - : "=&r" (__x.__ll) \ - : "r" (m0), "r" (m1)); \ - (xh) = __x.__i.__h; (xl) = __x.__i.__l; \ - } while (0) -#define sdiv_qrnnd(q, r, n1, n0, d) \ - do { \ - union {DItype __ll; \ - struct {USItype __h, __l;} __i; \ - } __x; \ - __x.__i.__h = n1; __x.__i.__l = n0; \ - __asm__ ("dr %0,%2" \ - : "=r" (__x.__ll) \ - : "0" (__x.__ll), "r" (d)); \ - (q) = __x.__i.__l; (r) = __x.__i.__h; \ - } while (0) -#else -#define smul_ppmm(xh, xl, m0, m1) \ - do { \ - register SItype __r0 __asm__ ("0"); \ - register SItype __r1 __asm__ ("1") = (m0); \ - \ - __asm__ ("mr\t%%r0,%3" \ - : "=r" (__r0), "=r" (__r1) \ - : "r" (__r1), "r" (m1)); \ - (xh) = __r0; (xl) = __r1; \ - } while (0) - -#define sdiv_qrnnd(q, r, n1, n0, d) \ - do { \ - register SItype __r0 __asm__ ("0") = (n1); \ - register SItype __r1 __asm__ ("1") = (n0); \ - \ - __asm__ ("dr\t%%r0,%4" \ - : "=r" (__r0), "=r" (__r1) \ - : "r" (__r0), "r" (__r1), "r" (d)); \ - (q) = __r1; (r) = __r0; \ - } while (0) -#endif /* __zarch__ */ -#endif - -#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "%0" ((USItype) (ah)), \ - "g" ((USItype) (bh)), \ - "%1" ((USItype) (al)), \ - "g" ((USItype) (bl))) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "0" ((USItype) (ah)), \ - "g" ((USItype) (bh)), \ - "1" ((USItype) (al)), \ - "g" ((USItype) (bl))) -#define umul_ppmm(w1, w0, u, v) \ - __asm__ ("mul{l} %3" \ - : "=a" ((USItype) (w0)), \ - "=d" ((USItype) (w1)) \ - : "%0" ((USItype) (u)), \ - "rm" ((USItype) (v))) -#define udiv_qrnnd(q, r, n1, n0, dv) \ - __asm__ ("div{l} %4" \ - : "=a" ((USItype) (q)), \ - "=d" ((USItype) (r)) \ - : "0" ((USItype) (n0)), \ - "1" ((USItype) (n1)), \ - "rm" ((USItype) (dv))) -#define count_leading_zeros(count, x) ((count) = __builtin_clz (x)) -#define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x)) -#define UMUL_TIME 40 -#define UDIV_TIME 40 -#endif /* 80x86 */ - -#if defined (__x86_64__) && W_TYPE_SIZE == 64 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}" \ - : "=r" ((UDItype) (sh)), \ - "=&r" ((UDItype) (sl)) \ - : "%0" ((UDItype) (ah)), \ - "rme" ((UDItype) (bh)), \ - "%1" ((UDItype) (al)), \ - "rme" ((UDItype) (bl))) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("sub{q} {%5,%1|%1,%5}\n\tsbb{q} {%3,%0|%0,%3}" \ - : "=r" ((UDItype) (sh)), \ - "=&r" ((UDItype) (sl)) \ - : "0" ((UDItype) (ah)), \ - "rme" ((UDItype) (bh)), \ - "1" ((UDItype) (al)), \ - "rme" ((UDItype) (bl))) -#define umul_ppmm(w1, w0, u, v) \ - __asm__ ("mul{q} %3" \ - : "=a" ((UDItype) (w0)), \ - "=d" ((UDItype) (w1)) \ - : "%0" ((UDItype) (u)), \ - "rm" ((UDItype) (v))) -#define udiv_qrnnd(q, r, n1, n0, dv) \ - __asm__ ("div{q} %4" \ - : "=a" ((UDItype) (q)), \ - "=d" ((UDItype) (r)) \ - : "0" ((UDItype) (n0)), \ - "1" ((UDItype) (n1)), \ - "rm" ((UDItype) (dv))) -#define count_leading_zeros(count, x) ((count) = __builtin_clzll (x)) -#define count_trailing_zeros(count, x) ((count) = __builtin_ctzll (x)) -#define UMUL_TIME 40 -#define UDIV_TIME 40 -#endif /* x86_64 */ - -#if defined (__i960__) && W_TYPE_SIZE == 32 -#define umul_ppmm(w1, w0, u, v) \ - ({union {UDItype __ll; \ - struct {USItype __l, __h;} __i; \ - } __xx; \ - __asm__ ("emul %2,%1,%0" \ - : "=d" (__xx.__ll) \ - : "%dI" ((USItype) (u)), \ - "dI" ((USItype) (v))); \ - (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;}) -#define __umulsidi3(u, v) \ - ({UDItype __w; \ - __asm__ ("emul %2,%1,%0" \ - : "=d" (__w) \ - : "%dI" ((USItype) (u)), \ - "dI" ((USItype) (v))); \ - __w; }) -#endif /* __i960__ */ - -#if defined (__ia64) && W_TYPE_SIZE == 64 -/* This form encourages gcc (pre-release 3.4 at least) to emit predicated - "sub r=r,r" and "sub r=r,r,1", giving a 2 cycle latency. The generic - code using "al>= _c; \ - if (_x >= 1 << 4) \ - _x >>= 4, _c += 4; \ - if (_x >= 1 << 2) \ - _x >>= 2, _c += 2; \ - _c += _x >> 1; \ - (count) = W_TYPE_SIZE - 1 - _c; \ - } while (0) -/* similar to what gcc does for __builtin_ffs, but 0 based rather than 1 - based, and we don't need a special case for x==0 here */ -#define count_trailing_zeros(count, x) \ - do { \ - UWtype __ctz_x = (x); \ - __asm__ ("popcnt %0 = %1" \ - : "=r" (count) \ - : "r" ((__ctz_x-1) & ~__ctz_x)); \ - } while (0) -#define UMUL_TIME 14 -#endif - -#ifdef __loongarch__ -# if W_TYPE_SIZE == 32 -# define count_leading_zeros(count, x) ((count) = __builtin_clz (x)) -# define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x)) -# define COUNT_LEADING_ZEROS_0 32 -# elif W_TYPE_SIZE == 64 -# define count_leading_zeros(count, x) ((count) = __builtin_clzll (x)) -# define count_trailing_zeros(count, x) ((count) = __builtin_ctzll (x)) -# define COUNT_LEADING_ZEROS_0 64 -# endif -#endif - -#if defined (__M32R__) && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - /* The cmp clears the condition bit. */ \ - __asm__ ("cmp %0,%0\n\taddx %1,%5\n\taddx %0,%3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "0" ((USItype) (ah)), \ - "r" ((USItype) (bh)), \ - "1" ((USItype) (al)), \ - "r" ((USItype) (bl)) \ - : "cbit") -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - /* The cmp clears the condition bit. */ \ - __asm__ ("cmp %0,%0\n\tsubx %1,%5\n\tsubx %0,%3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "0" ((USItype) (ah)), \ - "r" ((USItype) (bh)), \ - "1" ((USItype) (al)), \ - "r" ((USItype) (bl)) \ - : "cbit") -#endif /* __M32R__ */ - -#if defined (__mc68000__) && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \ - : "=d" ((USItype) (sh)), \ - "=&d" ((USItype) (sl)) \ - : "%0" ((USItype) (ah)), \ - "d" ((USItype) (bh)), \ - "%1" ((USItype) (al)), \ - "g" ((USItype) (bl))) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0" \ - : "=d" ((USItype) (sh)), \ - "=&d" ((USItype) (sl)) \ - : "0" ((USItype) (ah)), \ - "d" ((USItype) (bh)), \ - "1" ((USItype) (al)), \ - "g" ((USItype) (bl))) - -/* The '020, '030, '040, '060 and CPU32 have 32x32->64 and 64/32->32q-32r. */ -#if (defined (__mc68020__) && !defined (__mc68060__)) -#define umul_ppmm(w1, w0, u, v) \ - __asm__ ("mulu%.l %3,%1:%0" \ - : "=d" ((USItype) (w0)), \ - "=d" ((USItype) (w1)) \ - : "%0" ((USItype) (u)), \ - "dmi" ((USItype) (v))) -#define UMUL_TIME 45 -#define udiv_qrnnd(q, r, n1, n0, d) \ - __asm__ ("divu%.l %4,%1:%0" \ - : "=d" ((USItype) (q)), \ - "=d" ((USItype) (r)) \ - : "0" ((USItype) (n0)), \ - "1" ((USItype) (n1)), \ - "dmi" ((USItype) (d))) -#define UDIV_TIME 90 -#define sdiv_qrnnd(q, r, n1, n0, d) \ - __asm__ ("divs%.l %4,%1:%0" \ - : "=d" ((USItype) (q)), \ - "=d" ((USItype) (r)) \ - : "0" ((USItype) (n0)), \ - "1" ((USItype) (n1)), \ - "dmi" ((USItype) (d))) - -#elif defined (__mcoldfire__) /* not mc68020 */ - -#define umul_ppmm(xh, xl, a, b) \ - __asm__ ("| Inlined umul_ppmm\n" \ - " move%.l %2,%/d0\n" \ - " move%.l %3,%/d1\n" \ - " move%.l %/d0,%/d2\n" \ - " swap %/d0\n" \ - " move%.l %/d1,%/d3\n" \ - " swap %/d1\n" \ - " move%.w %/d2,%/d4\n" \ - " mulu %/d3,%/d4\n" \ - " mulu %/d1,%/d2\n" \ - " mulu %/d0,%/d3\n" \ - " mulu %/d0,%/d1\n" \ - " move%.l %/d4,%/d0\n" \ - " clr%.w %/d0\n" \ - " swap %/d0\n" \ - " add%.l %/d0,%/d2\n" \ - " add%.l %/d3,%/d2\n" \ - " jcc 1f\n" \ - " add%.l %#65536,%/d1\n" \ - "1: swap %/d2\n" \ - " moveq %#0,%/d0\n" \ - " move%.w %/d2,%/d0\n" \ - " move%.w %/d4,%/d2\n" \ - " move%.l %/d2,%1\n" \ - " add%.l %/d1,%/d0\n" \ - " move%.l %/d0,%0" \ - : "=g" ((USItype) (xh)), \ - "=g" ((USItype) (xl)) \ - : "g" ((USItype) (a)), \ - "g" ((USItype) (b)) \ - : "d0", "d1", "d2", "d3", "d4") -#define UMUL_TIME 100 -#define UDIV_TIME 400 -#else /* not ColdFire */ -/* %/ inserts REGISTER_PREFIX, %# inserts IMMEDIATE_PREFIX. */ -#define umul_ppmm(xh, xl, a, b) \ - __asm__ ("| Inlined umul_ppmm\n" \ - " move%.l %2,%/d0\n" \ - " move%.l %3,%/d1\n" \ - " move%.l %/d0,%/d2\n" \ - " swap %/d0\n" \ - " move%.l %/d1,%/d3\n" \ - " swap %/d1\n" \ - " move%.w %/d2,%/d4\n" \ - " mulu %/d3,%/d4\n" \ - " mulu %/d1,%/d2\n" \ - " mulu %/d0,%/d3\n" \ - " mulu %/d0,%/d1\n" \ - " move%.l %/d4,%/d0\n" \ - " eor%.w %/d0,%/d0\n" \ - " swap %/d0\n" \ - " add%.l %/d0,%/d2\n" \ - " add%.l %/d3,%/d2\n" \ - " jcc 1f\n" \ - " add%.l %#65536,%/d1\n" \ - "1: swap %/d2\n" \ - " moveq %#0,%/d0\n" \ - " move%.w %/d2,%/d0\n" \ - " move%.w %/d4,%/d2\n" \ - " move%.l %/d2,%1\n" \ - " add%.l %/d1,%/d0\n" \ - " move%.l %/d0,%0" \ - : "=g" ((USItype) (xh)), \ - "=g" ((USItype) (xl)) \ - : "g" ((USItype) (a)), \ - "g" ((USItype) (b)) \ - : "d0", "d1", "d2", "d3", "d4") -#define UMUL_TIME 100 -#define UDIV_TIME 400 - -#endif /* not mc68020 */ - -/* The '020, '030, '040 and '060 have bitfield insns. - cpu32 disguises as a 68020, but lacks them. */ -#if defined (__mc68020__) && !defined (__mcpu32__) -#define count_leading_zeros(count, x) \ - __asm__ ("bfffo %1{%b2:%b2},%0" \ - : "=d" ((USItype) (count)) \ - : "od" ((USItype) (x)), "n" (0)) -/* Some ColdFire architectures have a ff1 instruction supported via - __builtin_clz. */ -#elif defined (__mcfisaaplus__) || defined (__mcfisac__) -#define count_leading_zeros(count,x) ((count) = __builtin_clz (x)) -#define COUNT_LEADING_ZEROS_0 32 -#endif -#endif /* mc68000 */ - -#if defined (__m88000__) && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "%rJ" ((USItype) (ah)), \ - "rJ" ((USItype) (bh)), \ - "%rJ" ((USItype) (al)), \ - "rJ" ((USItype) (bl))) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "rJ" ((USItype) (ah)), \ - "rJ" ((USItype) (bh)), \ - "rJ" ((USItype) (al)), \ - "rJ" ((USItype) (bl))) -#define count_leading_zeros(count, x) \ - do { \ - USItype __cbtmp; \ - __asm__ ("ff1 %0,%1" \ - : "=r" (__cbtmp) \ - : "r" ((USItype) (x))); \ - (count) = __cbtmp ^ 31; \ - } while (0) -#define COUNT_LEADING_ZEROS_0 63 /* sic */ -#if defined (__mc88110__) -#define umul_ppmm(wh, wl, u, v) \ - do { \ - union {UDItype __ll; \ - struct {USItype __h, __l;} __i; \ - } __xx; \ - __asm__ ("mulu.d %0,%1,%2" \ - : "=r" (__xx.__ll) \ - : "r" ((USItype) (u)), \ - "r" ((USItype) (v))); \ - (wh) = __xx.__i.__h; \ - (wl) = __xx.__i.__l; \ - } while (0) -#define udiv_qrnnd(q, r, n1, n0, d) \ - ({union {UDItype __ll; \ - struct {USItype __h, __l;} __i; \ - } __xx; \ - USItype __q; \ - __xx.__i.__h = (n1); __xx.__i.__l = (n0); \ - __asm__ ("divu.d %0,%1,%2" \ - : "=r" (__q) \ - : "r" (__xx.__ll), \ - "r" ((USItype) (d))); \ - (r) = (n0) - __q * (d); (q) = __q; }) -#define UMUL_TIME 5 -#define UDIV_TIME 25 -#else -#define UMUL_TIME 17 -#define UDIV_TIME 150 -#endif /* __mc88110__ */ -#endif /* __m88000__ */ - -#if defined (__mn10300__) -# if defined (__AM33__) -# define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X)) -# define umul_ppmm(w1, w0, u, v) \ - asm("mulu %3,%2,%1,%0" : "=r"(w0), "=r"(w1) : "r"(u), "r"(v)) -# define smul_ppmm(w1, w0, u, v) \ - asm("mul %3,%2,%1,%0" : "=r"(w0), "=r"(w1) : "r"(u), "r"(v)) -# else -# define umul_ppmm(w1, w0, u, v) \ - asm("nop; nop; mulu %3,%0" : "=d"(w0), "=z"(w1) : "%0"(u), "d"(v)) -# define smul_ppmm(w1, w0, u, v) \ - asm("nop; nop; mul %3,%0" : "=d"(w0), "=z"(w1) : "%0"(u), "d"(v)) -# endif -# define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - do { \ - DWunion __s, __a, __b; \ - __a.s.low = (al); __a.s.high = (ah); \ - __b.s.low = (bl); __b.s.high = (bh); \ - __s.ll = __a.ll + __b.ll; \ - (sl) = __s.s.low; (sh) = __s.s.high; \ - } while (0) -# define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - do { \ - DWunion __s, __a, __b; \ - __a.s.low = (al); __a.s.high = (ah); \ - __b.s.low = (bl); __b.s.high = (bh); \ - __s.ll = __a.ll - __b.ll; \ - (sl) = __s.s.low; (sh) = __s.s.high; \ - } while (0) -# define udiv_qrnnd(q, r, nh, nl, d) \ - asm("divu %2,%0" : "=D"(q), "=z"(r) : "D"(d), "0"(nl), "1"(nh)) -# define sdiv_qrnnd(q, r, nh, nl, d) \ - asm("div %2,%0" : "=D"(q), "=z"(r) : "D"(d), "0"(nl), "1"(nh)) -# define UMUL_TIME 3 -# define UDIV_TIME 38 -#endif - -#if defined (__mips__) && W_TYPE_SIZE == 32 -#define umul_ppmm(w1, w0, u, v) \ - do { \ - UDItype __x = (UDItype) (USItype) (u) * (USItype) (v); \ - (w1) = (USItype) (__x >> 32); \ - (w0) = (USItype) (__x); \ - } while (0) -#define UMUL_TIME 10 -#define UDIV_TIME 100 - -#if (__mips == 32 || __mips == 64) && ! defined (__mips16) -#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X)) -#define COUNT_LEADING_ZEROS_0 32 -#endif -#endif /* __mips__ */ - -/* FIXME: We should test _IBMR2 here when we add assembly support for the - system vendor compilers. - FIXME: What's needed for gcc PowerPC VxWorks? __vxworks__ is not good - enough, since that hits ARM and m68k too. */ -#if (defined (_ARCH_PPC) /* AIX */ \ - || defined (__powerpc__) /* gcc */ \ - || defined (__POWERPC__) /* BEOS */ \ - || defined (__ppc__) /* Darwin */ \ - || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \ - || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \ - && CPU_FAMILY == PPC) \ - ) && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - do { \ - if (__builtin_constant_p (bh) && (bh) == 0) \ - __asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\ - else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \ - __asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\ - else \ - __asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3" \ - : "=r" (sh), "=&r" (sl) \ - : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \ - } while (0) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - do { \ - if (__builtin_constant_p (ah) && (ah) == 0) \ - __asm__ ("subf%I3c %1,%4,%3\n\tsubfze %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\ - else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0) \ - __asm__ ("subf%I3c %1,%4,%3\n\tsubfme %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\ - else if (__builtin_constant_p (bh) && (bh) == 0) \ - __asm__ ("subf%I3c %1,%4,%3\n\taddme %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\ - else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \ - __asm__ ("subf%I3c %1,%4,%3\n\taddze %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\ - else \ - __asm__ ("subf%I4c %1,%5,%4\n\tsubfe %0,%3,%2" \ - : "=r" (sh), "=&r" (sl) \ - : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \ - } while (0) -#define count_leading_zeros(count, x) \ - __asm__ ("cntlzw %0,%1" : "=r" (count) : "r" (x)) -#define COUNT_LEADING_ZEROS_0 32 -#if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \ - || defined (__ppc__) \ - || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \ - || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \ - && CPU_FAMILY == PPC) -#define umul_ppmm(ph, pl, m0, m1) \ - do { \ - USItype __m0 = (m0), __m1 = (m1); \ - __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \ - (pl) = __m0 * __m1; \ - } while (0) -#define UMUL_TIME 15 -#define smul_ppmm(ph, pl, m0, m1) \ - do { \ - SItype __m0 = (m0), __m1 = (m1); \ - __asm__ ("mulhw %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \ - (pl) = __m0 * __m1; \ - } while (0) -#define SMUL_TIME 14 -#define UDIV_TIME 120 -#endif -#endif /* 32-bit POWER architecture variants. */ - -/* We should test _IBMR2 here when we add assembly support for the system - vendor compilers. */ -#if (defined (_ARCH_PPC64) || defined (__powerpc64__)) && W_TYPE_SIZE == 64 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - do { \ - if (__builtin_constant_p (bh) && (bh) == 0) \ - __asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\ - else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \ - __asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\ - else \ - __asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3" \ - : "=r" (sh), "=&r" (sl) \ - : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \ - } while (0) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - do { \ - if (__builtin_constant_p (ah) && (ah) == 0) \ - __asm__ ("subf%I3c %1,%4,%3\n\tsubfze %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\ - else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \ - __asm__ ("subf%I3c %1,%4,%3\n\tsubfme %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\ - else if (__builtin_constant_p (bh) && (bh) == 0) \ - __asm__ ("subf%I3c %1,%4,%3\n\taddme %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\ - else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \ - __asm__ ("subf%I3c %1,%4,%3\n\taddze %0,%2" \ - : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\ - else \ - __asm__ ("subf%I4c %1,%5,%4\n\tsubfe %0,%3,%2" \ - : "=r" (sh), "=&r" (sl) \ - : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \ - } while (0) -#define count_leading_zeros(count, x) \ - __asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x)) -#define COUNT_LEADING_ZEROS_0 64 -#define umul_ppmm(ph, pl, m0, m1) \ - do { \ - UDItype __m0 = (m0), __m1 = (m1); \ - __asm__ ("mulhdu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \ - (pl) = __m0 * __m1; \ - } while (0) -#define UMUL_TIME 15 -#define smul_ppmm(ph, pl, m0, m1) \ - do { \ - DItype __m0 = (m0), __m1 = (m1); \ - __asm__ ("mulhd %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \ - (pl) = __m0 * __m1; \ - } while (0) -#define SMUL_TIME 14 /* ??? */ -#define UDIV_TIME 120 /* ??? */ -#endif /* 64-bit PowerPC. */ - -#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("a %1,%5\n\tae %0,%3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "%0" ((USItype) (ah)), \ - "r" ((USItype) (bh)), \ - "%1" ((USItype) (al)), \ - "r" ((USItype) (bl))) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("s %1,%5\n\tse %0,%3" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "0" ((USItype) (ah)), \ - "r" ((USItype) (bh)), \ - "1" ((USItype) (al)), \ - "r" ((USItype) (bl))) -#define umul_ppmm(ph, pl, m0, m1) \ - do { \ - USItype __m0 = (m0), __m1 = (m1); \ - __asm__ ( \ - "s r2,r2\n" \ -" mts r10,%2\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" m r2,%3\n" \ -" cas %0,r2,r0\n" \ -" mfs r10,%1" \ - : "=r" ((USItype) (ph)), \ - "=r" ((USItype) (pl)) \ - : "%r" (__m0), \ - "r" (__m1) \ - : "r2"); \ - (ph) += ((((SItype) __m0 >> 31) & __m1) \ - + (((SItype) __m1 >> 31) & __m0)); \ - } while (0) -#define UMUL_TIME 20 -#define UDIV_TIME 200 -#define count_leading_zeros(count, x) \ - do { \ - if ((x) >= 0x10000) \ - __asm__ ("clz %0,%1" \ - : "=r" ((USItype) (count)) \ - : "r" ((USItype) (x) >> 16)); \ - else \ - { \ - __asm__ ("clz %0,%1" \ - : "=r" ((USItype) (count)) \ - : "r" ((USItype) (x))); \ - (count) += 16; \ - } \ - } while (0) -#endif - -#if defined(__riscv) -#ifdef __riscv_mul -#define __umulsidi3(u,v) ((UDWtype)(UWtype)(u) * (UWtype)(v)) -#define __muluw3(a, b) ((UWtype)(a) * (UWtype)(b)) -#else -#if __riscv_xlen == 32 - #define MULUW3 "call __mulsi3" -#elif __riscv_xlen == 64 - #define MULUW3 "call __muldi3" -#else -#error unsupported xlen -#endif /* __riscv_xlen */ -/* We rely on the fact that MULUW3 doesn't clobber the t-registers. - It can get better register allocation result. */ -#define __muluw3(a, b) \ - ({ \ - register UWtype __op0 asm ("a0") = a; \ - register UWtype __op1 asm ("a1") = b; \ - asm volatile (MULUW3 \ - : "+r" (__op0), "+r" (__op1) \ - : \ - : "ra", "a2", "a3"); \ - __op0; \ - }) -#endif /* __riscv_mul */ -#define umul_ppmm(w1, w0, u, v) \ - do { \ - UWtype __x0, __x1, __x2, __x3; \ - UHWtype __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart (u); \ - __uh = __ll_highpart (u); \ - __vl = __ll_lowpart (v); \ - __vh = __ll_highpart (v); \ - \ - __x0 = __muluw3 (__ul, __vl); \ - __x1 = __muluw3 (__ul, __vh); \ - __x2 = __muluw3 (__uh, __vl); \ - __x3 = __muluw3 (__uh, __vh); \ - \ - __x1 += __ll_highpart (__x0);/* this can't give carry */ \ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos. */ \ - \ - (w1) = __x3 + __ll_highpart (__x1); \ - (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \ - } while (0) -#endif /* __riscv */ - -#if defined(__sh__) && W_TYPE_SIZE == 32 -#ifndef __sh1__ -#define umul_ppmm(w1, w0, u, v) \ - __asm__ ( \ - "dmulu.l %2,%3\n\tsts%M1 macl,%1\n\tsts%M0 mach,%0" \ - : "=r<" ((USItype)(w1)), \ - "=r<" ((USItype)(w0)) \ - : "r" ((USItype)(u)), \ - "r" ((USItype)(v)) \ - : "macl", "mach") -#define UMUL_TIME 5 -#endif - -/* This is the same algorithm as __udiv_qrnnd_c. */ -#define UDIV_NEEDS_NORMALIZATION 1 - -#ifdef __FDPIC__ -/* FDPIC needs a special version of the asm fragment to extract the - code address from the function descriptor. __udiv_qrnnd_16 is - assumed to be local and not to use the GOT, so loading r12 is - not needed. */ -#define udiv_qrnnd(q, r, n1, n0, d) \ - do { \ - extern UWtype __udiv_qrnnd_16 (UWtype, UWtype) \ - __attribute__ ((visibility ("hidden"))); \ - /* r0: rn r1: qn */ /* r0: n1 r4: n0 r5: d r6: d1 */ /* r2: __m */ \ - __asm__ ( \ - "mov%M4 %4,r5\n" \ -" swap.w %3,r4\n" \ -" swap.w r5,r6\n" \ -" mov.l @%5,r2\n" \ -" jsr @r2\n" \ -" shll16 r6\n" \ -" swap.w r4,r4\n" \ -" mov.l @%5,r2\n" \ -" jsr @r2\n" \ -" swap.w r1,%0\n" \ -" or r1,%0" \ - : "=r" (q), "=&z" (r) \ - : "1" (n1), "r" (n0), "rm" (d), "r" (&__udiv_qrnnd_16) \ - : "r1", "r2", "r4", "r5", "r6", "pr", "t"); \ - } while (0) -#else -#define udiv_qrnnd(q, r, n1, n0, d) \ - do { \ - extern UWtype __udiv_qrnnd_16 (UWtype, UWtype) \ - __attribute__ ((visibility ("hidden"))); \ - /* r0: rn r1: qn */ /* r0: n1 r4: n0 r5: d r6: d1 */ /* r2: __m */ \ - __asm__ ( \ - "mov%M4 %4,r5\n" \ -" swap.w %3,r4\n" \ -" swap.w r5,r6\n" \ -" jsr @%5\n" \ -" shll16 r6\n" \ -" swap.w r4,r4\n" \ -" jsr @%5\n" \ -" swap.w r1,%0\n" \ -" or r1,%0" \ - : "=r" (q), "=&z" (r) \ - : "1" (n1), "r" (n0), "rm" (d), "r" (&__udiv_qrnnd_16) \ - : "r1", "r2", "r4", "r5", "r6", "pr", "t"); \ - } while (0) -#endif /* __FDPIC__ */ - -#define UDIV_TIME 80 - -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("clrt;subc %5,%1; subc %4,%0" \ - : "=r" (sh), "=r" (sl) \ - : "0" (ah), "1" (al), "r" (bh), "r" (bl) : "t") - -#endif /* __sh__ */ - -#if defined (__sparc__) && !defined (__arch64__) && !defined (__sparcv9) \ - && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "%rJ" ((USItype) (ah)), \ - "rI" ((USItype) (bh)), \ - "%rJ" ((USItype) (al)), \ - "rI" ((USItype) (bl)) \ - __CLOBBER_CC) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0" \ - : "=r" ((USItype) (sh)), \ - "=&r" ((USItype) (sl)) \ - : "rJ" ((USItype) (ah)), \ - "rI" ((USItype) (bh)), \ - "rJ" ((USItype) (al)), \ - "rI" ((USItype) (bl)) \ - __CLOBBER_CC) -#if defined (__sparc_v9__) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - register USItype __g1 asm ("g1"); \ - __asm__ ("umul\t%2,%3,%1\n\t" \ - "srlx\t%1, 32, %0" \ - : "=r" ((USItype) (w1)), \ - "=r" (__g1) \ - : "r" ((USItype) (u)), \ - "r" ((USItype) (v))); \ - (w0) = __g1; \ - } while (0) -#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ - __asm__ ("mov\t%2,%%y\n\t" \ - "udiv\t%3,%4,%0\n\t" \ - "umul\t%0,%4,%1\n\t" \ - "sub\t%3,%1,%1" \ - : "=&r" ((USItype) (__q)), \ - "=&r" ((USItype) (__r)) \ - : "r" ((USItype) (__n1)), \ - "r" ((USItype) (__n0)), \ - "r" ((USItype) (__d))) -#else -#if defined (__sparc_v8__) -#define umul_ppmm(w1, w0, u, v) \ - __asm__ ("umul %2,%3,%1;rd %%y,%0" \ - : "=r" ((USItype) (w1)), \ - "=r" ((USItype) (w0)) \ - : "r" ((USItype) (u)), \ - "r" ((USItype) (v))) -#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ - __asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\ - : "=&r" ((USItype) (__q)), \ - "=&r" ((USItype) (__r)) \ - : "r" ((USItype) (__n1)), \ - "r" ((USItype) (__n0)), \ - "r" ((USItype) (__d))) -#else -#if defined (__sparclite__) -/* This has hardware multiply but not divide. It also has two additional - instructions scan (ffs from high bit) and divscc. */ -#define umul_ppmm(w1, w0, u, v) \ - __asm__ ("umul %2,%3,%1;rd %%y,%0" \ - : "=r" ((USItype) (w1)), \ - "=r" ((USItype) (w0)) \ - : "r" ((USItype) (u)), \ - "r" ((USItype) (v))) -#define udiv_qrnnd(q, r, n1, n0, d) \ - __asm__ ("! Inlined udiv_qrnnd\n" \ -" wr %%g0,%2,%%y ! Not a delayed write for sparclite\n" \ -" tst %%g0\n" \ -" divscc %3,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%%g1\n" \ -" divscc %%g1,%4,%0\n" \ -" rd %%y,%1\n" \ -" bl,a 1f\n" \ -" add %1,%4,%1\n" \ -"1: ! End of inline udiv_qrnnd" \ - : "=r" ((USItype) (q)), \ - "=r" ((USItype) (r)) \ - : "r" ((USItype) (n1)), \ - "r" ((USItype) (n0)), \ - "rI" ((USItype) (d)) \ - : "g1" __AND_CLOBBER_CC) -#define UDIV_TIME 37 -#define count_leading_zeros(count, x) \ - do { \ - __asm__ ("scan %1,1,%0" \ - : "=r" ((USItype) (count)) \ - : "r" ((USItype) (x))); \ - } while (0) -/* Early sparclites return 63 for an argument of 0, but they warn that future - implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0 - undefined. */ -#else -/* SPARC without integer multiplication and divide instructions. - (i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */ -#define umul_ppmm(w1, w0, u, v) \ - __asm__ ("! Inlined umul_ppmm\n" \ -" wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr\n"\ -" sra %3,31,%%o5 ! Don't move this insn\n" \ -" and %2,%%o5,%%o5 ! Don't move this insn\n" \ -" andcc %%g0,0,%%g1 ! Don't move this insn\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,%3,%%g1\n" \ -" mulscc %%g1,0,%%g1\n" \ -" add %%g1,%%o5,%0\n" \ -" rd %%y,%1" \ - : "=r" ((USItype) (w1)), \ - "=r" ((USItype) (w0)) \ - : "%rI" ((USItype) (u)), \ - "r" ((USItype) (v)) \ - : "g1", "o5" __AND_CLOBBER_CC) -#define UMUL_TIME 39 /* 39 instructions */ -/* It's quite necessary to add this much assembler for the sparc. - The default udiv_qrnnd (in C) is more than 10 times slower! */ -#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ - __asm__ ("! Inlined udiv_qrnnd\n" \ -" mov 32,%%g1\n" \ -" subcc %1,%2,%%g0\n" \ -"1: bcs 5f\n" \ -" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \ -" sub %1,%2,%1 ! this kills msb of n\n" \ -" addx %1,%1,%1 ! so this can't give carry\n" \ -" subcc %%g1,1,%%g1\n" \ -"2: bne 1b\n" \ -" subcc %1,%2,%%g0\n" \ -" bcs 3f\n" \ -" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \ -" b 3f\n" \ -" sub %1,%2,%1 ! this kills msb of n\n" \ -"4: sub %1,%2,%1\n" \ -"5: addxcc %1,%1,%1\n" \ -" bcc 2b\n" \ -" subcc %%g1,1,%%g1\n" \ -"! Got carry from n. Subtract next step to cancel this carry.\n" \ -" bne 4b\n" \ -" addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb\n" \ -" sub %1,%2,%1\n" \ -"3: xnor %0,0,%0\n" \ -" ! End of inline udiv_qrnnd" \ - : "=&r" ((USItype) (__q)), \ - "=&r" ((USItype) (__r)) \ - : "r" ((USItype) (__d)), \ - "1" ((USItype) (__n1)), \ - "0" ((USItype) (__n0)) : "g1" __AND_CLOBBER_CC) -#define UDIV_TIME (3+7*32) /* 7 instructions/iteration. 32 iterations. */ -#endif /* __sparclite__ */ -#endif /* __sparc_v8__ */ -#endif /* __sparc_v9__ */ -#endif /* sparc32 */ - -#if ((defined (__sparc__) && defined (__arch64__)) || defined (__sparcv9)) \ - && W_TYPE_SIZE == 64 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - do { \ - UDItype __carry = 0; \ - __asm__ ("addcc\t%r5,%6,%1\n\t" \ - "add\t%r3,%4,%0\n\t" \ - "movcs\t%%xcc, 1, %2\n\t" \ - "add\t%0, %2, %0" \ - : "=r" ((UDItype)(sh)), \ - "=&r" ((UDItype)(sl)), \ - "+r" (__carry) \ - : "%rJ" ((UDItype)(ah)), \ - "rI" ((UDItype)(bh)), \ - "%rJ" ((UDItype)(al)), \ - "rI" ((UDItype)(bl)) \ - __CLOBBER_CC); \ - } while (0) - -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - do { \ - UDItype __carry = 0; \ - __asm__ ("subcc\t%r5,%6,%1\n\t" \ - "sub\t%r3,%4,%0\n\t" \ - "movcs\t%%xcc, 1, %2\n\t" \ - "sub\t%0, %2, %0" \ - : "=r" ((UDItype)(sh)), \ - "=&r" ((UDItype)(sl)), \ - "+r" (__carry) \ - : "%rJ" ((UDItype)(ah)), \ - "rI" ((UDItype)(bh)), \ - "%rJ" ((UDItype)(al)), \ - "rI" ((UDItype)(bl)) \ - __CLOBBER_CC); \ - } while (0) - -#define umul_ppmm(wh, wl, u, v) \ - do { \ - UDItype tmp1, tmp2, tmp3, tmp4; \ - __asm__ __volatile__ ( \ - "srl %7,0,%3\n\t" \ - "mulx %3,%6,%1\n\t" \ - "srlx %6,32,%2\n\t" \ - "mulx %2,%3,%4\n\t" \ - "sllx %4,32,%5\n\t" \ - "srl %6,0,%3\n\t" \ - "sub %1,%5,%5\n\t" \ - "srlx %5,32,%5\n\t" \ - "addcc %4,%5,%4\n\t" \ - "srlx %7,32,%5\n\t" \ - "mulx %3,%5,%3\n\t" \ - "mulx %2,%5,%5\n\t" \ - "sethi %%hi(0x80000000),%2\n\t" \ - "addcc %4,%3,%4\n\t" \ - "srlx %4,32,%4\n\t" \ - "add %2,%2,%2\n\t" \ - "movcc %%xcc,%%g0,%2\n\t" \ - "addcc %5,%4,%5\n\t" \ - "sllx %3,32,%3\n\t" \ - "add %1,%3,%1\n\t" \ - "add %5,%2,%0" \ - : "=r" ((UDItype)(wh)), \ - "=&r" ((UDItype)(wl)), \ - "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \ - : "r" ((UDItype)(u)), \ - "r" ((UDItype)(v)) \ - __CLOBBER_CC); \ - } while (0) -#define UMUL_TIME 96 -#define UDIV_TIME 230 -#endif /* sparc64 */ - -#if defined (__vax__) && W_TYPE_SIZE == 32 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("addl2 %5,%1\n\tadwc %3,%0" \ - : "=g" ((USItype) (sh)), \ - "=&g" ((USItype) (sl)) \ - : "%0" ((USItype) (ah)), \ - "g" ((USItype) (bh)), \ - "%1" ((USItype) (al)), \ - "g" ((USItype) (bl))) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("subl2 %5,%1\n\tsbwc %3,%0" \ - : "=g" ((USItype) (sh)), \ - "=&g" ((USItype) (sl)) \ - : "0" ((USItype) (ah)), \ - "g" ((USItype) (bh)), \ - "1" ((USItype) (al)), \ - "g" ((USItype) (bl))) -#define umul_ppmm(xh, xl, m0, m1) \ - do { \ - union { \ - UDItype __ll; \ - struct {USItype __l, __h;} __i; \ - } __xx; \ - USItype __m0 = (m0), __m1 = (m1); \ - __asm__ ("emul %1,%2,$0,%0" \ - : "=r" (__xx.__ll) \ - : "g" (__m0), \ - "g" (__m1)); \ - (xh) = __xx.__i.__h; \ - (xl) = __xx.__i.__l; \ - (xh) += ((((SItype) __m0 >> 31) & __m1) \ - + (((SItype) __m1 >> 31) & __m0)); \ - } while (0) -#define sdiv_qrnnd(q, r, n1, n0, d) \ - do { \ - union {DItype __ll; \ - struct {SItype __l, __h;} __i; \ - } __xx; \ - __xx.__i.__h = n1; __xx.__i.__l = n0; \ - __asm__ ("ediv %3,%2,%0,%1" \ - : "=g" (q), "=g" (r) \ - : "g" (__xx.__ll), "g" (d)); \ - } while (0) -#endif /* __vax__ */ - -#ifdef _TMS320C6X -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - do \ - { \ - UDItype __ll; \ - __asm__ ("addu .l1 %1, %2, %0" \ - : "=a" (__ll) : "a" (al), "a" (bl)); \ - (sl) = (USItype)__ll; \ - (sh) = ((USItype)(__ll >> 32)) + (ah) + (bh); \ - } \ - while (0) - -#ifdef _TMS320C6400_PLUS -#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - UDItype __x = (UDItype) (USItype) (u) * (USItype) (v); \ - (w1) = (USItype) (__x >> 32); \ - (w0) = (USItype) (__x); \ - } while (0) -#endif /* _TMS320C6400_PLUS */ - -#define count_leading_zeros(count, x) ((count) = __builtin_clz (x)) -#ifdef _TMS320C6400 -#define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x)) -#endif -#define UMUL_TIME 4 -#define UDIV_TIME 40 -#endif /* _TMS320C6X */ - -#if defined (__xtensa__) && W_TYPE_SIZE == 32 -/* This code is not Xtensa-configuration-specific, so rely on the compiler - to expand builtin functions depending on what configuration features - are available. This avoids library calls when the operation can be - performed in-line. */ -#define umul_ppmm(w1, w0, u, v) \ - do { \ - DWunion __w; \ - __w.ll = __builtin_umulsidi3 (u, v); \ - w1 = __w.s.high; \ - w0 = __w.s.low; \ - } while (0) -#define __umulsidi3(u, v) __builtin_umulsidi3 (u, v) -#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X)) -#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X)) -#endif /* __xtensa__ */ - -#if defined xstormy16 -extern UHItype __stormy16_count_leading_zeros (UHItype); -#define count_leading_zeros(count, x) \ - do \ - { \ - UHItype size; \ - \ - /* We assume that W_TYPE_SIZE is a multiple of 16... */ \ - for ((count) = 0, size = W_TYPE_SIZE; size; size -= 16) \ - { \ - UHItype c; \ - \ - c = __clzhi2 ((x) >> (size - 16)); \ - (count) += c; \ - if (c != 16) \ - break; \ - } \ - } \ - while (0) -#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE -#endif - -#if defined (__z8000__) && W_TYPE_SIZE == 16 -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \ - : "=r" ((unsigned int)(sh)), \ - "=&r" ((unsigned int)(sl)) \ - : "%0" ((unsigned int)(ah)), \ - "r" ((unsigned int)(bh)), \ - "%1" ((unsigned int)(al)), \ - "rQR" ((unsigned int)(bl))) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \ - : "=r" ((unsigned int)(sh)), \ - "=&r" ((unsigned int)(sl)) \ - : "0" ((unsigned int)(ah)), \ - "r" ((unsigned int)(bh)), \ - "1" ((unsigned int)(al)), \ - "rQR" ((unsigned int)(bl))) -#define umul_ppmm(xh, xl, m0, m1) \ - do { \ - union {long int __ll; \ - struct {unsigned int __h, __l;} __i; \ - } __xx; \ - unsigned int __m0 = (m0), __m1 = (m1); \ - __asm__ ("mult %S0,%H3" \ - : "=r" (__xx.__i.__h), \ - "=r" (__xx.__i.__l) \ - : "%1" (__m0), \ - "rQR" (__m1)); \ - (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \ - (xh) += ((((signed int) __m0 >> 15) & __m1) \ - + (((signed int) __m1 >> 15) & __m0)); \ - } while (0) -#endif /* __z8000__ */ - -#endif /* __GNUC__ */ - -/* If this machine has no inline assembler, use C macros. */ - -#if !defined (add_ssaaaa) -#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ - do { \ - UWtype __x; \ - __x = (al) + (bl); \ - (sh) = (ah) + (bh) + (__x < (al)); \ - (sl) = __x; \ - } while (0) -#endif - -#if !defined (sub_ddmmss) -#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ - do { \ - UWtype __x; \ - __x = (al) - (bl); \ - (sh) = (ah) - (bh) - (__x > (al)); \ - (sl) = __x; \ - } while (0) -#endif - -/* If we lack umul_ppmm but have smul_ppmm, define umul_ppmm in terms of - smul_ppmm. */ -#if !defined (umul_ppmm) && defined (smul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - UWtype __w1; \ - UWtype __xm0 = (u), __xm1 = (v); \ - smul_ppmm (__w1, w0, __xm0, __xm1); \ - (w1) = __w1 + (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1) \ - + (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0); \ - } while (0) -#endif - -/* If we still don't have umul_ppmm, define it using plain C. */ -#if !defined (umul_ppmm) -#define umul_ppmm(w1, w0, u, v) \ - do { \ - UWtype __x0, __x1, __x2, __x3; \ - UHWtype __ul, __vl, __uh, __vh; \ - \ - __ul = __ll_lowpart (u); \ - __uh = __ll_highpart (u); \ - __vl = __ll_lowpart (v); \ - __vh = __ll_highpart (v); \ - \ - __x0 = (UWtype) __ul * __vl; \ - __x1 = (UWtype) __ul * __vh; \ - __x2 = (UWtype) __uh * __vl; \ - __x3 = (UWtype) __uh * __vh; \ - \ - __x1 += __ll_highpart (__x0);/* this can't give carry */ \ - __x1 += __x2; /* but this indeed can */ \ - if (__x1 < __x2) /* did we get it? */ \ - __x3 += __ll_B; /* yes, add it in the proper pos. */ \ - \ - (w1) = __x3 + __ll_highpart (__x1); \ - (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \ - } while (0) -#endif - -#if !defined (__umulsidi3) -#define __umulsidi3(u, v) \ - ({DWunion __w; \ - umul_ppmm (__w.s.high, __w.s.low, u, v); \ - __w.ll; }) -#endif - -/* Define this unconditionally, so it can be used for debugging. */ -#define __udiv_qrnnd_c(q, r, n1, n0, d) \ - do { \ - UWtype __d1, __d0, __q1, __q0; \ - UWtype __r1, __r0, __m; \ - __d1 = __ll_highpart (d); \ - __d0 = __ll_lowpart (d); \ - \ - __r1 = (n1) % __d1; \ - __q1 = (n1) / __d1; \ - __m = (UWtype) __q1 * __d0; \ - __r1 = __r1 * __ll_B | __ll_highpart (n0); \ - if (__r1 < __m) \ - { \ - __q1--, __r1 += (d); \ - if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\ - if (__r1 < __m) \ - __q1--, __r1 += (d); \ - } \ - __r1 -= __m; \ - \ - __r0 = __r1 % __d1; \ - __q0 = __r1 / __d1; \ - __m = (UWtype) __q0 * __d0; \ - __r0 = __r0 * __ll_B | __ll_lowpart (n0); \ - if (__r0 < __m) \ - { \ - __q0--, __r0 += (d); \ - if (__r0 >= (d)) \ - if (__r0 < __m) \ - __q0--, __r0 += (d); \ - } \ - __r0 -= __m; \ - \ - (q) = (UWtype) __q1 * __ll_B | __q0; \ - (r) = __r0; \ - } while (0) - -/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through - __udiv_w_sdiv (defined in libgcc or elsewhere). */ -#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd) -#define udiv_qrnnd(q, r, nh, nl, d) \ - do { \ - extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype); \ - UWtype __r; \ - (q) = __udiv_w_sdiv (&__r, nh, nl, d); \ - (r) = __r; \ - } while (0) -#endif - -/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */ -#if !defined (udiv_qrnnd) -#define UDIV_NEEDS_NORMALIZATION 1 -#define udiv_qrnnd __udiv_qrnnd_c -#endif - -#if !defined (count_leading_zeros) -#define count_leading_zeros(count, x) \ - do { \ - UWtype __xr = (x); \ - UWtype __a; \ - \ - if (W_TYPE_SIZE <= 32) \ - { \ - __a = __xr < ((UWtype)1<<2*__BITS4) \ - ? (__xr < ((UWtype)1<<__BITS4) ? 0 : __BITS4) \ - : (__xr < ((UWtype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \ - } \ - else \ - { \ - for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \ - if (((__xr >> __a) & 0xff) != 0) \ - break; \ - } \ - \ - (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \ - } while (0) -#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE -#endif - -#if !defined (count_trailing_zeros) -/* Define count_trailing_zeros using count_leading_zeros. The latter might be - defined in asm, but if it is not, the C version above is good enough. */ -#define count_trailing_zeros(count, x) \ - do { \ - UWtype __ctz_x = (x); \ - UWtype __ctz_c; \ - count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \ - (count) = W_TYPE_SIZE - 1 - __ctz_c; \ - } while (0) -#endif - -#ifndef UDIV_NEEDS_NORMALIZATION -#define UDIV_NEEDS_NORMALIZATION 0 -#endif diff --git a/stdlib/mod_1.c b/stdlib/mod_1.c index be3ae3d648f..a95051d4c45 100644 --- a/stdlib/mod_1.c +++ b/stdlib/mod_1.c @@ -24,8 +24,6 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include #include "gmp-impl.h" -#include "longlong.h" -#include #ifndef UMUL_TIME #define UMUL_TIME 1 diff --git a/stdlib/mul_1.c b/stdlib/mul_1.c index 0a04a8eb1e3..e53fbeaa793 100644 --- a/stdlib/mul_1.c +++ b/stdlib/mul_1.c @@ -21,8 +21,6 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" -#include "longlong.h" -#include mp_limb_t mpn_mul_1 (register mp_ptr res_ptr, register mp_srcptr s1_ptr, diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c index 7618adb2854..d00a336589d 100644 --- a/stdlib/strtod_l.c +++ b/stdlib/strtod_l.c @@ -82,8 +82,6 @@ extern double ____strtod_l_internal (const char *, char **, int, locale_t); #include #include #include "gmp-impl.h" -#include "longlong.h" -#include "gmp-arch.h" #include "fpioconst.h" #include diff --git a/stdlib/submul_1.c b/stdlib/submul_1.c index 0005c2e04e6..31a6d4b2e78 100644 --- a/stdlib/submul_1.c +++ b/stdlib/submul_1.c @@ -23,8 +23,6 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see #include #include "gmp-impl.h" -#include "longlong.h" -#include mp_limb_t mpn_submul_1 (register mp_ptr res_ptr, register mp_srcptr s1_ptr, diff --git a/sysdeps/generic/gmp-arch.h b/sysdeps/generic/gmp-arch.h index f5d6495f2b4..0860c0b2027 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -65,7 +65,6 @@ umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) *w0 = ll_lowpart (x1) * LL_B + ll_lowpart (x0); #endif } -#undef umul_ppmm #define umul_ppmm(__w1, __w0, __u, __v) \ ({ \ __typeof (__w0) __w0t; \ @@ -129,7 +128,6 @@ udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, *q = q1 * LL_B | q0; *r = r0; } -# undef UDIV_NEEDS_NORMALIZATION # define UDIV_NEEDS_NORMALIZATION 1 #else extern mp_limb_t __udiv_qrnnd (mp_limb_t *, mp_limb_t, mp_limb_t, mp_limb_t) @@ -141,7 +139,6 @@ udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, { *q = __udiv_qrnnd (r, n1, n0, d); } -# undef UDIV_NEEDS_NORMALIZATION # define UDIV_NEEDS_NORMALIZATION 0 #endif @@ -162,7 +159,6 @@ add_ssaaaa_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, *sl = al + bl; *sh = (ah + bh) + (*sl < al); } -#undef add_ssaaaa #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ add_ssaaaa_generic (&sh, &sl, ah, al, bh, bl) @@ -179,7 +175,6 @@ sub_ddmmss_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, *sl = al - bl; *sh = (ah - bh) - (*sl > al); } -#undef sub_ddmmss #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ sub_ddmmss_generic (&sh, &sl, ah, al, bh, bl) diff --git a/sysdeps/ieee754/dbl-64/dbl2mpn.c b/sysdeps/ieee754/dbl-64/dbl2mpn.c index cacf5da7d80..50974cfc621 100644 --- a/sysdeps/ieee754/dbl-64/dbl2mpn.c +++ b/sysdeps/ieee754/dbl-64/dbl2mpn.c @@ -17,8 +17,6 @@ #include "gmp.h" #include "gmp-impl.h" -#include "longlong.h" -#include #include #include #include diff --git a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c index fd75db1271c..cd0ee1e073f 100644 --- a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c +++ b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c @@ -17,8 +17,6 @@ #include "gmp.h" #include "gmp-impl.h" -#include "longlong.h" -#include #include #include #include diff --git a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c index d91699c3d04..72714eee2eb 100644 --- a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c +++ b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c @@ -17,7 +17,6 @@ #include "gmp.h" #include "gmp-impl.h" -#include "longlong.h" #include #include #include diff --git a/sysdeps/ieee754/ldbl-96/ldbl2mpn.c b/sysdeps/ieee754/ldbl-96/ldbl2mpn.c index 6c7aadbca2e..5826798631f 100644 --- a/sysdeps/ieee754/ldbl-96/ldbl2mpn.c +++ b/sysdeps/ieee754/ldbl-96/ldbl2mpn.c @@ -17,8 +17,6 @@ #include "gmp.h" #include "gmp-impl.h" -#include "longlong.h" -#include #include #include #include diff --git a/sysdeps/wordsize-32/divdi3.c b/sysdeps/wordsize-32/divdi3.c index 360094134f1..0269729b960 100644 --- a/sysdeps/wordsize-32/divdi3.c +++ b/sysdeps/wordsize-32/divdi3.c @@ -33,8 +33,6 @@ #include #include -#include -#include #if __BYTE_ORDER == __BIG_ENDIAN struct DWstruct { Wtype high, low;}; diff --git a/sysdeps/x86/gmp-arch.h b/sysdeps/x86/gmp-arch.h index c3aa0f2e3b1..64819f1562f 100644 --- a/sysdeps/x86/gmp-arch.h +++ b/sysdeps/x86/gmp-arch.h @@ -38,7 +38,6 @@ umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) "rm" (v)); #endif } -#undef umul_ppmm #define umul_ppmm(__w1, __w0, __u, __v) \ umul_ppmm_generic (&__w1, &__w0, __u, __v) @@ -62,9 +61,7 @@ udiv_qrnnd_x86 (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, "rm" (d)); #endif } -#undef UDIV_NEEDS_NORMALIZATION #define UDIV_NEEDS_NORMALIZATION 0 -#undef udiv_qrnnd #define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ udiv_qrnnd_x86 (&__q, &__r, __n1, __n0, __d) @@ -90,7 +87,6 @@ add_ssaaaa_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, "g" (bl)); #endif } -#undef add_ssaaaa #define add_ssaaaa(__sh, __sl, __ah, __al, __bh, __bl) \ add_ssaaaa_x86 (&__sh, &__sl, __ah, __al, __bh, __bl) @@ -116,7 +112,6 @@ sub_ddmmss_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, "g" (bl)); #endif } -#undef sub_ddmmss #define sub_ddmmss(__sh, __sl, __ah, __al, __bh, __bl) \ sub_ddmmss_x86 (&__sh, &__sl, __ah, __al, __bh, __bl) diff --git a/sysdeps/x86/ldbl2mpn.c b/sysdeps/x86/ldbl2mpn.c index 593c472e8ab..43a34bbcf7a 100644 --- a/sysdeps/x86/ldbl2mpn.c +++ b/sysdeps/x86/ldbl2mpn.c @@ -17,8 +17,6 @@ #include "gmp.h" #include "gmp-impl.h" -#include "longlong.h" -#include #include #include #include From patchwork Fri Oct 31 20:00:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123247 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 345CF3860C39 for ; Fri, 31 Oct 2025 20:06:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 345CF3860C39 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=IA9NXF7w X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id 772CB3850846 for ; Fri, 31 Oct 2025 20:03:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 772CB3850846 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 772CB3850846 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941031; cv=none; b=o0kjCBhmCpdIHaQIve2y1by8njOQaHn91W1aaEpq4R3wAS5GhJOC0jx3+Ej5vd6L3CIwFEszoeG8B8hjZsIfy3L7gd+jMGfRp8dk5GdmGfKTmgTM6cnjUhbn8RVFkJYh2ij/vxwJjwEXUE7XtoajHPv7G1nwUjndE8oCvOLl1ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941031; c=relaxed/simple; bh=QrHi2eQq2WgPheOEpbuvb4VqQApm3WnhmCcvyMS3Ork=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KkFSz/OQLBxWpXDgVmisxAHPgVS4hbjoU03m7E0r++86cimj6eP/gx48aPfXZThD1Aqd/L0sjxU/AWZ+Lh+pHKk9MrKuSnB8kDKBG8Frbq48kOVs7aaCC468e9D+LSqp41CxkoywyI1UIFw4tGGiKm+Q2ah9Ai2+CYGku2uuFEo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 772CB3850846 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-b6cf07258e3so1840829a12.0 for ; Fri, 31 Oct 2025 13:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941030; x=1762545830; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yNyWv/o2zxI5TmhJX42uHF48OVAjEZ+ViAM4ARWTuxA=; b=IA9NXF7w4Dewnpn7G4HZ5aw1kX2kg26pmhgJm7lVz5Hg2VdVarLUX94HTg3vP/CFEm UBLPKiHmFCcX3zaVs/67wtjdlKPfdNtMDl1k1WCJR1QH4B9PVb6ihmHs5fOQU3SgRkdH jprk0lv3/9jvoRveUnLC2n+OTH7j6f68LrcqEINV5dI5QOcnnw8TQeHPZKnVjpThipBl JRD+TzGy1tHukwK4QNCu9hmupB4wSsvY6VSik8mb/12Kc8I2reg6vuB3rLlAcXNvAOme Sfm2zu/Ck20VPfuDH9nO90X1pPa9AZSTL26dycsEJQAbArcmf4EoK7AWUDV/FbwsuVBr 5mUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941030; x=1762545830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yNyWv/o2zxI5TmhJX42uHF48OVAjEZ+ViAM4ARWTuxA=; b=u1AODMf8PnCjC5LIBvfuCs51joRBXi/1SKOpl2Wr5l+RISjeidC0KbTTKPFZ+RODQj EfNEr37Sb4/UiwLMhDFJcWWnMKk2eG2jaLWlKC4/3YCYTVFL8SQwEAernHA9ze/BHSx3 RkM/P1bOtIYu8YCH3IVdJu0hN/bWQDEDbrjOifFFM9YYNNv2zQckDL3mZEQGZ7V9FlM5 EvxU5LcSWRtE0TQzVOb1PRMcnEBwPsno0KdSViBwKDGeVRqpV6RPiZ2tUrc0a7uxc6VM 5g+zoG/lIotEoXznTagluk534xWvpl6FRG2OOkQ6cJG32Bn9BKD+/Obo7fJvrXHMbDwx i9rg== X-Gm-Message-State: AOJu0YyDIcpJtfo//+72Bu5vfQQUfjc58A3W+8bHoM/k9irurxYZyAXQ 7kIF1y3iTW5rSbh3mLn9quKyU/pUNxPYs4veo7ZwjfHMOZEAJ+8EXL1YNPE1pmC1z3K2h+ZTxxr Rp0+b+1w= X-Gm-Gg: ASbGncsTv/k4asvoBq4E/HBDe9Dx0jlAlXwCcsJI+rw3X5c6b02elqjmYAWrki4G9dk rja6VS6N0NBTVhSrUUU1BzShTmZrKm4xPHBfwBYt6iAkTFuCnk+HwVLVzIqEKCL5b3WZU+TohJQ j4uuOf2WxciuDrf1GrvIdeGJgOw/0ch0xJZ52l8TKFKQLTK6lxUNfERgk6IuoCXk1CDH+CzzRd8 0jgHGeZGh17Gid1cz7OFGIh1OrInUd1Zfb37kyVnOiqtoPyvifqvpJq8ODEL2/YFYILht6eBrhN wYgsI+/Nq16lv7SIOkxSjfx7wmqEfXX8WwRuuW354COC1Uv2KdwTbFkT1vCYHOECbyTYi/2MRv4 zhPgRhjiiZhtPJabd7mR80fa9AI7u/rzCY9CB6e62o7Dx4n87xa6n6/1bBeucwECv2W92SD5yrl 9icJyjzwJI/9Gev0/uXf3Zf4I= X-Google-Smtp-Source: AGHT+IHky2vSfQeH3iW4Q4G2uHywlt/OEXkXeRwj8gISwnxgQgGBBuSchCLyAiysZ9if/jmVgPCm3Q== X-Received: by 2002:a17:902:e5c3:b0:272:f9c3:31fb with SMTP id d9443c01a7336-2951a4cb9famr69536295ad.58.1761941029919; Fri, 31 Oct 2025 13:03:49 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:49 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 06/19] math: Don't redirect inlined builtin math functions Date: Fri, 31 Oct 2025 17:00:39 -0300 Message-ID: <20251031200300.3716090-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 When we want to inline builtin math functions, like truncf, for extern float truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); extern float __truncf (float __x) __attribute__ ((__nothrow__ )) __attribute__ ((__const__)); float (truncf) (float) asm ("__truncf"); compiler may redirect truncf calls to __truncf, instead of inlining it (for instance, clang). The USE_TRUNCF_BUILTIN is 1 to indicate that truncf should be inlined. In this case, we don't want the truncf redirection: 1. For each math function which may be inlined, we define #if USE_TRUNCF_BUILTIN # define NO_truncf_BUILTIN inline_truncf #else # define NO_truncf_BUILTIN truncf #endif in . 2. Include in include/math.h. 3. Change MATH_REDIRECT to #define MATH_REDIRECT(FUNC, PREFIX, ARGS) \ float (NO_ ## FUNC ## f ## _BUILTIN) (ARGS (float)) \ asm (PREFIX #FUNC "f"); With this change If USE_TRUNCF_BUILTIN is 0, we get float (truncf) (float) asm ("__truncf"); truncf will be redirected to __truncf. And for USE_TRUNCF_BUILTIN 1, we get: float (inline_truncf) (float) asm ("__truncf"); In both cases either truncf will be inlined or the internal alias (__truncf) will be called. It is not required for all math-use-builtin symbol, only the one defined in math.h. It also allows to remove all the math-use-builtin inclusion, since it is now implicitly included by math.h. For MIPS, some math-use-builtin headers include sysdep.h and this in turn includes a lot of extra headers that do not allow ldbl-128 code to override alias definition (math.h will include some stdlib.h definition). The math-use-builtin only requires the __mips_isa_rev, so move the defintion to sgidefs.h. Signed-off-by: H.J. Lu Co-authored-by: Adhemerval Zanella Reviewed-by: H.J. Lu --- include/math.h | 22 +- math/s_fmax_template.c | 1 - math/s_fmin_template.c | 2 - sysdeps/generic/math-use-builtins-copysign.h | 2 + sysdeps/generic/math-use-builtins.h | 196 ++++++++++++++++++ sysdeps/ieee754/dbl-64/e_hypot.c | 1 - sysdeps/ieee754/dbl-64/e_sqrt.c | 1 - sysdeps/ieee754/dbl-64/s_ceil.c | 1 - sysdeps/ieee754/dbl-64/s_floor.c | 1 - sysdeps/ieee754/dbl-64/s_fma.c | 1 - sysdeps/ieee754/dbl-64/s_fmaf.c | 1 - sysdeps/ieee754/dbl-64/s_llrint.c | 1 - sysdeps/ieee754/dbl-64/s_llround.c | 1 - sysdeps/ieee754/dbl-64/s_logb.c | 2 - sysdeps/ieee754/dbl-64/s_lrint.c | 1 - sysdeps/ieee754/dbl-64/s_lround.c | 1 - sysdeps/ieee754/dbl-64/s_modf.c | 1 - sysdeps/ieee754/dbl-64/s_nearbyint.c | 1 - sysdeps/ieee754/dbl-64/s_rint.c | 1 - sysdeps/ieee754/dbl-64/s_round.c | 2 - sysdeps/ieee754/dbl-64/s_roundeven.c | 1 - sysdeps/ieee754/dbl-64/s_trunc.c | 2 - sysdeps/ieee754/float128/float128_private.h | 1 - sysdeps/ieee754/flt-32/e_sqrtf.c | 1 - sysdeps/ieee754/flt-32/s_ceilf.c | 1 - sysdeps/ieee754/flt-32/s_floorf.c | 1 - sysdeps/ieee754/flt-32/s_llrintf.c | 1 - sysdeps/ieee754/flt-32/s_llroundf.c | 1 - sysdeps/ieee754/flt-32/s_logbf.c | 1 - sysdeps/ieee754/flt-32/s_lrintf.c | 1 - sysdeps/ieee754/flt-32/s_lroundf.c | 1 - sysdeps/ieee754/flt-32/s_modff.c | 1 - sysdeps/ieee754/flt-32/s_nearbyintf.c | 1 - sysdeps/ieee754/flt-32/s_rintf.c | 1 - sysdeps/ieee754/flt-32/s_roundevenf.c | 1 - sysdeps/ieee754/flt-32/s_roundf.c | 1 - sysdeps/ieee754/flt-32/s_truncf.c | 1 - sysdeps/ieee754/ldbl-128/s_ceill.c | 1 - sysdeps/ieee754/ldbl-128/s_copysignl.c | 1 - sysdeps/ieee754/ldbl-128/s_floorl.c | 1 - sysdeps/ieee754/ldbl-128/s_fma.c | 1 - sysdeps/ieee754/ldbl-128/s_fmal.c | 1 - sysdeps/ieee754/ldbl-128/s_llrintl.c | 1 - sysdeps/ieee754/ldbl-128/s_logbl.c | 1 - sysdeps/ieee754/ldbl-128/s_lrintl.c | 1 - sysdeps/ieee754/ldbl-128/s_nearbyintl.c | 1 - sysdeps/ieee754/ldbl-128/s_rintl.c | 1 - sysdeps/ieee754/ldbl-128/s_roundevenl.c | 1 - sysdeps/ieee754/ldbl-128/s_roundl.c | 1 - sysdeps/ieee754/ldbl-128/s_truncl.c | 1 - sysdeps/ieee754/ldbl-128ibm/s_fabsl.c | 1 - sysdeps/ieee754/ldbl-96/s_fabsl.c | 1 - sysdeps/mips/fpu/math-use-builtins-fma.h | 2 +- sysdeps/mips/math-use-builtins-ffs.h | 2 +- sysdeps/mips/sgidefs.h | 3 + sysdeps/powerpc/fpu/e_sqrt.c | 1 - sysdeps/powerpc/fpu/e_sqrtf.c | 1 - sysdeps/unix/mips/sysdep.h | 3 - sysdeps/x86_64/fpu/multiarch/s_modf-avx.c | 4 - sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c | 4 - sysdeps/x86_64/fpu/multiarch/s_modff-avx.c | 4 - sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c | 4 - 62 files changed, 219 insertions(+), 82 deletions(-) diff --git a/include/math.h b/include/math.h index 9ba4708801e..12150e5d64d 100644 --- a/include/math.h +++ b/include/math.h @@ -139,25 +139,35 @@ fabsf128 (_Float128 x) /* NB: Internal tests don't have access to internal symbols. */ # if !IS_IN (testsuite_internal) \ && !(defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0) +/* NO_MATH_REDIRECT must be defined in the source implementing function, + FUNC, if FUNC is implemented as an alias of __FUNC or vice versa to + avoid redirecting FUNC to __FUNC. */ +# include +/* NB: Do not redirect math builtin functions when they are inlined. */ # ifndef NO_MATH_REDIRECT /* Declare some functions for use within GLIBC. Compilers typically inline those functions as a single instruction. Use an asm to avoid use of PLTs if it doesn't. */ # define MATH_REDIRECT(FUNC, PREFIX, ARGS) \ - float (FUNC ## f) (ARGS (float)) asm (PREFIX #FUNC "f"); \ - double (FUNC) (ARGS (double)) asm (PREFIX #FUNC ); \ + float (NO_ ## FUNC ## f ## _BUILTIN) (ARGS (float)) \ + asm (PREFIX #FUNC "f"); \ + double (NO_ ## FUNC ## _BUILTIN) (ARGS (double)) \ + asm (PREFIX #FUNC ); \ MATH_REDIRECT_LDBL (FUNC, PREFIX, ARGS) \ MATH_REDIRECT_F128 (FUNC, PREFIX, ARGS) + # if defined __NO_LONG_DOUBLE_MATH \ || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS) # else -# define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS) \ - long double (FUNC ## l) (ARGS (long double)) asm (PREFIX #FUNC "l"); +# define MATH_REDIRECT_LDBL(FUNC, PREFIX, ARGS) \ + long double (NO_ ## FUNC ## l ## _BUILTIN) (ARGS (long double)) \ + asm (PREFIX #FUNC "l"); # endif # if __HAVE_DISTINCT_FLOAT128 -# define MATH_REDIRECT_F128(FUNC, PREFIX, ARGS) \ - _Float128 (FUNC ## f128) (ARGS (_Float128)) asm (PREFIX #FUNC "f128"); +# define MATH_REDIRECT_F128(FUNC, PREFIX, ARGS) \ + _Float128 (NO_ ## FUNC ## f128 ## _BUILTIN) (ARGS (_Float128)) \ + asm (PREFIX #FUNC "f128"); # else # define MATH_REDIRECT_F128(FUNC, PREFIX, ARGS) # endif diff --git a/math/s_fmax_template.c b/math/s_fmax_template.c index bdf71096afa..87e6ee67dfa 100644 --- a/math/s_fmax_template.c +++ b/math/s_fmax_template.c @@ -17,7 +17,6 @@ . */ #include -#include FLOAT M_DECL_FUNC (__fmax) (FLOAT x, FLOAT y) diff --git a/math/s_fmin_template.c b/math/s_fmin_template.c index 99d25aa5b9b..9ff330969f0 100644 --- a/math/s_fmin_template.c +++ b/math/s_fmin_template.c @@ -17,8 +17,6 @@ . */ #include -#include - FLOAT M_DECL_FUNC (__fmin) (FLOAT x, FLOAT y) diff --git a/sysdeps/generic/math-use-builtins-copysign.h b/sysdeps/generic/math-use-builtins-copysign.h index b774931f431..4bca2ee1b10 100644 --- a/sysdeps/generic/math-use-builtins-copysign.h +++ b/sysdeps/generic/math-use-builtins-copysign.h @@ -1,4 +1,6 @@ /* Generic implementations for float and double always use the builtin. */ +#define USE_COPYSIGNF_BUILTIN 1 +#define USE_COPYSIGN_BUILTIN 1 #define USE_COPYSIGNL_BUILTIN 1 #if __GNUC_PREREQ (7, 0) # define USE_COPYSIGNF128_BUILTIN 1 diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h index e069b161b18..13b037fb9e8 100644 --- a/sysdeps/generic/math-use-builtins.h +++ b/sysdeps/generic/math-use-builtins.h @@ -44,4 +44,200 @@ #include #include + +/* Disable internal alias optimizations done at include/math.h if the + compiler can expand the builtin for the symbol. Different than gcc, the + clang will always expand the alias before handling the builtin expansion, + which makes the builtin expansion ineffective. */ + +#if USE_SQRT_BUILTIN +# define NO_sqrt_BUILTIN inline_sqrt +#else +# define NO_sqrt_BUILTIN sqrt +#endif +#if USE_SQRTF_BUILTIN +# define NO_sqrtf_BUILTIN inline_sqrtf +#else +# define NO_sqrtf_BUILTIN sqrtf +#endif +#if USE_SQRTL_BUILTIN +# define NO_sqrtl_BUILTIN inline_sqrtl +#else +# define NO_sqrtl_BUILTIN sqrtl +#endif +#if USE_SQRTF128_BUILTIN +# define NO_sqrtf128_BUILTIN inline_sqrtf128 +#else +# define NO_sqrtf128_BUILTIN sqrtf128 +#endif + + +#if USE_CEIL_BUILTIN +# define NO_ceil_BUILTIN inline_ceil +#else +# define NO_ceil_BUILTIN ceil +#endif +#if USE_CEILF_BUILTIN +# define NO_ceilf_BUILTIN inline_ceilf +#else +# define NO_ceilf_BUILTIN ceilf +#endif +#if USE_CEILL_BUILTIN +# define NO_ceill_BUILTIN inline_ceill +#else +# define NO_ceill_BUILTIN ceill +#endif +#if USE_CEILF128_BUILTIN +# define NO_ceilf128_BUILTIN inline_ceilf128 +#else +# define NO_ceilf128_BUILTIN ceilf128 +#endif + +#if USE_FLOOR_BUILTIN +# define NO_floor_BUILTIN inline_floor +#else +# define NO_floor_BUILTIN floor +#endif +#if USE_FLOORF_BUILTIN +# define NO_floorf_BUILTIN inline_floorf +#else +# define NO_floorf_BUILTIN floorf +#endif +#if USE_FLOORL_BUILTIN +# define NO_floorl_BUILTIN inline_floorl +#else +# define NO_floorl_BUILTIN floorl +#endif +#if USE_FLOORF128_BUILTIN +# define NO_floorf128_BUILTIN inline_floorf128 +#else +# define NO_floorf128_BUILTIN floorf128 +#endif + +#if USE_ROUNDEVEN_BUILTIN +# define NO_roundeven_BUILTIN inline_roundeven +#else +# define NO_roundeven_BUILTIN roundeven +#endif +#if USE_ROUNDEVENF_BUILTIN +# define NO_roundevenf_BUILTIN inline_roundevenf +#else +# define NO_roundevenf_BUILTIN roundevenf +#endif +#if USE_ROUNDEVENL_BUILTIN +# define NO_roundevenl_BUILTIN inline_roundevenl +#else +# define NO_roundevenl_BUILTIN roundevenl +#endif +#if USE_ROUNDEVENF128_BUILTIN +# define NO_roundevenf128_BUILTIN inline_roundevenf128 +#else +# define NO_roundevenf128_BUILTIN roundevenf128 +#endif + +#if USE_RINT_BUILTIN +# define NO_rint_BUILTIN inline_rint +#else +# define NO_rint_BUILTIN rint +#endif +#if USE_RINTF_BUILTIN +# define NO_rintf_BUILTIN inline_rintf +#else +# define NO_rintf_BUILTIN rintf +#endif +#if USE_RINTL_BUILTIN +# define NO_rintl_BUILTIN inline_rintl +#else +# define NO_rintl_BUILTIN rintl +#endif +#if USE_RINTF128_BUILTIN +# define NO_rintf128_BUILTIN inline_rintf128 +#else +# define NO_rintf128_BUILTIN rintf128 +#endif + +#if USE_TRUNC_BUILTIN +# define NO_trunc_BUILTIN inline_trunc +#else +# define NO_trunc_BUILTIN trunc +#endif +#if USE_TRUNCF_BUILTIN +# define NO_truncf_BUILTIN inline_truncf +#else +# define NO_truncf_BUILTIN truncf +#endif +#if USE_TRUNCL_BUILTIN +# define NO_truncl_BUILTIN inline_truncl +#else +# define NO_truncl_BUILTIN truncl +#endif +#if USE_TRUNCF128_BUILTIN +# define NO_truncf128_BUILTIN inline_truncf128 +#else +# define NO_truncf128_BUILTIN truncf128 +#endif + +#if USE_ROUND_BUILTIN +# define NO_round_BUILTIN inline_round +#else +# define NO_round_BUILTIN round +#endif +#if USE_ROUNDF_BUILTIN +# define NO_roundf_BUILTIN inline_roundf +#else +# define NO_roundf_BUILTIN roundf +#endif +#if USE_ROUNDL_BUILTIN +# define NO_roundl_BUILTIN inline_roundl +#else +# define NO_roundl_BUILTIN roundl +#endif +#if USE_ROUNDF128_BUILTIN +# define NO_roundf128_BUILTIN inline_roundf128 +#else +# define NO_roundf128_BUILTIN roundf128 +#endif + +#if USE_COPYSIGN_BUILTIN +# define NO_copysign_BUILTIN inline_copysign +#else +# define NO_copysign_BUILTIN copysign +#endif +#if USE_COPYSIGNF_BUILTIN +# define NO_copysignf_BUILTIN inline_copysignf +#else +# define NO_copysignf_BUILTIN copysignf +#endif +#if USE_COPYSIGNL_BUILTIN +# define NO_copysignl_BUILTIN inline_copysignl +#else +# define NO_copysignl_BUILTIN copysignl +#endif +#if USE_COPYSIGNF128_BUILTIN +# define NO_copysignf128_BUILTIN inline_copysignf128 +#else +# define NO_copysignf128_BUILTIN copysignf128 +#endif + +#if USE_FMA_BUILTIN +# define NO_fma_BUILTIN inline_fma +#else +# define NO_fma_BUILTIN fma +#endif +#if USE_FMAF_BUILTIN +# define NO_fmaf_BUILTIN inline_fmaf +#else +# define NO_fmaf_BUILTIN fmaf +#endif +#if USE_FMAL_BUILTIN +# define NO_fmal_BUILTIN inline_fmal +#else +# define NO_fmal_BUILTIN fmal +#endif +#if USE_FMAF128_BUILTIN +# define NO_fmaf128_BUILTIN inline_fmaf128 +#else +# define NO_fmaf128_BUILTIN fmaf128 +#endif + #endif /* MATH_USE_BUILTINS_H */ diff --git a/sysdeps/ieee754/dbl-64/e_hypot.c b/sysdeps/ieee754/dbl-64/e_hypot.c index 29555927edf..799ccbd08ea 100644 --- a/sysdeps/ieee754/dbl-64/e_hypot.c +++ b/sysdeps/ieee754/dbl-64/e_hypot.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/sysdeps/ieee754/dbl-64/e_sqrt.c b/sysdeps/ieee754/dbl-64/e_sqrt.c index c01f0248c37..95956e44add 100644 --- a/sysdeps/ieee754/dbl-64/e_sqrt.c +++ b/sysdeps/ieee754/dbl-64/e_sqrt.c @@ -40,7 +40,6 @@ #include #include #include -#include /*********************************************************************/ /* An ultimate sqrt routine. Given an IEEE double machine number x */ diff --git a/sysdeps/ieee754/dbl-64/s_ceil.c b/sysdeps/ieee754/dbl-64/s_ceil.c index 37382113607..c401e4c0bf6 100644 --- a/sysdeps/ieee754/dbl-64/s_ceil.c +++ b/sysdeps/ieee754/dbl-64/s_ceil.c @@ -21,7 +21,6 @@ #include #include #include -#include double __ceil (double x) diff --git a/sysdeps/ieee754/dbl-64/s_floor.c b/sysdeps/ieee754/dbl-64/s_floor.c index 72c426ee59d..78ffb51e492 100644 --- a/sysdeps/ieee754/dbl-64/s_floor.c +++ b/sysdeps/ieee754/dbl-64/s_floor.c @@ -34,7 +34,6 @@ #include #include #include -#include /* * floor(x) diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c index d157e8b472a..c7ff3cf447f 100644 --- a/sysdeps/ieee754/dbl-64/s_fma.c +++ b/sysdeps/ieee754/dbl-64/s_fma.c @@ -30,7 +30,6 @@ #include #include #include -#include /* This implementation uses rounding to odd to avoid problems with double rounding. See a paper by Boldo and Melquiond: diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c b/sysdeps/ieee754/dbl-64/s_fmaf.c index 7bf9941dd88..26ced154657 100644 --- a/sysdeps/ieee754/dbl-64/s_fmaf.c +++ b/sysdeps/ieee754/dbl-64/s_fmaf.c @@ -23,7 +23,6 @@ #include #include #include -#include /* This implementation relies on double being more than twice as precise as float and uses rounding to odd in order to avoid problems diff --git a/sysdeps/ieee754/dbl-64/s_llrint.c b/sysdeps/ieee754/dbl-64/s_llrint.c index ec2643dcfec..0745a75666e 100644 --- a/sysdeps/ieee754/dbl-64/s_llrint.c +++ b/sysdeps/ieee754/dbl-64/s_llrint.c @@ -25,7 +25,6 @@ #include #include #include -#include long long int diff --git a/sysdeps/ieee754/dbl-64/s_llround.c b/sysdeps/ieee754/dbl-64/s_llround.c index e86d3dcb677..2339b92a167 100644 --- a/sysdeps/ieee754/dbl-64/s_llround.c +++ b/sysdeps/ieee754/dbl-64/s_llround.c @@ -27,7 +27,6 @@ #include #include #include -#include long long int __llround (double x) diff --git a/sysdeps/ieee754/dbl-64/s_logb.c b/sysdeps/ieee754/dbl-64/s_logb.c index 64749bc4996..cc6daf53aa4 100644 --- a/sysdeps/ieee754/dbl-64/s_logb.c +++ b/sysdeps/ieee754/dbl-64/s_logb.c @@ -17,11 +17,9 @@ . */ #include - #include #include #include -#include double __logb (double x) diff --git a/sysdeps/ieee754/dbl-64/s_lrint.c b/sysdeps/ieee754/dbl-64/s_lrint.c index 980959292e6..e4f034283e5 100644 --- a/sysdeps/ieee754/dbl-64/s_lrint.c +++ b/sysdeps/ieee754/dbl-64/s_lrint.c @@ -25,7 +25,6 @@ #include #include #include -#include long int diff --git a/sysdeps/ieee754/dbl-64/s_lround.c b/sysdeps/ieee754/dbl-64/s_lround.c index e92fa5ceedd..c7abd1410b9 100644 --- a/sysdeps/ieee754/dbl-64/s_lround.c +++ b/sysdeps/ieee754/dbl-64/s_lround.c @@ -23,7 +23,6 @@ #include #include #include -#include /* For LP64, lround is an alias for llround. */ #ifndef _LP64 diff --git a/sysdeps/ieee754/dbl-64/s_modf.c b/sysdeps/ieee754/dbl-64/s_modf.c index 90cd8e8c3ef..77e0226be93 100644 --- a/sysdeps/ieee754/dbl-64/s_modf.c +++ b/sysdeps/ieee754/dbl-64/s_modf.c @@ -19,7 +19,6 @@ #include #include #include "math_config.h" -#include double __modf (double x, double *iptr) diff --git a/sysdeps/ieee754/dbl-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/s_nearbyint.c index 606002d6808..b2a6a81517d 100644 --- a/sysdeps/ieee754/dbl-64/s_nearbyint.c +++ b/sysdeps/ieee754/dbl-64/s_nearbyint.c @@ -25,7 +25,6 @@ #include #include #include -#include double __nearbyint (double x) diff --git a/sysdeps/ieee754/dbl-64/s_rint.c b/sysdeps/ieee754/dbl-64/s_rint.c index 8604733ef95..a9740af4448 100644 --- a/sysdeps/ieee754/dbl-64/s_rint.c +++ b/sysdeps/ieee754/dbl-64/s_rint.c @@ -23,7 +23,6 @@ #include #include #include -#include double __rint (double x) diff --git a/sysdeps/ieee754/dbl-64/s_round.c b/sysdeps/ieee754/dbl-64/s_round.c index d3b8fcffc58..064773011ba 100644 --- a/sysdeps/ieee754/dbl-64/s_round.c +++ b/sysdeps/ieee754/dbl-64/s_round.c @@ -22,8 +22,6 @@ #include #include #include -#include - double __round (double x) diff --git a/sysdeps/ieee754/dbl-64/s_roundeven.c b/sysdeps/ieee754/dbl-64/s_roundeven.c index 9f6b108dbd3..f35a1f63e60 100644 --- a/sysdeps/ieee754/dbl-64/s_roundeven.c +++ b/sysdeps/ieee754/dbl-64/s_roundeven.c @@ -21,7 +21,6 @@ #include #include #include -#include #define BIAS 0x3ff #define MANT_DIG 53 diff --git a/sysdeps/ieee754/dbl-64/s_trunc.c b/sysdeps/ieee754/dbl-64/s_trunc.c index d2323d6f17f..c426770cb67 100644 --- a/sysdeps/ieee754/dbl-64/s_trunc.c +++ b/sysdeps/ieee754/dbl-64/s_trunc.c @@ -21,8 +21,6 @@ #include #include -#include - double __trunc (double x) diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h index 1430bba794c..d12cec94729 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -142,7 +142,6 @@ #define libm_alias_ldouble_narrow(from, to) \ libm_alias_float128_narrow (from, to) -#include #undef USE_NEARBYINTL_BUILTIN #define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN #undef USE_RINTL_BUILTIN diff --git a/sysdeps/ieee754/flt-32/e_sqrtf.c b/sysdeps/ieee754/flt-32/e_sqrtf.c index 0e29375786c..e06a778eed1 100644 --- a/sysdeps/ieee754/flt-32/e_sqrtf.c +++ b/sysdeps/ieee754/flt-32/e_sqrtf.c @@ -15,7 +15,6 @@ #include #include #include -#include float __ieee754_sqrtf(float x) diff --git a/sysdeps/ieee754/flt-32/s_ceilf.c b/sysdeps/ieee754/flt-32/s_ceilf.c index 0263552deed..4ff9fe3230f 100644 --- a/sysdeps/ieee754/flt-32/s_ceilf.c +++ b/sysdeps/ieee754/flt-32/s_ceilf.c @@ -16,7 +16,6 @@ #include #include #include -#include float __ceilf (float x) diff --git a/sysdeps/ieee754/flt-32/s_floorf.c b/sysdeps/ieee754/flt-32/s_floorf.c index a5c38818f1f..b0447d73dac 100644 --- a/sysdeps/ieee754/flt-32/s_floorf.c +++ b/sysdeps/ieee754/flt-32/s_floorf.c @@ -23,7 +23,6 @@ #include #include #include -#include float __floorf (float x) diff --git a/sysdeps/ieee754/flt-32/s_llrintf.c b/sysdeps/ieee754/flt-32/s_llrintf.c index dab8d22f675..7aba715a487 100644 --- a/sysdeps/ieee754/flt-32/s_llrintf.c +++ b/sysdeps/ieee754/flt-32/s_llrintf.c @@ -25,7 +25,6 @@ #include #include #include -#include long long int diff --git a/sysdeps/ieee754/flt-32/s_llroundf.c b/sysdeps/ieee754/flt-32/s_llroundf.c index bb92acbc495..849735aa627 100644 --- a/sysdeps/ieee754/flt-32/s_llroundf.c +++ b/sysdeps/ieee754/flt-32/s_llroundf.c @@ -23,7 +23,6 @@ #include #include #include -#include long long int __llroundf (float x) diff --git a/sysdeps/ieee754/flt-32/s_logbf.c b/sysdeps/ieee754/flt-32/s_logbf.c index b027e7b9c24..29316e5787d 100644 --- a/sysdeps/ieee754/flt-32/s_logbf.c +++ b/sysdeps/ieee754/flt-32/s_logbf.c @@ -16,7 +16,6 @@ #include #include #include -#include float __logbf (float x) diff --git a/sysdeps/ieee754/flt-32/s_lrintf.c b/sysdeps/ieee754/flt-32/s_lrintf.c index 079bc5d70bd..a63fb7ba04d 100644 --- a/sysdeps/ieee754/flt-32/s_lrintf.c +++ b/sysdeps/ieee754/flt-32/s_lrintf.c @@ -25,7 +25,6 @@ #include #include #include -#include long int diff --git a/sysdeps/ieee754/flt-32/s_lroundf.c b/sysdeps/ieee754/flt-32/s_lroundf.c index f31c53136a6..50decf66570 100644 --- a/sysdeps/ieee754/flt-32/s_lroundf.c +++ b/sysdeps/ieee754/flt-32/s_lroundf.c @@ -23,7 +23,6 @@ #include #include #include -#include long int __lroundf (float x) diff --git a/sysdeps/ieee754/flt-32/s_modff.c b/sysdeps/ieee754/flt-32/s_modff.c index 965136bac9f..b5dac7521d3 100644 --- a/sysdeps/ieee754/flt-32/s_modff.c +++ b/sysdeps/ieee754/flt-32/s_modff.c @@ -19,7 +19,6 @@ #include #include #include "math_config.h" -#include float __modff (float x, float *iptr) diff --git a/sysdeps/ieee754/flt-32/s_nearbyintf.c b/sysdeps/ieee754/flt-32/s_nearbyintf.c index 5dd0e8f8af8..162bcde906f 100644 --- a/sysdeps/ieee754/flt-32/s_nearbyintf.c +++ b/sysdeps/ieee754/flt-32/s_nearbyintf.c @@ -19,7 +19,6 @@ #include #include #include -#include float __nearbyintf (float x) diff --git a/sysdeps/ieee754/flt-32/s_rintf.c b/sysdeps/ieee754/flt-32/s_rintf.c index fe5258ae61d..32afd71e9aa 100644 --- a/sysdeps/ieee754/flt-32/s_rintf.c +++ b/sysdeps/ieee754/flt-32/s_rintf.c @@ -16,7 +16,6 @@ #include #include #include -#include float __rintf (float x) diff --git a/sysdeps/ieee754/flt-32/s_roundevenf.c b/sysdeps/ieee754/flt-32/s_roundevenf.c index 2981f365a58..882b55787de 100644 --- a/sysdeps/ieee754/flt-32/s_roundevenf.c +++ b/sysdeps/ieee754/flt-32/s_roundevenf.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #define BIAS 0x7f diff --git a/sysdeps/ieee754/flt-32/s_roundf.c b/sysdeps/ieee754/flt-32/s_roundf.c index eb714e975e4..746a7759f4e 100644 --- a/sysdeps/ieee754/flt-32/s_roundf.c +++ b/sysdeps/ieee754/flt-32/s_roundf.c @@ -21,7 +21,6 @@ #include #include -#include float diff --git a/sysdeps/ieee754/flt-32/s_truncf.c b/sysdeps/ieee754/flt-32/s_truncf.c index 6b36e1d4911..cef7c9168df 100644 --- a/sysdeps/ieee754/flt-32/s_truncf.c +++ b/sysdeps/ieee754/flt-32/s_truncf.c @@ -21,7 +21,6 @@ #include #include -#include float diff --git a/sysdeps/ieee754/ldbl-128/s_ceill.c b/sysdeps/ieee754/ldbl-128/s_ceill.c index f363d2f898b..5040a27325e 100644 --- a/sysdeps/ieee754/ldbl-128/s_ceill.c +++ b/sysdeps/ieee754/ldbl-128/s_ceill.c @@ -27,7 +27,6 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include -#include _Float128 __ceill (_Float128 x) diff --git a/sysdeps/ieee754/ldbl-128/s_copysignl.c b/sysdeps/ieee754/ldbl-128/s_copysignl.c index d512d9a1e23..92b83526483 100644 --- a/sysdeps/ieee754/ldbl-128/s_copysignl.c +++ b/sysdeps/ieee754/ldbl-128/s_copysignl.c @@ -26,7 +26,6 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include -#include _Float128 __copysignl (_Float128 x, _Float128 y) diff --git a/sysdeps/ieee754/ldbl-128/s_floorl.c b/sysdeps/ieee754/ldbl-128/s_floorl.c index 02eb663dd58..7c9d518fef5 100644 --- a/sysdeps/ieee754/ldbl-128/s_floorl.c +++ b/sysdeps/ieee754/ldbl-128/s_floorl.c @@ -27,7 +27,6 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include -#include _Float128 __floorl (_Float128 x) diff --git a/sysdeps/ieee754/ldbl-128/s_fma.c b/sysdeps/ieee754/ldbl-128/s_fma.c index 01ca5562608..bf1b0664d2f 100644 --- a/sysdeps/ieee754/ldbl-128/s_fma.c +++ b/sysdeps/ieee754/ldbl-128/s_fma.c @@ -26,7 +26,6 @@ #include #include #include -#include /* This implementation relies on long double being more than twice as precise as double and uses rounding to odd in order to avoid problems diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c b/sysdeps/ieee754/ldbl-128/s_fmal.c index 17ad90ca310..ea253330b3a 100644 --- a/sysdeps/ieee754/ldbl-128/s_fmal.c +++ b/sysdeps/ieee754/ldbl-128/s_fmal.c @@ -28,7 +28,6 @@ #include #include #include -#include /* This implementation uses rounding to odd to avoid problems with double rounding. See a paper by Boldo and Melquiond: diff --git a/sysdeps/ieee754/ldbl-128/s_llrintl.c b/sysdeps/ieee754/ldbl-128/s_llrintl.c index 07f5aca347e..d9283eab3ea 100644 --- a/sysdeps/ieee754/ldbl-128/s_llrintl.c +++ b/sysdeps/ieee754/ldbl-128/s_llrintl.c @@ -24,7 +24,6 @@ #include #include #include -#include long long int diff --git a/sysdeps/ieee754/ldbl-128/s_logbl.c b/sysdeps/ieee754/ldbl-128/s_logbl.c index 59b08aa2955..7927155cac3 100644 --- a/sysdeps/ieee754/ldbl-128/s_logbl.c +++ b/sysdeps/ieee754/ldbl-128/s_logbl.c @@ -25,7 +25,6 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include -#include _Float128 __logbl (_Float128 x) diff --git a/sysdeps/ieee754/ldbl-128/s_lrintl.c b/sysdeps/ieee754/ldbl-128/s_lrintl.c index e5c0d5adb87..027400d1371 100644 --- a/sysdeps/ieee754/ldbl-128/s_lrintl.c +++ b/sysdeps/ieee754/ldbl-128/s_lrintl.c @@ -24,7 +24,6 @@ #include #include #include -#include long int diff --git a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c index d76d0155ad2..8e2b5bd1fa1 100644 --- a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c +++ b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c @@ -27,7 +27,6 @@ #include #include #include -#include _Float128 __nearbyintl (_Float128 x) diff --git a/sysdeps/ieee754/ldbl-128/s_rintl.c b/sysdeps/ieee754/ldbl-128/s_rintl.c index 072ed8ec15e..7badd06e85d 100644 --- a/sysdeps/ieee754/ldbl-128/s_rintl.c +++ b/sysdeps/ieee754/ldbl-128/s_rintl.c @@ -30,7 +30,6 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include -#include _Float128 __rintl (_Float128 x) diff --git a/sysdeps/ieee754/ldbl-128/s_roundevenl.c b/sysdeps/ieee754/ldbl-128/s_roundevenl.c index ca3a5527cd9..0f935f63dde 100644 --- a/sysdeps/ieee754/ldbl-128/s_roundevenl.c +++ b/sysdeps/ieee754/ldbl-128/s_roundevenl.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #define BIAS 0x3fff diff --git a/sysdeps/ieee754/ldbl-128/s_roundl.c b/sysdeps/ieee754/ldbl-128/s_roundl.c index 9a87a463e89..c5e70f33a84 100644 --- a/sysdeps/ieee754/ldbl-128/s_roundl.c +++ b/sysdeps/ieee754/ldbl-128/s_roundl.c @@ -21,7 +21,6 @@ #include #include -#include _Float128 diff --git a/sysdeps/ieee754/ldbl-128/s_truncl.c b/sysdeps/ieee754/ldbl-128/s_truncl.c index 2db087e85b3..f4c6415521e 100644 --- a/sysdeps/ieee754/ldbl-128/s_truncl.c +++ b/sysdeps/ieee754/ldbl-128/s_truncl.c @@ -21,7 +21,6 @@ #include #include -#include _Float128 diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c b/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c index 7f26315e842..fabe08f0b3a 100644 --- a/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c +++ b/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c @@ -24,7 +24,6 @@ static char rcsid[] = "$NetBSD: $"; #include #include #include -#include long double __fabsl(long double x) { diff --git a/sysdeps/ieee754/ldbl-96/s_fabsl.c b/sysdeps/ieee754/ldbl-96/s_fabsl.c index 9891bb3a023..19bcf089b37 100644 --- a/sysdeps/ieee754/ldbl-96/s_fabsl.c +++ b/sysdeps/ieee754/ldbl-96/s_fabsl.c @@ -18,7 +18,6 @@ #include #include -#include long double __fabsl (long double x) diff --git a/sysdeps/mips/fpu/math-use-builtins-fma.h b/sysdeps/mips/fpu/math-use-builtins-fma.h index 06e97922aa0..bc65da7429e 100644 --- a/sysdeps/mips/fpu/math-use-builtins-fma.h +++ b/sysdeps/mips/fpu/math-use-builtins-fma.h @@ -19,7 +19,7 @@ ISA, double support can be subsetted. Only FMAF is enabled for this case. */ -#include +#include #if __mips_isa_rev >= 6 # ifdef __mips_single_float diff --git a/sysdeps/mips/math-use-builtins-ffs.h b/sysdeps/mips/math-use-builtins-ffs.h index 2ab6a03a168..4a3b432527a 100644 --- a/sysdeps/mips/math-use-builtins-ffs.h +++ b/sysdeps/mips/math-use-builtins-ffs.h @@ -1,3 +1,3 @@ -#include +#include #define USE_FFS_BUILTIN (__mips_isa_rev >= 1) #define USE_FFSLL_BUILTIN (__mips_isa_rev >= 1) diff --git a/sysdeps/mips/sgidefs.h b/sysdeps/mips/sgidefs.h index a8b31905df1..4656582782d 100644 --- a/sysdeps/mips/sgidefs.h +++ b/sysdeps/mips/sgidefs.h @@ -24,6 +24,9 @@ #undef __ASM_SGIDEFS_H #define __ASM_SGIDEFS_H +#ifndef __mips_isa_rev +# define __mips_isa_rev 0 +#endif /* * And remove any damage it might have already done */ diff --git a/sysdeps/powerpc/fpu/e_sqrt.c b/sysdeps/powerpc/fpu/e_sqrt.c index 9bac5c2bbcf..a65e8189261 100644 --- a/sysdeps/powerpc/fpu/e_sqrt.c +++ b/sysdeps/powerpc/fpu/e_sqrt.c @@ -20,7 +20,6 @@ #include #include #include -#include double __ieee754_sqrt (double x) diff --git a/sysdeps/powerpc/fpu/e_sqrtf.c b/sysdeps/powerpc/fpu/e_sqrtf.c index 7c339044495..d29a9a70173 100644 --- a/sysdeps/powerpc/fpu/e_sqrtf.c +++ b/sysdeps/powerpc/fpu/e_sqrtf.c @@ -20,7 +20,6 @@ #include #include #include -#include float __ieee754_sqrtf (float x) diff --git a/sysdeps/unix/mips/sysdep.h b/sysdeps/unix/mips/sysdep.h index 5f7706b182b..58e7aa2531b 100644 --- a/sysdeps/unix/mips/sysdep.h +++ b/sysdeps/unix/mips/sysdep.h @@ -18,9 +18,6 @@ #include #include -#ifndef __mips_isa_rev -# define __mips_isa_rev 0 -#endif #ifdef __ASSEMBLER__ diff --git a/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c b/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c index 0982280d252..9b8b951a97c 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c +++ b/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c @@ -1,6 +1,2 @@ -#include - #define __modf __modf_avx -#define trunc __trunc - #include diff --git a/sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c b/sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c index f6fb996f979..1f773863364 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c +++ b/sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c @@ -1,6 +1,2 @@ -#include - #define __modf __modf_sse41 -#define trunc __trunc - #include diff --git a/sysdeps/x86_64/fpu/multiarch/s_modff-avx.c b/sysdeps/x86_64/fpu/multiarch/s_modff-avx.c index b2afe1efe3c..488f93700c0 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_modff-avx.c +++ b/sysdeps/x86_64/fpu/multiarch/s_modff-avx.c @@ -1,6 +1,2 @@ -#include - #define __modff __modff_avx -#define truncf __truncf - #include diff --git a/sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c b/sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c index 0352c3ea4ba..8e49970ffc7 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c +++ b/sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c @@ -1,6 +1,2 @@ -#include - #define __modff __modff_sse41 -#define truncf __truncf - #include From patchwork Fri Oct 31 20:00:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123253 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4D5FC385021D for ; Fri, 31 Oct 2025 20:14:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D5FC385021D 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=VVIxrA/p X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id C09E8385040C for ; Fri, 31 Oct 2025 20:03:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C09E8385040C 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 C09E8385040C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941035; cv=none; b=AR+fw1IsXXunElns/U56ONO5JHBc4BVdhAu+K5epIfePKbiJs5rUQ6iLWnT5/HBlOa4AEx46Gu6qsBXflxwICzoidW+BPSFR0/kAceRalfRttBdH9TnjP6DVQzpU/BY+m4B7Sp9GKqqhyjAa2RezBc4+ZAJ9k/MGGHRY52IjZW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941035; c=relaxed/simple; bh=D+aL7Dwg1bRf3WSbhvVohJeqSH5ZEkWSxH/JM5pQQzQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=v8B/hV+aMGJJnQNzgovz8+LnbRf3HsTWfT7iBsR55m3VeqSZrqIDvd/iKjh/tVA2t+017GE97q85ls6xYnd639oyyPnqoRpg20x8WH4+kIvHqPryscEaXy2GH5JlOVuX+ShgQjMztl6Clqf7YouVBhgYRsjP1Ts6gVhHSAAOvGg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C09E8385040C Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-b6ceba7c97eso2413851a12.0 for ; Fri, 31 Oct 2025 13:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941033; x=1762545833; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WBUyaKTFPa2mD1bJxasThUDjwHPSUukb6a9D0d/tynk=; b=VVIxrA/poFY0HuaezC78oBlySXUwxY45wJwIKrKxczJ84TzhZJb4Zvq1SHbzryvU38 DkuEG2lU3auypQQA7NejF0FUEcUwEs1xC55AO2NxDzb0D0P99EW7t3qdWWmHNDWR99Zw d8sP2qh6UmL+sw+1sPnm7FhSFYgwXzhCXFvvh3hC5/HMyQmBC0dzPW7wMnVWwciOfjdF 5ii8603vhZ3E6SzkCM/4auZU8wKsViUjNwwvPRhIB+PslUyEhU5thfcNsoX38BR6Mrsf 4ZQm/47HuUzkFOSSZJ5If9qO5hL5wwoEITYZh6Y0p5AyeTX//GCTQ5MN4+8PV40/WCF8 z4ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941033; x=1762545833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WBUyaKTFPa2mD1bJxasThUDjwHPSUukb6a9D0d/tynk=; b=XZXoomBhGFm9L501xdThDLuwHRpdtti0Uj753jZpD5fY7LiQUsgdpLt0H6xJXRRBMT TqfuufzZnsaKtXLNl6MfRmGYuaASuwNW1KF5b/YsOAq6aHCqvUFbJjB8kEiGTV/Ludx/ BTWE4BIYwUPExiqfXyMF52xeg8eOSw0Ko6fT/T8EaIyJi3mtByAfQOKbVucEyVRBEaEy WaYqIYc3Kzln7yHt+fJf40t/zRJ68NSfSy6K4x9ypwfusEKbJFyMuGRtt9wFTE0ZdbHt 3wIxbdaoNloEiyRytrlV+3MeMc3Y745TaBpnxn4u6Tuwxr/mSls9AMiORPFna90Vc8K2 keKA== X-Gm-Message-State: AOJu0YytEbxZtnZsgsj5/3ZRtdvrk6HMbEzqVRETsqAJ/HlfObeok72G rKXd64S3pqKKKrQpR51TarFe/pZ0QoCUfzNqZbB4yZDlRuxgEcq67PIq0rqXBxklqBjIj+yU8ZQ iVKNucCM= X-Gm-Gg: ASbGncupPHGyKv5CkvrrqWONMbW6YwObjzroz3y6ZVurYMQYxsCFA8EjCnsXlaCGKez ipJXiozFc4p5ek8QzDuYHooYvjqJEPb4Pjl2nqtB4QgxUN1Ks9SsMs+/4ef4So0BEDSN4YdQLrp XmUi0+iMI09/pdPb6nklXaFg7En7cLhNw5sJEW+nPACPazZCtDHhyPpwdmDJPzPz17hpnE5wQ68 8wtAgCpOAaaKWPZazY7sI9FrIBqGLVnO8s2ujUiHY35bAntDuKD3rggh1sXDMK/rSiN25UBGIO3 XhtwlZM1aHx0pV0y3BGiVDHzzBfDF+0FRoYvxtzL+lBbTPpcoqn53Mh4f6eMoKNggbOXmGdqV+W c5CSKilhm5AYfYE4MDAseeDC2+MkQxnpYnMSVAXEU1gMKj5cgvIr2b5YYy8SPCKtW1SWrcS4EYj jnQJ73FZpvBapZ X-Google-Smtp-Source: AGHT+IFw6rfe0YbeIVDdqhjlv6VFnfFfowlGyvviKZrS5hVJgmKNuADfjNgahQumMf7throhc/q74A== X-Received: by 2002:a17:902:c408:b0:295:1a5b:f406 with SMTP id d9443c01a7336-2951a5bf436mr70293075ad.25.1761941032464; Fri, 31 Oct 2025 13:03:52 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:51 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 07/19] Handle clang -Wignored-attributes on weak aliases Date: Fri, 31 Oct 2025 17:00:40 -0300 Message-ID: <20251031200300.3716090-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 Clang issues a warning for double alias redirection, indicating that thei original symbol is used even if a weak definition attempts to override it. For instance, in the construction: int __internal_impl (...) {} weak_alias (__internal_impl, external_impl); #if SOMETHING weak_alias (external_impl, another_external_impl) #endif Clang warns that another_external_impl always resolves to __internal_impl, even if external_impl is a weak reference. Using the internal symbol for both aliases resolves this warning. This issue also occurs with certain libc_hidden_def usage: int __internal_impl (...) {} weak_alias (__internal_impl, __internal_alias) libc_hidden_weak (__internal_alias) In this case, using a strong_alias is sufficient to avoid the warning (since the alias is internal, there is no need to use a weak alias). However, for the constructions like: int __internal_impl (...) {} weak_alias (__internal_impl, __internal_alias) libc_hidden_def (__internal_alias) weak_alias (__internal_impl, external_alias) libc_hidden_def (external_alias) Clang warns that the internal external_alias will always resolve to __GI___internal_impl eve if a weak definition to __GI_internal_impl is overriden. For this case, a new macro named static_weak_alias is used to create a strong alias for SHARED, or a weak_alias otherwise. With these changes, there is no need to check and enable the -Wno-ignored-attributes suppression when using clang. --- Makefile.in | 2 - configure | 70 ------------------- configure.ac | 24 ------- dirent/Makefile | 1 - include/libc-symbols.h | 10 +++ inet/Makefile | 3 - inet/in6_addr.c | 4 +- io/Makefile | 18 +++-- io/Versions | 1 - io/lockf64.c | 2 +- libio/Makefile | 14 +--- libio/feof_u.c | 2 +- libio/ferror_u.c | 2 +- libio/fileno.c | 2 +- libio/getc_u.c | 2 +- libio/iofflush.c | 2 +- libio/iofflush_u.c | 2 +- libio/iofgets_u.c | 2 +- libio/iofputs.c | 2 +- libio/iofputs_u.c | 2 +- libio/iofwrite.c | 2 +- libio/ioputs.c | 2 +- libio/putc_u.c | 2 +- login/Makefile | 1 - misc/Makefile | 2 - misc/makedev.c | 6 +- posix/Makefile | 6 +- posix/confstr.c | 2 +- posix/fork.c | 2 +- resolv/Makefile | 1 - resolv/inet_pton.c | 2 +- resource/Makefile | 3 - socket/Makefile | 10 +-- stdio-common/Makefile | 2 - stdlib/Makefile | 12 ---- stdlib/secure-getenv.c | 2 +- stdlib/strtod_l.c | 10 +-- stdlib/strtof_l.c | 4 +- stdlib/strtol.c | 2 +- string/Makefile | 9 --- string/argz-next.c | 2 +- string/basename.c | 2 +- string/ffs.c | 2 +- string/ffsll.c | 4 +- string/memmem.c | 2 +- string/mempcpy.c | 2 +- string/test-memchr.c | 4 +- string/test-strchr.c | 4 +- string/test-strlen.c | 4 +- string/test-strnlen.c | 4 +- sysdeps/aarch64/Makefile | 1 - sysdeps/aarch64/fpu/fclrexcpt.c | 2 +- sysdeps/aarch64/fpu/fegetenv.c | 2 +- sysdeps/aarch64/fpu/fegetround.c | 2 +- sysdeps/aarch64/fpu/feholdexcpt.c | 2 +- sysdeps/aarch64/fpu/fesetenv.c | 2 +- sysdeps/aarch64/fpu/fesetround.c | 2 +- sysdeps/aarch64/fpu/feupdateenv.c | 2 +- sysdeps/aarch64/fpu/fraiseexcpt.c | 2 +- sysdeps/aarch64/fpu/ftestexcept.c | 2 +- sysdeps/arm/Makefile | 4 -- sysdeps/generic/math_ldbl_opt.h | 2 +- sysdeps/i386/i686/multiarch/wcschr-c.c | 4 +- sysdeps/ieee754/float128/s_fabsf128.c | 6 ++ sysdeps/ieee754/ldbl-128/strtold_l.c | 8 +-- sysdeps/ieee754/ldbl-96/strtold_l.c | 4 +- .../power4/multiarch/mempcpy-ppc32.c | 4 +- sysdeps/s390/wcschr-c.c | 4 +- sysdeps/unix/sysv/linux/accept.c | 2 +- sysdeps/unix/sysv/linux/connect.c | 4 +- sysdeps/unix/sysv/linux/dirfd.c | 2 +- sysdeps/unix/sysv/linux/fcntl64.c | 2 +- sysdeps/unix/sysv/linux/getlogin_r.c | 2 +- sysdeps/unix/sysv/linux/getrlimit64.c | 4 +- sysdeps/unix/sysv/linux/if_index.c | 8 +-- sysdeps/unix/sysv/linux/ifaddrs.c | 4 +- sysdeps/unix/sysv/linux/lseek64.c | 2 +- sysdeps/unix/sysv/linux/mmap64.c | 4 +- sysdeps/unix/sysv/linux/pread64.c | 2 +- sysdeps/unix/sysv/linux/pwrite64.c | 2 +- sysdeps/unix/sysv/linux/read.c | 4 +- sysdeps/unix/sysv/linux/recv.c | 4 +- sysdeps/unix/sysv/linux/send.c | 4 +- sysdeps/unix/sysv/linux/write.c | 4 +- sysdeps/wordsize-64/Makefile | 4 +- sysdeps/wordsize-64/strtol.c | 10 +-- sysdeps/wordsize-64/strtoul.c | 6 +- sysdeps/wordsize-64/wcstol.c | 6 +- sysdeps/wordsize-64/wcstoul.c | 6 +- sysdeps/x86_64/fpu/fclrexcpt.c | 2 +- sysdeps/x86_64/fpu/fegetenv.c | 2 +- sysdeps/x86_64/fpu/fegetround.c | 2 +- sysdeps/x86_64/fpu/feholdexcpt.c | 2 +- sysdeps/x86_64/fpu/fesetenv.c | 2 +- sysdeps/x86_64/fpu/fesetround.c | 2 +- sysdeps/x86_64/fpu/fraiseexcpt.c | 2 +- sysdeps/x86_64/fpu/ftestexcept.c | 2 +- sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c | 1 + sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c | 1 + sysdeps/x86_64/fpu/multiarch/s_sincos.c | 1 + sysdeps/x86_64/multiarch/mempcpy.c | 2 +- sysdeps/x86_64/multiarch/stpcpy.c | 2 +- sysdeps/x86_64/multiarch/strnlen.c | 2 +- sysdeps/x86_64/multiarch/wcschr.c | 2 +- sysdeps/x86_64/multiarch/wmemchr.c | 2 +- sysdeps/x86_64/multiarch/wmemset.c | 2 +- termios/Makefile | 1 - time/Makefile | 1 - time/mktime.c | 2 +- wcsmbs/Makefile | 24 +++---- wcsmbs/mbrtowc.c | 2 +- wcsmbs/wcrtomb.c | 2 +- wcsmbs/wcschr.c | 2 +- wcsmbs/wmemchr.c | 2 +- wcsmbs/wmemset.c | 2 +- wctype/Makefile | 2 - wctype/wcfuncs.c | 6 +- 117 files changed, 179 insertions(+), 318 deletions(-) diff --git a/Makefile.in b/Makefile.in index 15b44842ae7..e40dcbbc78b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -5,7 +5,6 @@ TEST_CXX = @TEST_CXX@ test-cc-option-wimplicit-fallthrough = @libc_cv_test_cc_wimplicit_fallthrough@ test-config-cflags-mprefer-vector-width = @libc_cv_test_cc_mprefer_vector_width@ test-config-cflags-signaling-nans = @libc_cv_test_cc_signaling_nans@ -test-config-cflags-wno-ignored-attributes = @libc_cv_test_wno_ignored_attributes@ test-cc-option-wfree-labels = @libc_cv_test_cc_wfree_labels@ test-cc-option-wmissing-parameter-name = @libc_cv_test_cc_wmissing_parameter_name@ test-enable-cet = @test_enable_cet@ @@ -26,7 +25,6 @@ check xcheck test: cc-option-wimplicit-fallthrough="$(test-cc-option-wimplicit-fallthrough)" \ config-cflags-mprefer-vector-width="$(test-config-cflags-mprefer-vector-width)" \ config-cflags-signaling-nans="$(test-config-cflags-signaling-nans)" \ - config-cflags-wno-ignored-attributes="$(test-config-cflags-wno-ignored-attributes)" \ cc-option-wfree-labels="$(test-cc-option-wfree-labels)" \ cc-option-wmissing-parameter-name="$(test-cc-option-wmissing-parameter-name)" \ enable-cet="$(test-enable-cet)" \ diff --git a/configure b/configure index 85bfeec8a90..122020db697 100755 --- a/configure +++ b/configure @@ -655,7 +655,6 @@ libc_cv_cc_loop_to_function libc_cv_test_cc_signaling_nans libc_cv_cc_submachine libc_cv_cc_nofma -libc_cv_test_wno_ignored_attributes libc_cv_has_glob_dat libc_cv_fpie libc_cv_test_static_pie @@ -7544,75 +7543,6 @@ rm -f conftest* config_vars="$config_vars have-test-mtls-traditional = $libc_cv_test_mtls_traditional" -conftest_code=" -void __foo (void) -{ -} -extern __typeof (__foo) foo __attribute__ ((weak, alias (\"__foo\"))); -extern __typeof (__foo) bar __attribute__ ((weak, alias (\"foo\"))); -" - -cat > conftest.c <&5 -printf %s "checking if -Wno-ignored-attributes is required for aliases... " >&6; } -if test ${libc_cv_wno_ignored_attributes+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -c -Werror -Wno-ignored-attributes conftest.c -o conftest 1>&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 - (eval $ac_try) 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } - then - libc_cv_wno_ignored_attributes="-Wno-ignored-attributes" - else - libc_cv_wno_ignored_attributes= - fi - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_wno_ignored_attributes" >&5 -printf "%s\n" "$libc_cv_wno_ignored_attributes" >&6; } -if test "$TEST_CC" = "$CC"; then - libc_cv_test_wno_ignored_attributes=$libc_cv_wno_ignored_attributes -else - -saved_CC="$CC" -CC="$TEST_CC" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -Wno-ignored-attributes is required for aliases in testing" >&5 -printf %s "checking if -Wno-ignored-attributes is required for aliases in testing... " >&6; } -if test ${libc_cv_test_wno_ignored_attributes+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -c -Werror -Wno-ignored-attributes conftest.c -o conftest 1>&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 - (eval $ac_try) 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } - then - libc_cv_test_wno_ignored_attributes="-Wno-ignored-attributes" - else - libc_cv_test_wno_ignored_attributes= - fi ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_wno_ignored_attributes" >&5 -printf "%s\n" "$libc_cv_test_wno_ignored_attributes" >&6; } - -CC="$saved_CC" - -fi -rm -f conftest* -config_vars="$config_vars -config-cflags-wno-ignored-attributes = $libc_cv_wno_ignored_attributes" - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wno-maybe-uninitialized" >&5 printf %s "checking for -Wno-maybe-uninitialized... " >&6; } if test ${libc_cv_wno_maybe_uninitialized+y} diff --git a/configure.ac b/configure.ac index 2cb49f49bc2..14a0f2dee89 100644 --- a/configure.ac +++ b/configure.ac @@ -1420,30 +1420,6 @@ LIBC_TRY_TEST_CC_COMMAND([for traditional tls support], LIBC_CONFIG_VAR([have-test-mtls-traditional], [$libc_cv_test_mtls_traditional]) -dnl clang emits an warning for a double alias redirection, to warn the -dnl original symbol is sed even when weak definition overrides it. -dnl It is a usual pattern for weak_alias, where multiple alias point to -dnl same symbol. -conftest_code=" -void __foo (void) -{ -} -extern __typeof (__foo) foo __attribute__ ((weak, alias (\"__foo\"))); -extern __typeof (__foo) bar __attribute__ ((weak, alias (\"foo\"))); -" -LIBC_TRY_CC_AND_TEST_CC_COMMAND([if -Wno-ignored-attributes is required for aliases], - [$conftest_code], - [-c -Werror -Wno-ignored-attributes], - libc_cv_wno_ignored_attributes, - [libc_cv_wno_ignored_attributes="-Wno-ignored-attributes"], - [libc_cv_wno_ignored_attributes=], - libc_cv_test_wno_ignored_attributes, - [libc_cv_test_wno_ignored_attributes="-Wno-ignored-attributes"], - [libc_cv_test_wno_ignored_attributes=]) -LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes], - [$libc_cv_wno_ignored_attributes]) -AC_SUBST(libc_cv_test_wno_ignored_attributes) - AC_CACHE_CHECK([for -Wno-maybe-uninitialized], libc_cv_wno_maybe_uninitialized, [dnl LIBC_TRY_CC_OPTION([-Werror -Wno-maybe-uninitialized], diff --git a/dirent/Makefile b/dirent/Makefile index f469b7f25d2..242fd4941aa 100644 --- a/dirent/Makefile +++ b/dirent/Makefile @@ -85,7 +85,6 @@ CFLAGS-scandir.c += $(uses-callbacks) CFLAGS-scandir64.c += $(uses-callbacks) CFLAGS-scandir-tail.c += $(uses-callbacks) CFLAGS-scandir64-tail.c += $(uses-callbacks) -CFLAGS-dirfd.c += $(config-cflags-wno-ignored-attributes) include ../Rules diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 2f9453e0d7b..5bee0c4311a 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -156,6 +156,16 @@ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \ __attribute_copy__ (name); +/* Define a strong_alias for SHARED, or weak_alias otherwise. It is + used to avoid potential compiler warnings with weak alias indirection + (when weak alias will always resolved to an symbol even if a weak + definition also exists). */ +# ifdef SHARED +# define static_weak_alias(name, aliasname) strong_alias (name, aliasname) +# else +# define static_weak_alias(name, aliasname) weak_alias (name, aliasname) +# endif + /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */ # define weak_extern(symbol) _weak_extern (weak symbol) # define _weak_extern(expr) _Pragma (#expr) diff --git a/inet/Makefile b/inet/Makefile index 104b5828bf2..a5729360860 100644 --- a/inet/Makefile +++ b/inet/Makefile @@ -124,9 +124,6 @@ ifeq ($(have-thread-library),yes) CFLAGS-rcmd.c += -fexceptions CFLAGS-either_ntoh.c += -fexceptions CFLAGS-either_hton.c += -fexceptions -CFLAGS-in6_addr.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-if_index.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-ifaddrs.c += $(config-cflags-wno-ignored-attributes) CFLAGS-tst-checks-posix.c += -std=c99 CFLAGS-tst-sockaddr.c += -fno-strict-aliasing diff --git a/inet/in6_addr.c b/inet/in6_addr.c index df99e4a23d3..f7f39fe3952 100644 --- a/inet/in6_addr.c +++ b/inet/in6_addr.c @@ -20,10 +20,10 @@ const struct in6_addr __in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }; libc_hidden_data_def (__in6addr_any) -weak_alias (__in6addr_any, in6addr_any) +static_weak_alias (__in6addr_any, in6addr_any) libc_hidden_data_weak (in6addr_any) const struct in6_addr __in6addr_loopback = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }; libc_hidden_data_def (__in6addr_loopback) -weak_alias (__in6addr_loopback, in6addr_loopback) +static_weak_alias (__in6addr_loopback, in6addr_loopback) libc_hidden_data_weak (in6addr_loopback) diff --git a/io/Makefile b/io/Makefile index 435f5a994f3..0810c0aa048 100644 --- a/io/Makefile +++ b/io/Makefile @@ -266,21 +266,20 @@ endif include ../Rules -CFLAGS-open.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) -CFLAGS-openat.c += $(config-cflags-wno-ignored-attributes) +CFLAGS-open.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-creat.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-creat64.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) -CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) +CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fcntl64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-poll.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-ppoll.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-lockf64.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) +CFLAGS-lockf64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-statfs.c += -fexceptions CFLAGS-fstatfs.c += -fexceptions -CFLAGS-statvfs.c += -fexceptions $(config-cflags-wno-ignored-attributes) -CFLAGS-fstatvfs.c += -fexceptions $(config-cflags-wno-ignored-attributes) +CFLAGS-statvfs.c += -fexceptions +CFLAGS-fstatvfs.c += -fexceptions CFLAGS-fts.c += -Wno-uninitialized $(uses-callbacks) -fexceptions CFLAGS-fts64.c += -Wno-uninitialized $(uses-callbacks) -fexceptions CFLAGS-fts64-time64.c += -Wno-uninitialized $(uses-callbacks) -fexceptions @@ -291,10 +290,9 @@ CFLAGS-posix_fallocate.c += -fexceptions CFLAGS-posix_fallocate64.c += -fexceptions CFLAGS-fallocate.c += -fexceptions CFLAGS-fallocate64.c += -fexceptions -CFLAGS-read.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) -CFLAGS-write.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) +CFLAGS-read.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-write.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-close.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-lseek64.c += $(config-cflags-wno-ignored-attributes) CFLAGS-tst-read-zero.c += $(no-fortify-source) -D_FORTIFY_SOURCE=$(supported-fortify) CFLAGS-test-stat.c += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE diff --git a/io/Versions b/io/Versions index 04d196eee0b..e5f297e39e8 100644 --- a/io/Versions +++ b/io/Versions @@ -138,7 +138,6 @@ libc { closefrom; } GLIBC_PRIVATE { - __libc_fcntl64; __fcntl_nocancel; __open64_nocancel; __write_nocancel; diff --git a/io/lockf64.c b/io/lockf64.c index c490730d1fd..354665cea86 100644 --- a/io/lockf64.c +++ b/io/lockf64.c @@ -58,5 +58,5 @@ __lockf64 (int fd, int cmd, off64_t len64) } weak_alias (__lockf64, lockf64) #ifdef __OFF_T_MATCHES_OFF64_T -weak_alias (lockf64, lockf) +weak_alias (__lockf64, lockf) #endif diff --git a/libio/Makefile b/libio/Makefile index 6ce669e1030..2bc98365225 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -198,18 +198,18 @@ CFLAGS-getchar.c += -fexceptions CFLAGS-getwc.c += -fexceptions CFLAGS-getwchar.c += -fexceptions CFLAGS-iofclose.c += -fexceptions -CFLAGS-iofflush.c += -fexceptions $(config-cflags-wno-ignored-attributes) +CFLAGS-iofflush.c += -fexceptions CFLAGS-iofgetpos64.c += -fexceptions CFLAGS-iofgetpos.c += -fexceptions CFLAGS-iofgets.c += -fexceptions CFLAGS-iofgetws.c += -fexceptions -CFLAGS-iofputs.c += -fexceptions $(config-cflags-wno-ignored-attributes) +CFLAGS-iofputs.c += -fexceptions CFLAGS-iofputws.c += -fexceptions CFLAGS-iofread.c += -fexceptions CFLAGS-iofsetpos64.c += -fexceptions CFLAGS-iofsetpos.c += -fexceptions CFLAGS-ioftell.c += -fexceptions -CFLAGS-iofwrite.c += -fexceptions $(config-cflags-wno-ignored-attributes) +CFLAGS-iofwrite.c += -fexceptions CFLAGS-iogetdelim.c += -fexceptions CFLAGS-iogetline.c += -fexceptions CFLAGS-iogets.c += -fexceptions @@ -239,14 +239,6 @@ CFLAGS-oldiofopen.c += -fexceptions CFLAGS-iofopen.c += -fexceptions CFLAGS-iofopen64.c += -fexceptions CFLAGS-oldtmpfile.c += -fexceptions -CFLAGS-fileno.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-feof_u.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-ferror_u.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-getc_u.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-iofflush_u.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-putc_u.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-iofgets_u.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-iofputs_u.c += $(config-cflags-wno-ignored-attributes) # XXX Do we need filedoalloc and wfiledoalloc? Others? # Prevent fortification as these are built with -O0 diff --git a/libio/feof_u.c b/libio/feof_u.c index 4d2babe3626..36a1e5b6286 100644 --- a/libio/feof_u.c +++ b/libio/feof_u.c @@ -35,5 +35,5 @@ __feof_unlocked (FILE *fp) CHECK_FILE (fp, EOF); return _IO_feof_unlocked (fp); } -weak_alias (__feof_unlocked, feof_unlocked) +static_weak_alias (__feof_unlocked, feof_unlocked) libc_hidden_weak (feof_unlocked) diff --git a/libio/ferror_u.c b/libio/ferror_u.c index 0e19e0c198b..d81facfac4d 100644 --- a/libio/ferror_u.c +++ b/libio/ferror_u.c @@ -35,5 +35,5 @@ __ferror_unlocked (FILE *fp) CHECK_FILE (fp, EOF); return _IO_ferror_unlocked (fp); } -weak_alias (__ferror_unlocked, ferror_unlocked) +static_weak_alias (__ferror_unlocked, ferror_unlocked) libc_hidden_weak (ferror_unlocked) diff --git a/libio/fileno.c b/libio/fileno.c index d1e945f5494..d580582b4d9 100644 --- a/libio/fileno.c +++ b/libio/fileno.c @@ -41,7 +41,7 @@ __fileno (FILE *fp) return _IO_fileno (fp); } libc_hidden_def (__fileno) -weak_alias (__fileno, fileno) +static_weak_alias (__fileno, fileno) libc_hidden_weak (fileno) /* The fileno implementation for libio does not require locking because diff --git a/libio/getc_u.c b/libio/getc_u.c index cfd052d7c2d..ea57c7d0492 100644 --- a/libio/getc_u.c +++ b/libio/getc_u.c @@ -36,6 +36,6 @@ __getc_unlocked (FILE *fp) return _IO_getc_unlocked (fp); } -weak_alias (__getc_unlocked, getc_unlocked) +static_weak_alias (__getc_unlocked, getc_unlocked) libc_hidden_weak (getc_unlocked) weak_alias (__getc_unlocked, fgetc_unlocked) diff --git a/libio/iofflush.c b/libio/iofflush.c index 3683c93e155..6165493c315 100644 --- a/libio/iofflush.c +++ b/libio/iofflush.c @@ -44,7 +44,7 @@ _IO_fflush (FILE *fp) } libc_hidden_def (_IO_fflush) -weak_alias (_IO_fflush, fflush) +static_weak_alias (_IO_fflush, fflush) libc_hidden_weak (fflush) #ifndef _IO_MTSAFE_IO diff --git a/libio/iofflush_u.c b/libio/iofflush_u.c index cd9e4afd803..5690db5a446 100644 --- a/libio/iofflush_u.c +++ b/libio/iofflush_u.c @@ -39,5 +39,5 @@ __fflush_unlocked (FILE *fp) } } libc_hidden_def (__fflush_unlocked) -weak_alias (__fflush_unlocked, fflush_unlocked) +static_weak_alias (__fflush_unlocked, fflush_unlocked) libc_hidden_weak (fflush_unlocked) diff --git a/libio/iofgets_u.c b/libio/iofgets_u.c index b9ac6b9640d..86e6ca55b72 100644 --- a/libio/iofgets_u.c +++ b/libio/iofgets_u.c @@ -63,5 +63,5 @@ __fgets_unlocked (char *buf, int n, FILE *fp) return result; } libc_hidden_def (__fgets_unlocked) -weak_alias (__fgets_unlocked, fgets_unlocked) +static_weak_alias (__fgets_unlocked, fgets_unlocked) libc_hidden_weak (fgets_unlocked) diff --git a/libio/iofputs.c b/libio/iofputs.c index 0a7e0b4b3ec..f90830f7516 100644 --- a/libio/iofputs.c +++ b/libio/iofputs.c @@ -42,7 +42,7 @@ _IO_fputs (const char *str, FILE *fp) } libc_hidden_def (_IO_fputs) -weak_alias (_IO_fputs, fputs) +static_weak_alias (_IO_fputs, fputs) libc_hidden_weak (fputs) # ifndef _IO_MTSAFE_IO diff --git a/libio/iofputs_u.c b/libio/iofputs_u.c index b283f488e89..dc4bd555148 100644 --- a/libio/iofputs_u.c +++ b/libio/iofputs_u.c @@ -39,5 +39,5 @@ __fputs_unlocked (const char *str, FILE *fp) return result; } libc_hidden_def (__fputs_unlocked) -weak_alias (__fputs_unlocked, fputs_unlocked) +static_weak_alias (__fputs_unlocked, fputs_unlocked) libc_hidden_weak (fputs_unlocked) diff --git a/libio/iofwrite.c b/libio/iofwrite.c index 7897c4afaf8..c88c91a4d49 100644 --- a/libio/iofwrite.c +++ b/libio/iofwrite.c @@ -79,7 +79,7 @@ _IO_fwrite (const void *buf, size_t size, size_t count, FILE *fp) libc_hidden_def (_IO_fwrite) # include -weak_alias (_IO_fwrite, fwrite) +static_weak_alias (_IO_fwrite, fwrite) libc_hidden_weak (fwrite) # ifndef _IO_MTSAFE_IO weak_alias (_IO_fwrite, fwrite_unlocked) diff --git a/libio/ioputs.c b/libio/ioputs.c index 8baf5021857..3e57e319d06 100644 --- a/libio/ioputs.c +++ b/libio/ioputs.c @@ -45,5 +45,5 @@ _IO_puts (const char *str) return result; } -weak_alias (_IO_puts, puts) +static_weak_alias (_IO_puts, puts) libc_hidden_def (_IO_puts) diff --git a/libio/putc_u.c b/libio/putc_u.c index 609ef42b6a7..d8f1562eb41 100644 --- a/libio/putc_u.c +++ b/libio/putc_u.c @@ -26,5 +26,5 @@ __putc_unlocked (int c, FILE *fp) CHECK_FILE (fp, EOF); return _IO_putc_unlocked (c, fp); } -weak_alias (__putc_unlocked, putc_unlocked) +static_weak_alias (__putc_unlocked, putc_unlocked) libc_hidden_weak (putc_unlocked) diff --git a/login/Makefile b/login/Makefile index d6a9a6975e7..e6b5a1fff45 100644 --- a/login/Makefile +++ b/login/Makefile @@ -110,7 +110,6 @@ endif # $(have-GLIBC_2.33) include ../Rules CFLAGS-getpt.c += -fexceptions -CFLAGS-getlogin_r.c += $(config-cflags-wno-ignored-attributes) # Exclude fortified routines from being built with _FORTIFY_SOURCE routines_no_fortify += \ diff --git a/misc/Makefile b/misc/Makefile index e792d94ebd5..d6514ca5d31 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -341,8 +341,6 @@ CFLAGS-tst-tsearch.c += $(stack-align-test-flags) CFLAGS-msync.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-fdatasync.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-fsync.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-makedev.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-mmap64.c += $(config-cflags-wno-ignored-attributes) # Called during static library initialization, so turn stack-protection # off for non-shared builds. diff --git a/misc/makedev.c b/misc/makedev.c index e7a0029f1de..3ad6dcb0aa6 100644 --- a/misc/makedev.c +++ b/misc/makedev.c @@ -26,11 +26,11 @@ rtype __gnu_dev_##name proto __SYSMACROS_DEFINE_MAJOR(OUT_OF_LINE_IMPL_TEMPL) -weak_alias (__gnu_dev_major, gnu_dev_major) +static_weak_alias (__gnu_dev_major, gnu_dev_major) libc_hidden_weak (gnu_dev_major) __SYSMACROS_DEFINE_MINOR(OUT_OF_LINE_IMPL_TEMPL) -weak_alias (__gnu_dev_minor, gnu_dev_minor) +static_weak_alias (__gnu_dev_minor, gnu_dev_minor) libc_hidden_weak (gnu_dev_minor) __SYSMACROS_DEFINE_MAKEDEV(OUT_OF_LINE_IMPL_TEMPL) -weak_alias (__gnu_dev_makedev, gnu_dev_makedev) +static_weak_alias (__gnu_dev_makedev, gnu_dev_makedev) libc_hidden_weak (gnu_dev_makedev) diff --git a/posix/Makefile b/posix/Makefile index f6421e5379c..062e7fdc203 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -568,9 +568,9 @@ $(objpfx)config-name.h: $(..)scripts/config-uname.sh $(common-objpfx)config.make CFLAGS-pause.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) +CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-pwrite.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-pwrite64.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) +CFLAGS-pwrite64.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-sleep.c += -fexceptions CFLAGS-wait.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-waitid.c += -fexceptions -fasynchronous-unwind-tables @@ -599,7 +599,7 @@ CFLAGS-execl.os = -fomit-frame-pointer CFLAGS-execvp.os = -fomit-frame-pointer CFLAGS-execlp.os = -fomit-frame-pointer CFLAGS-nanosleep.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-fork.c = $(libio-mtsafe) $(config-cflags-wno-ignored-attributes) +CFLAGS-fork.c = $(libio-mtsafe) tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \ --none random --col --color --colour diff --git a/posix/confstr.c b/posix/confstr.c index 415905b269f..1f41e14193b 100644 --- a/posix/confstr.c +++ b/posix/confstr.c @@ -291,4 +291,4 @@ __confstr (int name, char *buf, size_t len) } libc_hidden_def (__confstr) libc_hidden_def (confstr) -weak_alias (__confstr, confstr) +static_weak_alias (__confstr, confstr) diff --git a/posix/fork.c b/posix/fork.c index 011e92fc1da..dfd413051ec 100644 --- a/posix/fork.c +++ b/posix/fork.c @@ -137,6 +137,6 @@ __libc_fork (void) return pid; } -weak_alias (__libc_fork, __fork) +strong_alias (__libc_fork, __fork) libc_hidden_def (__fork) weak_alias (__libc_fork, fork) diff --git a/resolv/Makefile b/resolv/Makefile index ebb06cb14aa..d294c3f3fca 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -249,7 +249,6 @@ LOCALES := en_US.UTF-8 en_US.ISO-8859-1 include ../gen-locales.mk CFLAGS-res_hconf.c += -fexceptions -CFLAGS-inet_pton.c += $(config-cflags-wno-ignored-attributes) # The DNS NSS modules needs the resolver. $(objpfx)libnss_dns.so: $(objpfx)libresolv.so diff --git a/resolv/inet_pton.c b/resolv/inet_pton.c index 5307a5b243a..901bc3fb545 100644 --- a/resolv/inet_pton.c +++ b/resolv/inet_pton.c @@ -43,5 +43,5 @@ __inet_pton (int af, const char *src, void *dst) return __inet_pton_length (af, src, strlen (src), dst); } libc_hidden_def (__inet_pton) -weak_alias (__inet_pton, inet_pton) +static_weak_alias (__inet_pton, inet_pton) libc_hidden_weak (inet_pton) diff --git a/resource/Makefile b/resource/Makefile index 9b4998107ff..55982ebeed1 100644 --- a/resource/Makefile +++ b/resource/Makefile @@ -32,6 +32,3 @@ tests := \ include ../Rules - -CFLAGS-getrlimit64.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-getrlimit.c += $(config-cflags-wno-ignored-attributes) diff --git a/socket/Makefile b/socket/Makefile index 70fd4138b93..bc395796820 100644 --- a/socket/Makefile +++ b/socket/Makefile @@ -87,11 +87,11 @@ aux := sa_len include ../Rules -CFLAGS-recv.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) +CFLAGS-recv.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-recvfrom.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-sendto.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-recvmsg.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-sendmsg.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) -CFLAGS-send.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) -CFLAGS-connect.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) -CFLAGS-accept.c += -fexceptions -fasynchronous-unwind-tables $(config-cflags-wno-ignored-attributes) +CFLAGS-sendmsg.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-send.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-connect.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-accept.c += -fexceptions -fasynchronous-unwind-tables diff --git a/stdio-common/Makefile b/stdio-common/Makefile index cb816de3359..ddffe653e90 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -717,8 +717,6 @@ CFLAGS-isoc23_vscanf.c += -fexceptions CFLAGS-isoc23_fscanf.c += -fexceptions CFLAGS-isoc23_scanf.c += -fexceptions -CFLAGS-dprintf.c += $(config-cflags-wno-ignored-attributes) - # Called during static library initialization, so turn stack-protection # off for non-shared builds. CFLAGS-_itoa.o = $(no-stack-protector) diff --git a/stdlib/Makefile b/stdlib/Makefile index 02ad6d17fb0..eac764f5845 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -542,18 +542,6 @@ CFLAGS-strfromd.c += $(libio-mtsafe) CFLAGS-strfromf.c += $(libio-mtsafe) CFLAGS-strfroml.c += $(libio-mtsafe) -CFLAGS-strtol.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtoul.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtoll.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtoull.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtof.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtof_l.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtod.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtod_l.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtold.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strtold_l.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-secure-getenv.c += $(config-cflags-wno-ignored-attributes) - CFLAGS-tst-bsearch.c += $(stack-align-test-flags) CFLAGS-tst-qsort.c += $(stack-align-test-flags) CFLAGS-tst-makecontext.c += -funwind-tables diff --git a/stdlib/secure-getenv.c b/stdlib/secure-getenv.c index a2408a304f9..b16efcb40eb 100644 --- a/stdlib/secure-getenv.c +++ b/stdlib/secure-getenv.c @@ -29,7 +29,7 @@ __libc_secure_getenv (const char *name) return __libc_enable_secure ? NULL : getenv (name); } weak_alias (__libc_secure_getenv, secure_getenv) -libc_hidden_weak (__libc_secure_getenv) +libc_hidden_def (__libc_secure_getenv) #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_17) compat_symbol (libc, __libc_secure_getenv, __secure_getenv, GLIBC_2_0); diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c index d00a336589d..3988049f7ee 100644 --- a/stdlib/strtod_l.c +++ b/stdlib/strtod_l.c @@ -1785,7 +1785,7 @@ __STRTOF (const STRING_TYPE *nptr, STRING_TYPE **endptr, locale_t loc) libc_hidden_def (__STRTOF) libc_hidden_ver (__STRTOF, STRTOF) #endif -weak_alias (__STRTOF, STRTOF) +static_weak_alias (__STRTOF, STRTOF) #ifdef LONG_DOUBLE_COMPAT # if LONG_DOUBLE_COMPAT(libc, GLIBC_2_1) @@ -1809,18 +1809,18 @@ compat_symbol (libc, strtod_l, strtold_l, GLIBC_2_3); # undef strtof64_l # undef wcstof64_l # ifdef USE_WIDE_CHAR -weak_alias (wcstod_l, wcstof64_l) +weak_alias (__wcstod_l, wcstof64_l) # else -weak_alias (strtod_l, strtof64_l) +weak_alias (__strtod_l, strtof64_l) # endif # endif # if __HAVE_FLOAT32X && !__HAVE_DISTINCT_FLOAT32X # undef strtof32x_l # undef wcstof32x_l # ifdef USE_WIDE_CHAR -weak_alias (wcstod_l, wcstof32x_l) +weak_alias (__wcstod_l, wcstof32x_l) # else -weak_alias (strtod_l, strtof32x_l) +weak_alias (__strtod_l, strtof32x_l) # endif # endif #endif diff --git a/stdlib/strtof_l.c b/stdlib/strtof_l.c index 2ec5f576cfb..966db79725b 100644 --- a/stdlib/strtof_l.c +++ b/stdlib/strtof_l.c @@ -47,8 +47,8 @@ extern float ____strtof_l_internal (const char *, char **, int, locale_t); # undef strtof32_l # undef wcstof32_l # ifdef USE_WIDE_CHAR -weak_alias (wcstof_l, wcstof32_l) +weak_alias (__wcstof_l, wcstof32_l) # else -weak_alias (strtof_l, strtof32_l) +weak_alias (__strtof_l, strtof32_l) # endif #endif diff --git a/stdlib/strtol.c b/stdlib/strtol.c index 155bfe166d4..5b4e9d1cd9b 100644 --- a/stdlib/strtol.c +++ b/stdlib/strtol.c @@ -117,7 +117,7 @@ __strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, int base) return INTERNAL (__strtol_l) (nptr, endptr, base, 0, false, _NL_CURRENT_LOCALE); } -weak_alias (__strtol, strtol) +static_weak_alias (__strtol, strtol) libc_hidden_weak (strtol) INT diff --git a/string/Makefile b/string/Makefile index d842ae04570..2f30e66df58 100644 --- a/string/Makefile +++ b/string/Makefile @@ -285,15 +285,6 @@ CFLAGS-wordcopy.c += $(no-stack-protector) CFLAGS-strncmp.c += $(no-stack-protector) CFLAGS-memset.c += $(no-stack-protector) -CFLAGS-argz-next.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-basename.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-ffs.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-memmem.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-memchr.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-mempcpy.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-stpcpy.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-strnlen.c += $(config-cflags-wno-ignored-attributes) - ifeq ($(run-built-tests),yes) $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out cmp $^ > $@; \ diff --git a/string/argz-next.c b/string/argz-next.c index aac67a9d1c5..be567cf5736 100644 --- a/string/argz-next.c +++ b/string/argz-next.c @@ -36,5 +36,5 @@ __argz_next (const char *argz, size_t argz_len, const char *entry) return NULL; } libc_hidden_def (__argz_next) -weak_alias (__argz_next, argz_next) +static_weak_alias (__argz_next, argz_next) libc_hidden_weak (argz_next) diff --git a/string/basename.c b/string/basename.c index dd2c8182dbc..ca45ca8ae92 100644 --- a/string/basename.c +++ b/string/basename.c @@ -25,5 +25,5 @@ __basename (const char *filename) return p ? p + 1 : (char *) filename; } libc_hidden_def (__basename) -weak_alias (__basename, basename) +static_weak_alias (__basename, basename) libc_hidden_weak (basename) diff --git a/string/ffs.c b/string/ffs.c index a2aa5b1242d..7010059833e 100644 --- a/string/ffs.c +++ b/string/ffs.c @@ -47,7 +47,7 @@ __ffs (int i) return table[x >> a] + a; #endif } -weak_alias (__ffs, ffs) +static_weak_alias (__ffs, ffs) libc_hidden_def (__ffs) libc_hidden_builtin_def (ffs) diff --git a/string/ffsll.c b/string/ffsll.c index 1b01d8fb122..6794de1c2a5 100644 --- a/string/ffsll.c +++ b/string/ffsll.c @@ -37,9 +37,9 @@ __ffsll (long long int i) return 32 + ffs (i >> 32); #endif } -weak_alias (__ffsll, ffsll) +static_weak_alias (__ffsll, ffsll) #if ULONG_MAX != UINT_MAX #undef ffsl -weak_alias (ffsll, ffsl) +static_weak_alias (__ffsll, ffsl) #endif diff --git a/string/memmem.c b/string/memmem.c index 8d9b7d196e0..febb50b605e 100644 --- a/string/memmem.c +++ b/string/memmem.c @@ -125,5 +125,5 @@ __memmem (const void *haystack, size_t hs_len, return NULL; } libc_hidden_def (__memmem) -weak_alias (__memmem, memmem) +static_weak_alias (__memmem, memmem) libc_hidden_weak (memmem) diff --git a/string/mempcpy.c b/string/mempcpy.c index efbc9d42f15..1199f124ede 100644 --- a/string/mempcpy.c +++ b/string/mempcpy.c @@ -35,5 +35,5 @@ MEMPCPY (void *dest, const void *src, size_t len) return memcpy (dest, src, len) + len; } libc_hidden_def (__mempcpy) -weak_alias (__mempcpy, mempcpy) +static_weak_alias (__mempcpy, mempcpy) libc_hidden_builtin_def (mempcpy) diff --git a/string/test-memchr.c b/string/test-memchr.c index aaf9a6db298..fbfcd4d17d4 100644 --- a/string/test-memchr.c +++ b/string/test-memchr.c @@ -47,8 +47,8 @@ IMPL (MEMCHR, 1) /* Also check the generic implementation. */ #undef MEMCHR -#undef weak_alias -#define weak_alias(a, b) +#undef static_weak_alias +#define static_weak_alias(a, b) #undef libc_hidden_builtin_def #define libc_hidden_builtin_def(a) #undef libc_hidden_def diff --git a/string/test-strchr.c b/string/test-strchr.c index 765d69ecc21..8ea4335ac09 100644 --- a/string/test-strchr.c +++ b/string/test-strchr.c @@ -74,8 +74,8 @@ IMPL (STRCHR, 1) /* Also check the generic implementation. */ #undef STRCHR -#undef weak_alias -#define weak_alias(a, b) +#undef static_weak_alias +#define static_weak_alias(a, b) #undef libc_hidden_builtin_def #define libc_hidden_builtin_def(a) #undef libc_hidden_def diff --git a/string/test-strlen.c b/string/test-strlen.c index 03a8969e54e..2b85fc421a0 100644 --- a/string/test-strlen.c +++ b/string/test-strlen.c @@ -41,8 +41,8 @@ IMPL (STRLEN, 1) /* Also check the generic implementation. */ #undef STRLEN -#undef weak_alias -#define weak_alias(a, b) +#undef static_weak_alias +#define static_weak_alias(a, b) #undef libc_hidden_builtin_def #define libc_hidden_builtin_def(a) #ifndef WIDE diff --git a/string/test-strnlen.c b/string/test-strnlen.c index acb1c055fc1..29d291e66fb 100644 --- a/string/test-strnlen.c +++ b/string/test-strnlen.c @@ -47,7 +47,7 @@ typedef size_t (*proto_t) (const CHAR *, size_t); #undef STRNLEN #ifndef WIDE # define MEMCHR __memchr_default -# define weak_alias(a, b) +# define static_weak_alias(a, b) # define libc_hidden_def(a) # define libc_hidden_builtin_def(a) # include "string/memchr.c" @@ -58,7 +58,7 @@ typedef size_t (*proto_t) (const CHAR *, size_t); IMPL (__strnlen_default, 1) #else # define WMEMCHR __wmemchr_default -# define weak_alias(a, b) +# define static_weak_alias(a, b) # define libc_hidden_def(a) # define libc_hidden_weak(a) # include "wcsmbs/wmemchr.c" diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile index 9479fb96793..2de7a4cfe98 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -66,7 +66,6 @@ endif ifeq ($(subdir),math) CPPFLAGS += -I../soft-fp -CFLAGS-feupdateenv.c += $(config-cflags-wno-ignored-attributes) endif ifeq ($(subdir),misc) diff --git a/sysdeps/aarch64/fpu/fclrexcpt.c b/sysdeps/aarch64/fpu/fclrexcpt.c index 21eb731e292..9f6fc8dd03c 100644 --- a/sysdeps/aarch64/fpu/fclrexcpt.c +++ b/sysdeps/aarch64/fpu/fclrexcpt.c @@ -35,6 +35,6 @@ __feclearexcept (int excepts) return 0; } -weak_alias (__feclearexcept, feclearexcept) +static_weak_alias (__feclearexcept, feclearexcept) libm_hidden_def (__feclearexcept) libm_hidden_def (feclearexcept) diff --git a/sysdeps/aarch64/fpu/fegetenv.c b/sysdeps/aarch64/fpu/fegetenv.c index eb8117c61d8..76f68e77ef5 100644 --- a/sysdeps/aarch64/fpu/fegetenv.c +++ b/sysdeps/aarch64/fpu/fegetenv.c @@ -31,5 +31,5 @@ __fegetenv (fenv_t *envp) return 0; } libm_hidden_def (__fegetenv) -weak_alias (__fegetenv, fegetenv) +static_weak_alias (__fegetenv, fegetenv) libm_hidden_weak (fegetenv) diff --git a/sysdeps/aarch64/fpu/fegetround.c b/sysdeps/aarch64/fpu/fegetround.c index d6758c9879a..f5db20165fe 100644 --- a/sysdeps/aarch64/fpu/fegetround.c +++ b/sysdeps/aarch64/fpu/fegetround.c @@ -25,5 +25,5 @@ __fegetround (void) return get_rounding_mode (); } libm_hidden_def (__fegetround) -weak_alias (__fegetround, fegetround) +static_weak_alias (__fegetround, fegetround) libm_hidden_weak (fegetround) diff --git a/sysdeps/aarch64/fpu/feholdexcpt.c b/sysdeps/aarch64/fpu/feholdexcpt.c index 79ae5494c67..f1d6ef54e79 100644 --- a/sysdeps/aarch64/fpu/feholdexcpt.c +++ b/sysdeps/aarch64/fpu/feholdexcpt.c @@ -26,5 +26,5 @@ __feholdexcept (fenv_t *envp) return 0; } libm_hidden_def (__feholdexcept) -weak_alias (__feholdexcept, feholdexcept) +static_weak_alias (__feholdexcept, feholdexcept) libm_hidden_weak (feholdexcept) diff --git a/sysdeps/aarch64/fpu/fesetenv.c b/sysdeps/aarch64/fpu/fesetenv.c index 6a0df368c85..9c1d2114d00 100644 --- a/sysdeps/aarch64/fpu/fesetenv.c +++ b/sysdeps/aarch64/fpu/fesetenv.c @@ -74,5 +74,5 @@ __fesetenv (const fenv_t *envp) return 0; } libm_hidden_def (__fesetenv) -weak_alias (__fesetenv, fesetenv) +static_weak_alias (__fesetenv, fesetenv) libm_hidden_weak (fesetenv) diff --git a/sysdeps/aarch64/fpu/fesetround.c b/sysdeps/aarch64/fpu/fesetround.c index cd0c3bcfed8..f00437ab5b2 100644 --- a/sysdeps/aarch64/fpu/fesetround.c +++ b/sysdeps/aarch64/fpu/fesetround.c @@ -30,5 +30,5 @@ __fesetround (int round) return 0; } libm_hidden_def (__fesetround) -weak_alias (__fesetround, fesetround) +static_weak_alias (__fesetround, fesetround) libm_hidden_weak (fesetround) diff --git a/sysdeps/aarch64/fpu/feupdateenv.c b/sysdeps/aarch64/fpu/feupdateenv.c index 4690e84f21b..6117a464430 100644 --- a/sysdeps/aarch64/fpu/feupdateenv.c +++ b/sysdeps/aarch64/fpu/feupdateenv.c @@ -85,5 +85,5 @@ __feupdateenv (const fenv_t *envp) return 0; } libm_hidden_def (__feupdateenv) -weak_alias (__feupdateenv, feupdateenv) +static_weak_alias (__feupdateenv, feupdateenv) libm_hidden_weak (feupdateenv) diff --git a/sysdeps/aarch64/fpu/fraiseexcpt.c b/sysdeps/aarch64/fpu/fraiseexcpt.c index 518a6eb3210..9440339c93f 100644 --- a/sysdeps/aarch64/fpu/fraiseexcpt.c +++ b/sysdeps/aarch64/fpu/fraiseexcpt.c @@ -90,5 +90,5 @@ __feraiseexcept (int excepts) return 0; } libm_hidden_def (__feraiseexcept) -weak_alias (__feraiseexcept, feraiseexcept) +static_weak_alias (__feraiseexcept, feraiseexcept) libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/aarch64/fpu/ftestexcept.c b/sysdeps/aarch64/fpu/ftestexcept.c index f057616f7f8..46150510da8 100644 --- a/sysdeps/aarch64/fpu/ftestexcept.c +++ b/sysdeps/aarch64/fpu/ftestexcept.c @@ -25,5 +25,5 @@ __fetestexcept (int excepts) return libc_fetestexcept_aarch64 (excepts); } libm_hidden_def (__fetestexcept) -weak_alias (__fetestexcept, fetestexcept) +static_weak_alias (__fetestexcept, fetestexcept) libm_hidden_def (fetestexcept) diff --git a/sysdeps/arm/Makefile b/sysdeps/arm/Makefile index 9c4fd6b2369..d08dade3c5b 100644 --- a/sysdeps/arm/Makefile +++ b/sysdeps/arm/Makefile @@ -54,10 +54,6 @@ ifeq ($(subdir),gmon) sysdep_routines += arm-mcount endif -ifeq ($(subdir),math) -CFLAGS-feupdateenv.c += $(config-cflags-wno-ignored-attributes) -endif - ifeq ($(subdir),rt) librt-sysdep_routines += rt-aeabi_unwind_cpp_pr1 rt-arm-unwind-resume librt-shared-only-routines += rt-aeabi_unwind_cpp_pr1 rt-arm-unwind-resume diff --git a/sysdeps/generic/math_ldbl_opt.h b/sysdeps/generic/math_ldbl_opt.h index fbd2c82e2f5..0a14c723ca1 100644 --- a/sysdeps/generic/math_ldbl_opt.h +++ b/sysdeps/generic/math_ldbl_opt.h @@ -12,6 +12,6 @@ #define long_double_symbol(lib, local, symbol) #define ldbl_hidden_def(local, name) libc_hidden_def (name) #define ldbl_strong_alias(name, aliasname) strong_alias (name, aliasname) -#define ldbl_weak_alias(name, aliasname) weak_alias (name, aliasname) +#define ldbl_weak_alias(name, aliasname) static_weak_alias (name, aliasname) #define ldbl_compat_symbol(lib, local, symbol, version) \ compat_symbol (lib, local, symbol, version) diff --git a/sysdeps/i386/i686/multiarch/wcschr-c.c b/sysdeps/i386/i686/multiarch/wcschr-c.c index 38d41d04de0..f99a3486241 100644 --- a/sysdeps/i386/i686/multiarch/wcschr-c.c +++ b/sysdeps/i386/i686/multiarch/wcschr-c.c @@ -4,8 +4,8 @@ # undef libc_hidden_weak # define libc_hidden_weak(name) -# undef weak_alias -# define weak_alias(name,alias) +# undef static_weak_alias +# define static_weak_alias(name,alias) # ifdef SHARED # undef libc_hidden_def diff --git a/sysdeps/ieee754/float128/s_fabsf128.c b/sysdeps/ieee754/float128/s_fabsf128.c index 79ba47c3fd7..2c1f277653e 100644 --- a/sysdeps/ieee754/float128/s_fabsf128.c +++ b/sysdeps/ieee754/float128/s_fabsf128.c @@ -1,2 +1,8 @@ #include +#ifndef __USE_EXTERN_INLINES +# undef libm_alias_float128_r +# define libm_alias_float128_r(from, to, r) \ + static_weak_alias (from ## f128 ## r, to ## f128 ## r); \ + libm_alias_float128_other_r (from, to, r) +#endif #include "../ldbl-128/s_fabsl.c" diff --git a/sysdeps/ieee754/ldbl-128/strtold_l.c b/sysdeps/ieee754/ldbl-128/strtold_l.c index 64f14c11c7d..3366040c77e 100644 --- a/sysdeps/ieee754/ldbl-128/strtold_l.c +++ b/sysdeps/ieee754/ldbl-128/strtold_l.c @@ -50,9 +50,9 @@ # undef strtof128_l # undef wcstof128_l # ifdef USE_WIDE_CHAR -weak_alias (wcstold_l, wcstof128_l) +weak_alias (__wcstold_l, wcstof128_l) # else -weak_alias (strtold_l, strtof128_l) +weak_alias (__strtold_l, strtof128_l) # endif #endif @@ -60,8 +60,8 @@ weak_alias (strtold_l, strtof128_l) # undef strtof64x_l # undef wcstof64x_l # ifdef USE_WIDE_CHAR -weak_alias (wcstold_l, wcstof64x_l) +weak_alias (__wcstold_l, wcstof64x_l) # else -weak_alias (strtold_l, strtof64x_l) +weak_alias (__strtold_l, strtof64x_l) # endif #endif diff --git a/sysdeps/ieee754/ldbl-96/strtold_l.c b/sysdeps/ieee754/ldbl-96/strtold_l.c index c721ddc6960..ae6f87b44c5 100644 --- a/sysdeps/ieee754/ldbl-96/strtold_l.c +++ b/sysdeps/ieee754/ldbl-96/strtold_l.c @@ -45,8 +45,8 @@ # undef strtof64x_l # undef wcstof64x_l # ifdef USE_WIDE_CHAR -weak_alias (wcstold_l, wcstof64x_l) +static_weak_alias (__wcstold_l, wcstof64x_l) # else -weak_alias (strtold_l, strtof64x_l) +static_weak_alias (__strtold_l, strtof64x_l) # endif #endif diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c index d0bfe0da434..7ca044c213d 100644 --- a/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c +++ b/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c @@ -20,8 +20,8 @@ #undef libc_hidden_def #define libc_hidden_def(name) -#undef weak_alias -#define weak_alias(a, b) +#undef static_weak_alias +#define static_weak_alias(a, b) #if defined SHARED # undef libc_hidden_builtin_def diff --git a/sysdeps/s390/wcschr-c.c b/sysdeps/s390/wcschr-c.c index 18d6b329c20..404fcbbbb63 100644 --- a/sysdeps/s390/wcschr-c.c +++ b/sysdeps/s390/wcschr-c.c @@ -22,8 +22,8 @@ # if HAVE_WCSCHR_IFUNC || HAVE_WCSCHR_Z13 # define WCSCHR WCSCHR_C -# undef weak_alias -# define weak_alias(name, alias) +# undef static_weak_alias +# define static_weak_alias(name, alias) # if defined SHARED && IS_IN (libc) # undef libc_hidden_weak diff --git a/sysdeps/unix/sysv/linux/accept.c b/sysdeps/unix/sysv/linux/accept.c index 410b1c0bcb1..1cf84ff6ecd 100644 --- a/sysdeps/unix/sysv/linux/accept.c +++ b/sysdeps/unix/sysv/linux/accept.c @@ -30,5 +30,5 @@ __libc_accept (int fd, __SOCKADDR_ARG addr, socklen_t *len) return SOCKETCALL_CANCEL (accept, fd, addr.__sockaddr__, len); #endif } -weak_alias (__libc_accept, accept) +static_weak_alias (__libc_accept, accept) libc_hidden_def (accept) diff --git a/sysdeps/unix/sysv/linux/connect.c b/sysdeps/unix/sysv/linux/connect.c index d60dc2ef11e..dab24198fbd 100644 --- a/sysdeps/unix/sysv/linux/connect.c +++ b/sysdeps/unix/sysv/linux/connect.c @@ -28,6 +28,6 @@ __libc_connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len) return SOCKETCALL_CANCEL (connect, fd, addr.__sockaddr__, len); #endif } -weak_alias (__libc_connect, connect) -weak_alias (__libc_connect, __connect) +static_weak_alias (__libc_connect, connect) +static_weak_alias (__libc_connect, __connect) libc_hidden_weak (__connect) diff --git a/sysdeps/unix/sysv/linux/dirfd.c b/sysdeps/unix/sysv/linux/dirfd.c index 1c637c666bd..0f6b8b6a5f6 100644 --- a/sysdeps/unix/sysv/linux/dirfd.c +++ b/sysdeps/unix/sysv/linux/dirfd.c @@ -27,5 +27,5 @@ __dirfd (DIR *dirp) return dirp->fd; } -weak_alias (__dirfd, dirfd) +static_weak_alias (__dirfd, dirfd) libc_hidden_def (dirfd) diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c index 1861b18eee5..9682e4a0705 100644 --- a/sysdeps/unix/sysv/linux/fcntl64.c +++ b/sysdeps/unix/sysv/linux/fcntl64.c @@ -51,7 +51,7 @@ __libc_fcntl64 (int fd, int cmd, ...) return __fcntl64_nocancel_adjusted (fd, cmd, arg); } libc_hidden_def (__libc_fcntl64) -weak_alias (__libc_fcntl64, __fcntl64) +strong_alias (__libc_fcntl64, __fcntl64) libc_hidden_weak (__fcntl64) weak_alias (__libc_fcntl64, fcntl64) #if __TIMESIZE != 64 diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c index f03ecd4da93..d9ec2745228 100644 --- a/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/sysdeps/unix/sysv/linux/getlogin_r.c @@ -114,5 +114,5 @@ __getlogin_r (char *name, size_t namesize) return getlogin_r_fd0 (name, namesize); } libc_hidden_def (__getlogin_r) -weak_alias (__getlogin_r, getlogin_r) +static_weak_alias (__getlogin_r, getlogin_r) libc_hidden_weak (getlogin_r) diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c index 8500fe366ab..092eaea3e7b 100644 --- a/sysdeps/unix/sysv/linux/getrlimit64.c +++ b/sysdeps/unix/sysv/linux/getrlimit64.c @@ -48,8 +48,8 @@ strong_alias (__getrlimit64, __GI___getrlimit) strong_alias (__getrlimit64, __getrlimit) /* Alpha defines a versioned getrlimit{64}. */ # ifndef USE_VERSIONED_RLIMIT -weak_alias (__getrlimit64, getrlimit) -weak_alias (__getrlimit64, getrlimit64) +static_weak_alias (__getrlimit64, getrlimit) +static_weak_alias (__getrlimit64, getrlimit64) libc_hidden_weak (getrlimit64) # else weak_alias (__getrlimit64, __GI_getrlimit64) diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c index 5d137598f0e..601c5a2c112 100644 --- a/sysdeps/unix/sysv/linux/if_index.c +++ b/sysdeps/unix/sysv/linux/if_index.c @@ -51,7 +51,7 @@ __if_nametoindex (const char *ifname) return status < 0 ? 0 : ifr.ifr_ifindex; } libc_hidden_def (__if_nametoindex) -weak_alias (__if_nametoindex, if_nametoindex) +static_weak_alias (__if_nametoindex, if_nametoindex) libc_hidden_weak (if_nametoindex) @@ -67,7 +67,7 @@ __if_freenameindex (struct if_nameindex *ifn) free (ifn); } libc_hidden_def (__if_freenameindex) -weak_alias (__if_freenameindex, if_freenameindex) +static_weak_alias (__if_freenameindex, if_freenameindex) libc_hidden_weak (if_freenameindex) @@ -184,7 +184,7 @@ __if_nameindex (void) return idx; } -weak_alias (__if_nameindex, if_nameindex) +static_weak_alias (__if_nameindex, if_nameindex) libc_hidden_weak (if_nameindex) @@ -218,5 +218,5 @@ __if_indextoname (unsigned int ifindex, char ifname[IF_NAMESIZE]) else return strncpy (ifname, ifr.ifr_name, IFNAMSIZ); } -weak_alias (__if_indextoname, if_indextoname) +static_weak_alias (__if_indextoname, if_indextoname) libc_hidden_weak (if_indextoname) diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c index ddc4be78eec..ca7f2a39189 100644 --- a/sysdeps/unix/sysv/linux/ifaddrs.c +++ b/sysdeps/unix/sysv/linux/ifaddrs.c @@ -833,7 +833,7 @@ __getifaddrs (struct ifaddrs **ifap) return res; } -weak_alias (__getifaddrs, getifaddrs) +static_weak_alias (__getifaddrs, getifaddrs) libc_hidden_def (__getifaddrs) libc_hidden_weak (getifaddrs) @@ -843,6 +843,6 @@ __freeifaddrs (struct ifaddrs *ifa) { free (ifa); } -weak_alias (__freeifaddrs, freeifaddrs) +static_weak_alias (__freeifaddrs, freeifaddrs) libc_hidden_def (__freeifaddrs) libc_hidden_weak (freeifaddrs) diff --git a/sysdeps/unix/sysv/linux/lseek64.c b/sysdeps/unix/sysv/linux/lseek64.c index 49f41368449..f921bba9b08 100644 --- a/sysdeps/unix/sysv/linux/lseek64.c +++ b/sysdeps/unix/sysv/linux/lseek64.c @@ -43,7 +43,7 @@ __lseek64 (int fd, off64_t offset, int whence) #ifdef __OFF_T_MATCHES_OFF64_T weak_alias (__lseek64, lseek) -weak_alias (__lseek64, __lseek) +strong_alias (__lseek64, __lseek) strong_alias (__lseek64, __libc_lseek) libc_hidden_def (__lseek) #endif diff --git a/sysdeps/unix/sysv/linux/mmap64.c b/sysdeps/unix/sysv/linux/mmap64.c index e202356efed..6bf4b0ab7fb 100644 --- a/sysdeps/unix/sysv/linux/mmap64.c +++ b/sysdeps/unix/sysv/linux/mmap64.c @@ -62,7 +62,7 @@ weak_alias (__mmap64, mmap64) libc_hidden_def (__mmap64) #ifdef __OFF_T_MATCHES_OFF64_T -weak_alias (__mmap64, mmap) -weak_alias (__mmap64, __mmap) +static_weak_alias (__mmap64, mmap) +strong_alias (__mmap64, __mmap) libc_hidden_def (__mmap) #endif diff --git a/sysdeps/unix/sysv/linux/pread64.c b/sysdeps/unix/sysv/linux/pread64.c index 5fbf14b4be8..8db26c21abb 100644 --- a/sysdeps/unix/sysv/linux/pread64.c +++ b/sysdeps/unix/sysv/linux/pread64.c @@ -25,7 +25,7 @@ __libc_pread64 (int fd, void *buf, size_t count, off64_t offset) return SYSCALL_CANCEL (pread64, fd, buf, count, SYSCALL_LL64_PRW (offset)); } -weak_alias (__libc_pread64, __pread64) +strong_alias (__libc_pread64, __pread64) libc_hidden_weak (__pread64) weak_alias (__libc_pread64, pread64) diff --git a/sysdeps/unix/sysv/linux/pwrite64.c b/sysdeps/unix/sysv/linux/pwrite64.c index c1388b03bd8..aeccaa59625 100644 --- a/sysdeps/unix/sysv/linux/pwrite64.c +++ b/sysdeps/unix/sysv/linux/pwrite64.c @@ -25,7 +25,7 @@ __libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset) return SYSCALL_CANCEL (pwrite64, fd, buf, count, SYSCALL_LL64_PRW (offset)); } -weak_alias (__libc_pwrite64, __pwrite64) +strong_alias (__libc_pwrite64, __pwrite64) libc_hidden_weak (__pwrite64) weak_alias (__libc_pwrite64, pwrite64) diff --git a/sysdeps/unix/sysv/linux/read.c b/sysdeps/unix/sysv/linux/read.c index cb2f22e3198..3ec3acdf131 100644 --- a/sysdeps/unix/sysv/linux/read.c +++ b/sysdeps/unix/sysv/linux/read.c @@ -28,6 +28,6 @@ __libc_read (int fd, void *buf, size_t nbytes) libc_hidden_def (__libc_read) libc_hidden_def (__read) -weak_alias (__libc_read, __read) +strong_alias (__libc_read, __read) libc_hidden_def (read) -weak_alias (__libc_read, read) +static_weak_alias (__libc_read, read) diff --git a/sysdeps/unix/sysv/linux/recv.c b/sysdeps/unix/sysv/linux/recv.c index 24ee8f74e4b..64a7245bebc 100644 --- a/sysdeps/unix/sysv/linux/recv.c +++ b/sysdeps/unix/sysv/linux/recv.c @@ -30,6 +30,6 @@ __libc_recv (int fd, void *buf, size_t len, int flags) return SOCKETCALL_CANCEL (recv, fd, buf, len, flags); #endif } -weak_alias (__libc_recv, recv) -weak_alias (__libc_recv, __recv) +static_weak_alias (__libc_recv, recv) +static_weak_alias (__libc_recv, __recv) libc_hidden_weak (__recv) diff --git a/sysdeps/unix/sysv/linux/send.c b/sysdeps/unix/sysv/linux/send.c index 68cdd4069d5..84404be4d3c 100644 --- a/sysdeps/unix/sysv/linux/send.c +++ b/sysdeps/unix/sysv/linux/send.c @@ -30,6 +30,6 @@ __libc_send (int fd, const void *buf, size_t len, int flags) return SOCKETCALL_CANCEL (send, fd, buf, len, flags); #endif } -weak_alias (__libc_send, send) -weak_alias (__libc_send, __send) +static_weak_alias (__libc_send, send) +static_weak_alias (__libc_send, __send) libc_hidden_def (__send) diff --git a/sysdeps/unix/sysv/linux/write.c b/sysdeps/unix/sysv/linux/write.c index dd40926e76d..f6c4d314511 100644 --- a/sysdeps/unix/sysv/linux/write.c +++ b/sysdeps/unix/sysv/linux/write.c @@ -27,7 +27,7 @@ __libc_write (int fd, const void *buf, size_t nbytes) } libc_hidden_def (__libc_write) -weak_alias (__libc_write, __write) +strong_alias (__libc_write, __write) libc_hidden_weak (__write) -weak_alias (__libc_write, write) +static_weak_alias (__libc_write, write) libc_hidden_weak (write) diff --git a/sysdeps/wordsize-64/Makefile b/sysdeps/wordsize-64/Makefile index 6a84d0f8630..c1efde12d67 100644 --- a/sysdeps/wordsize-64/Makefile +++ b/sysdeps/wordsize-64/Makefile @@ -8,6 +8,6 @@ fmt-xscanf-uint-convs += uint ulong endif # strtol is aliased to stroll -CFLAGS-strtol.c += -fno-builtin-strtoll $(config-cflags-wno-ignored-attributes) +CFLAGS-strtol.c += -fno-builtin-strtoll # strtoul is aliased to strtoull -CFLAGS-strtoul.c += -fno-builtin-strtoull $(config-cflags-wno-ignored-attributes) +CFLAGS-strtoul.c += -fno-builtin-strtoull diff --git a/sysdeps/wordsize-64/strtol.c b/sysdeps/wordsize-64/strtol.c index a21fa8da10a..cd99cb22fd8 100644 --- a/sysdeps/wordsize-64/strtol.c +++ b/sysdeps/wordsize-64/strtol.c @@ -12,11 +12,11 @@ #undef __isoc23_strtoll strong_alias (__strtol_internal, __strtoll_internal) libc_hidden_ver (__strtol_internal, __strtoll_internal) -weak_alias (strtol, strtoll) -libc_hidden_ver (strtol, strtoll) -weak_alias (strtol, strtoq) -libc_hidden_ver (strtol, strtoq) -weak_alias (strtol, strtoimax) +weak_alias (__strtol, strtoll) +libc_hidden_ver (__strtol, strtoll) +weak_alias (__strtol, strtoq) +libc_hidden_ver (__strtol, strtoq) +weak_alias (__strtol, strtoimax) weak_alias (__isoc23_strtol, __isoc23_strtoll) libc_hidden_ver (__isoc23_strtol, __isoc23_strtoll) weak_alias (__isoc23_strtol, __isoc23_strtoimax) diff --git a/sysdeps/wordsize-64/strtoul.c b/sysdeps/wordsize-64/strtoul.c index 60c82b89d9a..00e83d2c387 100644 --- a/sysdeps/wordsize-64/strtoul.c +++ b/sysdeps/wordsize-64/strtoul.c @@ -12,9 +12,9 @@ #undef __isoc23_strtoull strong_alias (__strtoul_internal, __strtoull_internal) libc_hidden_ver (__strtoul_internal, __strtoull_internal) -weak_alias (strtoul, strtoull) -weak_alias (strtoul, strtouq) -weak_alias (strtoul, strtoumax) +weak_alias (__strtoul, strtoull) +weak_alias (__strtoul, strtouq) +weak_alias (__strtoul, strtoumax) weak_alias (__isoc23_strtoul, __isoc23_strtoull) libc_hidden_ver (__isoc23_strtoul, __isoc23_strtoull) weak_alias (__isoc23_strtoul, __isoc23_strtoumax) diff --git a/sysdeps/wordsize-64/wcstol.c b/sysdeps/wordsize-64/wcstol.c index 557c763941e..ba8796b9b9f 100644 --- a/sysdeps/wordsize-64/wcstol.c +++ b/sysdeps/wordsize-64/wcstol.c @@ -12,9 +12,9 @@ #undef __isoc23_wcstoll strong_alias (__wcstol_internal, __wcstoll_internal) libc_hidden_ver (__wcstol_internal, __wcstoll_internal) -weak_alias (wcstol, wcstoll) -weak_alias (wcstol, wcstoq) -weak_alias (wcstol, wcstoimax) +weak_alias (__wcstol, wcstoll) +weak_alias (__wcstol, wcstoq) +weak_alias (__wcstol, wcstoimax) weak_alias (__isoc23_wcstol, __isoc23_wcstoll) libc_hidden_ver (__isoc23_wcstol, __isoc23_wcstoll) weak_alias (__isoc23_wcstol, __isoc23_wcstoimax) diff --git a/sysdeps/wordsize-64/wcstoul.c b/sysdeps/wordsize-64/wcstoul.c index 9b48ca6ab21..f7a03871b6d 100644 --- a/sysdeps/wordsize-64/wcstoul.c +++ b/sysdeps/wordsize-64/wcstoul.c @@ -12,9 +12,9 @@ #undef __isoc23_wcstoull strong_alias (__wcstoul_internal, __wcstoull_internal) libc_hidden_ver (__wcstoul_internal, __wcstoull_internal) -weak_alias (wcstoul, wcstoull) -weak_alias (wcstoul, wcstouq) -weak_alias (wcstoul, wcstoumax) +weak_alias (__wcstoul, wcstoull) +weak_alias (__wcstoul, wcstouq) +weak_alias (__wcstoul, wcstoumax) weak_alias (__isoc23_wcstoul, __isoc23_wcstoull) libc_hidden_ver (__isoc23_wcstoul, __isoc23_wcstoull) weak_alias (__isoc23_wcstoul, __isoc23_wcstoumax) diff --git a/sysdeps/x86_64/fpu/fclrexcpt.c b/sysdeps/x86_64/fpu/fclrexcpt.c index 86b4228f2f4..d5f70458c0d 100644 --- a/sysdeps/x86_64/fpu/fclrexcpt.c +++ b/sysdeps/x86_64/fpu/fclrexcpt.c @@ -50,5 +50,5 @@ __feclearexcept (int excepts) return 0; } libm_hidden_def (__feclearexcept) -weak_alias (__feclearexcept, feclearexcept) +static_weak_alias (__feclearexcept, feclearexcept) libm_hidden_def (feclearexcept) diff --git a/sysdeps/x86_64/fpu/fegetenv.c b/sysdeps/x86_64/fpu/fegetenv.c index eea9d6bee70..fa21ec4f862 100644 --- a/sysdeps/x86_64/fpu/fegetenv.c +++ b/sysdeps/x86_64/fpu/fegetenv.c @@ -31,5 +31,5 @@ __fegetenv (fenv_t *envp) return 0; } libm_hidden_def (__fegetenv) -weak_alias (__fegetenv, fegetenv) +static_weak_alias (__fegetenv, fegetenv) libm_hidden_weak (fegetenv) diff --git a/sysdeps/x86_64/fpu/fegetround.c b/sysdeps/x86_64/fpu/fegetround.c index 9537cd3142e..a7fc1a8870f 100644 --- a/sysdeps/x86_64/fpu/fegetround.c +++ b/sysdeps/x86_64/fpu/fegetround.c @@ -30,5 +30,5 @@ __fegetround (void) return cw & 0xc00; } libm_hidden_def (__fegetround) -weak_alias (__fegetround, fegetround) +static_weak_alias (__fegetround, fegetround) libm_hidden_weak (fegetround) diff --git a/sysdeps/x86_64/fpu/feholdexcpt.c b/sysdeps/x86_64/fpu/feholdexcpt.c index 9a22a2ea77e..30e31205965 100644 --- a/sysdeps/x86_64/fpu/feholdexcpt.c +++ b/sysdeps/x86_64/fpu/feholdexcpt.c @@ -37,5 +37,5 @@ __feholdexcept (fenv_t *envp) return 0; } libm_hidden_def (__feholdexcept) -weak_alias (__feholdexcept, feholdexcept) +static_weak_alias (__feholdexcept, feholdexcept) libm_hidden_weak (feholdexcept) diff --git a/sysdeps/x86_64/fpu/fesetenv.c b/sysdeps/x86_64/fpu/fesetenv.c index e4e721afffd..a7b87efcde5 100644 --- a/sysdeps/x86_64/fpu/fesetenv.c +++ b/sysdeps/x86_64/fpu/fesetenv.c @@ -110,5 +110,5 @@ __fesetenv (const fenv_t *envp) return 0; } libm_hidden_def (__fesetenv) -weak_alias (__fesetenv, fesetenv) +static_weak_alias (__fesetenv, fesetenv) libm_hidden_weak (fesetenv) diff --git a/sysdeps/x86_64/fpu/fesetround.c b/sysdeps/x86_64/fpu/fesetround.c index e1ffb3b7a9e..8a5f6c425c6 100644 --- a/sysdeps/x86_64/fpu/fesetround.c +++ b/sysdeps/x86_64/fpu/fesetround.c @@ -44,5 +44,5 @@ __fesetround (int round) return 0; } libm_hidden_def (__fesetround) -weak_alias (__fesetround, fesetround) +static_weak_alias (__fesetround, fesetround) libm_hidden_weak (fesetround) diff --git a/sysdeps/x86_64/fpu/fraiseexcpt.c b/sysdeps/x86_64/fpu/fraiseexcpt.c index da3a31f4c20..dae0c3bc311 100644 --- a/sysdeps/x86_64/fpu/fraiseexcpt.c +++ b/sysdeps/x86_64/fpu/fraiseexcpt.c @@ -117,5 +117,5 @@ __feraiseexcept (int excepts) return 0; } libm_hidden_def (__feraiseexcept) -weak_alias (__feraiseexcept, feraiseexcept) +static_weak_alias (__feraiseexcept, feraiseexcept) libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/x86_64/fpu/ftestexcept.c b/sysdeps/x86_64/fpu/ftestexcept.c index 39df30fbd23..7e0a097696c 100644 --- a/sysdeps/x86_64/fpu/ftestexcept.c +++ b/sysdeps/x86_64/fpu/ftestexcept.c @@ -31,5 +31,5 @@ __fetestexcept (int excepts) return (temp | mxscr) & excepts & FE_ALL_EXCEPT; } libm_hidden_def (__fetestexcept) -weak_alias (__fetestexcept, fetestexcept) +static_weak_alias (__fetestexcept, fetestexcept) libm_hidden_def (fetestexcept) diff --git a/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c b/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c index 7bb1749a283..4b0c825fc5f 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c +++ b/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c @@ -18,6 +18,7 @@ #include #if MINIMUM_X86_ISA_LEVEL < AVX2_X86_ISA_LEVEL +# include # include extern float __redirect_exp10m1f (float); diff --git a/sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c b/sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c index 1361b79e519..890b149ec2f 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c +++ b/sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c @@ -18,6 +18,7 @@ #include #if MINIMUM_X86_ISA_LEVEL < AVX2_X86_ISA_LEVEL +# include # include extern float __redirect_exp2m1f (float); diff --git a/sysdeps/x86_64/fpu/multiarch/s_sincos.c b/sysdeps/x86_64/fpu/multiarch/s_sincos.c index 5d60cd05487..4514eedcd1e 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_sincos.c +++ b/sysdeps/x86_64/fpu/multiarch/s_sincos.c @@ -18,6 +18,7 @@ #include #if MINIMUM_X86_ISA_LEVEL < AVX2_X86_ISA_LEVEL +# include # include extern void __redirect_sincos (double, double *, double *); diff --git a/sysdeps/x86_64/multiarch/mempcpy.c b/sysdeps/x86_64/multiarch/mempcpy.c index ba5297e7c3b..cc67b425be8 100644 --- a/sysdeps/x86_64/multiarch/mempcpy.c +++ b/sysdeps/x86_64/multiarch/mempcpy.c @@ -36,7 +36,7 @@ weak_alias (__mempcpy, mempcpy) # ifdef SHARED __hidden_ver1 (__mempcpy, __GI___mempcpy, __redirect___mempcpy) __attribute__ ((visibility ("hidden"))) __attribute_copy__ (mempcpy); -__hidden_ver1 (mempcpy, __GI_mempcpy, __redirect_mempcpy) +__hidden_ver1 (__mempcpy, __GI_mempcpy, __redirect_mempcpy) __attribute__ ((visibility ("hidden"))) __attribute_copy__ (mempcpy); # endif #endif diff --git a/sysdeps/x86_64/multiarch/stpcpy.c b/sysdeps/x86_64/multiarch/stpcpy.c index df027e314e4..5b084e78f76 100644 --- a/sysdeps/x86_64/multiarch/stpcpy.c +++ b/sysdeps/x86_64/multiarch/stpcpy.c @@ -36,7 +36,7 @@ weak_alias (__stpcpy, stpcpy) # ifdef SHARED __hidden_ver1 (__stpcpy, __GI___stpcpy, __redirect___stpcpy) __attribute__ ((visibility ("hidden"))) __attribute_copy__ (stpcpy); -__hidden_ver1 (stpcpy, __GI_stpcpy, __redirect_stpcpy) +__hidden_ver1 (__stpcpy, __GI_stpcpy, __redirect_stpcpy) __attribute__ ((visibility ("hidden"))) __attribute_copy__ (stpcpy); # endif #endif diff --git a/sysdeps/x86_64/multiarch/strnlen.c b/sysdeps/x86_64/multiarch/strnlen.c index 6444ca1d802..0b0bd977de0 100644 --- a/sysdeps/x86_64/multiarch/strnlen.c +++ b/sysdeps/x86_64/multiarch/strnlen.c @@ -33,7 +33,7 @@ weak_alias (__strnlen, strnlen); # ifdef SHARED __hidden_ver1 (__strnlen, __GI___strnlen, __redirect___strnlen) __attribute__((visibility ("hidden"))) __attribute_copy__ (strnlen); -__hidden_ver1 (strnlen, __GI_strnlen, __redirect_strnlen) +__hidden_ver1 (__strnlen, __GI_strnlen, __redirect_strnlen) __attribute__((weak, visibility ("hidden"))) __attribute_copy__ (strnlen); # endif #endif diff --git a/sysdeps/x86_64/multiarch/wcschr.c b/sysdeps/x86_64/multiarch/wcschr.c index 3df2367f93c..5a10cccde1c 100644 --- a/sysdeps/x86_64/multiarch/wcschr.c +++ b/sysdeps/x86_64/multiarch/wcschr.c @@ -33,7 +33,7 @@ weak_alias (__wcschr, wcschr); # ifdef SHARED __hidden_ver1 (__wcschr, __GI___wcschr, __redirect___wcschr) __attribute__((visibility ("hidden"))); -__hidden_ver1 (wcschr, __GI_wcschr, __redirect_wcschr) +__hidden_ver1 (__wcschr, __GI_wcschr, __redirect_wcschr) __attribute__((weak, visibility ("hidden"))); # endif #endif diff --git a/sysdeps/x86_64/multiarch/wmemchr.c b/sysdeps/x86_64/multiarch/wmemchr.c index bba610394cb..b5bee75f385 100644 --- a/sysdeps/x86_64/multiarch/wmemchr.c +++ b/sysdeps/x86_64/multiarch/wmemchr.c @@ -33,7 +33,7 @@ weak_alias (__wmemchr, wmemchr) # ifdef SHARED __hidden_ver1 (__wmemchr, __GI___wmemchr, __redirect___wmemchr) __attribute__((visibility ("hidden"))); -__hidden_ver1 (wmemchr, __GI_wmemchr, __redirect_wmemchr) +__hidden_ver1 (__wmemchr, __GI_wmemchr, __redirect_wmemchr) __attribute__((weak, visibility ("hidden"))); # endif #endif diff --git a/sysdeps/x86_64/multiarch/wmemset.c b/sysdeps/x86_64/multiarch/wmemset.c index 0169f2ac542..096633b7acb 100644 --- a/sysdeps/x86_64/multiarch/wmemset.c +++ b/sysdeps/x86_64/multiarch/wmemset.c @@ -34,7 +34,7 @@ weak_alias (__wmemset, wmemset) # ifdef SHARED __hidden_ver1 (__wmemset, __GI___wmemset, __redirect___wmemset) __attribute__ ((visibility ("hidden"))); -__hidden_ver1 (wmemset, __GI_wmemset, __redirect_wmemset) +__hidden_ver1 (__wmemset, __GI_wmemset, __redirect_wmemset) __attribute__ ((visibility ("hidden"))); # endif #endif diff --git a/termios/Makefile b/termios/Makefile index 1e236082555..0308bacf74c 100644 --- a/termios/Makefile +++ b/termios/Makefile @@ -53,4 +53,3 @@ routines := \ include ../Rules CFLAGS-tcdrain.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-tcsetattr.c += $(config-cflags-wno-ignored-attributes) diff --git a/time/Makefile b/time/Makefile index 3e010d2c150..55b8b690ca0 100644 --- a/time/Makefile +++ b/time/Makefile @@ -141,7 +141,6 @@ CFLAGS-tzset.c += $(tz-cflags) CFLAGS-getdate.c += -fexceptions CFLAGS-clock_nanosleep.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-nanosleep.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-mktime.c += $(config-cflags-wno-ignored-attributes) # Don't warn about Y2k problem in strftime format string. CFLAGS-test_time.c += -Wno-format diff --git a/time/mktime.c b/time/mktime.c index 86d496ca65c..6769bab4784 100644 --- a/time/mktime.c +++ b/time/mktime.c @@ -573,6 +573,6 @@ mktime (struct tm *tp) #endif -weak_alias (mktime, timelocal) +static_weak_alias (mktime, timelocal) libc_hidden_def (mktime) libc_hidden_weak (timelocal) diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index 559438c1ce8..383cf43a076 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -248,32 +248,24 @@ CFLAGS-wcwidth.c += -I../wctype CFLAGS-wcswidth.c += -I../wctype strtox-CFLAGS = -I../include -CFLAGS-wcstol.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) -CFLAGS-wcstoul.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) +CFLAGS-wcstol.c += $(strtox-CFLAGS) +CFLAGS-wcstoul.c += $(strtox-CFLAGS) CFLAGS-wcstoll.c += $(strtox-CFLAGS) CFLAGS-wcstoull.c += $(strtox-CFLAGS) -CFLAGS-wcstod.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) -CFLAGS-wcstold.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) +CFLAGS-wcstod.c += $(strtox-CFLAGS) +CFLAGS-wcstold.c += $(strtox-CFLAGS) CFLAGS-wcstof128.c += $(strtox-CFLAGS) -CFLAGS-wcstof.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) +CFLAGS-wcstof.c += $(strtox-CFLAGS) CFLAGS-wcstol_l.c += $(strtox-CFLAGS) CFLAGS-wcstoul_l.c += $(strtox-CFLAGS) CFLAGS-wcstoll_l.c += $(strtox-CFLAGS) CFLAGS-wcstoull_l.c += $(strtox-CFLAGS) -CFLAGS-wcstod_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) -CFLAGS-wcstold_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) +CFLAGS-wcstod_l.c += $(strtox-CFLAGS) +CFLAGS-wcstold_l.c += $(strtox-CFLAGS) CFLAGS-wcstof128_l.c += $(strtox-CFLAGS) -CFLAGS-wcstof_l.c += $(strtox-CFLAGS) $(config-cflags-wno-ignored-attributes) +CFLAGS-wcstof_l.c += $(strtox-CFLAGS) CPPFLAGS-tst-wchar-h.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2 -CFLAGS-wcschr.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-wmemchr.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-wmemset.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-mbrtowc.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-wcrtomb.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-wcstoll.c += $(config-cflags-wno-ignored-attributes) -CFLAGS-wcstoull.c += $(config-cflags-wno-ignored-attributes) - CFLAGS-isoc99_wscanf.c += -fexceptions CFLAGS-isoc99_fwscanf.c += -fexceptions CFLAGS-isoc99_vwscanf.c += -fexceptions diff --git a/wcsmbs/mbrtowc.c b/wcsmbs/mbrtowc.c index 47068ed0e01..ce8f6045b13 100644 --- a/wcsmbs/mbrtowc.c +++ b/wcsmbs/mbrtowc.c @@ -117,5 +117,5 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) return result; } libc_hidden_def (__mbrtowc) -weak_alias (__mbrtowc, mbrtowc) +static_weak_alias (__mbrtowc, mbrtowc) libc_hidden_weak (mbrtowc) diff --git a/wcsmbs/wcrtomb.c b/wcsmbs/wcrtomb.c index d4ce1877810..19788ffbb51 100644 --- a/wcsmbs/wcrtomb.c +++ b/wcsmbs/wcrtomb.c @@ -123,5 +123,5 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps) { return __wcrtomb_internal (s, wc, ps, (size_t) -1); } -weak_alias (__wcrtomb, wcrtomb) +static_weak_alias (__wcrtomb, wcrtomb) libc_hidden_weak (wcrtomb) diff --git a/wcsmbs/wcschr.c b/wcsmbs/wcschr.c index 6bd3ad9ddf6..f64f6baac4e 100644 --- a/wcsmbs/wcschr.c +++ b/wcsmbs/wcschr.c @@ -45,5 +45,5 @@ WCSCHR (const wchar_t *wcs, const wchar_t wc) return dest; } libc_hidden_def (__wcschr) -weak_alias (__wcschr, wcschr) +static_weak_alias (__wcschr, wcschr) libc_hidden_weak (wcschr) diff --git a/wcsmbs/wmemchr.c b/wcsmbs/wmemchr.c index a5403581a3b..e78874d3022 100644 --- a/wcsmbs/wmemchr.c +++ b/wcsmbs/wmemchr.c @@ -60,5 +60,5 @@ __wmemchr (const wchar_t *s, wchar_t c, size_t n) return NULL; } libc_hidden_def (__wmemchr) -weak_alias (__wmemchr, wmemchr) +static_weak_alias (__wmemchr, wmemchr) libc_hidden_weak (wmemchr) diff --git a/wcsmbs/wmemset.c b/wcsmbs/wmemset.c index 3441ece2b2a..517a22b06b0 100644 --- a/wcsmbs/wmemset.c +++ b/wcsmbs/wmemset.c @@ -52,5 +52,5 @@ __wmemset (wchar_t *s, wchar_t c, size_t n) return s; } libc_hidden_def (__wmemset) -weak_alias (__wmemset, wmemset) +static_weak_alias (__wmemset, wmemset) libc_hidden_weak (wmemset) diff --git a/wctype/Makefile b/wctype/Makefile index 4708594d849..cdcf3b2328d 100644 --- a/wctype/Makefile +++ b/wctype/Makefile @@ -29,5 +29,3 @@ routines := wcfuncs wctype iswctype wctrans towctrans \ tests := test_wctype test_wcfuncs bug-wctypeh include ../Rules - -CFLAGS-wcfuncs.c += $(config-cflags-wno-ignored-attributes) diff --git a/wctype/wcfuncs.c b/wctype/wcfuncs.c index 49f9ed21572..0d078609a51 100644 --- a/wctype/wcfuncs.c +++ b/wctype/wcfuncs.c @@ -34,7 +34,7 @@ const char *desc = _NL_CURRENT (LC_CTYPE, i); \ return wctype_table_lookup (desc, wc); \ } \ - weak_alias (__isw##name, isw##name) + static_weak_alias (__isw##name, isw##name) #undef iswalnum func (alnum, __ISwalnum) @@ -78,7 +78,7 @@ __towlower (wint_t wc) return wctrans_table_lookup (desc, wc); } libc_hidden_def (__towlower) -weak_alias (__towlower, towlower) +static_weak_alias (__towlower, towlower) libc_hidden_weak (towlower) #undef towupper @@ -90,5 +90,5 @@ __towupper (wint_t wc) return wctrans_table_lookup (desc, wc); } libc_hidden_def (__towupper) -weak_alias (__towupper, towupper) +static_weak_alias (__towupper, towupper) libc_hidden_weak (towupper) From patchwork Fri Oct 31 20:00:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123246 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BFFF13850846 for ; Fri, 31 Oct 2025 20:06:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFFF13850846 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=jtNpaPNV X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id D5C783850847 for ; Fri, 31 Oct 2025 20:03:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5C783850847 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 D5C783850847 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941036; cv=none; b=eADjFDWd9K1QSchwxplxCUsD3aQFcln6zoDm2XX/508YII8+i1FASi6DbjPox7rzHKvw5ap42mMFZMq92LC9Oo07B7OkcvlfgybOygTTq3brRaMgyLI7DFb05g6C5JD1fu8vyCknjx9U6843KbmI1tbga/5dEZ08NgE3J/iD4Wc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941036; c=relaxed/simple; bh=xv0qHs+PhltbwN8uikZmQ8o08uJ6x5CprLAOUfK7l3c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=r9HcZiyla5gW6zdDiEMSLLNcXX0VmlE2mPAOugQ/9QDDFlK7d/HevzFwqZTuxj4UwJdRz6mxiiyuk5HnbkOmScYz5yC6BJ9EU5sqtyMKDpdrQWGEOJFJMP5Xu63aotA3JtlpWBfCePRXEXw6HFMrJI/E1r5ScwhbxPpWMy27dyM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5C783850847 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-b4755f37c3eso2282144a12.3 for ; Fri, 31 Oct 2025 13:03:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941034; x=1762545834; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lyM8i1B3idk+0RTW81cwjC+g5KIiSDfV/iTjtRJq1AE=; b=jtNpaPNVClW6bErSDUZOHTA3VPLuql48kI3/Otgu/fyTwDzNq9DhL2q/1kkPEWzgJa /dWjrIGMqFNvqFkLyAM3Y+aCXTQ91Aia2rNWmCjWxTPO/CyAPvdPdpLie1zRSt3XZNHJ q/wP5TSNkyf2+LfcMC/m4Vg/r7y2mENNJ75tPZzhX9LlS06KGbiq2ms18QKha7ukwcwz BE3svgQKV3wUDM3QunK1kiP+NKa0oFv7pJoTyo0EEBrqpjT+QW8/TWX4cfJLKtthcVZN Y+J8HH0DdtyTr8NemsSwhAEWDDC4o7lyLw1zgqv1LzhCLx6MYfv/V5jXuhhRoJgGyydd 8UOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941034; x=1762545834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lyM8i1B3idk+0RTW81cwjC+g5KIiSDfV/iTjtRJq1AE=; b=jy7hEGYGmnZ9LQqOaf0xAMHpPRcWq3l6dbmbDePGCMYhJu2BSdvUyf+dcjILRv/biJ 61lMxAhL/dlwY1rKDA20+sRCTGGh7EQTH14thMDlP87+QURgbu3ccvubGJDFXSpd8Oh1 UXZ6hZQqd5C5Usp+1AUlN+j82WjUz0EKbqp7yWzXVR2A60lQSuC0SzKZst1IvvTHP/gt gJbUy51buiTBfQRxT7b6NwDzjZ0KJRezBgcBjrhr8vvgFskIHpHT0ZnhDfzuSS0T0cWV pigmD7F0tucZjtuvQMoPOVsTxpAGivLsTiFPa8qcDBJjmWTAPY3onZvSbJw+YTC/V5mC z1Zw== X-Gm-Message-State: AOJu0YzKIjZ513jBqV7he2zqdCUlBzY0/iKr+cZeYsglCKIWi7jQqdcJ PZqS7CxuJUsxbXL8/45mjAX9AfCu7sZcVwo2f2QQ5rKcALrl0IAew1vQErv9npQkkBfl572INMy +xNR1FYk= X-Gm-Gg: ASbGncurc7EW9plSLQk3YOl/Ic1h9ZS0q8TdlgJUk1EcjQvNLeP8i4pFtRrhiuw2JOA gchFJ1s375y95LXKD5fqNzyoe6YnCOxtNAzDgWDGgLYW04/wKFBqLKshSk+XCwxMNMCBrQuUIz7 fvjSS0Uytu6d72fhRtZ7IDScnBlNSttizNKnspzUZSg1CwH40xTySgBWahR7/vUWtDKh8uByqgy jXzsnNbPvAC34egraJYaNqFByvqwgdjnif8hDaORjd8pgUpTTeHAMUMEgsfbZw+xCufu4BoOpqS pTgkhVV8OeRJNc8sUvgb9m/a2P6HWcMqzbw67YxyM1uX6raddhPKt+OcQekopbcO0yCafKyzClA m1OfGoztmQP1qexpf9T2ociPmmcrbmUJwWcJ3fJfdvuNpZzRwdb4hz3pr3Juw4y9cCTJTqBi+cy WBpeFj/JzWlOc/ X-Google-Smtp-Source: AGHT+IEtZzltlcerKOAF1YFYtNxk+BGyG//4lLuaC1IdDpOqkuppd4/a1wg0qAg1Ft7V6NKQD+6X2A== X-Received: by 2002:a17:903:1206:b0:295:f1f:67b with SMTP id d9443c01a7336-2951a4fb05bmr59389255ad.39.1761941034652; Fri, 31 Oct 2025 13:03:54 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:54 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 08/19] nss: Suppress clang -Wstring-plus-int on __nss_shlib_revision definition Date: Fri, 31 Oct 2025 17:00:41 -0300 Message-ID: <20251031200300.3716090-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang issues an warning that adding 'unsigned long' to a string does not append to the string. Reviewed-by: H.J. Lu --- nss/nss_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nss/nss_module.c b/nss/nss_module.c index 3cd1940b225..ac94e4d3f02 100644 --- a/nss/nss_module.c +++ b/nss/nss_module.c @@ -41,7 +41,7 @@ pointer manipulation. The "-1" accounts for the trailing NUL included in the sizeof. */ static const char *const __nss_shlib_revision - = LIBNSS_FILES_SO + sizeof("libnss_files.so") - 1; + = &LIBNSS_FILES_SO[sizeof("libnss_files.so") - 1]; /* A single-linked list used to implement a mapping from service names to NSS modules. (Most systems only use five or so modules, so a From patchwork Fri Oct 31 20:00:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123250 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 236EB3850846 for ; Fri, 31 Oct 2025 20:11:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 236EB3850846 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=jn5gnGro X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 34C0C3850416 for ; Fri, 31 Oct 2025 20:03:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34C0C3850416 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 34C0C3850416 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941038; cv=none; b=HBGvFcYd4U0XGT48aBUvo6/Iy+iGD/s7OAanYlXRbqC1ej/UJitY+DYSzcCrcQCWyHaFl1CMn9pa+Tm6eQpxbp8OyEojbSg6YYusgWE14TyWp13GSPSyOwtzyaQGCkhqIn1Mj0czfSLJGoZz5ocx0YcozD/KaL+BWYrsqD19rNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941038; c=relaxed/simple; bh=ZV7gF5D5e+Kw0KmzytcISkOIclzvRaGnG4YyVW8jVzg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Q+ueW8ko3FrxlPk4PZkQ4yinsb6N+aNN54nfwUTK02EHFDdsgIJCuPwUQEI8o9U/GS4u22yJylsRtzi63PiwHfctjXZv1v0rHy5Hn+H3Gn6xKZamlvxmEOpnV3XOZ0CxN8hrXR8tlwl6r4CYUKMOfJtzsE81lJThZvnurhaI6RE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34C0C3850416 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2698384978dso22608005ad.0 for ; Fri, 31 Oct 2025 13:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941037; x=1762545837; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4grIvFogvlmCbTuhr9CU9xLgfLiMEpvtqHOYJotxAE4=; b=jn5gnGroRLBLU0zRRSB+w/zht6NEEUMV2pM6BygJE8AFuAJO2FdOwKoqDIXbKeGrNJ 6EWvqTmpQrFnnvsLGuHDJyJCt9l32h1ZWm5J/c1Fu78aWCAl61q2E/9CPyz33kygRIts 0CILJn/rs7ynPDlUEy1AYgVK5HjwKCBZZ+/ygXdnh9tgQM+p7yIQ6zimDmbs3QtQtmfY XYwrgXMfCfSKCkxuL411HfvzvbzGqDF4GVs74XsorqIHaolgzWgvSg7cPfqtqgRgx4tR KCeABKBPDURm1996U4/YJnRYB2DEiOw4+zGHlQaiG/DQSHyhzD3hVuuR6SvD+BE6IvL9 4E0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941037; x=1762545837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4grIvFogvlmCbTuhr9CU9xLgfLiMEpvtqHOYJotxAE4=; b=EV7ts8KOhGEHdzf0xPGrwjbDEX+9+chwLQ0vlVhMR8Uld/XBThOf0T0VUmMzcI0kYp +LBQJrT7gkxxI641lLc/fvJ5Vx1CEzPN0r/A/13GT6dYWUpn95Q4aMfyBaRE+4K00nol hoI9DPIFWGoV9/mjN1XfIpoHcNCrJz+WMO8Gcu8rxdOJBPCA4lI2VWQTQSxHkajh2kN0 PlzezuOukONgJLO5M5ZfsuMtWGqXM8qMV7glaJcwJwUn+UQztTGQ0ZGwGppmOyIIZ9tv hUWHnlXQ4cCuL/AXj+mkvZecmz97bWXpdzRaP9tPwCzx8N/ldqtFTz1yYXVGdUbdAzaJ 9wKA== X-Gm-Message-State: AOJu0YzEW751qPmIDmdbctE/+Nx76MTVVfoouBuH0tnXDtIS3hpZiWcO CM4fIsgAkCG3IEDX7MXXZMpGswNdnCCjC0NfZPemPI2neB2GKV1bSkRxm4uM88seIBOi+a2BWa/ onUODDYk= X-Gm-Gg: ASbGncvvIeljHVlnq6Q+HGsxv8HSydnk4jQ/6Ff74O0h0MiL5LiHQmeF5W56QwgfaV6 WGsFatSlFU7VBlhlB53hE/quXZWWsKteVRO2nSE4WkjOgx1q0l6f+BKXUkHQUTdZl7DnB3zBkqy Bti9orZqN6tW+NW3vheN76x5GQAogTX592HmqsUecXEozWWSCssJZyRCATyDlMAC5yYvp9Mq1EA rmHtGskVXtx+r35+XWE6RgqcxDsJAe8Vi6DmHrg1EvII3lWUxLO1pjGi0M6RXkAg6g6jPimrfd4 64tzZUiO3BfWGRpwa2C9nKVr4iCaM0SD63VG2CpmggaI9YHxWQH8Db0It5N5jfO3gNZPPS5oe53 1lqcOFKrh4//y1dHYxNFBZ81f1IUOc1rbUljnc8yvGDmgG28JApT1QawuF6k9iNjMmuLhFGkNm8 V7aMzPDM416kJl X-Google-Smtp-Source: AGHT+IHNxPSqs9EgH+D23EcIbpe3N7/LUMgpiPXrOtfZf0gX8JUEPeEaPonfi0ZJ25QuFCZ6Xnw+yQ== X-Received: by 2002:a17:902:7c0a:b0:292:fc65:3584 with SMTP id d9443c01a7336-2951a5c2a92mr40287045ad.50.1761941036889; Fri, 31 Oct 2025 13:03:56 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:56 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 09/19] string: Check if attribute can declared after function declaration Date: Fri, 31 Oct 2025 17:00:42 -0300 Message-ID: <20251031200300.3716090-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 Some symbols that might be auto-generated by the compiler are redefined to internal alias (for instance mempcpy to __mempcpy). However, if fortify is enabled, the fortify wrapper is define before the alias re-defined and clang warns attribute declaration must precede definition. Use an asm alias if compiler does not support it, instead of an attribute. Reviewed-by: H.J. Lu --- config.h.in | 3 +++ configure | 29 +++++++++++++++++++++++++++++ configure.ac | 20 ++++++++++++++++++++ include/string.h | 5 +++++ 4 files changed, 57 insertions(+) diff --git a/config.h.in b/config.h.in index 53788830606..8a997f0d4b4 100644 --- a/config.h.in +++ b/config.h.in @@ -317,4 +317,7 @@ /* Define if trunc is inlined on x86. */ #undef HAVE_X86_INLINE_TRUNC +/* Define if compiler allows add attribute after function declaration. */ +#undef ATTR_AFTER_FUNC_DECL + #endif diff --git a/configure b/configure index 122020db697..c2e33a5c9f1 100755 --- a/configure +++ b/configure @@ -9468,6 +9468,35 @@ if test "$pthread_in_libc" = yes; then fi +# Some symbols that might be auto-generated by the compiler are redefined +# to internal alias (for instance mempcpy to __mempcpy). However, if fortify +# is enabled, the fortify wrapper is define before the alias re-defined and +# clang warns attribute declaration must precede definition. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking attribute can declared after function declaration" >&5 +printf %s "checking attribute can declared after function declaration... " >&6; } +if test ${libc_cv_attr_after_func_decl+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat > conftest.c <&5 2>&5 ; then + libc_cv_attr_after_func_decl=yes +fi +rm -rf conftest* ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_attr_after_func_decl" >&5 +printf "%s\n" "$libc_cv_attr_after_func_decl" >&6; } +if test "$libc_cv_attr_after_func_decl" = yes; then + printf "%s\n" "#define ATTR_AFTER_FUNC_DECL 1" >>confdefs.h + +fi + ac_config_files="$ac_config_files config.make Makefile" ac_config_commands="$ac_config_commands default" diff --git a/configure.ac b/configure.ac index 14a0f2dee89..1150ce9aac7 100644 --- a/configure.ac +++ b/configure.ac @@ -2181,6 +2181,26 @@ if test "$pthread_in_libc" = yes; then fi AC_SUBST(pthread_in_libc) +# Some symbols that might be auto-generated by the compiler are redefined +# to internal alias (for instance mempcpy to __mempcpy). However, if fortify +# is enabled, the fortify wrapper is define before the alias re-defined and +# clang warns attribute declaration must precede definition. +AC_CACHE_CHECK([attribute can declared after function declaration], + libc_cv_attr_after_func_decl, [dnl +cat > conftest.c <&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then + libc_cv_attr_after_func_decl=yes +fi +rm -rf conftest*]) +if test "$libc_cv_attr_after_func_decl" = yes; then + AC_DEFINE(ATTR_AFTER_FUNC_DECL) +fi + AC_CONFIG_FILES([config.make Makefile]) AC_CONFIG_COMMANDS([default],[[ case $CONFIG_FILES in *config.make*) diff --git a/include/string.h b/include/string.h index c26ca0927ca..59015c7819d 100644 --- a/include/string.h +++ b/include/string.h @@ -188,8 +188,13 @@ extern __typeof (strsep) strsep attribute_hidden; && !defined NO_MEMPCPY_STPCPY_REDIRECT /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call __mempcpy and __stpcpy if not inlined. */ +# ifdef ATTR_AFTER_FUNC_DECL extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy"); extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy"); +# else +__asm__ ("mempcpy = __mempcpy"); +__asm__ ("stpcpy = __stpcpy"); +# endif #endif extern void *__memcpy_chk (void *__restrict __dest, From patchwork Fri Oct 31 20:00:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123258 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 44E78386103B for ; Fri, 31 Oct 2025 20:18:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44E78386103B 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=lCehPtVE X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id 6ADA8386182D for ; Fri, 31 Oct 2025 20:04:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6ADA8386182D 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 6ADA8386182D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941040; cv=none; b=nEvatlo/sY+ahWEF44x1aRpR+Q/n9V5zp9OmgXkVeVFImw/xwMAjcPeTchEp4NazMgQz/OZaRjPkTEQxZZSLk0LR0NwibZp8VtHTXnTZ92naGlNt7uF2c+lOOWFYMQtMCoCHkZV7USoZFov8XEg5YkyRy8Qls9ZosUI8MjdsBTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941040; c=relaxed/simple; bh=727PL47SY+asfKYykcGzl334fOMswwemWVbcax7CQ88=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wxrUc3CuNvgfFT6Nae25jrfbM1E3kIe7YLybhJ/QEdcsX8eHOcGd1yRnoobU7FJZXz4Lmt85Z2Pgiy9yLQyyc19NKeqwcxAfIn/OmT7E4/HqBPuLy/rSM+1q0kgSQswwGXSzNA54QGS2XkfEX+WHUVBT12J7nUKzOPO3dU/X7q0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6ADA8386182D Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-3304dd2f119so2070756a91.2 for ; Fri, 31 Oct 2025 13:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941039; x=1762545839; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0bWkzYXGecTGXOMq2VU0COxAjdwDyHUtxcBx1+FUVak=; b=lCehPtVEMAn1MKlb83SKsl2rxwXkXGGfyvkrIO4gmV46+LLQ9sTtpMqMbvkiFFlR6I otmH6lVccEgYMQxaJ/3lzEy6Hnk0lAIUJI+NyTOgO+wniTH6GambKImmQ1lu35NGHySE eojauFicpNbJ7yGEtJk5Jm+c4RYwmeW6pOdXCODnJqfAVsxKHgsFoal+Sxzh6QjTAcRJ zNdPeHH9u6egdFXAhDmLirlpjYrP8xV8OCl1qe/k8k3kY11MmaHzO8GrKxv5uVpex1RK tHPuLz7+4kUuYNWncfxBM8bvs1M4NhLnbLMjzQTLEIdsAsV+rBOAUFjlfYFaxFbzHsj6 wfwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941039; x=1762545839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0bWkzYXGecTGXOMq2VU0COxAjdwDyHUtxcBx1+FUVak=; b=cpjauc1SSyfRJA/8qTQc7DFFU3Je+sTvHMpdpY/cib8elGpfrTDpuyGAenPbPgACoc +m11hJsKuN2Vi6NNkYkeRRzFrsLQ2gGi91yiKgu7Zb8Ht4b9ayi0ToFenrh9IKmIxTAX 26qnAS78V7ZUGYpWCLmZGyRCiqV7k2HaqT6AVeWJJ1AsGj7knezHQ4BlkzFg8NDinVyb wMW+DFJByFJjpnuEiWq9e1mE3TLRcHecaVnw2nqgMcmMPjS/qmgeHhXwRyx+23vpH+Z2 CkZ1AVdYDFbmNeWBkdZQmVKmRX6nj+scpTpNAu7xCHJyKu8/W9+VU2AflAGFjXqCrIfL Lw/A== X-Gm-Message-State: AOJu0YxEADI9hkR5bq/h5gV8Ga8Uh9xlN9mij723jtDjBcxhSmYLgNqV yk+4Lv85F318Fuzuz9suPBcoyQU970c8d5Rpcw9mV88iPnwIv3KHV68KzL+wdV1UYWJzYcVHuFw 0NeMkewE= X-Gm-Gg: ASbGncsQsJ8py+tClf6dSR5DwC++ISa+cM8f4EQqo0R2GWLxA4ahYhFmHtQoBEXoXcU pySMvaG6TVtUMy3n67k+goSSktDUIJAhsYORqWbGrhKi/knLyzqU2n9ISFD6egAE8bquGkw8hS6 Kx3FSKgLCSYm9I1gYY8E6GEBRQUBz85T7JCip1YvpTp19w8+zZrdx9qoXQrQopu1OXrzn4f10Ln mZbXYshYYPjyTarC1evZJ7H7ZOYtu86plinBD//TE4EQ6k7cNukLBg2d6+mzP/pNm1PBSq8QT3Z ep3SolTPA9lpoPpteBvimnBiYTPrNohwvVNHRd1bJNBWs5aTqI+VsqrWbhai92vCedlzHNI327S lEHF9dEaLcZDgeeMzmbkPei1/gv3ju7sRf1vkMh58SMIViUVJNRda/fb1ZY4PAMighi8suft0QS do7fTOEL2Vk+fb531bajqoqPuYX0MXnpnc1A== X-Google-Smtp-Source: AGHT+IHbFLG3mlwFchiA6d67CH37Rd8LuOVa5Gd4QzNv4BCkV6s5npkeYu+nURk52VUO94SANrpmbw== X-Received: by 2002:a17:903:3202:b0:294:b758:76b2 with SMTP id d9443c01a7336-2951a58890cmr74053805ad.43.1761941039010; Fri, 31 Oct 2025 13:03:59 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:03:58 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 10/19] x86: Use -mavx instead of -msse2avx Date: Fri, 31 Oct 2025 17:00:43 -0300 Message-ID: <20251031200300.3716090-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang supports it from version 19 and onwards, but it should be gated as an option to assembler (either with -Wa or -Xassembler). Add a test for -Wa as well if -msse2avx fully supported by the compiler. --- sysdeps/x86_64/fpu/multiarch/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index 708b14297fa..145ad08207b 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -150,13 +150,13 @@ CFLAGS-s_sin-fma4.c = -mfma4 CFLAGS-s_tan-fma4.c = -mfma4 CFLAGS-s_sincos-fma4.c = -mfma4 -CFLAGS-e_atan2-avx.c = -msse2avx -DSSE2AVX -CFLAGS-e_exp-avx.c = -msse2avx -DSSE2AVX -CFLAGS-e_log-avx.c = -msse2avx -DSSE2AVX -CFLAGS-s_atan-avx.c = -msse2avx -DSSE2AVX -CFLAGS-s_sin-avx.c = -msse2avx -DSSE2AVX -CFLAGS-s_tan-avx.c = -msse2avx -DSSE2AVX -CFLAGS-s_sincos-avx.c = -msse2avx -DSSE2AVX +CFLAGS-e_atan2-avx.c = -mavx +CFLAGS-e_exp-avx.c = -mavx +CFLAGS-e_log-avx.c = -mavx +CFLAGS-s_atan-avx.c = -mavx +CFLAGS-s_sin-avx.c = -mavx +CFLAGS-s_tan-avx.c = -mavx +CFLAGS-s_sincos-avx.c = -mavx CFLAGS-s_modf-sse4_1.c = -msse4.1 -fno-builtin-modff32x -fno-builtin-modff64 CFLAGS-s_modff-sse4_1.c = -msse4.1 -fno-builtin-modff32 From patchwork Fri Oct 31 20:00:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123257 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5131A3860C39 for ; Fri, 31 Oct 2025 20:18:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5131A3860C39 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=FyoX4Fg/ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id C7F213850856 for ; Fri, 31 Oct 2025 20:04:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C7F213850856 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 C7F213850856 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941043; cv=none; b=kUEf5PUfQ/USg7eCztFH8/Tl40xOmeCi9K1zJ3gjwB4iz3gPjsyZYrORq0X0HS91we/BMO1ncuW32SkWjuXAr4wAj+o+mTIJIY5pkADdQd8rNJF5SC0SHvE6KHWTCKv6DuCpmOmeYmtS9NELJIrewZvOkUZbYrgbNsGyxj2MgKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941043; c=relaxed/simple; bh=sQp3zCILmE6D4pmLPZKQNfHmWUGUMDk+WfWA9c2oWjY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=V2ZvCJrun/cI2owTO8cj/07YvfnVd4z03xyeE3z36CpBWHnljH7/gsHMSokhKS9Uc8W2M1hrFfM37MA72erlltNBZowl46h/JUQdPfT8cpltFe9U4StPhIs12r3CqU8TdD0BYdFWP/iqUiXgLBiqKjPofW/hPVCQ3+YapbDXRb0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7F213850856 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-b6ceba7c97eso2413957a12.0 for ; Fri, 31 Oct 2025 13:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941041; x=1762545841; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aOqTz9s8jBqOT8Qko2UzGS6KD7oBglUM+gVL0KWMMiU=; b=FyoX4Fg/rYLliznzNZXQ6INQJfuvnJ+lxqN/P38BDmWAEPgn/YBjKcjw9sFjAxGdsc L8DW5zyjDE8cctGYZIlx5Md7A1/d1BffxLYkB4hqa0TjGro4G4ugaWrF1RhqiAOEEohS cS5gsxncVpSYjjXr6JVInfUe5XRBLQhVjva/LPLPMoNKSORD3dwj+miaVzEX3t8xHzQ9 1oKOaYbiLOf+3h5rH96ndISbP7e/ySwctS+c4o5Jm8FEufIedcepmVu6e5zbB+B5yUgu ubtq6Ah73JeqokOVFCpzPMdghKc6l981uIDbYgVSEXLPRfxXTN55dYBNY5tw8zw/ztAd 5sSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941041; x=1762545841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aOqTz9s8jBqOT8Qko2UzGS6KD7oBglUM+gVL0KWMMiU=; b=abPEo/XMnHSMPGwHoyTKGP7O/Ziea7B6WbVGGJoGyCS+z7MVg1+DylBVGoFh65bV/H tvN7Lw5IFyu+f/RVHCSxZv8LvWQcsaI/XjT8sJu5+v0dSif9cHWbqs2af+GJC2hjxGfB anpo4LwsY71rre8r9P9oh8AYQMNxHFuyRDg/zv1/Y5EU8Pw67kSYCGwNFgSbx+hQQQRy OIyqNDKbEbc4JIRnC7u9e03k7VQ8KOaFUkZhsuLrBYMGMo900Pylj0H/Lim41i2GNwV/ bl4399+t9+qZWwxN5UC3Y8FjowlN91MEI97u+0pRsI7GhPDgQXtPcFm4O+Oltl/8cXhk wVfw== X-Gm-Message-State: AOJu0YwiOxTv6TuvG4ANU1EpAi2bJPRs5RpN+iZbNWg7hvq9DsJX7sZF P++21H+CTbgD6rsn3kkN44G0wKE7CQ5z1Tp1jqNYL/9GfJwwhfPrymEbXzkY5f3xusKejc2AC4m BHvavHx4= X-Gm-Gg: ASbGncsjaw93av0oR1qJvephv+miD71PCjg1ZBTtjXdD9QrEScO8z/uncY0fBoHfy1y nDIRFlfhiB5MghM97JlImtxnYMvSvWS/MGMZld2pmRF0jf3ybmNTArVkA4DWJ1Hyz1+mt5KldaC XVd2O7Fe4eMT+z4YwdbAhZLn/sTU+0nf5ivaRacSRCoL0JV35tpT4A6NWpW/aZwfkGHiUwddbCo IjBsHyMsMTklF5gb30kbdOJFdPqSvQTHtsgxgrF1AjxvljMnrdTZ+tej6LTrD29ZvJaaLzpvRMo hmhDLnKWSnmnZPDX75+lmskaD5oxow+FIYlbQGCtI6S49DMgwxbAIcU/ROFhG8wpGBRpui3OKwU ZRBe4RUSCsFcWBPTwyEwSxdn+cM1RaYrxWxovMhDfU6jAEnICFm3K0etHvbHw4jqJ+Fk3bkNZIL QYsKGOHdYhYhrYsjCMnkORrb8= X-Google-Smtp-Source: AGHT+IHyJPKIQY2MRvUzbxs8JnBHck29TvtCKJtDUQX+QUt7I/JR/tp9SUoqDhO+Ishn2e4XlU78lg== X-Received: by 2002:a17:902:e845:b0:295:3d5d:fe37 with SMTP id d9443c01a7336-2953d5e059emr26985795ad.41.1761941041217; Fri, 31 Oct 2025 13:04:01 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:00 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 11/19] x86: math: Use of __libgcc_cmp_return__ iff compiler supports it Date: Fri, 31 Oct 2025 17:00:44 -0300 Message-ID: <20251031200300.3716090-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang does not support '__attribute__ ((mode (__libgcc_cmp_return__)))', so use a more close related type instead fo the default 'int'. --- config.h.in | 3 +++ sysdeps/x86/configure | 39 +++++++++++++++++++++++++++++++++++ sysdeps/x86/configure.ac | 18 ++++++++++++++++ sysdeps/x86/fpu/sfp-machine.h | 10 ++++++++- 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/config.h.in b/config.h.in index 8a997f0d4b4..a7cc17df8ed 100644 --- a/config.h.in +++ b/config.h.in @@ -320,4 +320,7 @@ /* Define if compiler allows add attribute after function declaration. */ #undef ATTR_AFTER_FUNC_DECL +/* Define if compiler suport __attribute__ ((mode (__libgcc_cmp_return__))). */ +#undef HAVE_X86_LIBGCC_CMP_RETURN_ATTR + #endif diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure index 2e95277f29e..ad205f69751 100644 --- a/sysdeps/x86/configure +++ b/sysdeps/x86/configure @@ -392,6 +392,45 @@ else fi + +conftest_code=" +int __gcc_CMPtype_GCC __attribute__ ((mode (__libgcc_cmp_return__))); +" + +cat > conftest.c <&5 +printf %s "checking for __libgcc_cmp_return__ mode attribute support... " >&6; } +if test ${libc_cv_cc_x86_libgcc_cmp_return_attribute+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $CFLAGS conftest.c -o conftest 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_cc_x86_libgcc_cmp_return_attribute=yes + else + libc_cv_cc_x86_libgcc_cmp_return_attribute=no + fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_x86_libgcc_cmp_return_attribute" >&5 +printf "%s\n" "$libc_cv_cc_x86_libgcc_cmp_return_attribute" >&6; } +rm -f conftest* +if test "$libc_cv_cc_x86_libgcc_cmp_return_attribute" = yes; then + printf "%s\n" "#define HAVE_X86_LIBGCC_CMP_RETURN_ATTR 1" >>confdefs.h + +else + printf "%s\n" "#define HAVE_X86_LIBGCC_CMP_RETURN_ATTR 0" >>confdefs.h + +fi + + if test "${libc_cv_cc_no_direct_extern_access}${libc_cv_test_cc_cflags_no_direct_extern_access}" = yes; then libc_cv_protected_data=no fi diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac index f3888e6618b..e0500f21b4e 100644 --- a/sysdeps/x86/configure.ac +++ b/sysdeps/x86/configure.ac @@ -223,6 +223,24 @@ else AC_DEFINE(HAVE_X86_INLINE_TRUNC, 0) fi + +conftest_code=" +int __gcc_CMPtype_GCC __attribute__ ((mode (__libgcc_cmp_return__))); +" +dnl Check if CC support the __libgcc_cmp_return__ mode attribute +LIBC_TRY_CC_COMMAND([for __libgcc_cmp_return__ mode attribute support], + [$conftest_code], + [$CFLAGS], + libc_cv_cc_x86_libgcc_cmp_return_attribute, + [libc_cv_cc_x86_libgcc_cmp_return_attribute=yes], + [libc_cv_cc_x86_libgcc_cmp_return_attribute=no]) +if test "$libc_cv_cc_x86_libgcc_cmp_return_attribute" = yes; then + AC_DEFINE(HAVE_X86_LIBGCC_CMP_RETURN_ATTR, 1) +else + AC_DEFINE(HAVE_X86_LIBGCC_CMP_RETURN_ATTR, 0) +fi + + dnl If the building compiler enables no direct external data access by dnl default, access to protected data in shared libraries from executables dnl must be compiled with no direct external data access. If the testing diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h index cbcedb8621e..9ef85c4e6c2 100644 --- a/sysdeps/x86/fpu/sfp-machine.h +++ b/sysdeps/x86/fpu/sfp-machine.h @@ -1,9 +1,17 @@ /* Configure soft-fp for building sqrtf128. Based on sfp-machine.h in libgcc, with soft-float and other irrelevant parts removed. */ +#if HAVE_X86_LIBGCC_CMP_RETURN_ATTR /* The type of the result of a floating point comparison. This must match `__libgcc_cmp_return__' in GCC for the target. */ -typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); +typedef int __gcc_CMPtype_GCC __attribute__ ((mode (__libgcc_cmp_return__))); +#else +# if defined __x86_64__ && defined __ILP32__ +typedef long long int __gcc_CMPtype; +#else +typedef long int __gcc_CMPtype; +# endif +#endif #define CMPtype __gcc_CMPtype #ifdef __x86_64__ From patchwork Fri Oct 31 20:00:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123251 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A13E1385087E for ; Fri, 31 Oct 2025 20:12:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A13E1385087E 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=ouIShdrw X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id BBD6B385040A for ; Fri, 31 Oct 2025 20:04:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBD6B385040A 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 BBD6B385040A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941044; cv=none; b=LkGTEWOCXyBWD+UNYIoTuioi6uGDG4MTVBGN0N7HhqTg/Ub8HkwSYdic5pT3B/jBZV7pYd6uVcjXGcTsx+xxj8hPCkiKS5w6W3a6hHuO40vvfBrQd4y1kafoDEJK71kUaoOsdzO8xefvJpY+Zv8Xw+EVyqHHE8Aaw9AFqsDeBPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941044; c=relaxed/simple; bh=uLyW3z1mEktHs5BIbY0fIVcMRRsUqxYiY8fV/Mx6Ql8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=N6n5wxCPwjIBJsaBGpyjHavxy4UmyAfW0SL8tys2raSbvbq4TSTN/3b2IZfEj2pnddJCgZ2Ire0kEbzpISSJqfOlSTA1Uh8YUNUqhJS9ldYOWVE998+wNxr4V92/0MQVTV81sPMWdJQ4t6Rc5mKMFpGlD1/ENMios2wHI73HRCA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBD6B385040A Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-b6329b6e3b0so3112256a12.1 for ; Fri, 31 Oct 2025 13:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941043; x=1762545843; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R++g/K4uEajbhxCp0pWWBiV9VdMapiKfJZcVQLcmLkU=; b=ouIShdrw+dRf46/IGZv3xqlzyiS8XAjMLRB8Nm5oTmZ+hO8RLDNBRH3RV0uk2lWI2d zcZ++K6iTpnPCjCHku9MYzgmD0AKDyrlNOkEy1setOJHZmDHP1pLz94pAEfi9MwW6lZq 87lX/3A+cEDEob5YE7YOJYd9em9ZPc/pc4vAtDxRWfBYLAwgT0FM1uR5sugUuX9nrTLC UoZowIS1SqMUSajcxsuyKAFBdE776qUT5FRskKmv63CqLbZN5dX7aEQ2HnOWL7VtjYx0 k3mR6WkdXDDLXy05b7YTDqd0sPpBbVd512USbeO+4ab1dUFOk56muy0adqR30IAy20nU zXMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941043; x=1762545843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R++g/K4uEajbhxCp0pWWBiV9VdMapiKfJZcVQLcmLkU=; b=q8O+OUgkW+nOBWtLARUlm6xSxiQ0Onkpyw0tK6UYjoDY/Ue+Py0eHVic6VrEtcZ0hn ScC6Ebv2ZyF+NdNact5Q4CISeQ8SE3yRHnHMBr+gtSIamtODRXFg4/HetnrSjENoK/G7 v19U2pTFgrm1wa1LNP8kRDGEMKfFNVFMJcRZFrhSepq5PWj52N4plvj6knNNvqzXMfjP /R0mUaJ1xPxnlHQhT1LW2CCUWgUGgLz+CGI1X6k0J/xFAq41EzlTOsw87rPzkxD2Td9F oz7HCccoGElAYpLuA9dkPeyLiu1VdA0cRUZnvhm4tNyaKMjKuPOt7fOhT3+AtC80H1x+ fg2A== X-Gm-Message-State: AOJu0Yw7xtZKMPSLhfvO3JTTz8O+dsiBDK8Oqf/mUt4xtyd5vg+bTXNN YRWvIiZRswSSkfF2LlUUj2e04oD7usZZhXs0IaV3x2cxoXt6J5CBc4Rq6t70IN71KrErGRfE2/l RDZLpUXM= X-Gm-Gg: ASbGncuAIzKKTnWT7SpkD9+g0NTbFLPQIKj5E37+5badEwqLGerifgci2r8y/yZ2Z1c j/WE9xf0AVqxdoZ6ZHMdP6Y7YkM2wN+Tc8+T28fddLXJrG2IacaHhCqe6uUhfLW8kMqSgG/5nOH M+BtsB8HG7FHBBbMlM8zjMgdy+dvFugjphmh2c1Od8RW7WuYv562c5l9WjwIi/Xs8LSVAJ36Y5S Vim0T7j/X+MOOqEoXiNHXrZ0rw61spER5xrxkWl7HpxG/anzYWaOflkPSZKcwm77+N/Ok80lH5/ lMZxU6Q3ItA3iHYizXJ/2eGXYJIDk35YgqP+XV+51W8EOQBk583ffgHsDQTS4jL+6paScICu+zz eVoqKZp7xD0Fhpo9KKY9RzIMeSJ7EGD52bd9ehkwvowsJAxCVacN7tV8vfOdj7GRdR4luIMUeQP 4dA/Wfytm2IqQTPQ+Q1Dm6tiw= X-Google-Smtp-Source: AGHT+IHv8L1jaI/FjcjOBXzAz3PE09fTS70sWTbnqLP34x6mzITNFDvhoXZ3TRMU8keuyKXpXvcqUw== X-Received: by 2002:a17:903:2f8f:b0:267:9601:dca0 with SMTP id d9443c01a7336-29519cb62e5mr60105915ad.27.1761941043513; Fri, 31 Oct 2025 13:04:03 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:02 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 12/19] x86: Fix strstr ifunc on clang Date: Fri, 31 Oct 2025 17:00:45 -0300 Message-ID: <20251031200300.3716090-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang triggers multiple issue on how ifunc macro are used: ../sysdeps/x86_64/multiarch/strstr.c:38:54: error: attribute declaration must precede definition [-Werror,-Wignored-attributes] 38 | extern __typeof (__redirect_strstr) __strstr_generic attribute_hidden; | ^ ./../include/libc-symbols.h:356:43: note: expanded from macro 'attribute_hidden' 356 | # define attribute_hidden __attribute__ ((visibility ("hidden"))) | ^ ../string/strstr.c:76:1: note: previous definition is here 76 | STRSTR (const char *haystack, const char *needle) | ^ ../sysdeps/x86_64/multiarch/strstr.c:27:16: note: expanded from macro 'STRSTR' 27 | #define STRSTR __strstr_generic | ^ ../sysdeps/x86_64/multiarch/strstr.c:65:43: error: redefinition of '__libc_strstr' 65 | libc_ifunc_redirected (__redirect_strstr, __libc_strstr, IFUNC_SELECTOR ()); | ^ And ../sysdeps/x86_64/multiarch/strstr.c:65:43: error: redefinition of '__libc_strstr' 65 | libc_ifunc_redirected (__redirect_strstr, __libc_strstr, IFUNC_SELECTOR ()); | ^ ../sysdeps/x86_64/multiarch/strstr.c:59:13: note: previous definition is here 59 | libc_ifunc (__libc_strstr, | ^ Refactor to use a auxiliary function like other selection (for instance, x86_64/multiarch/strcmp.c). --- sysdeps/x86_64/multiarch/strstr.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sysdeps/x86_64/multiarch/strstr.c b/sysdeps/x86_64/multiarch/strstr.c index e18e6418aec..f669a57689e 100644 --- a/sysdeps/x86_64/multiarch/strstr.c +++ b/sysdeps/x86_64/multiarch/strstr.c @@ -31,19 +31,24 @@ __hidden_ver1 (__strstr_generic, __GI_strstr, __strstr_generic); #endif -#include "string/strstr.c" - extern __typeof (__redirect_strstr) __strstr_sse2_unaligned attribute_hidden; extern __typeof (__redirect_strstr) __strstr_generic attribute_hidden; +#include "string/strstr.c" + #include "init-arch.h" -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle - ifunc symbol properly. */ -extern __typeof (__redirect_strstr) __libc_strstr; -libc_ifunc (__libc_strstr, - HAS_ARCH_FEATURE (Fast_Unaligned_Load) - ? __strstr_sse2_unaligned - : __strstr_generic) +static inline void * +IFUNC_SELECTOR (void) +{ + const struct cpu_features *cpu_features = __get_cpu_features (); + + if (CPU_FEATURES_ARCH_P (cpu_features, Fast_Unaligned_Load)) + return __strstr_sse2_unaligned; + + return __strstr_generic; +} + +libc_ifunc_redirected (__redirect_strstr, __libc_strstr, IFUNC_SELECTOR ()); #undef strstr strong_alias (__libc_strstr, strstr) From patchwork Fri Oct 31 20:00:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123261 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7EDE5385021C for ; Fri, 31 Oct 2025 20:22:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EDE5385021C 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=XoXiS4C1 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 738423850846 for ; Fri, 31 Oct 2025 20:04:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 738423850846 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 738423850846 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941048; cv=none; b=xVNmC3XZY4/mW2RuphhyvqSCzFGW9KomgZ4Yik5YGRmzftaLjzOSOuynq+nHfxvofvDYGm+YjcZjDR3YzlsaSaLITBiH+a8ZBuiYRzhbOuSsF1ITewxAFy65lKwrpzm6hxTBSLPx92De/pRtIQB+2Q9mksj2iTbNMXVvohIU1fc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941048; c=relaxed/simple; bh=SrY2ilEQx1xilta4RqNNS/sU3cyzk8KEKLQKlt8g0Co=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JuG5ne7yqSz5XSZCmzrHA9/llvrf/w2Xcc53R0F5MkDbg11zMa4icofqBeq3nxMeX//fxEdSgO/tx4Pwe5vHlWkxR1goEIQOXQd/kzX7QWRRt8UKjq7i5XIaikGnDvqLPYVIWJCExgK6e/lsvj530Vd10VlXOUVM5MSVo6ejJW0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 738423850846 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-b6cf3174ca4so2123323a12.2 for ; Fri, 31 Oct 2025 13:04:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941047; x=1762545847; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sg9PGl/42NWVyaxhxnPG2uOlJTw05cODMMz6xSxAXWk=; b=XoXiS4C1tlpysuQZTyJrqQIhgLV1dbpi3MmYW6qHk6yrImRt+1lRr6MlJnIQJe+8On q/RbtVvdhr2XwhhDJEqGotjm4+uWptGM+JbM4EB4x/BBjbMNcbxk2DPwIGW2dGlpv3lx XAi20pFWltWMbpUqsGdFbWQJZ2W03jkH8E4sZjKbhQswYQK8MpHktwJhI78LBTYMz9x5 irZSwAk8xweOH9VPeXYYL6NIpOGyFYuHacyRxgGVFguGiD+khwhv9ztpT53OEGTqSuXb Zh13o8t4znxs0uLdUBWXnOToYPsDCs0UXYBljTh0yBpV24mn0zMkfa7XTmTtR5ge3Yjz d5UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941047; x=1762545847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sg9PGl/42NWVyaxhxnPG2uOlJTw05cODMMz6xSxAXWk=; b=NAMIIakTK+AYMdWYLbUpYxYkJR/jG6XUmTBsv4AX8+CUMKX7dHRxfjz9O+9f7QOzK5 Usq0J+BrE/H/49B4nMt9C6Tpt9ycN8czfTkY86JjZwlE2Nl3XfsKZzTh3nAahgkrLjQI 2Zv1lE2Qb/1ZizNJccQ6QJbUr8FvkLFl4xxI7dQl3ked7O/WRNyYQxGMmjxaVsePHiUX I86ckmyuK/fiCKZ8cIx3OJRv19g/pgZNlNi07MLx/eNSbg3ON3dAYHg+OOvpEFvQ2c85 rylNYRhdbkKRfTd6tuURXkJWXj+kpgGsrSYxL0BjH5TBVtsg2NQR+n7LMsBCWqQ5ymln vwKQ== X-Gm-Message-State: AOJu0Yw4DbRjlabPWlgWHd/3HpSheFnAvavrziPVIoJIBrneVeMHWWUE J52dTfVWMT1j5/6O99wnGYQ+VNuRGeBLIGLk4QMMa0JgOulI4Hyt6z4LjP4aqLObL8yk7Oh6Hce a4PK/Ka0= X-Gm-Gg: ASbGncs/bkG6UUkwnDwCC/ZuzXZHPbeQTtG5ohiZjcNUO/Zc27ctywNwmVvbRTbErs4 t781OdfC2oj5wY/BT2AvoluqrIRQUrAsAgOgvPX66olDZsWEoRN4BbGdqu09e/CtoVhyuPf5DkV IiLZoXLE0GV4nd3q7BgJoEduytQtkDVUlC1680uoAE198ncEcKx71Liayoj7yGIFgcd+9gyNttD FrPsuwUIL2O0lBemTVzD8V1AwQSowGIXdWc8mmDJyKrO/A6V0Jc4NskJRPOqUS6RGADrtlkw9o8 QEBG3WX3ZgXl3zVd1BOse8nE/BRj/veDx7/IsIo80wXFhbnRzqd0HXlYsPFIjl7IBRvMZY2dZjx Od/1aA/0Aw9jVcvM9uViuF65zUDD7zUx1RzCxRT8G6xYd/WA+oDq0qxeTB4u25LTVI8NMhu97N+ fw1/ZuZOCBUGdZ X-Google-Smtp-Source: AGHT+IGtPZby2fTPdu5WkLwUc1awQxBwtcsHFo3IgYk8t248tr113Bmf2s0lteHZDk4Y3aS+EK7Kxw== X-Received: by 2002:a17:902:e807:b0:295:2d76:72f7 with SMTP id d9443c01a7336-2952d767396mr30747195ad.14.1761941045788; Fri, 31 Oct 2025 13:04:05 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:05 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 13/19] x86: Adapt "%v" usage on clang to emit VEX enconding Date: Fri, 31 Oct 2025 17:00:46 -0300 Message-ID: <20251031200300.3716090-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang does not support the %v to select the AVX encoding, nor the '%d' asm contrain, and for AVX build it requires all 3 arguments. This patch add a new internal header, math-inline-asm.h, that adds functions to abstract the inline asm required differences between gcc and clang. Reviewed-by: H.J. Lu --- sysdeps/i386/fpu/fclrexcpt.c | 5 +- sysdeps/i386/fpu/fedisblxcpt.c | 5 +- sysdeps/i386/fpu/feenablxcpt.c | 5 +- sysdeps/i386/fpu/fegetenv.c | 3 +- sysdeps/i386/fpu/fegetmode.c | 3 +- sysdeps/i386/fpu/feholdexcpt.c | 5 +- sysdeps/i386/fpu/fesetenv.c | 5 +- sysdeps/i386/fpu/fesetexcept.c | 8 ++-- sysdeps/i386/fpu/fesetmode.c | 6 ++- sysdeps/i386/fpu/fesetround.c | 6 +-- sysdeps/i386/fpu/feupdateenv.c | 3 +- sysdeps/i386/fpu/fgetexcptflg.c | 6 +-- sysdeps/i386/fpu/fsetexcptflg.c | 5 +- sysdeps/i386/fpu/ftestexcept.c | 5 +- sysdeps/i386/setfpucw.c | 7 +-- sysdeps/x86/fpu/fenv_private.h | 37 +++++++-------- sysdeps/x86/fpu/math-inline-asm.h | 77 +++++++++++++++++++++++++++++++ sysdeps/x86/fpu/math_private.h | 8 ++-- sysdeps/x86/fpu/sfp-machine.h | 4 +- sysdeps/x86/fpu/test-fenv-sse-2.c | 23 +++------ sysdeps/x86_64/fpu/fclrexcpt.c | 5 +- sysdeps/x86_64/fpu/fedisblxcpt.c | 5 +- sysdeps/x86_64/fpu/feenablxcpt.c | 5 +- sysdeps/x86_64/fpu/fegetenv.c | 12 +++-- sysdeps/x86_64/fpu/fegetmode.c | 3 +- sysdeps/x86_64/fpu/feholdexcpt.c | 10 ++-- sysdeps/x86_64/fpu/fesetenv.c | 9 ++-- sysdeps/x86_64/fpu/fesetexcept.c | 6 +-- sysdeps/x86_64/fpu/fesetmode.c | 6 ++- sysdeps/x86_64/fpu/fesetround.c | 7 +-- sysdeps/x86_64/fpu/feupdateenv.c | 4 +- sysdeps/x86_64/fpu/fgetexcptflg.c | 5 +- sysdeps/x86_64/fpu/fraiseexcpt.c | 18 ++------ sysdeps/x86_64/fpu/fsetexcptflg.c | 5 +- sysdeps/x86_64/fpu/ftestexcept.c | 5 +- 35 files changed, 210 insertions(+), 121 deletions(-) create mode 100644 sysdeps/x86/fpu/math-inline-asm.h diff --git a/sysdeps/i386/fpu/fclrexcpt.c b/sysdeps/i386/fpu/fclrexcpt.c index 39bcf3de590..cd301a08199 100644 --- a/sysdeps/i386/fpu/fclrexcpt.c +++ b/sysdeps/i386/fpu/fclrexcpt.c @@ -19,6 +19,7 @@ #include #include #include +#include int __feclearexcept (int excepts) @@ -44,13 +45,13 @@ __feclearexcept (int excepts) unsigned int xnew_exc; /* Get the current MXCSR. */ - __asm__ ("%vstmxcsr %0" : "=m" (xnew_exc)); + stmxcsr_inline_asm (&xnew_exc); /* Clear the relevant bits. */ xnew_exc &= ~excepts; /* Put the new data in effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (xnew_exc)); + ldmxcsr_inline_asm (&xnew_exc); } /* Success. */ diff --git a/sysdeps/i386/fpu/fedisblxcpt.c b/sysdeps/i386/fpu/fedisblxcpt.c index a2dfa8e4c95..eb232eaadc3 100644 --- a/sysdeps/i386/fpu/fedisblxcpt.c +++ b/sysdeps/i386/fpu/fedisblxcpt.c @@ -19,6 +19,7 @@ #include #include #include +#include int fedisableexcept (int excepts) @@ -41,11 +42,11 @@ fedisableexcept (int excepts) unsigned int xnew_exc; /* Get the current control word. */ - __asm__ ("%vstmxcsr %0" : "=m" (xnew_exc)); + stmxcsr_inline_asm (&xnew_exc); xnew_exc |= excepts << 7; - __asm__ ("%vldmxcsr %0" : : "m" (xnew_exc)); + ldmxcsr_inline_asm (&xnew_exc); } return old_exc; diff --git a/sysdeps/i386/fpu/feenablxcpt.c b/sysdeps/i386/fpu/feenablxcpt.c index fa1d82a4b6b..01d19b8fcee 100644 --- a/sysdeps/i386/fpu/feenablxcpt.c +++ b/sysdeps/i386/fpu/feenablxcpt.c @@ -19,6 +19,7 @@ #include #include #include +#include int feenableexcept (int excepts) @@ -41,11 +42,11 @@ feenableexcept (int excepts) unsigned int xnew_exc; /* Get the current control word. */ - __asm__ ("%vstmxcsr %0" : "=m" (xnew_exc)); + stmxcsr_inline_asm (&xnew_exc); xnew_exc &= ~(excepts << 7); - __asm__ ("%vldmxcsr %0" : : "m" (xnew_exc)); + ldmxcsr_inline_asm (&xnew_exc); } return old_exc; diff --git a/sysdeps/i386/fpu/fegetenv.c b/sysdeps/i386/fpu/fegetenv.c index 5b355771511..9cfc884f3a0 100644 --- a/sysdeps/i386/fpu/fegetenv.c +++ b/sysdeps/i386/fpu/fegetenv.c @@ -19,6 +19,7 @@ #include #include #include +#include int __fegetenv (fenv_t *envp) @@ -30,7 +31,7 @@ __fegetenv (fenv_t *envp) __asm__ ("fldenv %0" : : "m" (*envp)); if (CPU_FEATURE_USABLE (SSE)) - __asm__ ("%vstmxcsr %0" : "=m" (envp->__eip)); + stmxcsr_inline_asm (&envp->__eip); /* Success. */ return 0; diff --git a/sysdeps/i386/fpu/fegetmode.c b/sysdeps/i386/fpu/fegetmode.c index 8b109072f50..1d9577855f4 100644 --- a/sysdeps/i386/fpu/fegetmode.c +++ b/sysdeps/i386/fpu/fegetmode.c @@ -20,12 +20,13 @@ #include #include #include +#include int fegetmode (femode_t *modep) { _FPU_GETCW (modep->__control_word); if (CPU_FEATURE_USABLE (SSE)) - __asm__ ("%vstmxcsr %0" : "=m" (modep->__mxcsr)); + stmxcsr_inline_asm (&modep->__mxcsr); return 0; } diff --git a/sysdeps/i386/fpu/feholdexcpt.c b/sysdeps/i386/fpu/feholdexcpt.c index f6f6b70dd4f..02351ce4fce 100644 --- a/sysdeps/i386/fpu/feholdexcpt.c +++ b/sysdeps/i386/fpu/feholdexcpt.c @@ -19,6 +19,7 @@ #include #include #include +#include int __feholdexcept (fenv_t *envp) @@ -33,12 +34,12 @@ __feholdexcept (fenv_t *envp) unsigned int xwork; /* Get the current control word. */ - __asm__ ("%vstmxcsr %0" : "=m" (envp->__eip)); + stmxcsr_inline_asm (&envp->__eip); /* Set all exceptions to non-stop and clear them. */ xwork = (envp->__eip | 0x1f80) & ~0x3f; - __asm__ ("%vldmxcsr %0" : : "m" (xwork)); + ldmxcsr_inline_asm (&xwork); } return 0; diff --git a/sysdeps/i386/fpu/fesetenv.c b/sysdeps/i386/fpu/fesetenv.c index e6b276a0fcd..4fdd0f9e99b 100644 --- a/sysdeps/i386/fpu/fesetenv.c +++ b/sysdeps/i386/fpu/fesetenv.c @@ -21,6 +21,7 @@ #include #include #include +#include /* All exceptions, including the x86-specific "denormal operand" @@ -80,7 +81,7 @@ __fesetenv (const fenv_t *envp) if (CPU_FEATURE_USABLE (SSE)) { unsigned int mxcsr; - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); if (envp == FE_DFL_ENV) { @@ -111,7 +112,7 @@ __fesetenv (const fenv_t *envp) else mxcsr = envp->__eip; - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } /* Success. */ diff --git a/sysdeps/i386/fpu/fesetexcept.c b/sysdeps/i386/fpu/fesetexcept.c index 876bde233fb..3604bcfca72 100644 --- a/sysdeps/i386/fpu/fesetexcept.c +++ b/sysdeps/i386/fpu/fesetexcept.c @@ -18,6 +18,7 @@ #include #include +#include int fesetexcept (int excepts) @@ -31,15 +32,16 @@ fesetexcept (int excepts) if (CPU_FEATURE_USABLE (SSE)) { - /* Get the control word of the SSE unit. */ unsigned int mxcsr; - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + + /* Get the control word of the SSE unit. */ + stmxcsr_inline_asm (&mxcsr); /* Set relevant flags. */ mxcsr |= excepts; /* Put the new data in effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } else { diff --git a/sysdeps/i386/fpu/fesetmode.c b/sysdeps/i386/fpu/fesetmode.c index ee61ca1cec6..a68fb223e1c 100644 --- a/sysdeps/i386/fpu/fesetmode.c +++ b/sysdeps/i386/fpu/fesetmode.c @@ -20,6 +20,7 @@ #include #include #include +#include /* All exceptions, including the x86-specific "denormal operand" exception. */ @@ -37,7 +38,8 @@ fesetmode (const femode_t *modep) if (CPU_FEATURE_USABLE (SSE)) { unsigned int mxcsr; - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + + stmxcsr_inline_asm (&mxcsr); /* Preserve SSE exception flags but restore other state in MXCSR. */ mxcsr &= FE_ALL_EXCEPT_X86; @@ -47,7 +49,7 @@ fesetmode (const femode_t *modep) mxcsr |= FE_ALL_EXCEPT_X86 << 7; else mxcsr |= modep->__mxcsr & ~FE_ALL_EXCEPT_X86; - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } return 0; } diff --git a/sysdeps/i386/fpu/fesetround.c b/sysdeps/i386/fpu/fesetround.c index e87d794319e..90fab76f78e 100644 --- a/sysdeps/i386/fpu/fesetround.c +++ b/sysdeps/i386/fpu/fesetround.c @@ -19,6 +19,7 @@ #include #include #include +#include int __fesetround (int round) @@ -38,11 +39,10 @@ __fesetround (int round) if (CPU_FEATURE_USABLE (SSE)) { unsigned int xcw; - - __asm__ ("%vstmxcsr %0" : "=m" (xcw)); + stmxcsr_inline_asm (&xcw); xcw &= ~0x6000; xcw |= round << 3; - __asm__ ("%vldmxcsr %0" : : "m" (xcw)); + ldmxcsr_inline_asm (&xcw); } return 0; diff --git a/sysdeps/i386/fpu/feupdateenv.c b/sysdeps/i386/fpu/feupdateenv.c index 9e1ad97118c..9544b86520f 100644 --- a/sysdeps/i386/fpu/feupdateenv.c +++ b/sysdeps/i386/fpu/feupdateenv.c @@ -19,6 +19,7 @@ #include #include #include +#include int __feupdateenv (const fenv_t *envp) @@ -31,7 +32,7 @@ __feupdateenv (const fenv_t *envp) /* If the CPU supports SSE we test the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) - __asm__ ("%vstmxcsr %0" : "=m" (xtemp)); + stmxcsr_inline_asm (&xtemp); temp = (temp | xtemp) & FE_ALL_EXCEPT; diff --git a/sysdeps/i386/fpu/fgetexcptflg.c b/sysdeps/i386/fpu/fgetexcptflg.c index 36dd297cdcb..ef8ec76c9b1 100644 --- a/sysdeps/i386/fpu/fgetexcptflg.c +++ b/sysdeps/i386/fpu/fgetexcptflg.c @@ -19,6 +19,7 @@ #include #include #include +#include int @@ -34,10 +35,9 @@ __fegetexceptflag (fexcept_t *flagp, int excepts) /* If the CPU supports SSE, we clear the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) { - unsigned int sse_exc; - /* Get the current MXCSR. */ - __asm__ ("%vstmxcsr %0" : "=m" (sse_exc)); + unsigned int sse_exc; + stmxcsr_inline_asm (&sse_exc); *flagp |= sse_exc & excepts & FE_ALL_EXCEPT; } diff --git a/sysdeps/i386/fpu/fsetexcptflg.c b/sysdeps/i386/fpu/fsetexcptflg.c index b78d1dcd3cd..e386e8032b0 100644 --- a/sysdeps/i386/fpu/fsetexcptflg.c +++ b/sysdeps/i386/fpu/fsetexcptflg.c @@ -18,6 +18,7 @@ #include #include +#include int __fesetexceptflag (const fexcept_t *flagp, int excepts) @@ -50,13 +51,13 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts) __asm__ ("fldenv %0" : : "m" (temp)); /* And now similarly for SSE. */ - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); /* Clear or set relevant flags. */ mxcsr ^= (mxcsr ^ *flagp) & excepts; /* Put the new data in effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } else { diff --git a/sysdeps/i386/fpu/ftestexcept.c b/sysdeps/i386/fpu/ftestexcept.c index 51abfd39172..8fb239aeea7 100644 --- a/sysdeps/i386/fpu/ftestexcept.c +++ b/sysdeps/i386/fpu/ftestexcept.c @@ -19,19 +19,20 @@ #include #include #include +#include int __fetestexcept (int excepts) { short temp; - int xtemp = 0; + unsigned int xtemp = 0; /* Get current exceptions. */ __asm__ ("fnstsw %0" : "=a" (temp)); /* If the CPU supports SSE we test the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) - __asm__ ("%vstmxcsr %0" : "=m" (xtemp)); + stmxcsr_inline_asm (&xtemp); return (temp | xtemp) & excepts & FE_ALL_EXCEPT; } diff --git a/sysdeps/i386/setfpucw.c b/sysdeps/i386/setfpucw.c index 8438c7ed754..baeddf9af59 100644 --- a/sysdeps/i386/setfpucw.c +++ b/sysdeps/i386/setfpucw.c @@ -21,6 +21,7 @@ #include #include #include +#include void __setfpucw (fpu_control_t set) @@ -40,14 +41,14 @@ __setfpucw (fpu_control_t set) /* If the CPU supports SSE, we set the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) { + /* Get the current MXCSR. */ unsigned int xnew_exc; - /* Get the current MXCSR. */ - __asm__ ("%vstmxcsr %0" : "=m" (xnew_exc)); + stmxcsr_inline_asm (&xnew_exc); xnew_exc &= ~((0xc00 << 3) | (FE_ALL_EXCEPT << 7)); xnew_exc |= ((set & 0xc00) << 3) | ((set & FE_ALL_EXCEPT) << 7); - __asm__ ("%vldmxcsr %0" : : "m" (xnew_exc)); + ldmxcsr_inline_asm (&xnew_exc); } } diff --git a/sysdeps/x86/fpu/fenv_private.h b/sysdeps/x86/fpu/fenv_private.h index c9b573cacd5..24a17419611 100644 --- a/sysdeps/x86/fpu/fenv_private.h +++ b/sysdeps/x86/fpu/fenv_private.h @@ -4,6 +4,7 @@ #include #include #include +#include /* This file is used by both the 32- and 64-bit ports. The 64-bit port has a field in the fenv_t for the mxcsr; the 32-bit port does not. @@ -22,10 +23,10 @@ static __always_inline void libc_feholdexcept_sse (fenv_t *e) { unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); e->__mxcsr = mxcsr; mxcsr = (mxcsr | 0x1f80) & ~0x3f; - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } static __always_inline void @@ -43,9 +44,9 @@ static __always_inline void libc_fesetround_sse (int r) { unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); mxcsr = (mxcsr & ~0x6000) | (r << 3); - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } static __always_inline void @@ -61,10 +62,10 @@ static __always_inline void libc_feholdexcept_setround_sse (fenv_t *e, int r) { unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); e->__mxcsr = mxcsr; mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | (r << 3); - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } /* Set both rounding mode and precision. A convenience function for use @@ -96,7 +97,7 @@ static __always_inline int libc_fetestexcept_sse (int e) { unsigned int mxcsr; - asm volatile ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); return mxcsr & e & FE_ALL_EXCEPT; } @@ -111,7 +112,7 @@ libc_fetestexcept_387 (int ex) static __always_inline void libc_fesetenv_sse (fenv_t *e) { - asm volatile ("%vldmxcsr %0" : : "m" (e->__mxcsr)); + ldmxcsr_inline_asm (&e->__mxcsr); } static __always_inline void @@ -129,13 +130,13 @@ static __always_inline int libc_feupdateenv_test_sse (fenv_t *e, int ex) { unsigned int mxcsr, old_mxcsr, cur_ex; - asm volatile ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); cur_ex = mxcsr & FE_ALL_EXCEPT; /* Merge current exceptions with the old environment. */ old_mxcsr = e->__mxcsr; mxcsr = old_mxcsr | cur_ex; - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); /* Raise SIGFPE for any new exceptions since the hold. Expect that the normal environment has all exceptions masked. */ @@ -181,10 +182,10 @@ static __always_inline void libc_feholdsetround_sse (fenv_t *e, int r) { unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); e->__mxcsr = mxcsr; mxcsr = (mxcsr & ~0x6000) | (r << 3); - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } static __always_inline void @@ -215,9 +216,9 @@ static __always_inline void libc_feresetround_sse (fenv_t *e) { unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); mxcsr = (mxcsr & ~0x6000) | (e->__mxcsr & 0x6000); - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); } static __always_inline void @@ -307,13 +308,13 @@ static __always_inline void libc_feholdexcept_setround_sse_ctx (struct rm_ctx *ctx, int r) { unsigned int mxcsr, new_mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); new_mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | (r << 3); ctx->env.__mxcsr = mxcsr; if (__glibc_unlikely (mxcsr != new_mxcsr)) { - asm volatile ("%vldmxcsr %0" : : "m" (new_mxcsr)); + ldmxcsr_inline_asm (&new_mxcsr); ctx->updated_status = true; } else @@ -404,13 +405,13 @@ libc_feholdsetround_sse_ctx (struct rm_ctx *ctx, int r) { unsigned int mxcsr, new_mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); new_mxcsr = (mxcsr & ~0x6000) | (r << 3); ctx->env.__mxcsr = mxcsr; if (__glibc_unlikely (new_mxcsr != mxcsr)) { - asm volatile ("%vldmxcsr %0" : : "m" (new_mxcsr)); + ldmxcsr_inline_asm (&new_mxcsr); ctx->updated_status = true; } else diff --git a/sysdeps/x86/fpu/math-inline-asm.h b/sysdeps/x86/fpu/math-inline-asm.h new file mode 100644 index 00000000000..d4588979c0c --- /dev/null +++ b/sysdeps/x86/fpu/math-inline-asm.h @@ -0,0 +1,77 @@ +/* Math inline asm compat layer + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_INLINE_ASM +#define _MATH_INLINE_ASM + +#include + +/* clang does not support the %v to select the AVX encoding, nor the '%d' asm + contrain, and for AVX build it requires all 3 arguments. */ +#ifdef __clang__ +#if defined __AVX__ +# define VPREFIX "v" +# define VROUND_ARG ", %0" +# else +# define VPREFIX "" +# define VROUND_ARG "" +# endif +# define VARGPREFIX "%" +#else +# define VPREFIX "%v" +# define VARGPREFIX "%d" +# define VROUND_ARG "" +#endif + +__extern_always_inline double +trunc_inline_asm (double x) +{ + asm (VPREFIX "roundsd $11, " VARGPREFIX "1, %0" VROUND_ARG : "=v" (x) + : "v" (x)); + return x; +} + +__extern_always_inline float +truncf_inline_asm (float x) +{ + asm (VPREFIX "roundss $11, " VARGPREFIX "1, %0" VROUND_ARG : "=v" (x) + : "v" (x)); + return x; +} + +static __always_inline void +stmxcsr_inline_asm (unsigned int *mxcsr) +{ + asm volatile (VPREFIX "stmxcsr %0" : "=m" (*mxcsr)); +} + +static __always_inline void +ldmxcsr_inline_asm (unsigned int *mxcsr) +{ + asm volatile (VPREFIX "ldmxcsr %0" : : "m" (*mxcsr)); +} + +static __always_inline float +divss_inline_asm (float x, float y) +{ + asm volatile (VPREFIX "divss %1, " VARGPREFIX "0" VROUND_ARG + : "+x" (x) : "x" (y)); + return x; +} + +#endif diff --git a/sysdeps/x86/fpu/math_private.h b/sysdeps/x86/fpu/math_private.h index bba085a5788..47de90bcec9 100644 --- a/sysdeps/x86/fpu/math_private.h +++ b/sysdeps/x86/fpu/math_private.h @@ -20,8 +20,10 @@ #define X86_MATH_PRIVATE_H 1 #include +#include #include_next + __extern_always_inline long double __NTH (__ieee754_atan2l (long double y, long double x)) { @@ -36,8 +38,7 @@ __trunc (double x) #if HAVE_X86_INLINE_TRUNC || !defined __SSE4_1__ return trunc (x); #else - asm ("%vroundsd $11, %d1, %0" : "=v" (x) : "v" (x)); - return x; + return trunc_inline_asm (x); #endif } @@ -47,8 +48,7 @@ __truncf (float x) #if HAVE_X86_INLINE_TRUNC || !defined __SSE4_1__ return truncf (x); #else - asm ("%vroundss $11, %d1, %0" : "=v" (x) : "v" (x)); - return x; + return truncf_inline_asm (x); #endif } diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h index 9ef85c4e6c2..227f5ffe49c 100644 --- a/sysdeps/x86/fpu/sfp-machine.h +++ b/sysdeps/x86/fpu/sfp-machine.h @@ -1,6 +1,8 @@ /* Configure soft-fp for building sqrtf128. Based on sfp-machine.h in libgcc, with soft-float and other irrelevant parts removed. */ +#include + #if HAVE_X86_LIBGCC_CMP_RETURN_ATTR /* The type of the result of a floating point comparison. This must match `__libgcc_cmp_return__' in GCC for the target. */ @@ -55,7 +57,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); # define FP_INIT_ROUNDMODE \ do { \ - __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw)); \ + stmxcsr_inline_asm (&_fcw); \ } while (0) #else # define _FP_W_TYPE_SIZE 32 diff --git a/sysdeps/x86/fpu/test-fenv-sse-2.c b/sysdeps/x86/fpu/test-fenv-sse-2.c index d12009bb811..0ab090c0ad9 100644 --- a/sysdeps/x86/fpu/test-fenv-sse-2.c +++ b/sysdeps/x86/fpu/test-fenv-sse-2.c @@ -24,33 +24,22 @@ #include #include #include - -static uint32_t -get_sse_mxcsr (void) -{ - uint32_t temp; - __asm__ __volatile__ ("%vstmxcsr %0" : "=m" (temp)); - return temp; -} - -static void -set_sse_mxcsr (uint32_t val) -{ - __asm__ __volatile__ ("%vldmxcsr %0" : : "m" (val)); -} +#include static void set_sse_mxcsr_bits (uint32_t mask, uint32_t bits) { - uint32_t mxcsr = get_sse_mxcsr (); + uint32_t mxcsr; + stmxcsr_inline_asm (&mxcsr); mxcsr = (mxcsr & ~mask) | bits; - set_sse_mxcsr (mxcsr); + ldmxcsr_inline_asm (&mxcsr); } static int test_sse_mxcsr_bits (const char *test, uint32_t mask, uint32_t bits) { - uint32_t mxcsr = get_sse_mxcsr (); + uint32_t mxcsr; + stmxcsr_inline_asm (&mxcsr); printf ("Testing %s: mxcsr = %x\n", test, mxcsr); if ((mxcsr & mask) == bits) { diff --git a/sysdeps/x86_64/fpu/fclrexcpt.c b/sysdeps/x86_64/fpu/fclrexcpt.c index d5f70458c0d..80dcbf91471 100644 --- a/sysdeps/x86_64/fpu/fclrexcpt.c +++ b/sysdeps/x86_64/fpu/fclrexcpt.c @@ -17,6 +17,7 @@ . */ #include +#include int __feclearexcept (int excepts) @@ -38,13 +39,13 @@ __feclearexcept (int excepts) __asm__ ("fldenv %0" : : "m" (temp)); /* And the same procedure for SSE. */ - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); /* Clear the relevant bits. */ mxcsr &= ~excepts; /* And put them into effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); /* Success. */ return 0; diff --git a/sysdeps/x86_64/fpu/fedisblxcpt.c b/sysdeps/x86_64/fpu/fedisblxcpt.c index dab9ad19c23..759cf85e6f8 100644 --- a/sysdeps/x86_64/fpu/fedisblxcpt.c +++ b/sysdeps/x86_64/fpu/fedisblxcpt.c @@ -17,6 +17,7 @@ . */ #include +#include int fedisableexcept (int excepts) @@ -35,11 +36,11 @@ fedisableexcept (int excepts) __asm__ ("fldcw %0" : : "m" (new_exc)); /* And now the same for the SSE MXCSR register. */ - __asm__ ("%vstmxcsr %0" : "=m" (new)); + stmxcsr_inline_asm (&new); /* The SSE exception masks are shifted by 7 bits. */ new |= excepts << 7; - __asm__ ("%vldmxcsr %0" : : "m" (new)); + ldmxcsr_inline_asm (&new); return old_exc; } diff --git a/sysdeps/x86_64/fpu/feenablxcpt.c b/sysdeps/x86_64/fpu/feenablxcpt.c index 828b2b247a8..4cf04b35bf1 100644 --- a/sysdeps/x86_64/fpu/feenablxcpt.c +++ b/sysdeps/x86_64/fpu/feenablxcpt.c @@ -17,6 +17,7 @@ . */ #include +#include int feenableexcept (int excepts) @@ -35,11 +36,11 @@ feenableexcept (int excepts) __asm__ ("fldcw %0" : : "m" (new_exc)); /* And now the same for the SSE MXCSR register. */ - __asm__ ("%vstmxcsr %0" : "=m" (new)); + stmxcsr_inline_asm (&new); /* The SSE exception masks are shifted by 7 bits. */ new &= ~(excepts << 7); - __asm__ ("%vldmxcsr %0" : : "m" (new)); + ldmxcsr_inline_asm (&new); return old_exc; } diff --git a/sysdeps/x86_64/fpu/fegetenv.c b/sysdeps/x86_64/fpu/fegetenv.c index fa21ec4f862..21ed713acad 100644 --- a/sysdeps/x86_64/fpu/fegetenv.c +++ b/sysdeps/x86_64/fpu/fegetenv.c @@ -17,15 +17,17 @@ . */ #include +#include int __fegetenv (fenv_t *envp) { - __asm__ ("fnstenv %0\n" - /* fnstenv changes the exception mask, so load back the - stored environment. */ - "fldenv %0\n" - "%vstmxcsr %1" : "=m" (*envp), "=m" (envp->__mxcsr)); + asm volatile ("fnstenv %0\n" + /* fnstenv changes the exception mask, so load back the + stored environment. */ + "fldenv %0" + : "=m" (*envp)); + stmxcsr_inline_asm (&envp->__mxcsr); /* Success. */ return 0; diff --git a/sysdeps/x86_64/fpu/fegetmode.c b/sysdeps/x86_64/fpu/fegetmode.c index 39d124a6d82..fc75d087fd1 100644 --- a/sysdeps/x86_64/fpu/fegetmode.c +++ b/sysdeps/x86_64/fpu/fegetmode.c @@ -18,11 +18,12 @@ #include #include +#include int fegetmode (femode_t *modep) { _FPU_GETCW (modep->__control_word); - __asm__ ("%vstmxcsr %0" : "=m" (modep->__mxcsr)); + stmxcsr_inline_asm (&modep->__mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/feholdexcpt.c b/sysdeps/x86_64/fpu/feholdexcpt.c index 30e31205965..f899e92193c 100644 --- a/sysdeps/x86_64/fpu/feholdexcpt.c +++ b/sysdeps/x86_64/fpu/feholdexcpt.c @@ -17,6 +17,7 @@ . */ #include +#include int __feholdexcept (fenv_t *envp) @@ -25,14 +26,13 @@ __feholdexcept (fenv_t *envp) /* Store the environment. Recall that fnstenv has a side effect of masking all exceptions. Then clear all exceptions. */ - __asm__ ("fnstenv %0\n\t" - "%vstmxcsr %1\n\t" - "fnclex" - : "=m" (*envp), "=m" (envp->__mxcsr)); + asm volatile ("fnstenv %0" : "=m" (*envp)); + stmxcsr_inline_asm (&envp->__mxcsr); + asm volatile ("fnclex" : "=m" (*envp)); /* Set the SSE MXCSR register. */ mxcsr = (envp->__mxcsr | 0x1f80) & ~0x3f; - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/fesetenv.c b/sysdeps/x86_64/fpu/fesetenv.c index a7b87efcde5..d4ab956ad32 100644 --- a/sysdeps/x86_64/fpu/fesetenv.c +++ b/sysdeps/x86_64/fpu/fesetenv.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include @@ -35,8 +36,8 @@ __fesetenv (const fenv_t *envp) values which we do not want to come from the saved environment. Therefore, we get the current environment and replace the values we want to use from the environment specified by the parameter. */ - __asm__ ("fnstenv %0\n" - "%vstmxcsr %1" : "=m" (temp), "=m" (temp.__mxcsr)); + asm volatile ("fnstenv %0" : "=m" (temp)); + stmxcsr_inline_asm (&temp.__mxcsr); if (envp == FE_DFL_ENV) { @@ -103,8 +104,8 @@ __fesetenv (const fenv_t *envp) temp.__mxcsr = envp->__mxcsr; } - __asm__ ("fldenv %0\n" - "%vldmxcsr %1" : : "m" (temp), "m" (temp.__mxcsr)); + asm volatile ("fldenv %0" : "=m" (temp)); + ldmxcsr_inline_asm (&temp.__mxcsr); /* Success. */ return 0; diff --git a/sysdeps/x86_64/fpu/fesetexcept.c b/sysdeps/x86_64/fpu/fesetexcept.c index 91d5270f8e7..39a9f75ddcb 100644 --- a/sysdeps/x86_64/fpu/fesetexcept.c +++ b/sysdeps/x86_64/fpu/fesetexcept.c @@ -17,15 +17,15 @@ . */ #include +#include int fesetexcept (int excepts) { unsigned int mxcsr; - - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); mxcsr |= excepts & FE_ALL_EXCEPT; - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/fesetmode.c b/sysdeps/x86_64/fpu/fesetmode.c index 2b35d7e719d..5959218538e 100644 --- a/sysdeps/x86_64/fpu/fesetmode.c +++ b/sysdeps/x86_64/fpu/fesetmode.c @@ -17,6 +17,7 @@ . */ #include +#include #include /* All exceptions, including the x86-specific "denormal operand" @@ -28,7 +29,8 @@ fesetmode (const femode_t *modep) { fpu_control_t cw; unsigned int mxcsr; - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + + stmxcsr_inline_asm (&mxcsr); /* Preserve SSE exception flags but restore other state in MXCSR. */ mxcsr &= FE_ALL_EXCEPT_X86; @@ -45,6 +47,6 @@ fesetmode (const femode_t *modep) mxcsr |= modep->__mxcsr & ~FE_ALL_EXCEPT_X86; } _FPU_SETCW (cw); - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/fesetround.c b/sysdeps/x86_64/fpu/fesetround.c index 8a5f6c425c6..c7d6421ec6b 100644 --- a/sysdeps/x86_64/fpu/fesetround.c +++ b/sysdeps/x86_64/fpu/fesetround.c @@ -17,12 +17,13 @@ . */ #include +#include int __fesetround (int round) { unsigned short int cw; - int mxcsr; + unsigned int mxcsr; if ((round & ~0xc00) != 0) /* ROUND is no valid rounding mode. */ @@ -36,10 +37,10 @@ __fesetround (int round) /* And now the MSCSR register for SSE, the precision is at different bit positions in the different units, we need to shift it 3 bits. */ - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); mxcsr &= ~ 0x6000; mxcsr |= round << 3; - asm ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/feupdateenv.c b/sysdeps/x86_64/fpu/feupdateenv.c index 0e26b92af51..ca946dc744b 100644 --- a/sysdeps/x86_64/fpu/feupdateenv.c +++ b/sysdeps/x86_64/fpu/feupdateenv.c @@ -17,6 +17,7 @@ . */ #include +#include int __feupdateenv (const fenv_t *envp) @@ -25,7 +26,8 @@ __feupdateenv (const fenv_t *envp) unsigned int xtemp; /* Save current exceptions. */ - __asm__ ("fnstsw %0\n\t%vstmxcsr %1" : "=m" (temp), "=m" (xtemp)); + asm volatile ("fnstsw %0" : "=m" (temp)); + stmxcsr_inline_asm (&xtemp); temp = (temp | xtemp) & FE_ALL_EXCEPT; /* Install new environment. */ diff --git a/sysdeps/x86_64/fpu/fgetexcptflg.c b/sysdeps/x86_64/fpu/fgetexcptflg.c index a7b500b6008..b52ba851d76 100644 --- a/sysdeps/x86_64/fpu/fgetexcptflg.c +++ b/sysdeps/x86_64/fpu/fgetexcptflg.c @@ -17,6 +17,7 @@ . */ #include +#include int fegetexceptflag (fexcept_t *flagp, int excepts) @@ -25,8 +26,8 @@ fegetexceptflag (fexcept_t *flagp, int excepts) unsigned int mxscr; /* Get the current exceptions for the x87 FPU and SSE unit. */ - __asm__ ("fnstsw %0\n" - "%vstmxcsr %1" : "=m" (temp), "=m" (mxscr)); + __asm__ ("fnstsw %0" : "=m" (temp)); + stmxcsr_inline_asm (&mxscr); *flagp = (temp | mxscr) & FE_ALL_EXCEPT & excepts; diff --git a/sysdeps/x86_64/fpu/fraiseexcpt.c b/sysdeps/x86_64/fpu/fraiseexcpt.c index dae0c3bc311..f0a1d8282b5 100644 --- a/sysdeps/x86_64/fpu/fraiseexcpt.c +++ b/sysdeps/x86_64/fpu/fraiseexcpt.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -29,23 +30,12 @@ __feraiseexcept (int excepts) /* First: invalid exception. */ if ((FE_INVALID & excepts) != 0) - { - /* One example of an invalid operation is 0.0 / 0.0. */ - float f = 0.0; - - __asm__ __volatile__ ("%vdivss %0, %d0 " : "+x" (f)); - (void) &f; - } + /* One example of an invalid operation is 0.0 / 0.0. */ + divss_inline_asm (0.0f, 0.0f); /* Next: division by zero. */ if ((FE_DIVBYZERO & excepts) != 0) - { - float f = 1.0; - float g = 0.0; - - __asm__ __volatile__ ("%vdivss %1, %d0" : "+x" (f) : "x" (g)); - (void) &f; - } + divss_inline_asm (1.0f, 0.0f); /* Next: overflow. */ if ((FE_OVERFLOW & excepts) != 0) diff --git a/sysdeps/x86_64/fpu/fsetexcptflg.c b/sysdeps/x86_64/fpu/fsetexcptflg.c index 34ea24c0613..86415573233 100644 --- a/sysdeps/x86_64/fpu/fsetexcptflg.c +++ b/sysdeps/x86_64/fpu/fsetexcptflg.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -44,13 +45,13 @@ fesetexceptflag (const fexcept_t *flagp, int excepts) __asm__ ("fldenv %0" : : "m" (temp)); /* And now similarly for SSE. */ - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + stmxcsr_inline_asm (&mxcsr); /* Clear or set relevant flags. */ mxcsr ^= (mxcsr ^ *flagp) & excepts; /* Put the new data in effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (&mxcsr); /* Success. */ return 0; diff --git a/sysdeps/x86_64/fpu/ftestexcept.c b/sysdeps/x86_64/fpu/ftestexcept.c index 7e0a097696c..1d23e7ca80f 100644 --- a/sysdeps/x86_64/fpu/ftestexcept.c +++ b/sysdeps/x86_64/fpu/ftestexcept.c @@ -17,6 +17,7 @@ . */ #include +#include int __fetestexcept (int excepts) @@ -25,8 +26,8 @@ __fetestexcept (int excepts) unsigned int mxscr; /* Get current exceptions. */ - __asm__ ("fnstsw %0\n" - "%vstmxcsr %1" : "=m" (temp), "=m" (mxscr)); + asm volatile ("fnstsw %0" : "=m" (temp)); + stmxcsr_inline_asm (&mxscr); return (temp | mxscr) & excepts & FE_ALL_EXCEPT; } From patchwork Fri Oct 31 20:00:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123256 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC19E385086F for ; Fri, 31 Oct 2025 20:17:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC19E385086F 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=R3Emv9sh X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id E9B733850847 for ; Fri, 31 Oct 2025 20:04:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9B733850847 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 E9B733850847 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::633 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941050; cv=none; b=CBIdlwmEzYXKVwNO4qWraOoqlQbyv6rWSDYfJ1xvq7So6xXPc4h4e0zRX106ThkcseVYPSjw1b3pYL3zi+AbLKMAHGVWmvAmyTPFssEE2F1teRNkLMh8nl/yAj9XqN16l3LVde0o/tGYk+agZxzFq06oI18gK3jAbhykENugtI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941050; c=relaxed/simple; bh=bKDxLp0uVDaX9kwHm28k4ix80JQr1tcMUmbulZAgl58=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=W8QJy6tIuySV7vnKMWzE117Te4ezfr3CsNDQNxlFhvFbOtXDfEI4YfU7hEaC4Qx5k23zKC67tq7Kf5i+ESnsDsUHdG4U8Jh43w2cIEm4SqjnHsk5Vhle/DE0bAwECcbyFoB10cVKj4qBCCyQnfzooPK7gde6wulI/2n5UkPcj9U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9B733850847 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2953ad5517dso8678585ad.0 for ; Fri, 31 Oct 2025 13:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941048; x=1762545848; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XCk42FuR+p5RehAt+YfScipcIgCx5r/r72schyIfZNc=; b=R3Emv9shJnvBLQhz6dpOjnFqBN6Vo/VwtLm2rSC4DJUGOJtn7EiPn9GhHtPdY9d8aE pY3MgzcgFBz9F6bH7k17TzsokFmEnv2gG6UKKlLYntEpk/rAKttyBmVQguAChM6KCaXW Pl4S7SNRNlMpbhUBlWuhzROTiGxYaCn1YfaD43fOHycMSNxFTpyJo+KeSOSxvGJZi+iX OW6rwyMrH9LnojqTNt89QjSCJch5rJn6t9A7RTGdtrQrBeay0IvfF0wlAKwLBlX1ar+V B4yx12K22tle8546hRhbgAtPUnNk9B6kwayagekaTStb3xE7ucmEpkoxC9uVus6vgKRS fCRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941048; x=1762545848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XCk42FuR+p5RehAt+YfScipcIgCx5r/r72schyIfZNc=; b=rHTOmHhk1cU7MYaZWFeJczPF0h2omsV0o0VO3QnsBGCpUBbUW1BnvVZI7DgB52RlX2 naBVOZs83kP9C6YD8Tz7VLHznsXCyvqEg18hVCHQvHDpan14skzUFzy2t9s0FrCYWgZO hhcyUi8HEBAW2Agrs6oIuRP/eSpFKiBiotm88bIH5XnJnw44DdO7wnt/kySK+Zpx1po9 JcnSXcl+XgqF2zIXy7gvMTb1Si8m82kpU5nHrQj3dHFZXg0oHEfrsHyrLxBhN6ZFb9h4 1zu99tzbm6048Dxi5qLGG+MvYOZBIiqj1Hi2tkhvZqHIo5LTNbA/rbDeNiHu3BSiKysP gHJw== X-Gm-Message-State: AOJu0YwFliQ2FzTqKMnRyHaBetMvecgxtiDnAuz8DavhJlXTIRNtE1tw /grtLI+wKsAyFbqfYDH+T2SLNW2axfJBUnoFW7MBQKb2JLEkXwb2NfhDjZW9q2yoh+doy6h3yNK sDIIj3pw= X-Gm-Gg: ASbGncvsZSdpdBQ6UUpgy6Lrh0bHTbwT3546+IjATf4m1kTGU+tovtA/QmwIGDX5W5T s8vtV2cS2PU1qdmqVldH63V0NZzMjVBjQb3D6IU5MRb7woPcioVBt1VKQQnOnbxCSgXgGSxmfx4 MD1VJlwqXMn/nTUsOHSI363CQWShj7zF84CUTPi0L3S3lvYjijSG42iEEj6O4KeV932Ecletocm HaLdILE/be41MdSkOVo1fXIFbhbwZYNkw908LGIXnvu6uAwigMl3xUUwxzaYp0zOT2dr1EicQme KZw1ibu67XtA+RW4n2b3PXwT6T6F5PZRBqN6tYbO+mjoivklV1mPNIkgVha7qdpbAlwX3BS6ACt 5RC/GLiD55ojaJiJ2AuQ2tfW4w2XuBHQ8W0XWqis988W9EzfQB+b3be8tcgTmVdDWOxH3ybz95s CVuy2hqStpBy5z+mjAtMB3Gmw= X-Google-Smtp-Source: AGHT+IEOTL9pfYNFdsxugxRxJOyu+IpvByjQHWq8RPXlyDeQUPmpUAPWGYhSV8JquXGZBDoyZzTPjQ== X-Received: by 2002:a17:903:2450:b0:269:6e73:b90a with SMTP id d9443c01a7336-2951a388519mr63676295ad.15.1761941047998; Fri, 31 Oct 2025 13:04:07 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:07 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 14/19] x86: Fix THREAD_GSCOPE_RESET_FLAG build on clang Date: Fri, 31 Oct 2025 17:00:47 -0300 Message-ID: <20251031200300.3716090-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang does not support __seg_fs in asm constraint. --- sysdeps/x86_64/nptl/tls.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h index abfeb880545..9d53f05e65c 100644 --- a/sysdeps/x86_64/nptl/tls.h +++ b/sysdeps/x86_64/nptl/tls.h @@ -198,10 +198,18 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80, # define THREAD_GSCOPE_FLAG_UNUSED 0 # define THREAD_GSCOPE_FLAG_USED 1 # define THREAD_GSCOPE_FLAG_WAIT 2 + +/* clang does not support __seg_fs in asm constraint. */ +# ifdef __clang__ +# define FS_ASM "%%fs:" +# else +# define FS_ASM +# endif + # define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res; \ - asm volatile ("xchgl %1, %0" \ + asm volatile ("xchgl " FS_ASM "%1, %0" \ : "=r" (__res) \ : "m" (((struct pthread __seg_fs *)0)->header.gscope_flag), \ "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ From patchwork Fri Oct 31 20:00:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123262 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 740BC385021E for ; Fri, 31 Oct 2025 20:25:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 740BC385021E 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=hAiilZgw X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 2647C385043A for ; Fri, 31 Oct 2025 20:04:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2647C385043A 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 2647C385043A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941052; cv=none; b=my7G7evbkxYlUF+14e9jjZnjwA67yx4LtK/tz9DDz94zZLQp8zxPSfEhE/+3fnupNu9qNZPEpR9SoQNDWlXTogozHUksdIP5cphnpBkfT2Ceyh8HX3mpqLfZXhRuMjBsHxPQAzGg35LBYvah7jqUQ1DxVfcCW9fQPbN736hqXfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941052; c=relaxed/simple; bh=Je0UbjIjh4oFMriIV+LdJR3SsrULAsAPpp3F4qqAdQ8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pH+D976kWPSZT6NNL3tvyTpLJhjgBZ2VoyZEqWnMxRWCw8HaGIHLZcgN+uAnJ6epXShc8Oym25S3ujZzPovXsFI/ABcH4eyFLCZh9CYUmw/A57ZvtzPfBS0QwmQ2uyZw+nrlb+hnL4niQ2kd10eE2wZR/NU8YxlOSrGIHz2sMlY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2647C385043A Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-29470bc80ceso29983535ad.1 for ; Fri, 31 Oct 2025 13:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941051; x=1762545851; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=psxyBi5ezZgpCQ/j4zk0vVjHMAJhEfxnfluRQuq7hmQ=; b=hAiilZgwaG7QbmFywI7o3DQs/bxo3r3UevKPAeUHQd7yRRojUIHpG9wTmaA/Zeywta DPT8A4OeSqoW+f48WfWWpDoqF+Ycm7kHHHz1xkFO7IscnjwtPzZ4v/380oqeADlAHayb QhhsO3JpPbEIdYOv9lkFKxyjN9vqgrsbSUiLjtL25hPymqbF60t2z+0DfLTpVhvsUmw3 sSERiMzKlvMsuysNW5zqQ84o/6wxBRaX1bwHPq94OzvCSks7+NNzWiQK908IWziOPiQw YelwJvqnEU4lyFR+UM3YRaugPzJ8bHqnMMFjQLz+sRKVFwwVKpn6TVl5wUvWJH3UYsIX 1phA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941051; x=1762545851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=psxyBi5ezZgpCQ/j4zk0vVjHMAJhEfxnfluRQuq7hmQ=; b=vD86x2/2mCcHIfaiEuXbq9hlYyYLH/7/6s9GdKQzviHC0bzA3X0zPNtW6oW0C8tXHP Jtp18RKNQzaE5tlmwVFBCQ0KH3HyKaDgznk1mh//r5XXvyR6sC7xtFhYQvCSIlbV7ZVj bbmWCP2NJCTzS6ZnPgKKRzwuCLc50YqPY4uXYlphagL/K24ZRNGh8mkgMf1+Dm6GTOjw iX7aAdaDANYafsLuke1Hbig7BYxFrjZJ7RmjFKFB8WY9PhxPg/XNQr801tiguziwHAty ipNDOnWMfBMfiCLVqIKDpkZPDhoK5v2mLKTiuOw7MrHo0QzytI70J98xJa0zTcwNrYuE feDg== X-Gm-Message-State: AOJu0Yxh5yB21K0i+NRqiO9NafsOSI1fRw5pf8HOChSKc7xj1wiCb6U8 T+eRBD9WnIh1V5Im+t0H9ahxl0MdD+7i4uuXrI1SXMmAnzZmhRWxRAApl1DbfUg6VaytMTfjDY+ IpK2kn9Y= X-Gm-Gg: ASbGncvRBHiA3OPY7snhKFQAi9qIIZUK+ROPtOrVzSbdGCSD5FcDaXenf5xX8rTZVMC sn6Y9UxEOVeEPWOr6l60j6ZM9Vcf3UvoqhGoUzm84owwrooFux4LzHooZTwEOD419IIqiwUME8A krlJqglBDg9T6ZLY17JSkrAnpD1wrANxEBn9WrSXMGwHysBJlkOJjhwMnjX4CDwEmapqobpaZ/n sz8NOM+Ky7IO7uUqyPGHcD1oDCg9kZsX3d9mBt9uCgWsQYqLtFyF4AT5Fhlr3JGKcXtfxfpyrH2 2G6rp+yNTlmnc39F4R3Q4kVWSzwQyuuProm0IwjbfB1IdfDioWO3NlRQsy9a31TPdxrBNl1uMpX VX2phkJ+TPpvwY3cMTPGirBhhuSAYrRCwMW70KUoPn94XIr0TYHEfDj30xysRo7IoyrlLWODM94 mJDEFcNtlpkBL2 X-Google-Smtp-Source: AGHT+IHqRLgWEuEweuGtTLQj5BPaoLGkrcZ7M9Cw/KGpmMNEWCBmP5aDxUj1SAUP21ADgwEsVq/z0w== X-Received: by 2002:a17:902:e84e:b0:27c:3690:2c5d with SMTP id d9443c01a7336-294ece0ac03mr118004305ad.0.1761941050293; Fri, 31 Oct 2025 13:04:10 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:09 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 15/19] Enable --enable-fortify-source with clang Date: Fri, 31 Oct 2025 17:00:48 -0300 Message-ID: <20251031200300.3716090-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang generates internal calls for some _chk symbol, so add internal aliases for them, and stub some with rtld-stubbed-symbols to avoid ld.so linker issues. --- debug/vasprintf_chk.c | 1 + debug/vfprintf_chk.c | 1 + elf/Makefile | 8 ++++++++ include/arpa/inet.h | 2 -- include/bits/inet-fortified-decl.h | 5 +++++ include/bits/stdio2-decl.h | 7 +++++++ include/bits/string_fortified.h | 15 +++++++++++++++ include/bits/syslog-decl.h | 4 ++++ include/bits/unistd-decl.h | 6 ++++++ include/bits/wchar2-decl.h | 5 +++++ include/stdio.h | 10 ++++++++-- include/unistd.h | 4 ---- include/wchar.h | 1 - inet/bits/inet-fortified.h | 2 ++ libio/Makefile | 1 + misc/syslog.c | 4 +++- string/Makefile | 1 + sysdeps/generic/symbol-hacks.h | 15 +++++++++++++++ .../ieee754/ldbl-128ibm-compat/ieee128-snprintf.c | 4 ++++ .../ieee754/ldbl-128ibm-compat/ieee128-syslog.c | 5 +++-- 20 files changed, 89 insertions(+), 12 deletions(-) diff --git a/debug/vasprintf_chk.c b/debug/vasprintf_chk.c index 41c15689eeb..f86320cadb0 100644 --- a/debug/vasprintf_chk.c +++ b/debug/vasprintf_chk.c @@ -35,3 +35,4 @@ __vasprintf_chk (char **result_ptr, int flag, const char *format, va_list ap) return __vasprintf_internal (result_ptr, format, ap, mode); } +libc_hidden_def (__vasprintf_chk) diff --git a/debug/vfprintf_chk.c b/debug/vfprintf_chk.c index 74b7c86add2..999b6aa3934 100644 --- a/debug/vfprintf_chk.c +++ b/debug/vfprintf_chk.c @@ -29,3 +29,4 @@ ___vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap) return __vfprintf_internal (fp, format, ap, mode); } ldbl_strong_alias (___vfprintf_chk, __vfprintf_chk) +ldbl_hidden_def (___vfprintf_chk, __vfprintf_chk) diff --git a/elf/Makefile b/elf/Makefile index 5a676f858d6..dd21fe62411 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1487,6 +1487,14 @@ rtld-stubbed-symbols = \ realloc \ # rtld-stubbed-symbols +# These symbols might be emitted by the compiler when fortify is enabled +# (through builtins). +rtld-stubbed-symbols += \ + __GI___vfprintf_chk \ + __GI___vsprintf_chk \ + __GI___vsyslog_chk \ + # rtld-stubbed-symbols + ifeq ($(have-ssp),yes) # rtld is not built with the stack protector, so these references will # go away in the rebuilds. diff --git a/include/arpa/inet.h b/include/arpa/inet.h index 3db8f1a96fd..7650e1acb5e 100644 --- a/include/arpa/inet.h +++ b/include/arpa/inet.h @@ -14,12 +14,10 @@ libc_hidden_proto (__inet_aton_exact) extern __typeof (inet_ntop) __inet_ntop; libc_hidden_proto (__inet_ntop) -libc_hidden_proto (__inet_ntop_chk) libc_hidden_proto (inet_pton) extern __typeof (inet_pton) __inet_pton; libc_hidden_proto (__inet_pton) -libc_hidden_proto (__inet_pton_chk) extern __typeof (inet_makeaddr) __inet_makeaddr; libc_hidden_proto (__inet_makeaddr) diff --git a/include/bits/inet-fortified-decl.h b/include/bits/inet-fortified-decl.h index e6ad4d4663c..1110ce49f2c 100644 --- a/include/bits/inet-fortified-decl.h +++ b/include/bits/inet-fortified-decl.h @@ -1 +1,6 @@ #include + +#ifndef _ISOMAC +libc_hidden_proto (__inet_ntop_chk) +libc_hidden_proto (__inet_pton_chk) +#endif diff --git a/include/bits/stdio2-decl.h b/include/bits/stdio2-decl.h index bbb052f1922..9758bf4b557 100644 --- a/include/bits/stdio2-decl.h +++ b/include/bits/stdio2-decl.h @@ -1 +1,8 @@ #include + +#ifndef _ISOMAC +libc_hidden_proto (__fgets_unlocked_chk) +libc_hidden_ldbl_proto (vfprintf) +libc_hidden_ldbl_proto (__vasprintf_chk) +libc_hidden_ldbl_proto (__vfprintf_chk) +#endif diff --git a/include/bits/string_fortified.h b/include/bits/string_fortified.h index 88bf073c9cf..0cf0e76db1d 100644 --- a/include/bits/string_fortified.h +++ b/include/bits/string_fortified.h @@ -1 +1,16 @@ +#ifndef _ISOMAC +# if IS_IN(libc) && defined SHARED +/* Redirect calls from __builtin_stpcpy_chk to internal __stpcpy when building + with fortify enable. */ +__asm__ ("stpcpy = __GI___stpcpy"); +# endif + +/* Add the internal aliass attribute to symbol before they first usage on the + fortify wrappers. */ +libc_hidden_builtin_proto (memcpy) +libc_hidden_builtin_proto (mempcpy) +libc_hidden_builtin_proto (memmove) +libc_hidden_builtin_proto (memset) +#endif + #include diff --git a/include/bits/syslog-decl.h b/include/bits/syslog-decl.h index 491a263777a..762b2891842 100644 --- a/include/bits/syslog-decl.h +++ b/include/bits/syslog-decl.h @@ -1 +1,5 @@ #include + +#ifndef _ISOMAC +libc_hidden_ldbl_proto (__vsyslog_chk) +#endif diff --git a/include/bits/unistd-decl.h b/include/bits/unistd-decl.h index 7fcbd272acb..dd6af7e4c8d 100644 --- a/include/bits/unistd-decl.h +++ b/include/bits/unistd-decl.h @@ -1 +1,7 @@ #include + +#ifndef _ISOMAC +libc_hidden_proto (__read_chk) +libc_hidden_proto (__getdomainname_chk) +libc_hidden_proto (__getlogin_r_chk) +#endif diff --git a/include/bits/wchar2-decl.h b/include/bits/wchar2-decl.h index 00b1b93342e..f3b8a8cf879 100644 --- a/include/bits/wchar2-decl.h +++ b/include/bits/wchar2-decl.h @@ -1 +1,6 @@ #include + +#ifndef _ISOMAC +libc_hidden_builtin_proto (__wmemset_chk) +libc_hidden_proto (__wcrtomb_chk) +#endif diff --git a/include/stdio.h b/include/stdio.h index b892c5b4af9..e5fe5db43d4 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -23,8 +23,12 @@ redirecting ldouble to _Float128 variants. We can therefore safely directly alias them to their internal name. */ # if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 && IS_IN (libc) -# define stdio_hidden_ldbl_proto(p, f) \ - extern __typeof (p ## f) p ## f __asm (__ASMNAME ("___ieee128_" #f)); +# ifdef SHARED +# define stdio_hidden_ldbl_proto(p, f) __LDBL_REDIR2_DECL (f) +# else +# define stdio_hidden_ldbl_proto(p, f) \ + extern __typeof (p ## f) p ## f __asm (#p __ASMNAME (#f "ieee128")); +# endif # elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # define stdio_hidden_ldbl_proto(p,f) __LDBL_REDIR1_DECL (p ## f, p ## f ## ieee128) # else @@ -70,10 +74,12 @@ extern int __printf_chk (int, const char *, ...); extern int __fprintf_chk (FILE *, int, const char *, ...); extern int __vprintf_chk (int, const char *, __gnuc_va_list); extern int __vfprintf_chk (FILE *, int, const char *, __gnuc_va_list); +stdio_hidden_ldbl_proto (__, vfprintf_chk) extern char *__fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp); extern char *__fgets_chk (char *buf, size_t size, int n, FILE *fp); extern int __asprintf_chk (char **, int, const char *, ...) __THROW; extern int __vasprintf_chk (char **, int, const char *, __gnuc_va_list) __THROW; +stdio_hidden_ldbl_proto (__, vasprintf_chk) extern int __dprintf_chk (int, int, const char *, ...); extern int __vdprintf_chk (int, int, const char *, __gnuc_va_list); extern int __obstack_printf_chk (struct obstack *, int, const char *, ...) diff --git a/include/unistd.h b/include/unistd.h index 376ab5a9368..c1a4736951b 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -32,10 +32,6 @@ libc_hidden_proto (readlinkat) libc_hidden_proto (fsync) libc_hidden_proto (fdatasync) -libc_hidden_proto (__read_chk) -libc_hidden_proto (__getdomainname_chk) -libc_hidden_proto (__getlogin_r_chk) - /* Now define the internal interfaces. */ extern int __access (const char *__name, int __type); libc_hidden_proto (__access) diff --git a/include/wchar.h b/include/wchar.h index bf326257364..6abb0d26972 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -166,7 +166,6 @@ libc_hidden_proto (putwc) libc_hidden_proto (mbrtowc) libc_hidden_proto (wcrtomb) -libc_hidden_proto (__wcrtomb_chk) extern int __wcscmp (const wchar_t *__s1, const wchar_t *__s2) __THROW __attribute_pure__; diff --git a/inet/bits/inet-fortified.h b/inet/bits/inet-fortified.h index cc476ebcfde..0919bc9779f 100644 --- a/inet/bits/inet-fortified.h +++ b/inet/bits/inet-fortified.h @@ -45,6 +45,7 @@ __NTH (inet_pton (int __af, __fortify_clang_warning_only_if_bos0_lt (4, __dst, "inet_pton called with destination buffer size less than 4") { +#if !__fortify_use_clang size_t __sz = 0; if (__af == AF_INET) __sz = sizeof (struct in_addr); @@ -52,6 +53,7 @@ __NTH (inet_pton (int __af, __sz = sizeof (struct in6_addr); else return __inet_pton_alias (__af, __src, __dst); +#endif return __glibc_fortify (inet_pton, __sz, sizeof (char), __glibc_objsize (__dst), diff --git a/libio/Makefile b/libio/Makefile index 2bc98365225..f946cd311b4 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -60,6 +60,7 @@ routines_no_fortify += \ iofgets_u \ iofgetws \ iofgetws_u \ + iovdprintf \ swprintf \ vasprintf \ vsnprintf \ diff --git a/misc/syslog.c b/misc/syslog.c index 53bb3342591..b7414e7b43a 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -114,10 +114,12 @@ ldbl_hidden_def (___syslog_chk, __syslog_chk) ldbl_strong_alias (___syslog_chk, __syslog_chk) void -__vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) +___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) { __vsyslog_internal (pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0); } +ldbl_hidden_def (___vsyslog_chk, __vsyslog_chk) +ldbl_strong_alias (___vsyslog_chk, __vsyslog_chk) void __vsyslog_internal (int pri, const char *fmt, va_list ap, diff --git a/string/Makefile b/string/Makefile index 2f30e66df58..7c0245452b2 100644 --- a/string/Makefile +++ b/string/Makefile @@ -121,6 +121,7 @@ routines := \ # Exclude fortified routines from being built with _FORTIFY_SOURCE routines_no_fortify += \ + bzero \ explicit_bzero \ memcpy \ memmove \ diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h index 1115e4c0a7a..58398d33a5f 100644 --- a/sysdeps/generic/symbol-hacks.h +++ b/sysdeps/generic/symbol-hacks.h @@ -6,6 +6,21 @@ asm ("memmove = __GI_memmove"); asm ("memset = __GI_memset"); asm ("memcpy = __GI_memcpy"); +/* clang might generate the internal fortfify calls when it is enabled, + through the buitintin. */ +asm ("__vfprintf_chk = __GI___vfprintf_chk"); +asm ("__vsprintf_chk = __GI___vsprintf_chk"); +asm ("__vsyslog_chk = __GI___vsyslog_chk"); +asm ("__memcpy_chk = __GI___memcpy_chk"); +asm ("__memmove_chk = __GI___memmove_chk"); +asm ("__memset_chk = __GI___memset_chk"); +asm ("__mempcpy_chk = __GI___mempcpy_chk"); +asm ("__stpcpy_chk = __GI___stpcpy_chk"); +asm ("__strcpy_chk = __GI___strcpy_chk"); +asm ("strcpy = __GI_strcpy"); +asm ("strncpy = __GI_strncpy"); +asm ("strcat = __GI_strcat"); + /* Some targets do not use __stack_chk_fail_local. In libc.so, redirect __stack_chk_fail to a hidden reference __stack_chk_fail_local, to avoid the PLT reference. diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c index d458da7903c..f880a55e0b9 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c @@ -33,3 +33,7 @@ ___ieee128_snprintf (char *s, size_t maxlen, const char *format, ...) return done; } strong_alias (___ieee128_snprintf, __snprintfieee128) +ldbl_hidden_def (___ieee128_snprintf, ___ieee128_snprintf) +#ifdef SHARED +strong_alias (___ieee128_snprintf, __GI____ieee128___snprintf) +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c index 197b149d0f2..e08ae3aa280 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c @@ -56,7 +56,7 @@ hidden_def (___ieee128___syslog_chk) strong_alias (___ieee128___syslog_chk, __syslog_chkieee128) void -___ieee128___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) +____ieee128___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) { unsigned int mode = PRINTF_LDBL_USES_FLOAT128; if (flag > 0) @@ -64,4 +64,5 @@ ___ieee128___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) __vsyslog_internal (pri, fmt, ap, mode); } -strong_alias (___ieee128___vsyslog_chk, __vsyslog_chkieee128) +strong_alias (____ieee128___vsyslog_chk, ___ieee128___vsyslog_chk) +strong_alias (____ieee128___vsyslog_chk, __vsyslog_chkieee128) From patchwork Fri Oct 31 20:00:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123260 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CC553850416 for ; Fri, 31 Oct 2025 20:21:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CC553850416 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=mfVcyP4t X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 591F83860C36 for ; Fri, 31 Oct 2025 20:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 591F83860C36 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 591F83860C36 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941054; cv=none; b=syUDB5uLTfh/FhEa0+pP6AG2WaKYWyrw/WY472z764CY6nhKMUEB6ZPxhXKUCO95kt8vpwQIAMwkD+lqRF7zxpDXpw/zGumAxTfp3LfMkcHwFSi7VqQgEhgRMtFE5UqNC0+A/xazDbprxTBrzpzLjuiZbdspjWd3s5tH971JeSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941054; c=relaxed/simple; bh=OztPmIbbVWAJsICOXcCoO2YbXbaTyiTLx1rT5rhZnmU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=woNgqTUso43NqF5/5GbwXwk9GPObKP6IbCP//mM1bxuU3sP/T7k7vm6z70OukgKw4NwcW0WJ77YpRj6S4blMPGtnDnPMRCalmOp2aMR9vjAj6BxKhaaSlXL3SX5eLLJLOCRGsj5evbI0TGjijtL6sg2M5wB21xB6hK89cmz5XKk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 591F83860C36 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2953ad5517dso8679515ad.0 for ; Fri, 31 Oct 2025 13:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941053; x=1762545853; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ajtI6RAiBRERunfa1akmDzH99Vk9XsMsqpmVDYJgRmw=; b=mfVcyP4thSQWMBEzycxdq31h7DOuX9BxPMd/eaUJOEqR5Juni9TvmmaDAzrFUkSPbP ulVCnA1R0QMznDkTHgqsrjpQCQDzj4+w6RU+NnphrP21klPsuHKGI683H+B/LXE/Cqu0 VD4iSEOVL6qWVXnufTymcOMu/v6jVJb14YNT61TMef1PgbuRk52jBqmNo51PHSluAsaL PS2KOvnG95TWZsuTr0+s3eL7VlyYTN6GL+SGjY0U5gCbYjjSyvssJEpnbb34ek94WXFM C/IDu4NmG+F0GXOwOLPYTSB2jsjhwJZLAtIlS/3mETYSiROD+wl1PofgSSxifywYcIvK E/yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941053; x=1762545853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ajtI6RAiBRERunfa1akmDzH99Vk9XsMsqpmVDYJgRmw=; b=ifre89w7o4bCBHKm9hY+68J/lfoI2bxxX5Z3tzzzPqYB7QnNBtV0MnWBhY36SAmVMt fb0ak2AhZrs5pIY6f5h7wxVN4qfrowy7B6Mg69hcusPyUDB0Yt5akI09u1JD/AC9wlPU 7g7aJlodvEoJkm36yyJ8grbrWK9m0VY6EI/Z0Nx+pj7vVAhuMDdWjxPg3SGx8WJZ6mAD 4Y32hYRPM6clrPJcm+i2Sj/1oDm0xOlB2P9jB0rqcV8el88rCHxTmA/HQj0Jg8Dnl7jZ K4q1PeFcijbr4JaHyBt8GSFNZ2Gq4a55v76StUkYH6y0w6Cgt2/+grNxUsB/huhB2DLM HJlg== X-Gm-Message-State: AOJu0YzUvmCsPiux4Xe3Z3OJ9V4OFwBJErReaD2iIOl3LufC5HtR7vN8 wykoZJw5VyFf0loMxHlV5hxHXKXOQQJDoFCZmt1jI4iTvXkxvg4GCCe2VgiIhpn1+j61WfMX90F KKifNSHM= X-Gm-Gg: ASbGncv/y6w1CVHOC/2u1sIJWj8nZR/AqnY6bPUbzm8fLvR9NfPoji/RfICxkG9SLp/ 8zSPNkGK2U+w9RXCURvNXTnvhaSHok0Y0zmgdZJ34I4dg1LOMQW6e9Sr+qdBAfiu1eMr5z9yj+v XFERW1vvCUL6tyhyuioIBHDYl2hzWXuSjgS5lV/OIHk6nPBW4YEgMbScfBsBLK0ZtkskYbwdBtN 8NVQnf5CC0TeW6H2HbNRz/mJcSWSNgHpKdd+JUasbSoKn+h3w9Z9YQ2sbCZFOKwiGNpZfSLXVCL qfEE5O1A3Xiq2Og0cjQ28AgpnKy+VWP4e/w2TWqdV+Im0KQM5ZfRL6kyYCUgwmpKx0H2HQuLyKd /t9Ol5zuikHh3puENIWxXo780Wc/elX+L0FaEbd+eGHf+HL9rl5/MqqDzohKF/rGG11fKkF27BY tjeSQ81hg6kuoM5NAoshcwwHQ= X-Google-Smtp-Source: AGHT+IGb2uCiwaGvG72yf1elVoGF7V7ijMfCT0FhE2BzBlTTA4Jznv2C0Id8ylvpodNpjv+qUGMY0A== X-Received: by 2002:a17:902:e949:b0:295:bba:9734 with SMTP id d9443c01a7336-2951a3adde5mr60207905ad.24.1761941052980; Fri, 31 Oct 2025 13:04:12 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:12 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 16/19] Filter out internal abort during ld.so build Date: Fri, 31 Oct 2025 17:00:49 -0300 Message-ID: <20251031200300.3716090-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang might generate an abort call when cleanup functions (set by __attribute__ ((cleanup)) calls functions not marked as nothrow. The hurd already provides abort for the loader at sysdeps/mach/hurd/dl-sysdep.c, and adding it rtld-stubbed-symbols triggers duplicate symbols. Reviewed-by: H.J. Lu --- configure | 4 ++++ configure.ac | 3 +++ elf/Makefile | 7 +++++++ sysdeps/mach/hurd/configure | 2 ++ sysdeps/mach/hurd/configure.ac | 2 ++ 5 files changed, 18 insertions(+) diff --git a/configure b/configure index c2e33a5c9f1..086791356a8 100755 --- a/configure +++ b/configure @@ -8915,6 +8915,7 @@ libc_cv_localstatedir=$localstatedir libc_cv_gcc_unwind_find_fde=no libc_cv_idn=no pthread_in_libc=yes +abort_in_ld=no # Iterate over all the sysdep directories we will use, running their # configure fragments. @@ -9497,6 +9498,9 @@ if test "$libc_cv_attr_after_func_decl" = yes; then fi +config_vars="$config_vars +abort-in-ld = $abort_in_ld"; + ac_config_files="$ac_config_files config.make Makefile" ac_config_commands="$ac_config_commands default" diff --git a/configure.ac b/configure.ac index 1150ce9aac7..663eca3caa3 100644 --- a/configure.ac +++ b/configure.ac @@ -1916,6 +1916,7 @@ libc_cv_localstatedir=$localstatedir libc_cv_gcc_unwind_find_fde=no libc_cv_idn=no pthread_in_libc=yes +abort_in_ld=no # Iterate over all the sysdep directories we will use, running their # configure fragments. @@ -2201,6 +2202,8 @@ if test "$libc_cv_attr_after_func_decl" = yes; then AC_DEFINE(ATTR_AFTER_FUNC_DECL) fi +LIBC_CONFIG_VAR([abort-in-ld],[$abort_in_ld]); + AC_CONFIG_FILES([config.make Makefile]) AC_CONFIG_COMMANDS([default],[[ case $CONFIG_FILES in *config.make*) diff --git a/elf/Makefile b/elf/Makefile index dd21fe62411..e95747c7950 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1495,6 +1495,13 @@ rtld-stubbed-symbols += \ __GI___vsyslog_chk \ # rtld-stubbed-symbols +ifeq (no,$(abort-in-ld)) +# clang might generate an abort call for cleanup functions. +rtld-stubbed-symbols += \ + __GI_abort \ + # rtld-stubbed-symbols +endif + ifeq ($(have-ssp),yes) # rtld is not built with the stack protector, so these references will # go away in the rebuilds. diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure index 6ca3bab5112..743bad5fcba 100644 --- a/sysdeps/mach/hurd/configure +++ b/sysdeps/mach/hurd/configure @@ -220,4 +220,6 @@ fi # Hurd has libpthread as a separate library. pthread_in_libc=no +# Hurd already provides abort implementation for the loader +abort_in_ld=yes diff --git a/sysdeps/mach/hurd/configure.ac b/sysdeps/mach/hurd/configure.ac index 1695e94eccb..6d33feed0e7 100644 --- a/sysdeps/mach/hurd/configure.ac +++ b/sysdeps/mach/hurd/configure.ac @@ -48,3 +48,5 @@ fi # Hurd has libpthread as a separate library. pthread_in_libc=no +# Hurd already provides abort implementation for the loader +abort_in_ld=yes From patchwork Fri Oct 31 20:00:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123252 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8EF92385084F for ; Fri, 31 Oct 2025 20:12:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EF92385084F 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=iGk0jLGb X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 85ACD386103B for ; Fri, 31 Oct 2025 20:04:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85ACD386103B 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 85ACD386103B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941056; cv=none; b=tD9J+Bog3pvqWBMnJ2XqHSI/Fj3Co/JYUPvI9XZh1h5nK5rB3J6lAvgKvBqABQOf1V+QmnpHu+gqW1fonGG6A9K0+uudHe2KaYxDQEITK4Wzp10z3teSbGRlOJz/FF57lqeaQK//SC3YuHHyPo+yS3T4NLK/5P7wX4PAsEOKzn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941056; c=relaxed/simple; bh=ggqEVB6xcxQsJMsS0q9y5Jp3RAwgWBfpRh2YL8bKUM0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jZNIT4jGPjwEwXLZ+AL6jWCJMwRBJsORArkq/Nd/Z3qlXM9+0NAoZAB5Ph78Nk9cW8B+kgzVjW2RNirGmXFyEr73ibL5IPP1O4szuqjRttQ3OaDuwZZm52fSOYddTaZGypc3psIM9lJbcrzf7JPsxInN2zHDuT4QaJEb5WN+8uk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85ACD386103B Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-295070beaa4so21071655ad.0 for ; Fri, 31 Oct 2025 13:04:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941055; x=1762545855; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KUxDdSAdhubYRc9gSD7x7NV13bEhmrKRnRvGPppHPoE=; b=iGk0jLGb838t7kpteevjXyk4lTGvTuFXqsOetiRN/3CsoLK6frq92y13XGhvMXP7O2 7WxT/pCsvjE3r1jcTr2W1Vod+14OrD9XrC8OTAODbfk0D93Pr+BH6uCG2caEF1v6o14H rPoe908HsC5W0G6ZsVSKP3is/jqzt+dkqXcUNmlorHRlnFWX4vGcHf6eEoUdpUKN13PN bpc/csQCQJd4OjF7eyXKCTA5Y1Ql05xqYUjIQ7jpHQEn+chfc3Y3603/jlNYmh/SeZcn DXuGD4q1nuuh8IRR6/YpD/MIQaKI1HaXjt8QJz3DrP49FhP8ZTDjheFqUYMR8hcevJh1 qqbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941055; x=1762545855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KUxDdSAdhubYRc9gSD7x7NV13bEhmrKRnRvGPppHPoE=; b=kNjUw9KFKNAwfZ2sqhFbFsB1VfG25d68mWChrLCca+v7tVr0m42OrHPwu98agklRSv z5gK1cx6a0tobSD0iWxGgY3o479+IrvpX6pa+zEc60xctLU+ZsQuemZTos7LiGdMgnFH 2ic+DUekN9gnAKh3Mrlim6vEUGQRKt/ivr2ndjE7I3Ca2ejNpHGTeIgN3v2lW7Uqa1yE 87o126vYnRkiuRltt9s5DMzXlvQpJxYO+s0vLrFVm/8ZNSeFF66gnxMXLUAWhbeOYBzy Ky27QQqaYIROJxdbj90KNabw2CI5Y4/N4F6rXFf6MA1BOTNuYqD/NiwhIabVMcxdnqQ5 UmRg== X-Gm-Message-State: AOJu0YxPfa2pP/FOD8pP6ma6JezRhWVoD4X5ypzcXM3cw0oS0Pi1NaoL 1aHKrP1oEtwm1cdCVP74xi5LH8UMwlUn9HvyXD2c3/swo6B2Zgtsz/XcKZWbj9brO3zmm71RebT 3EVdDrRA= X-Gm-Gg: ASbGncuUOAlMVAnRKSKH4US2LrG+xsNnp/CCX6L1kt8J1Z71RsfRYFyGxE1DrI3Ehiy SeMhMTPJDqcuMUX5K/APc9VOSfuyhgnQjDIrPWU5PivAc4UxYxYD7MhRsHdfOt2yxRePHRNyuVU +MQbxGNRgJzgSnGF/7zdyL8JZtOgEnYUOqnElLWyQWPHe/RQk0AdnOgFs92gok/OY6J8+iw4eha 3hmXv43KFAGfMqVo4TkCxPGpB5HTqv25Q6dQnrLFWuqflRQ8aibIvAhSnXZqr/b2JMOLi0RJZdg x/enZX5ta+MBwdnhBVMWxJG9SX0jBzOsLjzmTCillVtSxuzDBu1UMDZKH+owlKceYQRn+BxLF93 +56JM9dnfsNt7D7Nq3bCGN9wba3Oz55h+qOY7NTBTiFZozrO6AA9HOX1MQh+qgVEsemrBbXDvBB /MwRjlcJOl2pBg X-Google-Smtp-Source: AGHT+IHI5qnDOgweBOWwpJSluH0TRDQ3iOutcZtES2HTAnbzsEAD8NfEjFxnk5PJJLyRpaiqPz2d7g== X-Received: by 2002:a17:903:41c7:b0:290:c317:a34e with SMTP id d9443c01a7336-2951a3f3a49mr65574105ad.25.1761941055251; Fri, 31 Oct 2025 13:04:15 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:14 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 17/19] math: Handle fabsf128 !__USE_EXTERN_INLINES Date: Fri, 31 Oct 2025 17:00:50 -0300 Message-ID: <20251031200300.3716090-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang on x86_64 fails to build s_fabsf128.c with: ../sysdeps/ieee754/float128/../ldbl-128/s_fabsl.c:32:1: error: attribute declaration must precede definition [-Werror,-Wignored-attributes] 32 | libm_alias_ldouble (__fabs, fabs) | ^ ../sysdeps/generic/libm-alias-ldouble.h:63:38: note: expanded from macro 'libm_alias_ldouble' 63 | #define libm_alias_ldouble(from, to) libm_alias_ldouble_r (from, to, ) | ^ ../sysdeps/ieee754/float128/float128_private.h:133:43: note: expanded from macro 'libm_alias_ldouble_r' 133 | #define libm_alias_ldouble_r(from, to, r) libm_alias_float128_r (from, to, r) | ^ ../sysdeps/ieee754/float128/s_fabsf128.c:5:3: note: expanded from macro 'libm_alias_float128_r' 5 | static_weak_alias (from ## f128 ## r, to ## f128 ## r); \ | ^ ./../include/libc-symbols.h:166:46: note: expanded from macro 'static_weak_alias' 166 | # define static_weak_alias(name, aliasname) weak_alias (name, aliasname) | ^ ./../include/libc-symbols.h:154:38: note: expanded from macro 'weak_alias' 154 | # define weak_alias(name, aliasname) _weak_alias (name, aliasname) | ^ ./../include/libc-symbols.h:156:52: note: expanded from macro '_weak_alias' 156 | extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \ | ^ ../include/math.h:134:1: note: previous definition is here 134 | fabsf128 (_Float128 x) If compiler does not support __USE_EXTERN_INLINES we need to route fabsf128 call to an internal symbol. --- include/math.h | 11 ++++++++--- sysdeps/ieee754/float128/s_fabsf128.c | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/math.h b/include/math.h index 12150e5d64d..d349f237dce 100644 --- a/include/math.h +++ b/include/math.h @@ -114,9 +114,11 @@ __issignalingf (float x) # if __HAVE_DISTINCT_FLOAT128 +# ifdef __USE_EXTERN_INLINES + /* __builtin_isinf_sign is broken in GCC < 7 for float128. */ -# if ! __GNUC_PREREQ (7, 0) -# include +# if ! __GNUC_PREREQ (7, 0) +# include extern inline int __isinff128 (_Float128 x) { @@ -126,13 +128,16 @@ __isinff128 (_Float128 x) lx |= -lx; return ~(lx >> 63) & (hx >> 62); } -# endif +# endif extern inline _Float128 fabsf128 (_Float128 x) { return __builtin_fabsf128 (x); } +# else +libm_hidden_proto (fabsf128) +# endif # endif diff --git a/sysdeps/ieee754/float128/s_fabsf128.c b/sysdeps/ieee754/float128/s_fabsf128.c index 2c1f277653e..9d64f150402 100644 --- a/sysdeps/ieee754/float128/s_fabsf128.c +++ b/sysdeps/ieee754/float128/s_fabsf128.c @@ -6,3 +6,6 @@ libm_alias_float128_other_r (from, to, r) #endif #include "../ldbl-128/s_fabsl.c" +#ifndef __USE_EXTERN_INLINES +libm_hidden_def (fabsf128) +#endif From patchwork Fri Oct 31 20:00:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123255 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3DE103860C36 for ; Fri, 31 Oct 2025 20:15:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DE103860C36 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=AAVC0Lhy X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 07AAC3860C39 for ; Fri, 31 Oct 2025 20:04:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07AAC3860C39 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 07AAC3860C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941060; cv=none; b=Apt7ZpH+2u6Xid6Ueb0Ok1jT5UlMXhQabK1eVEnK340hPt8z64ru6bVyBi5LypagEW/t39rUUAPFZLcLh2QTcgNGsmCdL1xBwbt6czvcG5k97uTYHh4m6LZWuNyZgAqKxLrytPQLwWukWRxYBdiONtVd99QmNCfxxTTF41uPPHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941060; c=relaxed/simple; bh=V9GQKoGFJ4fD/DZq8RXeOeJgFbl0LIp3vzp66dCts9s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VZ2zgGQ11aeayFeH9d92t//4JvZIsUYw49yC7kfmcuTpfhjeu5yprpRmrUKHxZYd887MF3fda0IOlNY5Sxxk1G81TNlBHngvQ0f5O5bFeytk06q8oINMcHrH17beOi9E3l2JSH2zu0s+kUm37hauGFBt2Yt0Anc9PHLj/HtH1f8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07AAC3860C39 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-7a2738daea2so2711520b3a.0 for ; Fri, 31 Oct 2025 13:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941057; x=1762545857; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/9hy9RHgwdQA1rY1NBBmJYkTO5s0fYDG3hEfjsAOdjk=; b=AAVC0Lhyq0WjACVZu8eoHwA8Po6aoKZo1UFiDwV0bhivVX1/SA+htVDxoQ1j6xjDhy PuImrgqm6iDJJhY5haUZz/jQTpTFaFKCq/RZlo0H8w+rdPcsVxUtRouHdFu7wr4qxh4f 7JPQnzEsMZbtVBZG4QoStQIqiSpZ18Ao4USFuXu2tIWsQQbkggY1ZSW592sfG8TxpBWC SanuTbZP5OIYcK9noPBbUpDaME4qAjd/awTCr9esZ1mFPp+ap4gnC6owfMtrFvVSCcne 13j53TMEp/2Om7rMmYpEi7H4Dh9s7S7vJHTQ9qUN9/WwnlA4/shpCcSfSJ7yLZqr6Rad YxQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941057; x=1762545857; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/9hy9RHgwdQA1rY1NBBmJYkTO5s0fYDG3hEfjsAOdjk=; b=AC8muJdCUVsZpomebLosY5lLbg6N6jPIZhz34KDPqUMDSGGEtwqZd+m7dyldjqT+7J DjopjcHY41zE1jMkIKNl7YzEv32M+omqKDTvGu0kv+BPwHI9vfMswhaf/F5wKPEkzNJD 55HELGvPUAcE8ROqGUDzxNJa19Q9UB2LkLmgrCKnOzxv0DpCP/dQIcmMlzt4I2ew5mGu XBW5J9goU3Q+hXVlgO00AZzz1Z7bEohM6BDYgCcIOhZhFw8vtXxHTDTh4qOJSxtb0/0/ /ui+aM+vQU8VgISbqW87bbEG3DkiUDJyTh9QlG9PesBNLMZioSb/VXYnNgXHPCeCYPQI ToaA== X-Gm-Message-State: AOJu0YzJVsjGAjOVxnT0XR4w1FFtO6llsA8qKoHfZRWfs1YNAPmuPwDm ND4EAeRv+PohfbiSaFvkJbikVVqDFDbYEtI3Cw5Ufq3FnlVk9rHgnOsgJkO/tjPRdqYZDHPeksq TNAWo6OI= X-Gm-Gg: ASbGncusjL7nPj9Rr/Dwiyve5o1bzkX1UGL3wq3Wle5ILyDLjwGQ6stMrf5SZA75m4e a+c95S5tr5KP2DCZ0f86b5wM+jKXozx6PnjpOUptDBAYnIIfUofOkAETvad8TXV7Mqeui9FALLg LEYqZ1TixSAK7bt62PKC1upeXUp0h2Kb6e4Y4QGRnAmLcDlZiPNZtbnAYiE7B6y3h/OVexT2Ory NVunnzUFn7YsXywiDqNER5oT9r1xO1wsY0AZmnlM7jpXKSTudSs37eSPSOmTKV9LEq0O4HHhgwx LZ3+S27j5Sx4hLAXT+r18SOjr7Cpyai6OyH4el8OJasPsWahNrbUgC7EHIwNkWo6ild7shPTG4N sPjoL3zu/+kNMnMBwnYWXlVub0pSbUrRjU25hp7hM1vK5RbHuwh/jC/7F7vFSrMqtq6SR1oP0BP Yo5GoG/K0I26Nj X-Google-Smtp-Source: AGHT+IHMGzKLg69vZ1Z/GvYE7F5lZbhnv+uyp5dovu3jVcqedTZfYhU943URCKRcJiq3uxyfwluc3w== X-Received: by 2002:a17:903:1b4f:b0:28e:ccd7:dd61 with SMTP id d9443c01a7336-2951a600dbcmr60755845ad.57.1761941057353; Fri, 31 Oct 2025 13:04:17 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:16 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 18/19] configure: Remove for redirection of built-in functions Date: Fri, 31 Oct 2025 17:00:51 -0300 Message-ID: <20251031200300.3716090-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 check was initially used to define HAVE_BUILTIN_REDIRECTION, which enables or not libc_hidden_builtin_proto support. I was later removed with 3ce1f2959437e952b9db4eaeed2407424f11a4d1, making the feature mandatory. The configure check was kept as a transition knob. Current minimum gcc/linker always supports this, as well as clang with some extra care. Also, missing hidden_proto/hidden_def support is already flagged in the check-localplt test. --- configure | 33 --------------------------------- configure.ac | 20 -------------------- 2 files changed, 53 deletions(-) diff --git a/configure b/configure index 086791356a8..2e3b803aca6 100755 --- a/configure +++ b/configure @@ -7632,39 +7632,6 @@ if test "$libc_cv_gcc_builtin_memset" = yes ; then fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for redirection of built-in functions" >&5 -printf %s "checking for redirection of built-in functions... " >&6; } -if test ${libc_cv_gcc_builtin_redirection+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat > conftest.c <<\EOF -extern char *strstr (const char *, const char *) __asm ("my_strstr"); -char *foo (const char *a, const char *b) -{ - return __builtin_strstr (a, b); -} -EOF -if { ac_try='${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 - (eval $ac_try) 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; -then - libc_cv_gcc_builtin_redirection=yes -else - libc_cv_gcc_builtin_redirection=no -fi -rm -f conftest* ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_gcc_builtin_redirection" >&5 -printf "%s\n" "$libc_cv_gcc_builtin_redirection" >&6; } -if test "$libc_cv_gcc_builtin_redirection" = no; then - as_fn_error $? "support for the symbol redirection needed" "$LINENO" 5 -fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for compiler option to disable generation of FMA instructions" >&5 printf %s "checking for compiler option to disable generation of FMA instructions... " >&6; } if test ${libc_cv_cc_nofma+y} diff --git a/configure.ac b/configure.ac index 663eca3caa3..6e95f730e31 100644 --- a/configure.ac +++ b/configure.ac @@ -1469,26 +1469,6 @@ if test "$libc_cv_gcc_builtin_memset" = yes ; then AC_DEFINE(HAVE_BUILTIN_MEMSET) fi -AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl -cat > conftest.c <<\EOF -extern char *strstr (const char *, const char *) __asm ("my_strstr"); -char *foo (const char *a, const char *b) -{ - return __builtin_strstr (a, b); -} -EOF -dnl -if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]); -then - libc_cv_gcc_builtin_redirection=yes -else - libc_cv_gcc_builtin_redirection=no -fi -rm -f conftest* ]) -if test "$libc_cv_gcc_builtin_redirection" = no; then - AC_MSG_ERROR([support for the symbol redirection needed]) -fi - dnl Determine how to disable generation of FMA instructions. AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions], libc_cv_cc_nofma, [dnl From patchwork Fri Oct 31 20:00:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 123259 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42C44385040C for ; Fri, 31 Oct 2025 20:21:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42C44385040C 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=ILy8a1GL X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id B9DC8385087C for ; Fri, 31 Oct 2025 20:04:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9DC8385087C 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 B9DC8385087C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941061; cv=none; b=eFPLzJJMSUY6Dj9FzDM+vLZ9tV6P9+L1ACMNu4vOH+OlzQLmbZG3udSCdHuCkyIxSLiZeo3WV6MGSOg7MPWZrcYE/jxRZJgVY2yhsSLdT1ZoRj6Nvwey2ylvfDylEHDNCN4+yDdTpBKfsw55Lwbm9X0X/2zKi6dmgSbj9nLl9AE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761941061; c=relaxed/simple; bh=SX4C+cluDdODCBDvw4Bp2JRMK7pkz3xYJlQApdauybs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wYldpx7x+P3mgOmDOBkCa5hz3O3YbmYz6cSUirdkyKNqb0BcRBaXwDVrH9cyi4bI9MBA0YHLWUYYLz52pcb+aDlIoj26vAptBACOQ2L9V2brSPgubV1qCXaOD1noNC7e1axOsHUqDGE7eSeMOEmdMgueW2n+pB/eTVWMQ0s7svE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9DC8385087C Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7a683385ad8so2203046b3a.3 for ; Fri, 31 Oct 2025 13:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761941059; x=1762545859; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=01daI8V+c4FB+B8NofC0prgH7Xn1YkqsUpvQaoFFYp0=; b=ILy8a1GLtsW2aBrAg4q5mJ3F3qD9GYux4DdjfoT7Buq/yKgvQpzm9nuFlBXk2EF433 BD1hExKr78Ua7Cb5q5y0s6m9XT+2+PwtvlliWDrwxpSnfYtyRE5/GArhcL+HujwFbkYL zI0CjRJXLXQUQrNlcvRVE7prdjUhtNNqxSrn8cNJ695Zau+QcVTVdVZ66f1B+OInorot RfUh1h53AIKexZli9JxQeVfJlJ/E3pn/ne6x5n3ImR6rC018m3jKz4YmHoCbdZi+SsKh irkf6MdbvDuRAcwp3OX2VVz0FUw0puN6lnJsylw30zx3xJIOq1SX2z2Ndq3pn5RmPhg/ dKTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761941059; x=1762545859; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=01daI8V+c4FB+B8NofC0prgH7Xn1YkqsUpvQaoFFYp0=; b=mnQwp6/QRYMTWY8veqI5uWOsXXJ7/iIwE0SnqMvjfvg8pbEqW0gBsUidgpv80iqKZz 4dxd7JhPbDEBm9fGltyOJ/kICDwbEOlqYCOfSClMiykK12jNjTfRgnHcCMSNWut7KTWd Y1noNqK34qYWyKGX4+k1UHmwQwdsBdO8syO9cw35AG4KtnJW1XxLUu4Mw+3z/8BM0lz9 SNWFdOgxEWC1bLnF6nbTW8/vi29xF249E1HTxtZ5smJ1zZY+TnNUu82pcmEeyFB1wRjA b9TTJ3Hi7WKDOdm2IQgxEvS978DLx0fBzKDH1uhzxTMco7KYc699ok5JE70l9jRid9U/ ccsg== X-Gm-Message-State: AOJu0YwWP/Lc2XfC4ympXeeq6bCh7ijZYLFP721gbuzfY6Hyk0q7STtQ Wtmyx9HS98zftAAF/7zXytiRTOanm5Hs7c1QXPvhJ8M3sREwfnRuyO67s5C8AL07vNrTnrZXyFt aZhNlwXE= X-Gm-Gg: ASbGncuqt/s4eGYIrbcAHuCa3MhbiLvWLgWW/t+MvfU4ydPZHSeOPwkZ/JgUBvxPPwz rkfvi34ZNkoKGYIfXxelHENYihkN0g8eIjeF0Iqv0NWVXSOcDIV9jAUolss/AcwGKTaTWUKwmJ5 o3yFtfI/puBLNsHPLDdcJbuPUlJOLqJi7DjSx7iJVClCGbjtHPcmVOS/S9OFXOd2UbwPd9lesLj fnolHfV5IgEPoVpJw8h2+wi8eCokelZlB6eYejpi/OGKdirYslxKDbC99hXFkFVWNvxjDyQ4L+c +WYdf2e2mT9F7Z/z4CwoyGOnp0znbjUnBNJJ9phGCbP+u2pHzjY/a3sKLzfjB8FP2HIqMWXGV50 tAL8P07qBrClRRgM6nsMJFoOGnrFpTFSFsVySGdNsJvW4Z95aQ42pgUsIFNS96cBKD1ygO4j3ea PIE0f8HoyeUlLa X-Google-Smtp-Source: AGHT+IELltGkdcuM32WJbGqlHsCxw3IUPFZBUO4HuXhdz3oqmqvUU6CGkGhfIFi9N6bLhZgDGCT9ew== X-Received: by 2002:a17:902:e84c:b0:262:79a:93fb with SMTP id d9443c01a7336-2951a4935f4mr58846915ad.32.1761941059455; Fri, 31 Oct 2025 13:04:19 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:eac0:af8e:37f0:c980:aa36]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2952699c482sm32939305ad.80.2025.10.31.13.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Oct 2025 13:04:19 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v3 19/19] configure: Allow clang 18 or above Date: Fri, 31 Oct 2025 17:00:52 -0300 Message-ID: <20251031200300.3716090-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> References: <20251031200300.3716090-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 clang support is still experimental and not all testcase build or run correctly. Only clang 18 and onwards is supported and only for x86_64-linux-gnu and aarch64-linux-gnu. Reviewed-by: Collin Funk --- NEWS | 5 +++++ configure | 2 +- configure.ac | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 4b1f259fde6..895292855ea 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,11 @@ Major new features: * The ISO C23 memalignment function has been added. +* Initial support for building with clang has been added. It requires + at least clang version 18, aarch64-linux-gnu or x86_64-linux-gnu + targets, and libgcc compatible runtime (including libgcc_s.so for + pthread cancellation and backtrace runtime support). + Deprecated and removed features, and other changes affecting compatibility: * Support for dumped heaps has been removed - malloc_set_state() now always diff --git a/configure b/configure index 2e3b803aca6..7ba84221b02 100755 --- a/configure +++ b/configure @@ -5799,7 +5799,7 @@ int main (void) { -#if !defined __GNUC__ || __GNUC__ < 12 || (__GNUC__ == 12 && __GNUC_MINOR__ < 1) +#if (!defined __GNUC__ || __GNUC__ < 12 || (__GNUC__ == 12 && __GNUC_MINOR__ < 1)) && (!defined __clang__ || __clang_major__ < 18) #error insufficient compiler #endif ; diff --git a/configure.ac b/configure.ac index 6e95f730e31..602ceb932fd 100644 --- a/configure.ac +++ b/configure.ac @@ -585,7 +585,7 @@ AC_CHECK_PROG_VER(BISON, bison, --version, # Require GCC 12.1 to build. AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [ AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[ -#if !defined __GNUC__ || __GNUC__ < 12 || (__GNUC__ == 12 && __GNUC_MINOR__ < 1) +#if (!defined __GNUC__ || __GNUC__ < 12 || (__GNUC__ == 12 && __GNUC_MINOR__ < 1)) && (!defined __clang__ || __clang_major__ < 18) #error insufficient compiler #endif]])], [libc_cv_compiler_ok=yes],