From patchwork Mon Nov 10 13:28:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123948 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 6E9833858413 for ; Mon, 10 Nov 2025 13:34:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E9833858413 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=Rb+TKzWw X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by sourceware.org (Postfix) with ESMTPS id F10043858D20 for ; Mon, 10 Nov 2025 13:32:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F10043858D20 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 F10043858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1041 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781544; cv=none; b=wWjGT78P8olJQtOGsxh/jXQWL6LnMICZiwfPfJzlvrVfXYjlUcH0XgI3D9WVqSaaSMxVIV6SjVXoCoqXdqBjhCIfd1GCAhyHcEu1TIIinplU+4T6PaEzr1uo6eqpSFTKxJqV7WWRCHjBIwwSwtRco8YGj4oeoIyi6KG/6dST2EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781544; c=relaxed/simple; bh=byvS3ibA+wRVacgGQk0gRHr3F4YkvCFhEPMIoKtzLDw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ecvZNR80zP3FAAcXHlY6K+BElT3VzlK3YkOBXApWZEjDWnQppfai683Yh8ODs0p/bRlFZr53KIN4/o4fS0MJfjQ10N0kfUORDHVmb2QW5og0YLmsfhG9tvv8WEJ0EyjYkxK9NBBIGCBAbrkb2WpQBnjq2WiBYMDPiWIb5D7plyI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F10043858D20 Received: by mail-pj1-x1041.google.com with SMTP id 98e67ed59e1d1-3436a328bbbso2799914a91.2 for ; Mon, 10 Nov 2025 05:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781543; x=1763386343; 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=xsdFUDu/byv7uxHzGiMU6eUHSog37jmnMZpVlL1Rpbo=; b=Rb+TKzWwcz+vFjU6JIO6A/32EJVucGu8IhaHLUVIXyCuHwJwhnVA+8/JOWYlnoqu/3 onGW8Ss7R8yP+j9ORKxCwAzEF0p9T4MWujbMftuBJV6T51tIV1H3sW0hGlSOECq0UlMB 5cn9P26v3YGID9MnWpCr7tqpbn85O6399gzPOUHSuBcSjFnGlKy73EoZc3atrnmglft/ bjc1zQjJ1M5X1T6EtFgkBKewwRRFZEW5eTi3ieVMLJ0KerRSH9YCoVUMdNXcFgEbDqgN tQ8KZkyI8sRC9hdIn2l88hv61Oikve3IBdq9RaycQMagh+K0ndG/SXLC7tx/a+P3CDWJ UePg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781543; x=1763386343; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xsdFUDu/byv7uxHzGiMU6eUHSog37jmnMZpVlL1Rpbo=; b=oQ6hShajwrKhRIF+818u7b0KhAjxDZLIeA66Blv9+Z14RRscndzpBO0cSrL8D9c08Z 3UAsmGyJLUFZPxwQZuARJdZuh0uruFnHcuUlOm172L8XLuc6tZVPiiKRrYkOG8F9azid C8ycDp4MSdimJ2mPCVqQRXGbBDbAKITNYTvmf8l8AwHN2dmpw33FniN1hYMynWJENNuw 2LbxdbIs50z/oF7mGL13bLVdEG35PM79sVhDw+8OYNRuTxua7gcOzM9Ty1j2Cykb6J9V qXITI3OB5nTF7hRwyFDJcKuFQdXlXySLDTQkFHK+XqQmqpNp/Z0/h+pQTvdsd7u8poMq v5ww== X-Gm-Message-State: AOJu0YxEoQAarmi5zK0usXwDIoAS6/7FlRcHZhh1xhESIK57qdC7BBzx a67Ri5hjIgAkk882K72EUhqyjZsCnoTrXO0E5GTHXAoZhjXy9R0KYKLXfgGwlnddGU8nOzsTXeK tewM83nTXLlUD X-Gm-Gg: ASbGncsJmGVDBsGomitvF5esCly2xqIQh4gegYxhi01+g/4gjkkt3kloLEKmN2eCVr+ sR+V172326wMcUKHVknLB3bGgWOFVwaZ8IWjBro+fa0bY5TdLpLGUybrS77Ot5QQi3ZSqCb1Q5W F2KXudXc97iItBiihBfp794HUur3jKVrcufGU2CSOuNQ61jyK92fXJpLaPXfCG99Rt5n5+MCNc0 u/YHUis6S+PkLB6xQganueBHq+3bwX2y3w06ngNqt9i55R7H1vUYunsz5HfWEr+lRG6lkaQToa5 C0Bdsv370bb81x6WKxt6vWGHuSa/Jr1nK5ruJ+j/uRnaPblCNUzb1AcAQlLk9ni1Gxo00upQ/3Y Z7w48ZhnfbZven4GBrGTHAeIXhvg23oM5U9i0GlTxcEB6ZEti/rMmUx5Z+LtjUOtuu7yKpXSUpf hV9phw+X2IIF3s X-Google-Smtp-Source: AGHT+IHitRkciSF1kZDChGecq6Vk9oPiCtgbl6qNY4WqJk10sqiJYTRabaZ72igyeCeREcBSk2BPsg== X-Received: by 2002:a17:90b:3811:b0:340:d578:f299 with SMTP id 98e67ed59e1d1-3436cb7d923mr9966855a91.3.1762781542205; Mon, 10 Nov 2025 05:32:22 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:21 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 01/12] Add gmp-arch and udiv_qrnnd Date: Mon, 10 Nov 2025 10:28:52 -0300 Message-ID: <20251110133214.311261-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 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 | 39 ++++ sysdeps/generic/gmp-arch.h | 100 ++++++++++ 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 | 52 +++++ sysdeps/x86/ldbl2mpn.c | 1 + 22 files changed, 219 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..5897af7ce72 --- /dev/null +++ b/sysdeps/alpha/gmp-arch.h @@ -0,0 +1,39 @@ +/* Multiprecision generic functions. Alpha version. + 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_ALPHA_ARCH_H +#define __GMP_ALPHA_ARCH_H + +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_alpha (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 +# undef udiv_qrnnd +# define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ + udiv_qrnnd_alpha (&__q, &__r, __n1, __n0, __d) + +#include + +#endif diff --git a/sysdeps/generic/gmp-arch.h b/sysdeps/generic/gmp-arch.h new file mode 100644 index 00000000000..b093f59e200 --- /dev/null +++ b/sysdeps/generic/gmp-arch.h @@ -0,0 +1,100 @@ +/* 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 +#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 udiv_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 +# undef udiv_qrnnd +# define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ + udiv_qrnnd_generic (&__q, &__r, __n1, __n0, __d) +#endif + +#endif /* __GMP_ARCH_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..5d65b162168 --- /dev/null +++ b/sysdeps/x86/gmp-arch.h @@ -0,0 +1,52 @@ +/* Multiprecision generic functions. x86 version. + 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_X64_ARCH_H +#define __GMP_X64_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) + +#include + +#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 Mon Nov 10 13:28:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123950 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 E7AF73858D20 for ; Mon, 10 Nov 2025 13:35:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7AF73858D20 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=Gc8BdftZ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 350573858D29 for ; Mon, 10 Nov 2025 13:32:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 350573858D29 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 350573858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781546; cv=none; b=Nr8T3WG7NTw10qYyRhudk1cXZ9Z4bIO3y5YINHExx+g0kP4FNd4N3ddzCMUq2akYdMmcdzxRfzEbEIctP7xKRyWF8w033DXLFwv7mAZ9PD7iWJaIQxCaVlxnuohVGlkM1FGTHKGH9KkUor9KfpVWaUCD4GMnfXVu52AX7J7P7wI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781546; c=relaxed/simple; bh=iSVGINvViiVI3eFsIKG3vz2t0c+T0PXPdhTjL4T5T1g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BI/YSF8Nps7fjvTrooHXtgiAwItm69udJ3AmDoepIw+SJg79KPtgte3m6fDTti7OAwGczdAjnpbNM8gm2z4D8pTo6ZdoSjduHhamUxwz2BRDS8iQqtdpDvHlrYJ0YzxH+8CYrPs63XZAas7AEvUtWwm3GXknKr1h/F7Y8hlevZ0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 350573858D29 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-7a9cdf62d31so3572754b3a.3 for ; Mon, 10 Nov 2025 05:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781545; x=1763386345; 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=2WcEcTdNmYB29s7bFO7ug/zfmmUYGdAL3Nas8u7IIqI=; b=Gc8BdftZRY3oyPbTuOfCwjoacQxoyexbIbWubeLqyuAXgv1L07Gj0ueq2ePtirbwDk 2WfFM1kTS/8FYNcNncB1l1K6eG32duyb4NtebaU712IlJx38K9plDWziRSzDerC58brr VRx1eTp8kMjk7dJ+kLI1Axesklk43wENJUgyA8hc/bTZ/b7BsGLM2kkPoMVyuJigrzT5 HrSy+CRlwFsPZD+9Sd78jUYGOyrjLbF83NnxC199dVqnnBiytcgnEUbK3q54Uq+bkPPb LpkzvMnkozakweUvg/fmQLNVrg5VCk73BOpdpuVDwxoLVrtLhRpqqin35ADYIB7sePro 3y2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781545; x=1763386345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2WcEcTdNmYB29s7bFO7ug/zfmmUYGdAL3Nas8u7IIqI=; b=KmoMk4LpAsSd/zsTC7KIXYm/ZexJPWdEYmO1hqsiEAGXNaeW/gfpBB30N4chs6Z/b0 hiCNw7SDLkSrfhmVhMwWblzW5PJlXVomOZE87JWXVgW3V8qRSL3DuPYRZGyudbHcsq1k 9Efcz8Oyn9IoVJ8WS39/lrnaTMAPisHZmbxIWRlGQ7xepppFt8msrYmmnuVWHWDnlvOk L8A8n1DMnelwZ5A5XAXFCIql2HkXUDYbXuzLc8opMkRPY6tukirQlmfW0JLhYlUhSCyi I1BiZKBq0AyC7vvWEO46ftkB1/7YvUWba3bXwK9FSDau3XLkm7MvLAq+Cu3awphEAr6W uYQA== X-Gm-Message-State: AOJu0Yxfp9U4/ts08hcSPqBJGrS1q7b8pk5fquhEg5+FAov/UbU1aj8O fm6cD4R3VUARc5CYUaV5e44h6fqmw5y5QB26fsAOebMfoYhfyd5zSj5xdrFyK2KI3xuODhVpgGO MNCVAilBPbw== X-Gm-Gg: ASbGncsCUTsVSe0i6cttu6NVUXjCVVqMJFY95p9znlg9+72zycBd0E9n1llGOtmIZJD kwKX7EXEMgvXC/TaeJWoEa5p+nRCa4tJoldjiibWsHDCwwKZHyz/vInOlKGucHe0MA8sDFfxkrF rIwGY3zBqj8VnN+v8ZBCElYnOUt3pCtm8EN4ZPdIpCcgO6Wr9gShh+b7HwmUna1ggRlVD84iqS9 W6eeCqTVH27mymMo5RDbb5YMgbUiMXyE3RrFe80g527Z9AMbXfy9aeBnVBaCsD300dXFBbUiHX0 tPmjwsSzvb0O//5LePvDHAwnEtutnnMZNnu6GhsVJqVdd41vQpnRg2ofyGPkr3thrDXj3MNJC+U 7D537B12gX8fzkEYZgfLcywd3RhBbmozrB4mACZsF/siKvEtd9I25fdKRDWV1elE6+2kfxLsP8c xQS9xoWOIyyDfdaO9jJD9UbHymuA7/nUxrNg== X-Google-Smtp-Source: AGHT+IG8syfayx9ay3IzMapUckNU41Z4lYL/x3n4UdUky0iA1I0ctGCt/Ead8cX3ezRZIS0M1J9YhQ== X-Received: by 2002:a17:90b:5588:b0:343:60ab:ca8e with SMTP id 98e67ed59e1d1-3436ccf9da2mr12571913a91.17.1762781544513; Mon, 10 Nov 2025 05:32:24 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:24 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 02/12] Add add_ssaaaa and sub_ssaaaa to gmp-arch.h Date: Mon, 10 Nov 2025 10:28:53 -0300 Message-ID: <20251110133214.311261-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 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; and it also works better with clang. Most architectures use the generic implementation, with except of arc, arm, hppa, x86, m68k, powerpc, and sparc. The 32 bit architectures the compiler generates good enough code using uint64_t types, where for 64 bit architecture the patch leverages the math_u128.h definitions that uses 128-bit integers when available (all 64 bit architectures on gcc 15). 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 | 55 +++++++++++++++++++ sysdeps/generic/math_uint128.h | 27 +++++++-- 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 ++++-- 7 files changed, 101 insertions(+), 21 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 b093f59e200..3adab107329 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -21,6 +21,7 @@ #include #include +#include #define LL_B ((mp_limb_t) 1 << (BITS_PER_MP_LIMB / 2)) @@ -97,4 +98,58 @@ 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 + +/* 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) +{ +#if __WORDSIZE == 32 + uint64_t a = (uint64_t)ah << 32 | al; + uint64_t b = (uint64_t)bh << 32 | bl; + uint64_t r = a + b; + *sh = r >> 32; + *sl = r & 0xFFFFFFFF; +#else + u128 r = u128_add (u128_from_hl (ah, al), + u128_from_hl (bh, bl)); + *sh = u128_high (r); + *sl = u128_low (r); +#endif +} +#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) +{ +#if __WORDSIZE == 32 + uint64_t a = (uint64_t)ah << 32 | al; + uint64_t b = (uint64_t)bh << 32 | bl; + uint64_t r = a - b; + *sh = r >> 32; + *sl = r & 0xFFFFFFFF; +#else + u128 r = u128_sub (u128_from_hl (ah, al), + u128_from_hl (bh, bl)); + *sh = u128_high (r); + *sl = u128_low (r); +#endif +} +#undef sub_ddmmss +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ + sub_ddmmss_generic (&sh, &sl, ah, al, bh, bl) + #endif /* __GMP_ARCH_H */ diff --git a/sysdeps/generic/math_uint128.h b/sysdeps/generic/math_uint128.h index 56d0fba7806..438314cabcd 100644 --- a/sysdeps/generic/math_uint128.h +++ b/sysdeps/generic/math_uint128.h @@ -19,6 +19,8 @@ #ifndef _MATH_INT128_H #define _MATH_INT128_H +#include + /* Limited support for internal 128 bit integer, used on some math implementations. It uses compiler builtin type if supported, otherwise it is emulated. Only unsigned and some operations are currently supported: @@ -27,8 +29,11 @@ - u128_high: return the high part of the number. - u128_low: return the low part of the number. - u128_from_u64: create a 128 bit number from a 64 bit one. + - u128_from_hl: create a 128 bit number from two 64 bit numbers. - u128_mul: multiply two 128 bit numbers. - u128_add: add two 128 bit numbers. + - u128_sub: subtract two 128 bit numbers. + - u128_neg: negate a 128 bit number. - u128_lshift: left shift a number. - u128_rshift: right shift a number. */ @@ -47,8 +52,10 @@ typedef unsigned __int128 u128; # define u128_high(__x) (uint64_t)((__x) >> 64) # define u128_low(__x) (uint64_t)(__x) # define u128_from_u64(__x) (u128)(__x) +# define u128_from_hl(__h, __l) (((u128)(__h) << 64) | (__l)) # define u128_mul(__x, __y) (__x) * (__y) # define u128_add(__x, __y) (__x) + (__y) +# define u128_sub(__x, __y) (__x) - (__y) # define u128_lshift(__x, __y) (__x) << (__y) # define u128_rshift(__x, __y) (__x) >> (__y) #else @@ -61,16 +68,28 @@ typedef struct # define u128_high(__x) (__x).high # define u128_low(__x) (__x).low # define u128_from_u64(__x) (u128){.low = (__x), .high = 0} +# define u128_from_hl(__h, __l) (u128){.low = (__l), .high = (__h)} # define MASK32 (UINT64_C(0xffffffff)) -static u128 u128_add (u128 x, u128 y) +static inline u128 u128_add (u128 x, u128 y) { bool carry = x.low + y.low < x.low; return (u128) { .high = x.high + y.high + carry, .low = x.low + y.low }; } -static u128 u128_lshift (u128 x, unsigned int n) +static inline u128 u128_neg (u128 x) +{ + u128 xbitnot = u128_from_hl (~x.high, ~x.low); + return u128_add (xbitnot, u128_from_u64 (1)); +} + +static inline u128 u128_sub (u128 x, u128 y) +{ + return u128_add (x, u128_neg (y)); +} + +static inline u128 u128_lshift (u128 x, unsigned int n) { switch (n) { @@ -82,7 +101,7 @@ static u128 u128_lshift (u128 x, unsigned int n) } } -static u128 u128_rshift (u128 x, unsigned int n) +static inline u128 u128_rshift (u128 x, unsigned int n) { switch (n) { @@ -94,7 +113,7 @@ static u128 u128_rshift (u128 x, unsigned int n) } } -static u128 u128_mul (u128 x, u128 y) +static inline u128 u128_mul (u128 x, u128 y) { if (x.high == 0 && y.high == 0) { 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 e30cbdb20bf..aae0653c836 100644 --- a/sysdeps/x86/fpu/sfp-machine.h +++ b/sysdeps/x86/fpu/sfp-machine.h @@ -18,9 +18,15 @@ typedef long int __gcc_CMPtype; #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))); @@ -55,9 +61,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" \ From patchwork Mon Nov 10 13:28:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123953 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 7E2683858C36 for ; Mon, 10 Nov 2025 13:39:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E2683858C36 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=QmcYx9Kq X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id 174D13858D2A for ; Mon, 10 Nov 2025 13:32:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 174D13858D2A 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 174D13858D2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1032 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781548; cv=none; b=tZHfP8X0JT0gr94YqCxhu7/cM8qT4D+GLhRGHX+E1jeKofWhIbm/2JwVRDoMC8UeSzfQswKpCmxk2AWPC9QS1glpgkam0cuwCv7bUm6Hu9bJIh7AgHbwiUXUn0gwS1ypjwlbI5kwre0gdrOjfAhhfX3VlNHewK5ZAEk/rh41sIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781548; c=relaxed/simple; bh=FJ4x4VdPskOSa0r/EFq+bx94RMSGBpe/UolCIwl0T6s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IKDkic86wQOnrfkyReqfB+6lOpob5MFsqYebUF8aJ5Cs2VklbTt2k/MfJkgV9hZezsG++S78t8ku73HhYDXmBVgPqj5fL5OBTjlUJe6eMjGgrERg7V0PHXrdAgO/Yy9QuqxWCYS/ObylX4vEv636TvR+RUo0tshiRjahFGl15Xs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 174D13858D2A Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-340c1c05feeso2484232a91.1 for ; Mon, 10 Nov 2025 05:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781547; x=1763386347; 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=+Y4eFnAR3XwCM/TOiyeZVfDFBc5aMgtS3K0g9kMY/mo=; b=QmcYx9KqibYjq+rPMiaF/rx94nETk/XZQHsJglm6PM+IfV/UGhxy1TDI5atb3cXrT9 NLgl4MXAN9GJ+FrkFSAtMPeCPQaP/UDsXYF9Vw4dItAM1lSTvSzXyZCV/jrNh87kTK4C vUHbr3i05vLmqzjXXHegSKeISXPFjBmadzZxt8Q9i5ZhC3OQ7c9fGSVWPRlIQLtx2n+V AWnQSssoyGXB0BGUDAVtfMb4XLvNryinvp2SqcHUcAnJsTVrg8gcAw0EGy7ag/bQrhIK Yavao/Iqh83o/NagynVTpa9tg04ZA6fKZwp9CKF2mdPXRfXeY22pHwyvXvWE71ORLjCz ASnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781547; x=1763386347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+Y4eFnAR3XwCM/TOiyeZVfDFBc5aMgtS3K0g9kMY/mo=; b=cUqQADM7D4bI0+56fGLWfGMpuQAYMhcbEF7y71meDf/e5dXYpnWdIwH5KYUG5MZ7fZ 4YIK9zEq9FBReQnEBRk/6IaADhELJyhu6YiFcDfxYq4RxU1xhbHoplkwZFsuYdDv8T3g wsnG0CXHcgkD5UsBa9yuVyzCNeClKSUKRw5lVANUUASJc+Uh5+dK3esj9vzaEo1Xs6x4 Y25JJyhGQS0Naf5a6FqCb7hxiXZILUk3dYqEIoc6qapl1szsPkOVkP1YW5GckKUPD0at mylTfUwPi0O4DsTzkOF5uFF72+zZX2kU1SPzsT4zxUQIKj74HXYCtzjdGFQ65pvTg34l s3wA== X-Gm-Message-State: AOJu0YwLjOO+vE9zL8vJKoWbVb9hkKXiEx/Hgtson6rsjiDtuxsar0yV 7FC2j13WabFWUgv8Jb+9GISvEwXpsB6LuokRysaKtb1TEFX3zBb6WHJFkZ7NIT6vzRuGG1W02KN UvtmRMm6ctw== X-Gm-Gg: ASbGnctLNSISQcMzluWqpRhT/48F9pl84zQyqiXhUpBCqpC87NcCKIJPUQgDmv3nP0K GVNtsf+WFnAf/fExgAOQrwRIs81k+JI5AjoB4FyuhxkpEWHVVYsNokxTnmMmE6LpvS73GVExQMk 9eI5plDR6m9ui4kmK+q9TF7o2RIB4sWMJ1oYM/LteGZlOooNkxYWjypuK/fXRMUTKpBhD4kwxRX Zvcqi0SNMHAlPhQ2ligTW7zWg+FzR/kZpb3gokfw1xwqS2ha9+n+cenekAqzbhYhzdXQihm9pFo NEB3iZQmHYa/67FG/N29cXAefmCooHscy+vnBbhSLRUnf3SuuHM8G2PY0vu2JCW4WwSUhf5QZ2E Y8idRBN0KtdyaCme23up3ndEXbIn7KPuJ5tRd8QZ0Z1bEG/56OpUfGXM67PqbBfW2OT17iX0AoW gyYeOHFcJCCfvkGkmZ4SCT0EE= X-Google-Smtp-Source: AGHT+IH9AFrnCOW1RwTDBSsht6Bcnhd4wLCbjVnsQ+Xj8pR+KAsQEwN0ff/b+tuzMw/CYV2uWEmekg== X-Received: by 2002:a17:90b:2e85:b0:340:ad5e:ca with SMTP id 98e67ed59e1d1-3436cb92071mr15030921a91.12.1762781546665; Mon, 10 Nov 2025 05:32:26 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:26 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 03/12] Add umul_ppmm to gmp-arch.hdoc Date: Mon, 10 Nov 2025 10:28:54 -0300 Message-ID: <20251110133214.311261-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 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. The 32 bit architectures the compiler generates good enough code using uint64_t types, where for 64 bit architecture the patch leverages the math_u128.h definitions that uses 128-bit integers when available (all 64 bit architectures on gcc 15). --- sysdeps/generic/gmp-arch.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sysdeps/generic/gmp-arch.h b/sysdeps/generic/gmp-arch.h index 3adab107329..f1dba1384bc 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -37,6 +37,32 @@ 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 + u128 r = u128_mul(u128_from_u64 (u), u128_from_u64 (v)); + *w1 = u128_high (r); + *w0 = u128_low (r); +#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 From patchwork Mon Nov 10 13:28:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123955 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 C5F1B3858D20 for ; Mon, 10 Nov 2025 13:42:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5F1B3858D20 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=qECG3/fl X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by sourceware.org (Postfix) with ESMTPS id 01FA13858CD1 for ; Mon, 10 Nov 2025 13:32:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01FA13858CD1 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 01FA13858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::442 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781552; cv=none; b=cGZGlsA5irj1tS9/VB4t5OOvTLAXL5+dMJ+syMICytPo1n8tobR+P1CDUgPFFk0KP13BZgspWgj4oR/jxi4VBAuktGeVlpirHVhesNXbR7AQDBlXDz7M0N/Rs1EjklxRPkyvcfCXxxy9pxuxRqWKqEbSABWroxugUWLah/96Qcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781552; c=relaxed/simple; bh=qkKwEwpSSjuJemCqyseHTQv3MIeq/5FNf25d5NITHnM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qGQFQwu9ozMfLCQWQo4Br5cKvpuOHb9JfGXQiRAViOmPl1doAuERmtlfFbfYDcy+0o8M0IcHDvUFwoGQ5JNYFK1eAdoWsEUZOpJMqo8rhJQb8p+rFVI7SJ+AsL3WbzuM+wK1FpAkjEYkUFHFNNM/ONxscPkqQksr5idyMc8e19g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01FA13858CD1 Received: by mail-pf1-x442.google.com with SMTP id d2e1a72fcca58-7a4c202a30aso2328443b3a.2 for ; Mon, 10 Nov 2025 05:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781551; x=1763386351; 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=Son54JKordbfjlZfs8G/p7smL3nFOH2t2KXMsdK8/Hg=; b=qECG3/fleH1kw266PlMVqE2gLnR47j99+W5XVRxO6x5k0ZMDCRXbr9WfxbOwttsWRt 5b1wreh4MmGywGAC87MYHbZpd9tWgVo6efhDOqlCd9kTpQUFNBxM8+ueD8UiIVH82Wmw nxrrxPfZoZ5Zm3BT4UY2xjYSIOZRii9LFbpJ6bFJ/u3H+7uSkrkuy14411lu6BZAmvQk 0Ueb1MZDaEDsWBL+YqojzAzeqsIZLlobNI3u1bMLInzsJTO+KeZVKzvCL9ZDUtmejmLG Fl6yrOxcXKG169tngfh7c4znXLQ8r4JyfY+ijMISoIdDx23pdkYAXq12AuJsxs9Xlt/V YQBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781551; x=1763386351; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Son54JKordbfjlZfs8G/p7smL3nFOH2t2KXMsdK8/Hg=; b=EnQcMWpSpyFR0AK5uropOr6QHmHYF8bt7bJGx3fgQOmZi/uX1Uanv6SYltn3ExR9YQ pMWfHZQ62O4K71OQ11e5Kw79IxzEXpDeazMJg9zVmP3zIYXkEpm96zp8ctRLfqWV/s1e ksUM+lRQPe4cVJFKfIeNwL3CnqQZYFxnCCIvAIcvTGmhkw2vsObQS3l3RReJSvEIYN+X lUD5d45D/ei3PC1pP0HpqBafADIIQJkcI9651buy4QLas5jlcWes5b0Z888sYTKUufR7 eOtD5n4g9AOIYks2fZw3+1qIj6LUI0nYkt5PCkRDwScn6tgXn325Bnm5utj1uwRSKbkD V+6w== X-Gm-Message-State: AOJu0Yw7IuKYumOXoomC3bWJlz0T5xmeXZ6RmJsPxy0R20JK+HHdPZzM Rgx55l4ql0SU/kMS0zRlUgLQZ0r+A7CKbmbcEYVR45P43pOCcl2TaXwgWAUsl3JjhVLNw7OxZ6D E1C8DGpXls1tt X-Gm-Gg: ASbGncv0qrKa4B9TQhLJ1B3ZjJCAQ1NRG/qCLSFFcIZwSpECyJYxdqa8XHYIDIRQJ9x yu/4d4/QmRwMsxUGoQ/iH377e9B49GQMHvCO7N9bVMd7oMXpcgKhK/D2GYqARWcgsFle8A4RQyX 4qNBMAuY2K+Zuoy9HaSurEjUNzfa+sxr4WNfe3FhkgxXXLSdZVfDrIttXsSD3rsTHCQZcjyzWgQ XhpgHv9BrIRziNrRC/uxrgGV+AH6iYHwC75QH19QMfPX2Hp2Vwj/aDJzTscffEWD4CXVQ3kBKuj mNP85/t+/f9+dNII0z2WVBGKJN/W8YNvAmvgQzGFqltNzsT63xfAkz7CYZhy77dNrgxLuX8Ej8r QPUOOP3jmv5lWDOO2SUhWDJ27Al7w14ZkTFFyOSrR2DVXf45L53Suo32GYoEH+v0KIMsY9o6vKy 1cCRmfyck3N0Lw26qnGOeu37Q= X-Google-Smtp-Source: AGHT+IHx9+1H3HRZ3igyTbSGSUJ/E+UrCN6oOz88T7XBMa4PAsWTqdwUYXG2v79fOwP9wVwkwpE1fw== X-Received: by 2002:a05:6a20:9389:b0:33e:84f7:94ef with SMTP id adf61e73a8af0-353a13a4ff0mr11086268637.11.1762781549408; Mon, 10 Nov 2025 05:32:29 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:28 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 04/12] stdlib: Remove longlong.h Date: Mon, 10 Nov 2025 10:28:55 -0300 Message-ID: <20251110133214.311261-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 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 | 2 - sysdeps/x86/ldbl2mpn.c | 2 - 21 files changed, 2 insertions(+), 1824 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 f1dba1384bc..b3004c90ede 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -53,7 +53,6 @@ umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) *w0 = u128_low (r); #endif } -#undef umul_ppmm #define umul_ppmm(__w1, __w0, __u, __v) \ ({ \ __typeof (__w0) __w0t; \ @@ -117,9 +116,7 @@ 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 -# undef udiv_qrnnd # define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ udiv_qrnnd_generic (&__q, &__r, __n1, __n0, __d) #endif @@ -147,7 +144,6 @@ add_ssaaaa_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, *sl = u128_low (r); #endif } -#undef add_ssaaaa #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ add_ssaaaa_generic (&sh, &sl, ah, al, bh, bl) @@ -174,7 +170,6 @@ sub_ddmmss_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, *sl = u128_low (r); #endif } -#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 5d65b162168..d739350d0b2 100644 --- a/sysdeps/x86/gmp-arch.h +++ b/sysdeps/x86/gmp-arch.h @@ -41,9 +41,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) 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 Mon Nov 10 13:28:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123958 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 3632A385842D for ; Mon, 10 Nov 2025 13:47:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3632A385842D 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=HsFQYt8r X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by sourceware.org (Postfix) with ESMTPS id 1A1513858C62 for ; Mon, 10 Nov 2025 13:32:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A1513858C62 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 1A1513858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::444 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781561; cv=none; b=elNT36nCX9uG2XHbBK6YXaUDdOomOIIDngG8ocAz3G30zVPNeK+lbVg8ooBzj5VtH9D3RDSHsF4mawUyTUs2cx4JfiMwA1tswBgZd5CtC3LVSIAuzFwIHAKLmxR1mJdmkgCo+QHF1hE0PXG/38Fq4MQrFOrNcTQUqxNhI4IcTe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781561; c=relaxed/simple; bh=Pdh52LwuJQyPY66GjtAI5WfapwX4Ltfu7P3LoBU1+3Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WKaGX2rZD7lQ1IPT/1yugNuHB4E7dRHXyoWUh7a+qngh94M/962GHTjEtgZdztvTYu4R6lxgfOsyp8KIm/bI+x50ER6tYbuitG7vwM4ZgcExmQlRKITZbWv0kqwSP0wXcoQWMotfztf88OSn7wXmAlbHoeTxOleDtaEoI4O7yEo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A1513858C62 Received: by mail-pf1-x444.google.com with SMTP id d2e1a72fcca58-7aad4823079so2659819b3a.0 for ; Mon, 10 Nov 2025 05:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781555; x=1763386355; 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=/i6UMCC+/lhht5Jaj8JI+B9poaYaOfm/p/lMMUrk83s=; b=HsFQYt8rQ7GuV6uWhgYYitH4r1F62nK5siRUP7aCl21j9cPeoq7wIWamHZaWFyksgz 9a5ik5hUDZ2y63Kiq7sdWVxeouJ0MRQgPNP8sfavuAVhidZ4kyid71RNUEO+/zvtLQBw t9muFyjkVL15+L5yPLTANc79jL7Xw6H7mS1xwbW2o1lRZpuihOhb8OePJb9ynbX6R3JB sBDUwHy8YLIdJvURdaimKyNL0kv1vNnSc4u1pfCsl6F085Fc9yLizg0C33qjxflgMJ8D 13Lqu0gMRE8NMmwVBsqSi/7tP133jr4AcaJL10JlswonJOvCbSatqqRBMCxNG7M+LfXK dC5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781555; x=1763386355; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/i6UMCC+/lhht5Jaj8JI+B9poaYaOfm/p/lMMUrk83s=; b=MdtkjLcUDjLugds2oLm+dLInJuCdzQ4CsAX7xkrIzgvLvL07rWeQ7Af7SnnqExvhf/ /ph9f92BfrIwWlUIsz+RIe/bnyi6o8DCvTaynY7/9H9Zq4xiVWcv0KBA7X6LivESb11S hWRSNtxW0/eRdaxNTCm+JmASQqW0M1livipRoD4hS7M/RS7gfLRQHqKbhczdOtWr6erR FG+Fc56vALVe7l6idBpu+DmGk8Bd3nXMQw93kMD8OXogv6CvAMs5RDUNO+BHSRvU2/rK SLwq4eBJhkCnNNAEKE4Zn1VV7pDoqUm2IENZSPXONT5zdvwzNTcUNVrzGAA1gN5B3LD/ sccQ== X-Gm-Message-State: AOJu0YxVS2Mz3OF1RcEek7yI8iJ02C+4VeY+drWFwWQn62dQWNsam3/7 RrgSZqFWC64QCO24uJspevCyhFgN3y1axetpUlSBVDWvjLf/gEpg9SvQYpyaW+LOf2pp2LKgl/Z 0donQjF256uXI X-Gm-Gg: ASbGncv4GlFx8YQHe+oKtkB3/vAk51ivUfOR5gHvnQampnIleS8fdcvCQI6cbFwlIK2 kEwRQlyn/5QuVr4FdKZ2CH9PtxsLuivBk3dLMgPnt5d6rGH+rxU1Ycg0eij6Ll7YG/RUj+0yuSk yMvqFIab18cTIi10M2IMyvobMoVByMVI5tR4TaGPysKmo0X3ZRGKKwlW0ZsZZmzozpYAF88RQBL C79LgW/9qV3F/A/Fkb/f2kzU7H/2meKQ2lmdJAnSjATd2+KeFHgoN6+THnIfADOjw9ULVACbpMf XPDUUwJNINIOqMuggBviefN2heAAT/RFs0uj8kvYE+Q6mg+5Uyrlg4ZWS2YXBNpSujhyo/61Uw7 ujfk9kHP/g9sLJDwaw4gCrXsyR3/fK+pmfSmXfFVA6ssXPnPaFnxHQYIiFdQMijSKjrt5Ac6mUJ rQy8y2odLLWjTTTkPzJaDd/6OClWhVW59MWA== X-Google-Smtp-Source: AGHT+IFdFdr/lR78ilo+8TfKYRnLeSO8gLrdYKom6S/VhSkI3Om0BcjfIlJiaAoR9foIuoCSeOKHEw== X-Received: by 2002:a05:6a21:3290:b0:34a:1db8:4591 with SMTP id adf61e73a8af0-353a31533ebmr11367876637.35.1762781554402; Mon, 10 Nov 2025 05:32:34 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:33 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 05/12] math: Don't redirect inlined builtin math functions Date: Mon, 10 Nov 2025 10:28:56 -0300 Message-ID: <20251110133214.311261-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-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 --- 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/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/isarev.h | 8 + sysdeps/mips/math-use-builtins-ffs.h | 2 +- sysdeps/powerpc/fpu/e_sqrt.c | 1 - sysdeps/unix/mips/sysdep.h | 4 +- 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 - 60 files changed, 225 insertions(+), 80 deletions(-) create mode 100644 sysdeps/mips/isarev.h diff --git a/include/math.h b/include/math.h index 12362688041..84d44d44dc1 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/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..5a8e170aa29 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/isarev.h b/sysdeps/mips/isarev.h new file mode 100644 index 00000000000..d3da6a9cb36 --- /dev/null +++ b/sysdeps/mips/isarev.h @@ -0,0 +1,8 @@ +#ifndef _ISAREV_H +#define _ISAREV_H + +#ifndef __mips_isa_rev +# define __mips_isa_rev 0 +#endif + +#endif diff --git a/sysdeps/mips/math-use-builtins-ffs.h b/sysdeps/mips/math-use-builtins-ffs.h index 2ab6a03a168..94393ce91a1 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/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/unix/mips/sysdep.h b/sysdeps/unix/mips/sysdep.h index 5f7706b182b..4b58344bb7b 100644 --- a/sysdeps/unix/mips/sysdep.h +++ b/sysdeps/unix/mips/sysdep.h @@ -15,12 +15,10 @@ License along with the GNU C Library. If not, see . */ +#include #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 Mon Nov 10 13:28:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123959 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 B24A93858C60 for ; Mon, 10 Nov 2025 13:50:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B24A93858C60 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=F+sARHPl X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 3A83E3858D3C for ; Mon, 10 Nov 2025 13:32:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A83E3858D3C 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 3A83E3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::443 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781559; cv=none; b=smElFJ/eP0Uo95oNd/0rkvPktYan/EDNCZpdjsjo625aXec2IPx0B9aeWz7CvSUlN4QQFmPq3lxZtprx7oNIKJH580Ox69WTHNY1rsLHSlz1STXxFoE7EX5HGVUoMyxW1UEn58NOELT754kWOcHlOFRUuPGdt1hTd+4qkcu+DTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781559; c=relaxed/simple; bh=pl1eGX+uk4OUI+XqJ0Tx5iPZ6BxNWg15ldwl67h2cyg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KCUmG1bTnOiwMmIqxK9FPT0kD50HyXllZmQDHtAaHx3lSJamLYHf5DtpI/mf5xZgCbVPf5APdjMSbT9vtJ4I0MZ4cFzpOB42TYkqoFVn3H/E1WxjIm+/g4KDpI5gq8TgkAefxqJJGcZcjAyKftKJEUYJ++VfR43spYQpX1xOa54= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A83E3858D3C Received: by mail-pf1-x443.google.com with SMTP id d2e1a72fcca58-781997d195aso1893200b3a.3 for ; Mon, 10 Nov 2025 05:32:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781558; x=1763386358; 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=e8mS+agzKxbcZWfKqaCgxRbdXurEHjbLmryU6acenJw=; b=F+sARHPlKL8ydAkWXqoBd31zZIXnRm57iEsqRm+T+GbOxCOGvDaL3+dBsrYudksNgE XCqDZ4Na9N7iZ6D8TDWVn0L+iAxBcqwWKP1GeiJiNTbVMSAf0FAjMlyaBSagZmKtcGKq GhK9loMdXUDy6sXKQ+cVRP2X2sITU+XMZ35KqSkK70BlyLkD6S1LEvkkD0qbYlS6t+0s UyZ2vKZ9ZJrrEFsXNxh1hqrFy9BGHpXXNJytTtinF3vQCOemrX4xtfCNCMlj3aBAaHjE jh6qRjssa2dTXFERKF1s1tBKpe26T4QYs+W1BW1d3yBn7EMRWzdwnhSaIT+R8TTG7Pk5 7m5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781558; x=1763386358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e8mS+agzKxbcZWfKqaCgxRbdXurEHjbLmryU6acenJw=; b=LPSYsWfLGtiXpav49lPt0MEqbmKObVFnGYZ7GaHr7iGe1UePaIDgY9iL/crufFv+YK 1TGa48l9K0EjrMK2u/OKxZ99HiQGY3T/V8UmanF5N2BR9UK2Jm+vUAi7WQ9UrEjAvGBi bbXfxwzlvHuPyGibwDqNkl/t+N7dETfIRpFuwasKJ72NhN4HfKM+amlIwMnqvEzkuzhx Lpimen1LRy2vAS0Zq1yt7669SNEWBN0NuBHQ3dxPlhb865ZbbZBqpoWjR4XG6WwbODjx 2a3eQrIXLy/jqKEcppxALAHpus2h1T/cKypDDW6xHkp+aHtVbyqupg6RwLJ60uP9qxOs uwtA== X-Gm-Message-State: AOJu0YzAcUFBC2MZNDGgOFrqWe95TzPNkONFgeaUyX919mtGIy+nfkgh P0GRI5He6IIg9c1Z7odouvtGiI5x6uhUYtaXfcOcmZfYaV5HKJhJwqMdntsfVWIhb9MlTfc7KLt URmXgb5xh74FQ X-Gm-Gg: ASbGncvvOTZQExNjtKoC5J42ORJtsAtBLJeTDn+iqYpg5QmE+T5+wRB0PnzEj+tsu8I bD5duxyHhoHQNa6f0e0zZ1EXDJqBL8++BWMGarcCIWQXU8z9irXNNGeDk7GIXJjHiQ/uS+SldUs ko/ZAZchXNIzXauXNs9Jky6Cxt4iry/fI6nB/c1QjN8jB/8eFCpE+0FF1dju7NsDXUeIgz3fRol QjcseXLcrtStmN7V61tIzwkUEg0CAyLiye2Ht4vK/QxEEH/Dr5wftAtMKyA4cp4nCTv9oNuFLkM KIY9/j7YSq9Is+C+v8p7b0qfPzldrEyIdd9406ZUQ+ldmkXgf8xkk4C6wWyGJ5ZS84JKHsILkbs L8pmrh/6B3agP1MNLas0Hk6ocKv8KcdtgyFemQeJ6EB+AI+FR30aPbvwqGC9sOp1yoI+wUq705Z 2rdJUoDkStOE59gn5O5zDEQJ0= X-Google-Smtp-Source: AGHT+IFjx6k55c/kDQD7G1ZP/aCN6l+NpdPt5qk8VUn0vMDdljPSfgzXhmSd8NY5eBH+HbxYxFbdaA== X-Received: by 2002:a05:6a20:7f9f:b0:33d:7c76:5d68 with SMTP id adf61e73a8af0-353a3d59618mr12683881637.46.1762781556948; Mon, 10 Nov 2025 05:32:36 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:36 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 06/12] Handle clang -Wignored-attributes on weak aliases Date: Mon, 10 Nov 2025 10:28:57 -0300 Message-ID: <20251110133214.311261-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-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 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 df51b0c1a37..cd825395791 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 dd0b7a4c7c4..46b33fd9f49 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 29348912e36..b0944d6b212 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -58,7 +58,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 82029af7f62..80dcbf91471 100644 --- a/sysdeps/x86_64/fpu/fclrexcpt.c +++ b/sysdeps/x86_64/fpu/fclrexcpt.c @@ -51,5 +51,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 a2523e09788..21ed713acad 100644 --- a/sysdeps/x86_64/fpu/fegetenv.c +++ b/sysdeps/x86_64/fpu/fegetenv.c @@ -33,5 +33,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 74314b0fc97..f899e92193c 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 9cf5f889ed0..d4ab956ad32 100644 --- a/sysdeps/x86_64/fpu/fesetenv.c +++ b/sysdeps/x86_64/fpu/fesetenv.c @@ -111,5 +111,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 e06225213ab..c7d6421ec6b 100644 --- a/sysdeps/x86_64/fpu/fesetround.c +++ b/sysdeps/x86_64/fpu/fesetround.c @@ -45,5 +45,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 05474bec131..f0a1d8282b5 100644 --- a/sysdeps/x86_64/fpu/fraiseexcpt.c +++ b/sysdeps/x86_64/fpu/fraiseexcpt.c @@ -107,5 +107,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 5e7054edcbb..1d23e7ca80f 100644 --- a/sysdeps/x86_64/fpu/ftestexcept.c +++ b/sysdeps/x86_64/fpu/ftestexcept.c @@ -32,5 +32,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 Mon Nov 10 13:28:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123957 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 57E363858C41 for ; Mon, 10 Nov 2025 13:45:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57E363858C41 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=T+GIHpny X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 747CD3858C52 for ; Mon, 10 Nov 2025 13:32:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 747CD3858C52 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 747CD3858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::429 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781560; cv=none; b=PoFtrR0lJPEKKXoqp55LaFZD0TuYCJDhFpgHckpgbhnrOVfOrVWZd/zGI4ysbEIcDxsnMvgSEv3UZsJO/T1PFdns1O2YlTZqAIu+CVEbg56DiFYSmkyOZytXkkYYQImwkMooB2E0QXp1w0t3BYDBBneiMfcHDo3jp8krBdH5vzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781560; c=relaxed/simple; bh=Z6MyPSNzR0mkZNeF+GseWrI0mbeZ0HEi+JI+ifJtjK4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dEscNhWAy1WOY/WcX1tC/ha60I8Y4TtnKD8kW+VpMG4WNvT98xQzQrDPtML2wvoalWb9z4bmozbDRkKO9oH9DPV29s/h6MJBhUW5wmw4bNn28qslytG5FO//w0R2QHqJsMjL6YEscOE7GjpZ/mMjfxJUkROfPtmR0bBxRxj7NFw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 747CD3858C52 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-7aab061e7cbso3601280b3a.1 for ; Mon, 10 Nov 2025 05:32:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781559; x=1763386359; 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=6lVFeo56yCxmWet7iylIrv38qQMlIlud0Joqzy6yD5c=; b=T+GIHpnycI6ANQVWUBozV9u6iHCTilGIEP+JxaHUoNY+80M9mgmpQtJinFhAagIIMR /irgIYBjNY+sDnp/rWZGSZxxV/L3RCxyoe31nhrf9sPY27V01x01oGj+jeypvdRY8WVz 5NMm11q8wOLI4nLF2Xuw6Dx7mq0oublyY7jK3+98Al45j+lv6lNgXACeY7qGfDhUZdeX 2sXSSFWz2wrpAv1EZ0a2BKOJ3j7RRst0xG0bRlccpj8a74524Arytb/PttJvzhtxgOVu ZU5j5eBaFsWpzgMCMYVluHGn20WX0ONc1A95P37SZpLJmO2L5qN/Y+gPbkHrbXJwqj9l OSOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781559; x=1763386359; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6lVFeo56yCxmWet7iylIrv38qQMlIlud0Joqzy6yD5c=; b=SW83TG91XdyiHw4+lRA6ZEwLzaovFMUbRUsAUKw6gZA/aDDP5PRIdRtuc1AAsTd+ru ZAmdPc9+7i9/+HO/GH1ul9aPR0a4FWUUpb9aOkoxNX2cyleg5k/ssopFAYSu0WdbmQAM ++TzZe2p5Ap4LHWMWNB/KOLY46nXJN8PFiCpk+apmpG7I+mA1ewzEnAwbqpXeOOySqkD HTaCoRo1PO6ruPgJU2wBQpb1ilSZbUPtgP2/VfP07MiWJIrxel5KC19/bKCM67t2z6Vg if0G8LGphX9JqM4Gw/qr1AD22avmoguvwyFPzUBdI22F7LOKlVF5ZQKFB/bZvbLvv8RW s4xg== X-Gm-Message-State: AOJu0YzCRH++BzKGV8l7hgy2ggtT9HvEuZ1rlWpLcoInYwvHSWvW7d6O xO2etN1Mg2zeZpqVN1Adln0Wm9VuPd7vvpU7dFTpaG8A28TULDPFwFbYxN1M+CvlAjy6y7QRW0L PPRT4WqrzsQ== X-Gm-Gg: ASbGnctFA47D69Fql+zCrSFZbbcSZL9t4VmqXpNLt21gbM/mT481pKfHdnF9UleGoNP DUFm81Xd/WOuQVnmlEiKn51e27hgwU5B1hZ4/L++Q9/NpgKKJ5Fas20349YEASk8V/9ytGJLZML 7Jn/9eQRHpTABI44DbMzGSt877Ws4mZ5pQBqZCVexfRfvwJH8LjdvsqmqTezTPZ0Wi9Aip92GA/ H0RAEDV6mL0iE8ZkEt1dFUrsshXxjTWbKkdi9nq5p8OfodDHcVUV1Vk0UYHF6afWTjosIbZXcd1 zjaEH+9Y1CP2etVy4z/dJX+pqnivMcHEx8sb0Gm7Aq0p3KKZ5kYKvqI+L7X+u2t5gZ0oPr0qzRv Sr+JaIYskcFioLSJMI4eJYWrh/YQ8SwOVWGWGfCvBsiTe/a1qH91UNJOMruYblAsWiknZvpl0Bx AhkaxbjGS43ljCefHLRNYgqPw= X-Google-Smtp-Source: AGHT+IHcGxYbWal93q7WjcIuZePS7PwPypvV2WiLRNH4r381ui+1XNj2hS7WKmDxI4S7Et7J4tHkeg== X-Received: by 2002:a05:6a20:3c8d:b0:341:1dc6:aea with SMTP id adf61e73a8af0-3539e34786cmr10667343637.0.1762781559197; Mon, 10 Nov 2025 05:32:39 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:38 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 07/12] x86: Use -mavx instead of -msse2avx Date: Mon, 10 Nov 2025 10:28:58 -0300 Message-ID: <20251110133214.311261-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-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 clang supports it from version 19 and onwards, but it should be gated as an option to assembler (either with -Wa or -Xassembler). Use -mavx which is supported on both compilers. --- 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 Mon Nov 10 13:28:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123949 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 9BF5B3858C40 for ; Mon, 10 Nov 2025 13:35:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BF5B3858C40 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=xP0xCusf X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id C00103858C53 for ; Mon, 10 Nov 2025 13:32:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C00103858C53 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 C00103858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781562; cv=none; b=aURYjyetQ15cSu0fB7nNWhy19qbzkX79NyejNaPOe0ZoRkLILky6D+19gWm4fIHnkRCD4pdR74IPVBUJo7kIS8ZWH2L9aBBlYA3oGi19Rk13clYGFUyavI3j27anILriQKCbXiUYz4aj2TvkdsNwJ0cnUlTvINJ3lsjRZTfHChg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781562; c=relaxed/simple; bh=uLyW3z1mEktHs5BIbY0fIVcMRRsUqxYiY8fV/Mx6Ql8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tNLDX4T/UCcO/4VZcrXIXBwxyaEYO/Y+YB+dyPOmvhPMVynpsx+zcS7KrMJmk8hDhd/s34bEmyhRgs1120N7OFwqs7ki+idOtxiiuDxuKfggZbJ1oo6BAA5+SXumLCDjvkGm8LCEjmVPgHSy7WfBnsP70bbBnV5yRPwoqmhLDDs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C00103858C53 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-3438231df5fso1507000a91.2 for ; Mon, 10 Nov 2025 05:32:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781561; x=1763386361; 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=xP0xCusfVB0ck9KgHMnUoDnn5ZYt/nul+zUbNJLZ59a1qVu6BphI2SCfa9Nd+vD+9q HYoyGgxx1xIdiivpMfCY4K48KdEPGLiD7bAnErvkt49YnB+NsV1zHgEeVlPc6Yi8f4I4 kRdp0iawG6SUfyoTEEaL8vKBtymiQIiO6SUuZMp25yzRoi7uB/oynxxQLUVJFh/Sbhd4 WriIcGKtqBBJjDcAe8miuBCFitbpOyiB53uPi2K2Pmi3vKyjwmlotPJ+qt+NS55ggFqq LIgD1Er/xquj4A9jl0Al7q1AOrPltxTTKpKt/mRcdttaHUOBKOT2Y9Aw1+0kisXbi83h 7TQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781561; x=1763386361; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R++g/K4uEajbhxCp0pWWBiV9VdMapiKfJZcVQLcmLkU=; b=r+iZHReQsRhYnbSjmsa0n8hePtZTpCx5rAnUdM6TFIWflT25nxub0QgMoO9AdDsB3x WRdGp1j5n2IIv8z5g7mw43IjgixswvWO7zcm/eGo5U5byC12KMw8CV9ts1iDub7zhSR7 pNLHLINsKDlg1lnE7HZnwoJjKOh8+T9jqwIqj/3GqfyU4anx4k3CXhQWWhB919bYNFcl n8EWZWRU7fuSo57KGYs4TTchWx4265l796f1RKFcEAOn1pikAmZe+GeyPY6aPp/JW5I2 WILsUUWQ39CH2vBnX9SiAa29wkr7v7frP7YDo/POMPoX1QRTW1DE51wP+jDvKr+iSwIy 6R8Q== X-Gm-Message-State: AOJu0Yz6d0oCRD8XOjSHSVaGE3+g8HVnZYn2OMQOYLDMbsFXp5TcQPry ut7F4m0xKOIkOYlEyRM5bHsvVT3OCPJCd0j3DTwWOBBEOEjtV+MRfAuYLivR0dPEWw8980R3ePB AL04pTGg7jw== X-Gm-Gg: ASbGncuaif5U9nDjffgjfHiFFs63+OifnYvqv9K64WSr58u2YCqiCLatnjwefftwXYb UdPwDcM4jfQyDO0gW0bGp+d8+0vXHcefSUlvjAV1fSPeF8/RP7MVigmo2ifCc7wC+AzmYuEgq1J /viTB9PRxGnNGgaYpMY5+1UITY52xmWX6z4wROze7HHHG8s1G951Zunoj0d6ozdN5CnbqcWjq5I KcD9MWqMtsQUH5TgFxp2fJA5njnQk+5lFCXaLfPcxNZSFXwbT/LNJQDUgVHHHGutmInecrpUVFs 17V6eVAn2tZ9zRWbxSYYItvt8gz+C/mcoBmFyR/kpd0k/B9cEbKSrnpeHArrMd2yRtT2CvvnAdp p3NBZFNlfikge3+5T/DlGhZIipf8jjp9npkTRUbIG7LQ1OrjwS58mfmZ3RhDwDF+gKuDs4ybRI2 lIKkvtLfAeUsQ1 X-Google-Smtp-Source: AGHT+IFgl3w74C/9vJeteejGpB0X+2O5BoMpgoSO0lIgyeiCtKwpvDDEkYYbL99KiTEh+qVqNTUsJw== X-Received: by 2002:a17:90b:3848:b0:33f:ebc2:645 with SMTP id 98e67ed59e1d1-3436cbb3b4dmr9825908a91.20.1762781561429; Mon, 10 Nov 2025 05:32:41 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:41 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 08/12] x86: Fix strstr ifunc on clang Date: Mon, 10 Nov 2025 10:28:59 -0300 Message-ID: <20251110133214.311261-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-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 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 Mon Nov 10 13:29:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123951 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 0E8C13858C41 for ; Mon, 10 Nov 2025 13:39:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E8C13858C41 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=BBRZ/FFM X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id 2A5F23858C36 for ; Mon, 10 Nov 2025 13:32:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A5F23858C36 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 2A5F23858C36 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781565; cv=none; b=IObzT19Mp2Ms0ru8n3J5wo8Q3t/V4nBt8zEIFizJfTa0Ys1QJObXOra/YSTQsQfWlYwQ7UX5wD0vteKmvp5/KTfC3nz8nFgKZYoc4MC1iuUGHFGLXY7y7bmSaMfmlP0uUkqSacP1HyQ5+MJtSmc76+6uBG5mCfCHUmhXwLmJpQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781565; c=relaxed/simple; bh=qAzgtJFs7L2KMO0IFnbJJCChs5SxHcZWbgucSzYEF1U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pFDAgQXuAiqOLZ6e4sR6j0gk/NTR/jCPSIdUKdz92iG7Lxy/zR/CA2K4DkSrNIsdMsbndrcAll5FC5X8CSLHPCO1EhJHGHesnmkTvmEMpkjBgBj0H0k/GLXkfv6ROQ5gXRvBp655bH5g8C2kuDzSQwRLwPQ7DK1INoMRW9D4pBo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A5F23858C36 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-3438d4ae152so1286919a91.1 for ; Mon, 10 Nov 2025 05:32:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781564; x=1763386364; 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=DdzWWSmdIsuxRRPSAlagIv3/MNl2lw26Jh3MPEdDgk0=; b=BBRZ/FFMFyg1ICVB6cSYSLsCkVB43RuMm7qXOXpqquHiZYLC37fFM7GUQJ651AIqSA /b36FkBQ7vAWzJjuq9UqlfiNY3/9WiCqtuhXIbM93q+pnAAwJ9dTQulOr/qfiC3KfnXQ xbsGz2C0BCIpfYtd0HgGubX58d2CitwCnVezXeJN4AuD6D6U4HDPlL5v38jWRi/xuMwV aDCqUTMV+koo/E7+RkoDvv3A/VtXck4urJ9jzB4KhJHRjobsC+pnJfvEVe9tye+6Pdgl qxEPYy3rassITXWfIYnvFr9QeGHPBBsbgdU1cLaeUGpjJHmlaum/wh4x0phl6W2oj4xN +ylQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781564; x=1763386364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DdzWWSmdIsuxRRPSAlagIv3/MNl2lw26Jh3MPEdDgk0=; b=ksek7Lo+A6nxneMAJnAf2hoTyyr1dEdBnDR9u4A1Ua2+NqsTPzOgGQ2pGTWrQIBV0Y 9uUc7sjCJv7937N9vDZ8lDUpUkJr3EmhZZQW5VLAinqTYi5EFewHjemawrFnLUyViTR5 x1mGt8bI2MFQpMVJ+dU7NUgRDXWpgEGGNjCYKl6tHPGvmd72+1EPmvxacn/GkNwawr/I wCE2RLmCQLAKGyWR5iXoUeqybujOrdXCT8h14eiwSoL8e2fvmjB/Kd+59AwnOqa1ix5L XE6stcH/JDuIQsHV85KFbWEy5yG1s5h2Az97Yl+qedDAfx8Zef0K9bhI83wJMHS70Bev laqQ== X-Gm-Message-State: AOJu0Yym6pdKxi8ROlAreoATZNDaXJr8NUcC0Kj/ULb0PAsxwEVg9Kru h3o8+Fs9QivJ3oG6fWskQ4dN9Vt30wIzrWXEIpaDvArRy5zQQHrlerE5V96bweoWpyr6Ofo3t2M QEj4J6ava7g== X-Gm-Gg: ASbGncvnnYgizPf9DWx2dchUOYpD/XXXcPPLT6k0LBWMqMSfxDmTKfwyNna2wF1h3pu HWJwqCF8IOKqk9rElobMwN/plOzRoBeSXICP324jHd+MMasffyVvfXjOhipGP/DaVmmFmsdq+hX zdYCbhCYBTjcUmrlpBknSwD5N/NRcU2+ciErSLYjiv9jjhDM2RISq/ow7yL/KABABWcHTxmfhuK MZOsQyqCsO+PAAEXKU95nrASE22bl2fPmg/RUDAkPuHJUfeDKUyK6Gf2JA3ONw1O0wdW8KgFPqn sISDi5soTkTkE6yWPaia1mkaFuWT84lg3v0fMrmz5jSpBNPC6Aw9QVbKw4sfDDKpmtDRq3VRh1l DurzShyFnIUkR7jyg8nrwGRZZtbeqrV0rrzknPg9mHDzjVH0fixAqNvDqLua6EQxuLFEK/Zs7Cb nK04FG81HVXVWA X-Google-Smtp-Source: AGHT+IEnrFupbTQx7kbyies/lUzYXRFNiokRvQ93c8jw3XY4rzawJtP8gEiMrGumm/w3vboPyrQKzg== X-Received: by 2002:a17:90a:ac08:b0:343:7f04:79c1 with SMTP id 98e67ed59e1d1-3437f047a07mr6143723a91.9.1762781563745; Mon, 10 Nov 2025 05:32:43 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:43 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 09/12] Enable --enable-fortify-source with clang Date: Mon, 10 Nov 2025 10:29:00 -0300 Message-ID: <20251110133214.311261-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-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 bcdc6aa625d..07b456f4f5f 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1494,6 +1494,14 @@ rtld-stubbed-symbols += \ # rtld-stubbed-symbols endif +# 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 Mon Nov 10 13:29:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123954 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 448A43858405 for ; Mon, 10 Nov 2025 13:40:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 448A43858405 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=pi1Giccb X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by sourceware.org (Postfix) with ESMTPS id 3F89A3858D1E for ; Mon, 10 Nov 2025 13:32:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F89A3858D1E 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 3F89A3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1033 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781567; cv=none; b=doi2cbqCD0FNqiBU7aA7nIgY6E3luF/hQhe1SENg9yyoNhaZfwIpaN0NrtW/xdpz9acTNiczEmz5gYNh8msLTEvhOSe3hfFV9QS8Ut98N7dLpsqRA4hEHJdaqRRPdf0V9m0iiOad132iMD05Bh308RUmh1MwWEfUjWrTrVLhzf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781567; c=relaxed/simple; bh=ewfeEyEr+KYpEq3rku266NVPR6EDbCjGyaAyPn8WgKc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EFEgO6OcNwbR7uRMOYty3l+3UjrX1X+LpbLHuRY7AbihOZfps3dNStsqWwmgBHf2um9oqbrLZoJ9tnQUSoETkdWd7SkzT2/qi+31NNQwDFBfTdsaH8ITd/sKlux+sfYHjzSqy/gvAwyErpmaBqMqMeG7UPNlAkULTI83mIvPjYI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F89A3858D1E Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-34381ec9197so1265643a91.1 for ; Mon, 10 Nov 2025 05:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781566; x=1763386366; 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=MSGPUwWY0KStxqbM0xC0UWIY6qtHSpscWF31AZdui6I=; b=pi1Giccbn6tTIwHq303Q8o31u2dTg4tp5SXM3MnZaa0VqV3CBLVCgN9h6OdcKyd64J Ga5U1N6A93TeaVijw5C24flm00pu/gEfxyVF/MCHCyGhyQEgzGVr494TN/rTMFi2eruW Yw1B9nw4YVHCS8bHAWY3n/v72pxznDCMieBx+kRl+uD1XufP/yqmtieRI7ApfX2I7QHq VxlyYoSLBhBhepT/xJG7JlplQVlYSaVOmWCJS+z2D7Y3qqSjt0+T03j1ch7PFMwup2MM K6V7nYKWnZ2g1XbLMkZtNxhmVjeDwP66qMhaqMw3EWYczGqqlyh3o9DksUUdnMqpcqjc a5fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781566; x=1763386366; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MSGPUwWY0KStxqbM0xC0UWIY6qtHSpscWF31AZdui6I=; b=nn7wZ86X3iGXsvLI6uUPNBB8zbFwXAM/N2mIwAgbw+463AbxXZH2TK2QtOjnywpi/a gp78CZYwWbza0wQlTw4qFH5kuOUrsURgpnR3KxvkCKp32PVhE7LE1d0msl95QuUYFJCE JnbAkvQXCL1CZlfDen+rNX69RjCZBvnIRlU9a1g4l8ZIsemzyIAgGCmeisZbdehsdlNJ ac6953p4tJQSiCSqioqQhKbsFz+8Brp4kGNpz4f7tdX6EOh8UGeSNSo/2vyckDxDfkKw pgGNM6ggd4sSRmwrWxXpoj9nYWBUmEbvp2QgJXhsVMoSmZvAuENkaEf05qm/r4b9bGrj GLSw== X-Gm-Message-State: AOJu0YyDoEGqwcfoVFsCPDgfXx+rVpl5J7GnkFTsDZgxbH4v2kXoMMaX pcHQBEoRXtq3uVlm0Elq78vDMrVV0J0W48x49e/NjwCSgUMXsixOxHI22rmgvtUhOSBFy9Htjky OmA/D7XtiLA== X-Gm-Gg: ASbGncvsVSf2kyhpexoGBhBosZuo0+I/f7GNq65OsPzbL0B7pk1nQMbNsLApTpz41VS rX2gg31+lS/J8G5liKA+4Rkqz7X6y0qY06YoOOle4K6ujP1XHsVybHybr7XRs6CLXfzspX/zHc1 fO475lZHRpM7ECzyu0mBB4/NiyuwBdonp0XPKK9uPmYyUhPYMcNMcC5ptIJjlzmMb3UNxTdIQ+W yMIwJfnjS9Anv/4lepWOHoftFMtIWsKlB0JyhIlepUlKoTC21cWHPs8CMRBDJu0Q9joVBohXoeu 2YqeQeOkONBi9HX7DQA4NHwEOv/LRViNA3EKqLd5bHmdC8Gi76l1jqfCd/napT+p03KSa0xaWSo cC5ui0tTR7DwOMJTLxXuj8bfOaK26xjrqzLdLZ1eQ40+ZDvpKZfHK8YyWUq2e7UW4jdUB5XPZ12 13sEyi8sTmPVbCydsQ60txvYA= X-Google-Smtp-Source: AGHT+IG1dpU7CIqRa4DAyRaomUSStdP00DlYp72KajGUewmT/nBqb/izZ2dz8DdUqgYPRSUlZRFNfQ== X-Received: by 2002:a17:90b:3145:b0:340:d1b5:bfda with SMTP id 98e67ed59e1d1-3436cb0d072mr9787698a91.3.1762781565953; Mon, 10 Nov 2025 05:32:45 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:45 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 10/12] math: Handle fabsf128 !__USE_EXTERN_INLINES Date: Mon, 10 Nov 2025 10:29:01 -0300 Message-ID: <20251110133214.311261-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-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 84d44d44dc1..2565a4723ae 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 Mon Nov 10 13:29:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123956 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 951C23858CD1 for ; Mon, 10 Nov 2025 13:43:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 951C23858CD1 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=B8kHvcDJ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 8331F3858C74 for ; Mon, 10 Nov 2025 13:32:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8331F3858C74 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 8331F3858C74 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::443 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781569; cv=none; b=lTGdCdE5ezg8rSzFM48jx7f20LEKLX5oQruxqQXBYWPtMfWucsF3+ZfHgfUNeG7Sn0TJBPqN+MAUZIXT3egy2TH9xxaYbJZMEwXdmpOyjI9MTzcu9NRjDydTHxZI52cc22q9RIAz6kbuU6G/iTdgkiC9BC1A2R+7loY9/uyiis8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781569; c=relaxed/simple; bh=rl6yBRuKtBpwktom7dgm8Mp6awyfOv1C4mcG4uo2GgE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LhOiIYM9WNEUc/Whzq4wAX2vanAxzlTppMSTQpom6CfrG+7DjvAW1hwPPdjLJ2yCWA5UVuQuDIXEGRDG6IIsYQgWUJoDURTNk8A9HaIVXrAJSax8f46irMsozUFSJUt70rLl0ZTwWMnPHytMJdU5ZtCfBHBazruPGrEidxxUp58= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8331F3858C74 Received: by mail-pf1-x443.google.com with SMTP id d2e1a72fcca58-7ade456b6abso2493673b3a.3 for ; Mon, 10 Nov 2025 05:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781568; x=1763386368; 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=ez3U+Fu78+RHjpHKXrPw/H26HuERCUJ3VKHjJEtG5/Q=; b=B8kHvcDJfPdUt0oMeOwcM6zPFRzWWBHccOH9XOUwOU/gHK90D+PBNYhkYAM95m7G94 YXqmvljXS0N+ps4pN2YkfiJu6ta9deQ4b+Q9k9bEV4S1ApNCH/XFZbdtkQkvw+GTJoIu TeGtPpabyNOuBbQiFStl1zZJHZoXrLXz8catKIm9n3U7txtbw4Cv/lmeWX38sXMK9HTC nAD978ov0IjuCMo7OLNhQFQGJFVVQ08VXMvuv4a5BA0eccrC1s1moYLdgBVBG7Y+pjhW 2R5265Wjtl9TgMDUaYXVTwlPpIGC+RZrE39R1cIyLJtT9k4Ac29LCdWWIy2oBX9P+GTT 1jiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781568; x=1763386368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ez3U+Fu78+RHjpHKXrPw/H26HuERCUJ3VKHjJEtG5/Q=; b=OnbZcQHRMZTl432ZY2X9pSJkFhapSF2icJDvPILOZLQagIa7tcxm8JVZzLA8VQt7wB s/p39DH3/VPC7PmpuRBFTZ0C4CQqwMBfsGuFF8TQxOHQ/l9J1abxj8/mUH5tkHNC1DYN Dq1bxJCG10gDHHg6doQfC9xhdfXQvgY/7lSR7T1rOOmUV+WTS5ZUwNA+xeLgNCjd++QP nXaBkMVIgwBdwF4UyPLqknptNpQkbO5Cdf7K11B0zGdV0cLX9kVFknsG6Il9G5ZinKTH GQ2HDWgXCy8j3NGb1P53EZ8VPfLxb5p42yUvu8fAtDNgwhLPtMrcgrahRl7biYleeheW Vutw== X-Gm-Message-State: AOJu0YyBexI4XBPny62/73PqB8qDwdg6se9ZlyWB+a+rQR4P4OV9wXal x2a8XcxwgkQsCJGNsiJSI7gqbuqggXWKVJse4ojYUUbNQaIISyG6z11kTCJKE2dBQ4emXA+NkMQ 4xOSO7qiEUD5Y X-Gm-Gg: ASbGncvgn8zXkMEvu2Sm7W1ztBe7O9OyxydaYzhcrtc7G3gowQm/8eiDy+gRQomZ3On I7Tla9/evjJT/5X6LNoLQKDJYqSTNdWy2a/f5r8MKj1VjSCZ6WJDwy2hQKDZTeAjT38/XiewSOi R5dr16+I5bVt11gd90XOBIrKnFXngmZxWoR+b1aceKJ5jpsxb/vw6HXxBWBEYDX8A0sIodz/ZGX ZgntzPhLtl/Y7f+myNMlCemV8WtQs6sBWxsfsYjKuq7bLb4SUYzyHk16JOc9L6a8WBcNTQTrdsZ Vl4kUFsnaYNVe59UgmX8wbYxaoi7xYjBxTebs8LmFXJ3UQvHodcACFvzSqUlUvFKdJbnQ1rF3qm 5ilhA/SIqsZ3gjO9UOS5G325sHLCTDTu6bfBC+SCjsF61tA8vSLQwN/+lAlNa0FcviDynvDEmEf vzVW1/JVdqnDT7Fb3wIRH1BeGVuzc+iiY/2A== X-Google-Smtp-Source: AGHT+IEFZ/mu1QxsMMkpZeZ22ZcgG6wevZy/OCRdGm3y5bGmMPs6p4wKIbjrklVlR88H+vq1Ctwk6g== X-Received: by 2002:a05:6a20:9186:b0:347:67b8:731e with SMTP id adf61e73a8af0-353a19e5f61mr10936728637.14.1762781568202; Mon, 10 Nov 2025 05:32:48 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:47 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 11/12] configure: Remove for redirection of built-in functions Date: Mon, 10 Nov 2025 10:29:02 -0300 Message-ID: <20251110133214.311261-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-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 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 cd825395791..e490bb95f54 100755 --- a/configure +++ b/configure @@ -7674,39 +7674,6 @@ else 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 46b33fd9f49..c9939a6db2a 100644 --- a/configure.ac +++ b/configure.ac @@ -1496,26 +1496,6 @@ else AC_DEFINE(__HAVE_64B_ATOMICS, 0) 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 Mon Nov 10 13:29:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 123952 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 CA2633858C40 for ; Mon, 10 Nov 2025 13:39:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA2633858C40 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=HK76SD97 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by sourceware.org (Postfix) with ESMTPS id B90C63858405 for ; Mon, 10 Nov 2025 13:32:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B90C63858405 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 B90C63858405 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::441 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781571; cv=none; b=wn0nAxlObdJDzsjyLDZCNrZGloDbaJuhwMhE4zunIBi6eQPITTcPLKUcEv7mOYeEFbMmPq4n4FchgFsuI2faSCatPIkl8b8ibdDGTx25MeKmz7zLq4sqQ8QIiLzHMheNL/HGvZIuE/3C4vdYLG379jmVixn1VHdh7a5eCzSv6PU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762781571; c=relaxed/simple; bh=eL6mhP1E1yOm3qah3CnR3ps+htLVCs281oVYuzkIOZ4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Wb/ujnnDe+HxDPTWQxuaRRl2B5bSXWy8uEuDz3x2lUdgOcDuN4HogtqedJJQKZsfIV6DOjsParDkGbTsEBc29NE5nbZ2b+QHcB1ya09mUN1gTxcyMqfinFmM5HE3+/EoXlDyle8somFS+DaTN/fXDZ3VK0gpIx8YtMEgLTm8Ni8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B90C63858405 Received: by mail-pf1-x441.google.com with SMTP id d2e1a72fcca58-7a9cdf62d31so3573279b3a.3 for ; Mon, 10 Nov 2025 05:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762781570; x=1763386370; 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=cG/qLbWMhjSH5Td3M3i/XtwAiuCIn//OaLddKFHi8Qk=; b=HK76SD97+s74TBAtV5+fWeA+Y9scMknoGxnwDYDOBh2gcuDign06lWyNugVIvuASeP EKjQAErr91xVNzpKw8AeJwZQdZeYtCUkEe9qH35ot2/ZKYwjAUvpoNL0VCdeRvKdSwML h2kOdg0G6c3UOin8XBZ7DiBhckoHh/WCVekEAO7EqulnvoKCG1hcOAiFlFFk4oD7W89i OkspIt0jSxjJ+XJSE+0+RhIjeXt67oeLdar9M+kfoEN6QoTO4c6nYVOx2vz1vaoOs9QF 1p2t06aRTpSch04vaalLsC8P9Hgnj5mrkih5PC3e0vXnSMfJV3CJdUAeyWZkrjrzA1NA dBNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762781570; x=1763386370; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cG/qLbWMhjSH5Td3M3i/XtwAiuCIn//OaLddKFHi8Qk=; b=PZ+4/mmtdTM1NS8ykC4X3Mh3EdXSPFEHgKamKLUxczTklTFINXhjXUIH1+BYltiuf8 gTqsoC2jEEHPbmlzAkAuPZEkXx0Wk27bM7U0SL9II+LSre1Bm6vars+BNrBdp4oQ87LP L3JyuRIyyjkdNMaVMpOC2sUN4jUdLMtfqLCih5SAxxuTfKn23QH2jDOzi0VVXXy7TyjW mXdAO0pgaXkoQIv8OQbyG4fiGsrhxrQ6Acuw3SOKDC603Kn3c185ugOEjwyN+T/kjLJg K4Y7eVzwXbxpMenRkFKjwqObNEbvXLrCaETiIpxnvzyKec+ZUbcE7FZiUH61U+wOM0Gl 0ocw== X-Gm-Message-State: AOJu0YxU5fIrcD7csn6DwrK6aQitl7s14u1rqZ7OiWvkSmr2V4EFSr/p /C4emwgw5/ASbmWDToTRy+CVQncU0z9Yq+t0MWIZhXx43zzrxgyb/6cjI5a2vi0s9RtkIh0od26 6QaJRDk1jvy5U X-Gm-Gg: ASbGncssq/bqUR+sD0uY0WUTLOSXSYOpvwUKjc6wqJIOWz34nUbRoewSREpkK6xj/ZI aNNl7j3pddH4DUaEafdoCvO1NawuIYBXuMNyUJVcRKf13VU/1gCk3af9Gu6ThbI1qsC5IHdWWn9 mCbWmNjxmGjjah0yOY8CnL4yLoYcDSZ9KQutdTpNbJOhDOsTKddGNngEbAZMynMJLv47siOp2rt m0RLQ4ytT5bz3RurB3hhJXCVZS65gXPAR4MjlLUCSmKknP+go+ekvEVj8C413ivlj1xTMka3KqY IRJpoqcZ3dg4zZfQyLpdFBY/v6qwzLFC4yA7+LUdBTvjllOlMoPoi3Yc12UACt3KFdOgGmESDJF M4JyxVZ+TQignQxGANb0fVrIP1xXUUYHDtrXLkSP4CzWBhaaXXxWt2z6dOrp+1DZm0iu7hdADqb i18Tsjm9cZqKH5 X-Google-Smtp-Source: AGHT+IHjqojz7eZMm3atwnekV7Lenfk9dmRQGc4qjUd2xZIizVl8PlK04LonC4zgYPgqzbrJnEXUrg== X-Received: by 2002:a05:6a20:7353:b0:34e:409e:eea0 with SMTP id adf61e73a8af0-353a0f94ba2mr11728660637.12.1762781570468; Mon, 10 Nov 2025 05:32:50 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:954c:fa26:525c:4143:feb5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba901c39ea7sm12820393a12.29.2025.11.10.05.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 05:32:50 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v4 12/12] configure: remove overly restrictive check for clang Date: Mon, 10 Nov 2025 10:29:03 -0300 Message-ID: <20251110133214.311261-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251110133214.311261-1-adhemerval.zanella@linaro.org> References: <20251110133214.311261-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 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. --- NEWS | 5 +++++ configure | 2 +- configure.ac | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 0f01b751f98..1a14d125640 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,11 @@ Major new features: platforms supporting _Float128) _Float128_t, introduced in TS 18661-3:2015, have been added to . +* Experimental 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 e490bb95f54..eb94c8577f7 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 c9939a6db2a..9be9f566123 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],