From patchwork Tue Oct 28 17:08:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122867 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 4B40D3858C40 for ; Tue, 28 Oct 2025 17:15:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B40D3858C40 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=z7BWao6L X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 6DB7C3858CB6 for ; Tue, 28 Oct 2025 17:11:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DB7C3858CB6 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 6DB7C3858CB6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1036 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671516; cv=none; b=jRPKQ9mHEfQQRpLau2RhrPwNGeLefU661mXlXSHI3v+vxhuuNHcPgMJbWaP2C0U2rpvP95+pF6/tBWqhS1vKf6kiw1v8kwoVNeblo7StHgtTQe8wRqBUVXNLxiIXBNvS9SOfTXw1qO4D8U1rE9mKABtBxzSToiQYqRXlzdDvv6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671516; c=relaxed/simple; bh=+fatDvx2gnqqEH9p21cMPcrX8TbcA9iSqGJqtMj17d8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k8qnKc1lQLcBA+ybatVn96u5RtV2yXrWDsUZiED57Eg9TONwrhhPBmI16QUhcaQEWSCkkxYqZn/80hH2lJ6l0iegX2eA693oNGuESVyAquAdBC1vqURLhS2rlJ5dtLDwVKfkXIQD58XS3Rz0zHAxJxBWRVaphjCjV7A3DvNZkyo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DB7C3858CB6 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-339e71ccf48so7943348a91.3 for ; Tue, 28 Oct 2025 10:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671515; x=1762276315; 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=RihH/veA4xPglpjwI5Ijz3nN10B41F674adR8W22NYQ=; b=z7BWao6LEwATMnD/XR29f9o87eahN9Bi3AXoocSg4Muis53f3mNVcVgy2RsLmo+Trm UZmSrhqUhg9qgg1eU59jQYStl+8jLWrx3r5osIqZnxfzPGyfklWPGOdFSNVXb8MYeyTt apwnd34Bf2ZciBlg4czuW0E1mqVeFj4e1uj3vNHTdLCMbWNcY/28ktzi3Cjl95ZJ2mDa xJO4dxjoKjnytJdYePcgPSEiYkbFOXpYjJivzl/Qpv17SfOZw1Jg5Nhp+2GXtN9N2TKo aLljXsTSseP5DZTrCGVsRu4j10HdL0cExhV+7gSdd6XBsNR0R5sDWb0upMRKzZKL+vVk Qn7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671515; x=1762276315; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RihH/veA4xPglpjwI5Ijz3nN10B41F674adR8W22NYQ=; b=NMqgfQsDczP93LbOE2Z+4JwY0akE1bEkOaRd+Scl7dUKx9XjDqd3DNIfZZ8CtEXxWj NlV0S0uMDAuYjZ8X4AVi47xkT6qXmB7Y+vOF2AMo8wSr1itMJgNdK+nXSvWJ5/hEhwpW 3JgmmkeV4fzg8EX7Ks2m637kBTqDKlIGnatDFlyMbZdcOx3i1Nk/0aGEmQqJSDO2JNK7 gr8hE9DFbgFCyYax+OUyCINAEeSTMwI9qgien4N/9GmU15752/n9BAVT9UzOp5nY1ugz itz7plXQP6qNnhVsqEJsN6FkOh+VKHOg1tF81v5NnmjyrS97tqhWjCrZ3u5qWZX+Sx3c dX8g== X-Gm-Message-State: AOJu0Yzo1BNMQgjcFUCUqcdfXe8v/Tg5xmuGt4BMsxgNtjpwbnNadWU7 N+Oj4rRQyJk6Aqjuc1eGcG61JzdZUszvA40Oe8q46/xmCck9sUhV5ag9iJeMnKMDXCEEqKXQKVg KuLiUjaM= X-Gm-Gg: ASbGncvVDQQd8ALAVCOEkSI6C9tPIEj+i4O7RYuyymObY1tY5j74y/Z8mqLjkpP941d djFBOXR67/CfCi7fZKTS3JXwYRfyeQ+FgTrvu/fRHKnNOgh/rXzM8dm3ao7fYJbnZmHJ4xXWKzn U3BOKklhH5VlUTyMQSVUluStfciZVkCEcz0dopppbl70PEJXgPNsLz8XgY+UomfVZkBp3yCDi+q fLxgsaxomclW4PuUmSVy2VKK0lSv2ry4Gyvx5co80W/S8mUsal2RCKoUTmP5g/KxEEd0UR+oszA ICoIRoItZCAoaNvsnlZET3gfR7sl/gIfVAqvSlFm0zxkNl2mrJ/s0AGDjD/Jzf9Pe3EW0NAbMUY GeFmbGAj2T/aEdbfSKYSmOLv8JcTllTBJzrh8oQTN9O1sd3QKohkiOKGOueCpNXGM/yoKZelTCC Ey1AFejW/yn7kOX+Par5XiIK+K6F4sT7pSO2I/71zyeR9K71MP4DdLszYl X-Google-Smtp-Source: AGHT+IEbRlcAo4XhsNzll/SirlGlV3ECOQe1ll7gaJvPgByXDYmGgdFOiXfW377dIfInqlj7gmGZKQ== X-Received: by 2002:a17:90b:3b51:b0:330:6edd:9cf with SMTP id 98e67ed59e1d1-34027bcb05emr5035813a91.22.1761671514399; Tue, 28 Oct 2025 10:11:54 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:11:52 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 01/28] include: Sync gnulib intprops Date: Tue, 28 Oct 2025 14:08:10 -0300 Message-ID: <20251028171141.3208834-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, 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 It syncs with gnulib commit 1790ef25d81983d1d25a77d452c0080345df459b. The main change is to proper support clang by using builtins. It fixes a sprof build issue, where previous version uses the generic code path when building with clang: sprof.c:682:8: error: result of comparison of constant 288230376151711743 with expression of type 'Elf64_Half' (aka 'unsigned short') is always false [-Werror,-Wtautological-constant-out-of-range-compare] 682 | if (INT_MULTIPLY_WRAPV (ehdr2.e_shnum, sizeof (ElfW(Shdr)), &size)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/intprops.h:415:34: note: expanded from macro 'INT_MULTIPLY_WRAPV' 415 | _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/intprops.h:504:45: note: expanded from macro '_GL_INT_OP_WRAPV' 504 | : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ ../include/intprops.h:511:41: note: expanded from macro '_GL_INT_OP_WRAPV_LONGISH' 511 | : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 512 | unsigned long int, 0, ULONG_MAX)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/intprops.h:533:4: note: expanded from macro '_GL_INT_OP_CALC' 533 | (overflow (a, b, tmin, tmax) \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/intprops.h:608:22: note: expanded from macro '_GL_INT_MULTIPLY_RANGE_OVERFLOW' 608 | : (tmax) / (b) < (a))) | ~~~~~~~~~~~~ ^ ~~~ 1 error generated. --- include/intprops-internal.h | 396 ++++++++++++++++++++++++++++++++++++ include/intprops.h | 368 ++++----------------------------- 2 files changed, 432 insertions(+), 332 deletions(-) create mode 100644 include/intprops-internal.h diff --git a/include/intprops-internal.h b/include/intprops-internal.h new file mode 100644 index 0000000000..2609803094 --- /dev/null +++ b/include/intprops-internal.h @@ -0,0 +1,396 @@ +/* intprops-internal.h -- properties of integer types not visible to users + + Copyright (C) 2001-2025 Free Software Foundation, Inc. + + This program 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. + + This program 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 this program. If not, see . */ + +#ifndef _GL_INTPROPS_INTERNAL_H +#define _GL_INTPROPS_INTERNAL_H + +#include + +/* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED. */ +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) && !defined __clang__ +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif + +/* Return a value with the common real type of E and V and the value of V. + Do not evaluate E. */ +#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) + +/* The extra casts in the following macros work around compiler bugs, + e.g., in Cray C 5.0.3.0. */ + +/* True if the real type T is signed. */ +#define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) + +/* Return 1 if the real expression E, after promotion, has a + signed or floating type. Do not evaluate E. */ +#define _GL_EXPR_SIGNED(e) (_GL_INT_CONVERT (e, -1) < 0) + + +/* Minimum and maximum values for integer types and expressions. */ + +/* The width in bits of the integer type or expression T. + Do not evaluate T. T must not be a bit-field expression. + Padding bits are not supported; this is checked at compile-time below. */ +#define _GL_TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT) + +/* The maximum and minimum values for the type of the expression E, + after integer promotion. E is not evaluated. */ +#define _GL_INT_MINIMUM(e) \ + (_GL_EXPR_SIGNED (e) \ + ? ~ _GL_SIGNED_INT_MAXIMUM (e) \ + : _GL_INT_CONVERT (e, 0)) +#define _GL_INT_MAXIMUM(e) \ + (_GL_EXPR_SIGNED (e) \ + ? _GL_SIGNED_INT_MAXIMUM (e) \ + : _GL_INT_CONVERT (e, -1)) +#define _GL_SIGNED_INT_MAXIMUM(e) \ + (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1) + +/* Work around OpenVMS incompatibility with C99. */ +#if !defined LLONG_MAX && defined __INT64_MAX +# define LLONG_MAX __INT64_MAX +# define LLONG_MIN __INT64_MIN +#endif + +/* This include file assumes that signed types are two's complement without + padding bits; the above macros have undefined behavior otherwise. + If this is a problem for you, please let us know how to fix it for your host. + This assumption is tested by the intprops-tests module. */ + +/* Does the __typeof__ keyword work? This could be done by + 'configure', but for now it's easier to do it by hand. */ +#if ((defined __GNUC__ && 2 <= __GNUC__) \ + || (defined __clang_major__ && 4 <= __clang_major__) \ + || (defined __IBMC__ && 1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ + || (defined __SUNPRO_C && 0x5110 <= __SUNPRO_C && !__STDC__) \ + || (defined _MSC_VER && 1939 <= _MSC_VER)) +# define _GL_HAVE___TYPEOF__ 1 +#else +# define _GL_HAVE___TYPEOF__ 0 +#endif + +/* Return 1 if the integer type or expression T might be signed. Return 0 + if it is definitely unsigned. T must not be a bit-field expression. + This macro does not evaluate its argument, and expands to an + integer constant expression. */ +#if _GL_HAVE___TYPEOF__ +# define _GL_SIGNED_TYPE_OR_EXPR(t) _GL_TYPE_SIGNED (__typeof__ (t)) +#else +# define _GL_SIGNED_TYPE_OR_EXPR(t) 1 +#endif + +/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. + A should not have side effects, and A's type should be an + integer with minimum value MIN and maximum MAX. */ +#define _GL_INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ + ((min) < 0 ? (a) < - (max) : 0 < (a)) + +/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow + (A, B, P) work when P is non-null. */ +#ifdef __EDG__ +/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned + . */ +# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0 +#elif defined __has_builtin +# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow) +/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, + see . */ +#elif 7 <= __GNUC__ +# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 +#else +# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0 +#endif + +/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ +#if defined __clang_major__ && __clang_major__ < 14 +/* Work around Clang bug . */ +# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 +#else +# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW +#endif + +/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for + __builtin_sub_overflow_p and __builtin_mul_overflow_p. */ +#ifdef __EDG__ +/* In EDG-based compilers like ICC 2021.3 and earlier, + __builtin_add_overflow_p etc. are not treated as integral constant + expressions even when all arguments are. */ +# define _GL_HAS_BUILTIN_OVERFLOW_P 0 +#elif defined __has_builtin +# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p) +#else +# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) +#endif + +#if (!defined _GL_STDCKDINT_H && 202311 <= __STDC_VERSION__ \ + && ! (_GL_HAS_BUILTIN_ADD_OVERFLOW && _GL_HAS_BUILTIN_MUL_OVERFLOW)) +# include +#endif + +/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R. + Return 1 if the result overflows. Arguments should not have side + effects and A, B and *R can be of any integer type other than char, + bool, a bit-precise integer type, or an enumeration type. */ +#if _GL_HAS_BUILTIN_ADD_OVERFLOW +# define _GL_INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r) +# define _GL_INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r) +#elif defined ckd_add && defined ckd_sub && !defined _GL_STDCKDINT_H +# define _GL_INT_ADD_WRAPV(a, b, r) ckd_add (r, + (a), + (b)) +# define _GL_INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, + (a), + (b)) +#else +# define _GL_INT_ADD_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW) +# define _GL_INT_SUBTRACT_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) +#endif +#if _GL_HAS_BUILTIN_MUL_OVERFLOW +# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ + || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ + && !defined __clang__ && !defined __EDG__) +# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) +# else + /* Work around GCC bug 91450. */ +# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \ + ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \ + && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, \ + (__typeof__ (*(r))) 0, \ + (__typeof__ (*(r))) -1)) \ + ? ((void) __builtin_mul_overflow (a, b, r), 1) \ + : __builtin_mul_overflow (a, b, r)) +# endif +#elif defined ckd_mul && !defined _GL_STDCKDINT_H +# define _GL_INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, + (a), + (b)) +#else +# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \ + _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) +#endif + +/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: + https://gcc.gnu.org/PR68193 + https://llvm.org/bugs/show_bug.cgi?id=25390 + For now, assume GCC < 14 and all Clang versions generate bogus + warnings for _Generic. This matters only for compilers that + lack relevant builtins. */ +#if (__GNUC__ && __GNUC__ < 14) || defined __clang__ +# define _GL__GENERIC_BOGUS 1 +#else +# define _GL__GENERIC_BOGUS 0 +#endif + +/* Store the low-order bits of A B into *R, where OP specifies + the operation and OVERFLOW the overflow predicate. Return 1 if the + result overflows. Arguments should not have side effects, + and A, B and *R can be of any integer type other than char, bool, a + bit-precise integer type, or an enumeration type. */ +#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS +# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \ + (_Generic \ + (*(r), \ + signed char: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + signed char, SCHAR_MIN, SCHAR_MAX), \ + unsigned char: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + unsigned char, 0, UCHAR_MAX), \ + short int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + short int, SHRT_MIN, SHRT_MAX), \ + unsigned short int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + unsigned short int, 0, USHRT_MAX), \ + int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + int, INT_MIN, INT_MAX), \ + unsigned int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + unsigned int, 0, UINT_MAX), \ + long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX), \ + unsigned long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + unsigned long int, 0, ULONG_MAX), \ + long long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + long long int, LLONG_MIN, LLONG_MAX), \ + unsigned long long int: \ + _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + unsigned long long int, 0, ULLONG_MAX))) +#else +/* Store the low-order bits of A B into *R, where OP specifies + the operation and OVERFLOW the overflow predicate. If *R is + signed, its type is ST with bounds SMIN..SMAX; otherwise its type + is UT with bounds U..UMAX. ST and UT are narrower than int. + Return 1 if the result overflows. Arguments should not have side + effects, and A, B and *R can be of any integer type other than + char, bool, a bit-precise integer type, or an enumeration type. */ +# if _GL_HAVE___TYPEOF__ +# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \ + (_GL_TYPE_SIGNED (__typeof__ (*(r))) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax)) +# else +# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \ + (overflow (a, b, smin, smax) \ + ? (overflow (a, b, 0, umax) \ + ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \ + : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \ + : (overflow (a, b, 0, umax) \ + ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \ + : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0))) +# endif + +# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \ + (sizeof *(r) == sizeof (signed char) \ + ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \ + signed char, SCHAR_MIN, SCHAR_MAX, \ + unsigned char, UCHAR_MAX) \ + : sizeof *(r) == sizeof (short int) \ + ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \ + short int, SHRT_MIN, SHRT_MAX, \ + unsigned short int, USHRT_MAX) \ + : sizeof *(r) == sizeof (int) \ + ? (_GL_EXPR_SIGNED (*(r)) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + int, INT_MIN, INT_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ + unsigned int, 0, UINT_MAX)) \ + : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) +# ifdef LLONG_MAX +# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ + (sizeof *(r) == sizeof (long int) \ + ? (_GL_EXPR_SIGNED (*(r)) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + unsigned long int, 0, ULONG_MAX)) \ + : (_GL_EXPR_SIGNED (*(r)) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + long long int, LLONG_MIN, LLONG_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ + unsigned long long int, 0, ULLONG_MAX))) +# else +# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ + (_GL_EXPR_SIGNED (*(r)) \ + ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + long int, LONG_MIN, LONG_MAX) \ + : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ + unsigned long int, 0, ULONG_MAX)) +# endif +#endif + +/* Store the low-order bits of A B into *R, where the operation + is given by OP. Use the unsigned type UT for calculation to avoid + overflow problems. *R's type is T, with extrema TMIN and TMAX. + T can be any signed integer type other than char, bool, a + bit-precise integer type, or an enumeration type. + Return 1 if the result overflows. */ +#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \ + (overflow (a, b, tmin, tmax) \ + ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \ + : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0)) + +/* Return 1 if the integer expressions A - B and -A would overflow, + respectively. Arguments should not have side effects, + and can be any signed integer type other than char, bool, a + bit-precise integer type, or an enumeration type. + These macros are tuned for their last input argument being a constant. */ + +#if _GL_HAS_BUILTIN_OVERFLOW_P +# define _GL_INT_NEGATE_OVERFLOW(a) \ + __builtin_sub_overflow_p (0, a, (__typeof__ (- (a))) 0) +#else +# define _GL_INT_NEGATE_OVERFLOW(a) \ + _GL_INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) +#endif + +/* Return the low-order bits of A B, where the operation is given + by OP. Use the unsigned type UT for calculation to avoid undefined + behavior on signed integer overflow, and convert the result to type T. + UT is at least as wide as T and is no narrower than unsigned int, + T is two's complement, and there is no padding or trap representations. + Assume that converting UT to T yields the low-order bits, as is + done in all known two's-complement C compilers. E.g., see: + https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html + + According to the C standard, converting UT to T yields an + implementation-defined result or signal for values outside T's + range. However, code that works around this theoretical problem + runs afoul of a compiler bug in Oracle Studio 12.3 x86. See: + https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html + As the compiler bug is real, don't try to work around the + theoretical problem. */ + +#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \ + ((t) ((ut) (a) op (ut) (b))) + +/* Return true if the numeric values A + B, A - B, A * B fall outside + the range TMIN..TMAX. Arguments should not have side effects + and can be any integer type other than char, bool, + a bit-precise integer type, or an enumeration type. + TMIN should be signed and nonpositive. + TMAX should be positive, and should be signed unless TMIN is zero. */ +#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \ + ((b) < 0 \ + ? (((tmin) \ + ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \ + && (a) < (tmin) - (b)) \ + : (a) <= -1 - (b)) \ + || ((_GL_EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \ + : (a) < 0 \ + ? (((tmin) \ + ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \ + && (b) < (tmin) - (a)) \ + : (b) <= -1 - (a)) \ + || ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \ + && (tmax) < (a) + (b))) \ + : (tmax) < (b) || (tmax) - (b) < (a)) +#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \ + (((a) < 0) == ((b) < 0) \ + ? ((a) < (b) \ + ? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \ + : (tmax) < (a) - (b)) \ + : (a) < 0 \ + ? ((!_GL_EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \ + || (a) - (tmin) < (b)) \ + : ((! (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \ + && _GL_EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \ + && (tmax) <= -1 - (b)) \ + || (tmax) + (b) < (a))) +#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \ + ((b) < 0 \ + ? ((a) < 0 \ + ? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \ + ? (a) < (tmax) / (b) \ + : ((_GL_INT_NEGATE_OVERFLOW (b) \ + ? _GL_INT_CONVERT (b, tmax) >> (_GL_TYPE_WIDTH (+ (b)) - 1) \ + : (tmax) / -(b)) \ + <= -1 - (a))) \ + : _GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \ + ? (_GL_EXPR_SIGNED (a) \ + ? 0 < (a) + (tmin) \ + : 0 < (a) && -1 - (tmin) < (a) - 1) \ + : (tmin) / (b) < (a)) \ + : (b) == 0 \ + ? 0 \ + : ((a) < 0 \ + ? (_GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \ + ? (_GL_EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \ + : (tmin) / (a) < (b)) \ + : (tmax) / (b) < (a))) + +#endif /* _GL_INTPROPS_INTERNAL_H */ diff --git a/include/intprops.h b/include/intprops.h index 140e51054a..72e866ff5b 100644 --- a/include/intprops.h +++ b/include/intprops.h @@ -15,19 +15,10 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ - #ifndef _GL_INTPROPS_H #define _GL_INTPROPS_H -#include - -/* Return a value with the common real type of E and V and the value of V. - Do not evaluate E. */ -#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v)) - -/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see - . */ -#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v)) +#include "intprops-internal.h" /* The extra casts in the following macros work around compiler bugs, e.g., in Cray C 5.0.3.0. */ @@ -37,11 +28,19 @@ #define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) /* True if the real type T is signed. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +#define TYPE_SIGNED(t) _GL_TYPE_SIGNED (t) /* Return 1 if the real expression E, after promotion, has a signed or floating type. Do not evaluate E. */ -#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) +#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e) + +/* The same value as as the arithmetic expression E, but with E's type + after integer promotions. For example, if E is of type 'enum {A, B}' + then 'switch (INT_PROMOTE (E))' pacifies gcc -Wswitch-enum if some + enum values are deliberately omitted from the switch's cases. + Here, unary + is safer than a cast or inline function, as unary + + does only integer promotions and is disallowed on pointers. */ +#define INT_PROMOTE(e) (+ (e)) /* Minimum and maximum values for integer types and expressions. */ @@ -49,7 +48,7 @@ /* The width in bits of the integer type or expression T. Do not evaluate T. T must not be a bit-field expression. Padding bits are not supported; this is checked at compile-time below. */ -#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT) +#define TYPE_WIDTH(t) _GL_TYPE_WIDTH (t) /* The maximum and minimum values for the integer type T. */ #define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t)) @@ -58,51 +57,6 @@ ? (t) -1 \ : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))) -/* The maximum and minimum values for the type of the expression E, - after integer promotion. E is not evaluated. */ -#define _GL_INT_MINIMUM(e) \ - (EXPR_SIGNED (e) \ - ? ~ _GL_SIGNED_INT_MAXIMUM (e) \ - : _GL_INT_CONVERT (e, 0)) -#define _GL_INT_MAXIMUM(e) \ - (EXPR_SIGNED (e) \ - ? _GL_SIGNED_INT_MAXIMUM (e) \ - : _GL_INT_NEGATE_CONVERT (e, 1)) -#define _GL_SIGNED_INT_MAXIMUM(e) \ - (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1) - -/* Work around OpenVMS incompatibility with C99. */ -#if !defined LLONG_MAX && defined __INT64_MAX -# define LLONG_MAX __INT64_MAX -# define LLONG_MIN __INT64_MIN -#endif - -/* This include file assumes that signed types are two's complement without - padding bits; the above macros have undefined behavior otherwise. - If this is a problem for you, please let us know how to fix it for your host. - This assumption is tested by the intprops-tests module. */ - -/* Does the __typeof__ keyword work? This could be done by - 'configure', but for now it's easier to do it by hand. */ -#if (2 <= __GNUC__ \ - || (4 <= __clang_major__) \ - || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \ - || (0x5110 <= __SUNPRO_C && !__STDC__)) -# define _GL_HAVE___TYPEOF__ 1 -#else -# define _GL_HAVE___TYPEOF__ 0 -#endif - -/* Return 1 if the integer type or expression T might be signed. Return 0 - if it is definitely unsigned. T must not be a bit-field expression. - This macro does not evaluate its argument, and expands to an - integer constant expression. */ -#if _GL_HAVE___TYPEOF__ -# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t)) -#else -# define _GL_SIGNED_TYPE_OR_EXPR(t) 1 -#endif - /* Bound on length of the string representing an unsigned integer value representable in B bits. log10 (2.0) < 146/485. The smallest value of B where this bound is not tight is 2621. */ @@ -129,12 +83,11 @@ /* Range overflow checks. The INT__RANGE_OVERFLOW macros return 1 if the corresponding C - operators might not yield numerically correct answers due to - arithmetic overflow. They do not rely on undefined or - implementation-defined behavior. Their implementations are simple - and straightforward, but they are harder to use and may be less - efficient than the INT__WRAPV, INT__OK, and - INT__OVERFLOW macros described below. + operators overflow arithmetically when given the same arguments. + These macros do not rely on undefined or implementation-defined behavior. + Although their implementations are simple and straightforward, + they are harder to use and may be less efficient than the + INT__WRAPV, INT__OK, and INT__OVERFLOW macros described below. Example usage: @@ -181,9 +134,7 @@ /* Return 1 if - A would overflow in [MIN,MAX] arithmetic. See above for restrictions. */ #define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ - ((min) < 0 \ - ? (a) < - (max) \ - : 0 < (a)) + _GL_INT_NEGATE_RANGE_OVERFLOW (a, min, max) /* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. See above for restrictions. Avoid && and || as they tickle @@ -227,40 +178,6 @@ ? (a) < (min) >> (b) \ : (max) >> (b) < (a)) -/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow - (A, B, P) work when P is non-null. */ -/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, - see . */ -#if 7 <= __GNUC__ && !defined __ICC -# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 -#elif defined __has_builtin -# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow) -#else -# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0 -#endif - -/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */ -#ifdef __clang__ -/* Work around Clang bug . */ -# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0 -#else -# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW -#endif - -/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for - __builtin_sub_overflow_p and __builtin_mul_overflow_p. */ -#if defined __clang__ || defined __ICC -/* Clang 11 lacks __builtin_mul_overflow_p, and even if it did it - would presumably run afoul of Clang bug 16404. ICC 2021.1's - __builtin_add_overflow_p etc. are not treated as integral constant - expressions even when all arguments are. */ -# define _GL_HAS_BUILTIN_OVERFLOW_P 0 -#elif defined __has_builtin -# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p) -#else -# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__) -#endif - /* The _GL*_OVERFLOW macros have the same restrictions as the *_RANGE_OVERFLOW macros, except that they do not assume that operands (e.g., A and B) have the same type as MIN and MAX. Instead, they assume @@ -288,11 +205,11 @@ || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) #endif #define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ + ((min) < 0 ? (b) == _GL_INT_CONVERT (min, -1) && (a) < - (max) \ : (a) < 0 ? (b) <= (a) + (b) - 1 \ : (b) < 0 && (a) + (b) <= (a)) #define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ + ((min) < 0 ? (b) == _GL_INT_CONVERT (min, -1) && (a) < - (max) \ : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) @@ -347,13 +264,18 @@ Because the WRAPV macros convert the result, they report overflow in different circumstances than the OVERFLOW macros do. For example, in the typical case with 16-bit 'short' and 32-bit 'int', - if A, B and R are all of type 'short' then INT_ADD_OVERFLOW (A, B) + if A, B and *R are all of type 'short' then INT_ADD_OVERFLOW (A, B) returns false because the addition cannot overflow after A and B - are converted to 'int', whereas INT_ADD_WRAPV (A, B, &R) returns + are converted to 'int', whereas INT_ADD_WRAPV (A, B, R) returns true or false depending on whether the sum fits into 'short'. These macros are tuned for their last input argument being a constant. + A, B, and *R should be integers; they need not be the same type, + and they need not be all signed or all unsigned. + However, none of the integer types should be bit-precise, + and *R's type should not be char, bool, or an enumeration type. + Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, A % B, and A << B would overflow, respectively. */ @@ -361,12 +283,7 @@ _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) #define INT_SUBTRACT_OVERFLOW(a, b) \ _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) -#if _GL_HAS_BUILTIN_OVERFLOW_P -# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a) -#else -# define INT_NEGATE_OVERFLOW(a) \ - INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a)) -#endif +#define INT_NEGATE_OVERFLOW(a) _GL_INT_NEGATE_OVERFLOW (a) #define INT_MULTIPLY_OVERFLOW(a, b) \ _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) #define INT_DIVIDE_OVERFLOW(a, b) \ @@ -388,224 +305,9 @@ /* Store the low-order bits of A + B, A - B, A * B, respectively, into *R. Return 1 if the result overflows. See above for restrictions. */ -#if _GL_HAS_BUILTIN_ADD_OVERFLOW -# define INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r) -# define INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r) -#else -# define INT_ADD_WRAPV(a, b, r) \ - _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW) -# define INT_SUBTRACT_WRAPV(a, b, r) \ - _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) -#endif -#if _GL_HAS_BUILTIN_MUL_OVERFLOW -# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \ - || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \ - && !defined __ICC) -# define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r) -# else - /* Work around GCC bug 91450. */ -# define INT_MULTIPLY_WRAPV(a, b, r) \ - ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \ - && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \ - ? ((void) __builtin_mul_overflow (a, b, r), 1) \ - : __builtin_mul_overflow (a, b, r)) -# endif -#else -# define INT_MULTIPLY_WRAPV(a, b, r) \ - _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW) -#endif - -/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193 - https://llvm.org/bugs/show_bug.cgi?id=25390 - For now, assume all versions of GCC-like compilers generate bogus - warnings for _Generic. This matters only for compilers that - lack relevant builtins. */ -#if __GNUC__ || defined __clang__ -# define _GL__GENERIC_BOGUS 1 -#else -# define _GL__GENERIC_BOGUS 0 -#endif - -/* Store the low-order bits of A B into *R, where OP specifies - the operation and OVERFLOW the overflow predicate. Return 1 if the - result overflows. See above for restrictions. */ -#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS -# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \ - (_Generic \ - (*(r), \ - signed char: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - signed char, SCHAR_MIN, SCHAR_MAX), \ - unsigned char: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - unsigned char, 0, UCHAR_MAX), \ - short int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - short int, SHRT_MIN, SHRT_MAX), \ - unsigned short int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - unsigned short int, 0, USHRT_MAX), \ - int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - int, INT_MIN, INT_MAX), \ - unsigned int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - unsigned int, 0, UINT_MAX), \ - long int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - long int, LONG_MIN, LONG_MAX), \ - unsigned long int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - unsigned long int, 0, ULONG_MAX), \ - long long int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ - long long int, LLONG_MIN, LLONG_MAX), \ - unsigned long long int: \ - _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ - unsigned long long int, 0, ULLONG_MAX))) -#else -/* Store the low-order bits of A B into *R, where OP specifies - the operation and OVERFLOW the overflow predicate. If *R is - signed, its type is ST with bounds SMIN..SMAX; otherwise its type - is UT with bounds U..UMAX. ST and UT are narrower than int. - Return 1 if the result overflows. See above for restrictions. */ -# if _GL_HAVE___TYPEOF__ -# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \ - (TYPE_SIGNED (__typeof__ (*(r))) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \ - : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax)) -# else -# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \ - (overflow (a, b, smin, smax) \ - ? (overflow (a, b, 0, umax) \ - ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \ - : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \ - : (overflow (a, b, 0, umax) \ - ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \ - : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0))) -# endif - -# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \ - (sizeof *(r) == sizeof (signed char) \ - ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \ - signed char, SCHAR_MIN, SCHAR_MAX, \ - unsigned char, UCHAR_MAX) \ - : sizeof *(r) == sizeof (short int) \ - ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \ - short int, SHRT_MIN, SHRT_MAX, \ - unsigned short int, USHRT_MAX) \ - : sizeof *(r) == sizeof (int) \ - ? (EXPR_SIGNED (*(r)) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - int, INT_MIN, INT_MAX) \ - : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ - unsigned int, 0, UINT_MAX)) \ - : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) -# ifdef LLONG_MAX -# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ - (sizeof *(r) == sizeof (long int) \ - ? (EXPR_SIGNED (*(r)) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - long int, LONG_MIN, LONG_MAX) \ - : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - unsigned long int, 0, ULONG_MAX)) \ - : (EXPR_SIGNED (*(r)) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ - long long int, LLONG_MIN, LLONG_MAX) \ - : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \ - unsigned long long int, 0, ULLONG_MAX))) -# else -# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \ - (EXPR_SIGNED (*(r)) \ - ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - long int, LONG_MIN, LONG_MAX) \ - : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ - unsigned long int, 0, ULONG_MAX)) -# endif -#endif - -/* Store the low-order bits of A B into *R, where the operation - is given by OP. Use the unsigned type UT for calculation to avoid - overflow problems. *R's type is T, with extrema TMIN and TMAX. - T must be a signed integer type. Return 1 if the result overflows. */ -#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \ - (overflow (a, b, tmin, tmax) \ - ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \ - : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0)) - -/* Return the low-order bits of A B, where the operation is given - by OP. Use the unsigned type UT for calculation to avoid undefined - behavior on signed integer overflow, and convert the result to type T. - UT is at least as wide as T and is no narrower than unsigned int, - T is two's complement, and there is no padding or trap representations. - Assume that converting UT to T yields the low-order bits, as is - done in all known two's-complement C compilers. E.g., see: - https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html - - According to the C standard, converting UT to T yields an - implementation-defined result or signal for values outside T's - range. However, code that works around this theoretical problem - runs afoul of a compiler bug in Oracle Studio 12.3 x86. See: - https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html - As the compiler bug is real, don't try to work around the - theoretical problem. */ - -#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \ - ((t) ((ut) (a) op (ut) (b))) - -/* Return true if the numeric values A + B, A - B, A * B fall outside - the range TMIN..TMAX. Arguments should be integer expressions - without side effects. TMIN should be signed and nonpositive. - TMAX should be positive, and should be signed unless TMIN is zero. */ -#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \ - ((b) < 0 \ - ? (((tmin) \ - ? ((EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \ - && (a) < (tmin) - (b)) \ - : (a) <= -1 - (b)) \ - || ((EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \ - : (a) < 0 \ - ? (((tmin) \ - ? ((EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \ - && (b) < (tmin) - (a)) \ - : (b) <= -1 - (a)) \ - || ((EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \ - && (tmax) < (a) + (b))) \ - : (tmax) < (b) || (tmax) - (b) < (a)) -#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \ - (((a) < 0) == ((b) < 0) \ - ? ((a) < (b) \ - ? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \ - : (tmax) < (a) - (b)) \ - : (a) < 0 \ - ? ((!EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \ - || (a) - (tmin) < (b)) \ - : ((! (EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \ - && EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \ - && (tmax) <= -1 - (b)) \ - || (tmax) + (b) < (a))) -#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \ - ((b) < 0 \ - ? ((a) < 0 \ - ? (EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \ - ? (a) < (tmax) / (b) \ - : ((INT_NEGATE_OVERFLOW (b) \ - ? _GL_INT_CONVERT (b, tmax) >> (TYPE_WIDTH (+ (b)) - 1) \ - : (tmax) / -(b)) \ - <= -1 - (a))) \ - : INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \ - ? (EXPR_SIGNED (a) \ - ? 0 < (a) + (tmin) \ - : 0 < (a) && -1 - (tmin) < (a) - 1) \ - : (tmin) / (b) < (a)) \ - : (b) == 0 \ - ? 0 \ - : ((a) < 0 \ - ? (INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \ - ? (EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \ - : (tmin) / (a) < (b)) \ - : (tmax) / (b) < (a))) +#define INT_ADD_WRAPV(a, b, r) _GL_INT_ADD_WRAPV (a, b, r) +#define INT_SUBTRACT_WRAPV(a, b, r) _GL_INT_SUBTRACT_WRAPV (a, b, r) +#define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r) /* The following macros compute A + B, A - B, and A * B, respectively. If no overflow occurs, they set *R to the result and return 1; @@ -621,6 +323,8 @@ A, B, and *R should be integers; they need not be the same type, and they need not be all signed or all unsigned. + However, none of the integer types should be bit-precise, + and *R's type should not be char, bool, or an enumeration type. These macros work correctly on all known practical hosts, and do not rely on undefined behavior due to signed arithmetic overflow. @@ -632,8 +336,8 @@ These macros are tuned for B being a constant. */ -#define INT_ADD_OK(a, b, r) ! INT_ADD_WRAPV (a, b, r) -#define INT_SUBTRACT_OK(a, b, r) ! INT_SUBTRACT_WRAPV (a, b, r) -#define INT_MULTIPLY_OK(a, b, r) ! INT_MULTIPLY_WRAPV (a, b, r) +#define INT_ADD_OK(a, b, r) (! INT_ADD_WRAPV (a, b, r)) +#define INT_SUBTRACT_OK(a, b, r) (! INT_SUBTRACT_WRAPV (a, b, r)) +#define INT_MULTIPLY_OK(a, b, r) (! INT_MULTIPLY_WRAPV (a, b, r)) #endif /* _GL_INTPROPS_H */ From patchwork Tue Oct 28 17:08:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122873 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 197163858C2F for ; Tue, 28 Oct 2025 17:19:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 197163858C2F 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=DBGTVWF6 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id 61DDD3858D1E for ; Tue, 28 Oct 2025 17:11:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61DDD3858D1E 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 61DDD3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671518; cv=none; b=RCmyrm6O0DDrEAm0NVC3m983GiT9vhUxFBvgKUeuUWJIqBB4HuytOh/CmzzXewshqmRfWj3JY8dh/8uc1tgfQDXP1C+bDhPpnDkV/fTR1e+7hcQq0bsxnGVoIKz45KuWcfzMsOsgIskBq2CdHZTAcai/GoPjZ6UwJptncdPk+QQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671518; c=relaxed/simple; bh=51M573HLI9o2SPUCw0kdkGMz3A8rQk96fxxF/wmnKIQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tx++XzBpgM/tZsHYte1hO51Z0gigdH8DqJmXWYCBCkaNkXsdGt7VrOiBD9IbPCgH6pPQDNEt3jgJ2slgHeCpfKMOWERoTOPNzIY8J40Sr069UyDNcpnjucYj1ONlnZ8a8b1wWflsTn5Ichfdo21/yKYoFjBclp6r4KxY2Ak20DQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61DDD3858D1E Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-34003f73a05so118321a91.1 for ; Tue, 28 Oct 2025 10:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671517; x=1762276317; 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=ShwQSuZ0G54p7xd95jPF35KA9I7Vhr2Pg7dI6zdwnDw=; b=DBGTVWF65fmd80l/b3roA0caicRDD/0VD19cgoZis8C+m/ONNEgzCF3/Kz1Ajo7Pqy C5ZqSvjLmBvp0xzNYVzciOYiagmEipv99SM4hzxHM+6s5UrkWlmVblTcnBWh1zTuXbz1 1c3Drqc9lEg4QnkC14+zVeTbE9fjuvUmKoM+CjtH68YdfBuTF2xfMSijd+y2baPTSsZm rEGOw7EkrAPkhs3eC0JS8pI9dRqtAgne/dLQLZAthhAbnzKusF2iW1uNFOHpw6h+Br36 NA2A/h0PKYR8nhILLOwnMHN0oBmArUz3cEtef+dpfNMtyYecvfJ6h6uzJoP9O7BUyjtu WPzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671517; x=1762276317; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ShwQSuZ0G54p7xd95jPF35KA9I7Vhr2Pg7dI6zdwnDw=; b=kfY0S0xa1P6Ima/ff/BlDHfXP6DfkN/mWJ4OtQ+vAIRO7WPEd10XFzb9brAWNvm0qB YoosV0w1szrCDMTihZC6fB0qpM849+x7vXBmDQljR7YqWKWew/KRZ0tbDI7c8Vpxyp16 B/TGo2K6OZjr6bStt27ftE6MTBJPRR83t6NGcoqjYRDNVnrsDgPLFCQT9gVZhZRDEqxK Otzzgn/l91Qpk2N7QKfxHoPJfQIVqaVdGsSo0OQTZEofUcU4rXtciCTe6qrwcLhoodpY RiBfCQcxC6DByAv67cxdGwW0TnxQY9755kTAp85kOGJ7W1J38IFH5y6DDWAeJfDHk9E7 s4lg== X-Gm-Message-State: AOJu0YwhixKZCOGWauIKo4zuzvmvQJmLmMtJ8v5to4B8JaWsGv710PI7 IXH8ZOzr7QTNkY1QD19GOxP8Or1ruHFJOl0/p1oqOW9BmzC06Z/CsBFJS8hU9w3NmYFaWFJPZNG Iyzpr0YY= X-Gm-Gg: ASbGncsU0WKOZEbNJWgtNcFwAgAkdxiX9iOu0qpyyCYR06yS7IC8fFJQ/yn3s9ck+os DPeiem3FI9p/Ert0pBpUbzBpHsmFgO2KvwZU89phlz/mVAHmKHiF7VRR6ytOXhT59/vZHswMMuV AtljGzFwcYJ9uJmewBkcvzn92yp/KVSW9IrI0XcNBAS+1nsD7oqmP/W10lgoZLEpjhjqVkVNzxg dhotPBn0tIN0xCYCPexiEk+wZcDBtkOWRW92blQb8zM/7MNIXiNKqCGvvE8lv5yiSAsnDNaimUL +zB79zZczUEloQ/Ca/9hrRpTyH/rcf6SMQIxlqB2wm5NBQChrsCGNluqU+c8IL1oCpU5tKxRtrS tlVpX3FpbVeXYMJu6ceY4mQd+HvvitI/XquuOFwHLXDgQEYcaQxvB+irYebZjFoJDRlmfWbz2rr Nl2090nectsvoOJZ9AMtGE1HiOQYTSjsDKkBmTll//TNODgQ== X-Google-Smtp-Source: AGHT+IF6AGDRcy00Fc4EUxNuqz14ONck3l3ujrdT9hq6oUwDab7YerypNgr5R/dRSMxk59Glb4GQ5Q== X-Received: by 2002:a17:90b:1d46:b0:32e:2fa7:fe6b with SMTP id 98e67ed59e1d1-340287372efmr5013068a91.14.1761671517033; Tue, 28 Oct 2025 10:11:57 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:11:56 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 02/28] malloc: Remove unused tcache_set_inactive Date: Tue, 28 Oct 2025 14:08:11 -0300 Message-ID: <20251028171141.3208834-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 warns that this function is not used. --- malloc/malloc.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 1cdeb08437..0b21bdf1bd 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3141,13 +3141,6 @@ tcache_enabled (void) return (! tcache_inactive () && ! tcache_disabled ()); } -/* Sets the tcache to INACTIVE state. */ -static __always_inline void -tcache_set_inactive (void) -{ - tcache = (tcache_perthread_struct *) &__tcache_dummy.inactive; -} - /* Sets the tcache to DISABLED state. */ static __always_inline void tcache_set_disabled (void) From patchwork Tue Oct 28 17:08:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122868 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 21FC7385841B for ; Tue, 28 Oct 2025 17:15:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21FC7385841B 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=A1ap/e7O X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 52D5F3858C2F for ; Tue, 28 Oct 2025 17:12:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52D5F3858C2F 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 52D5F3858C2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671521; cv=none; b=X8ZOnTDPEjY88JQtHjeoN87Z+xRGEyfjBXcGsCF411GJKB+pxie3VEHcS5k3DTlciM04Kp/uNo53X344mO+WPnG47roxw9U7vqpWlyYNAIMuf5PumV4anedfiJBl8jILiHyhkI9k+Fqu6ZvLgGqL1wGZwmgzl+Lmc0Ptvj8hioU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671521; c=relaxed/simple; bh=fsKkbk746ivxCENUFvHLs2YA65sCmihNm23v+sN7cb0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=p2IQ498RJtgWqz6U/1/D2gea8hIPnJ3SgZq1aFyfzvHVUsJHV8eBjnn+dp5R5R6qkm/xbEjch4jOaFeXlkUf8TwIIozElR6kqMGct0+SqQVdnKNVmffzEIjOH/GDDuCIySaal+2aaQvuETtYliBPxuMUhtatAzi7x7FeEs+9SpE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52D5F3858C2F Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-33d463e79ddso7774318a91.0 for ; Tue, 28 Oct 2025 10:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671520; x=1762276320; 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=rvr3j0G9iXeHd5ISYQYSQZDz2hLA6JKTrlAtz8WvW6o=; b=A1ap/e7OYaxq7KUBwBymjxUYroxYE3CGkJXMzuSkIssFhzv/eo5sbyRUj0tibpWyLO irbSMm/ueY8znT8kcEJN4S6zmALQTqlhGmFR7FDqaz2mMZTVSH3E7iqWH00uzHOg5EvT GGMITSP+CxtQkvr3hsFRJRWRJ5+9HTdBGtGprr6HEgNqQnqd8bN74NPjC7n2RuJrtuCU xzDBgBjByaIk/aFhMvcJF8YCxG5IuYeDbdXSAxW/nNHtdin9xsjkUCF3p/MEZw2eeUPJ 01O/tuR283WlPF1E6IVU0BcV9Kga1wHp/hPsVV4xBle+eq5Utwf4CLFpjxYOHacyRzOB mfCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671520; x=1762276320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rvr3j0G9iXeHd5ISYQYSQZDz2hLA6JKTrlAtz8WvW6o=; b=pWdIST3sgd4g0QOxGFkObudA9QLcYNxkWBTeoXZ1pscxHir6iuV+4hbmQlIK2IHA8W wcj/r+mqOy1X0Z07Z67ubd78aHuKZgNiP+GJM+fkETQ5XmxjHpXVAGZwiYltwvA1Y5mO uQo8zv74QDc4O3/qwpPAkDBtth2ke6O/f6wigCABL3x7aHflL2epD6J7tXuDSbJftpL8 vjdHba32cqdRvLgh/q2+yOqOl28/QgIAFVUb32fKUe1QePhCZXqrn34KLOvfgOM3ngws bMwQUZw3iJZi52Nt5fmYXxHZoeGYj4KVlPfC95qnj8OU9Utw+hPcdQ94T4FhqwtP3Ckb e8GA== X-Gm-Message-State: AOJu0YyzvIV50HvlGucOyEUdgf4job3sh5OmgfSnn7pk5Hmg0ePI5t73 AVGugPijOn6smuvAavgzZaMx1bbHzxoqxsEWkfAFWwIlfXEQi+OHqJiQtO4jYTfI5uF8Thl0Z45 OqjDPr9Q= X-Gm-Gg: ASbGncuPNznfF3Cb6Rd2TxWZEkOM0F+OKEy90PTcPNopE86hNETG646XdazLZ6/p4i8 HUlmTzJYYQxGhB8o0W8hbEBnVI4wiQHxs7kvoxgwrQUiS6NsqAUsvTfeLo9Ikuubn9kLfoqEuLK DAwxxWfcu0+eaE+vRQcipEAGX8U0icI3aSptKx0mSxPeb3D9Ii88NgXeVguwHjwv6ExBUtRdaL+ 0KPyxA6MNrqGUrFkxkYPxVzTd8qIm06lSxQzTv1YvU9aT1MmydXg3PtstVbD3lbNhce2NDF48iC r2IPqUfl+iIIryI8g0f5lqJF9+mVHJGvNj1Nm/aZOWbOBQJBa/SsqxGXeVoq60KY1Nz0BJbiRWh qWT6pxgjxWvPNYOOw8tpYH+zzxbHcJSLguwSXH9HVqOfGfiDGevicX5NYPGzkJLbZFi7rGid9IQ NWDPMMVGYVv3p49dkfZyieJAEI8R9C1BOl2Rihjzjigm37hFkjB6flwhTW X-Google-Smtp-Source: AGHT+IEhBAcdH/M8NF5DGNdlCDvUysrEm8l5CRzpruG8/e6JxqrNyImpa6fDRWdfjBTuobqkE9/eTA== X-Received: by 2002:a17:90b:3905:b0:338:3221:9dc0 with SMTP id 98e67ed59e1d1-34027c0782dmr5298089a91.37.1761671519821; Tue, 28 Oct 2025 10:11:59 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:11:59 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 03/28] Replace count_leading_zeros with stdc_leading_zeros Date: Tue, 28 Oct 2025 14:08:12 -0300 Message-ID: <20251028171141.3208834-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, 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 Checked on x86_64-linux-gnu and aarch64-linux-gnu. --- stdlib/divmod_1.c | 9 +++------ stdlib/mod_1.c | 9 +++------ stdlib/strtod_l.c | 12 +++++------- sysdeps/ieee754/dbl-64/dbl2mpn.c | 5 +++-- sysdeps/ieee754/ldbl-128/ldbl2mpn.c | 7 ++++--- sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c | 7 ++++--- sysdeps/ieee754/ldbl-96/ldbl2mpn.c | 5 +++-- sysdeps/wordsize-32/divdi3.c | 7 ++++--- sysdeps/x86/ldbl2mpn.c | 5 +++-- 9 files changed, 32 insertions(+), 34 deletions(-) diff --git a/stdlib/divmod_1.c b/stdlib/divmod_1.c index f5030420fc..b91ab9e593 100644 --- a/stdlib/divmod_1.c +++ b/stdlib/divmod_1.c @@ -25,6 +25,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see . */ #include +#include #include "gmp-impl.h" #include "longlong.h" @@ -62,9 +63,7 @@ mpn_divmod_1 (mp_ptr quot_ptr, if (UDIV_TIME > (2 * UMUL_TIME + 6) && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME) { - int normalization_steps; - - count_leading_zeros (normalization_steps, divisor_limb); + int normalization_steps = stdc_leading_zeros (divisor_limb); if (normalization_steps != 0) { mp_limb_t divisor_limb_inverted; @@ -144,9 +143,7 @@ mpn_divmod_1 (mp_ptr quot_ptr, { if (UDIV_NEEDS_NORMALIZATION) { - int normalization_steps; - - count_leading_zeros (normalization_steps, divisor_limb); + int normalization_steps = stdc_leading_zeros (divisor_limb); if (normalization_steps != 0) { divisor_limb <<= normalization_steps; diff --git a/stdlib/mod_1.c b/stdlib/mod_1.c index a4d81d4db0..74c1f6a521 100644 --- a/stdlib/mod_1.c +++ b/stdlib/mod_1.c @@ -22,6 +22,7 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see . */ #include +#include #include "gmp-impl.h" #include "longlong.h" @@ -58,9 +59,7 @@ mpn_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size, if (UDIV_TIME > (2 * UMUL_TIME + 6) && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME) { - int normalization_steps; - - count_leading_zeros (normalization_steps, divisor_limb); + int normalization_steps = stdc_leading_zeros (divisor_limb); if (normalization_steps != 0) { mp_limb_t divisor_limb_inverted; @@ -137,9 +136,7 @@ mpn_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size, { if (UDIV_NEEDS_NORMALIZATION) { - int normalization_steps; - - count_leading_zeros (normalization_steps, divisor_limb); + int normalization_steps = stdc_leading_zeros (divisor_limb); if (normalization_steps != 0) { divisor_limb <<= normalization_steps; diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c index f9572b9ebf..5814475e40 100644 --- a/stdlib/strtod_l.c +++ b/stdlib/strtod_l.c @@ -72,6 +72,7 @@ extern double ____strtod_l_internal (const char *, char **, int, locale_t); #include #include #include +#include /* The gmp headers need some configuration frobs. */ #define HAVE_ALLOCA 1 @@ -1247,7 +1248,7 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group, } /* Determine how many bits of the result we already have. */ - count_leading_zeros (bits, num[numsize - 1]); + bits = stdc_leading_zeros (num[numsize - 1]); bits = numsize * BITS_PER_MP_LIMB - bits; /* Now we know the exponent of the number in base two. @@ -1465,7 +1466,8 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group, |--- n ---| */ - count_leading_zeros (cnt, den[densize - 1]); + cnt = stdc_leading_zeros (den[densize - 1]); + if (cnt > 0) { @@ -1504,11 +1506,7 @@ ____STRTOF_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group, #define got_limb \ if (bits == 0) \ { \ - int cnt; \ - if (quot == 0) \ - cnt = BITS_PER_MP_LIMB; \ - else \ - count_leading_zeros (cnt, quot); \ + int cnt = stdc_leading_zeros (quot); \ exponent -= cnt; \ if (BITS_PER_MP_LIMB - cnt > MANT_DIG) \ { \ diff --git a/sysdeps/ieee754/dbl-64/dbl2mpn.c b/sysdeps/ieee754/dbl-64/dbl2mpn.c index af369cd38a..d69973419b 100644 --- a/sysdeps/ieee754/dbl-64/dbl2mpn.c +++ b/sysdeps/ieee754/dbl-64/dbl2mpn.c @@ -21,6 +21,7 @@ #include #include #include +#include /* Convert a `double' in IEEE754 standard double-precision format to a multi-precision integer representing the significand scaled up by its @@ -68,7 +69,7 @@ __mpn_extract_double (mp_ptr res_ptr, mp_size_t size, if (res_ptr[N - 1] != 0) { - count_leading_zeros (cnt, res_ptr[N - 1]); + cnt = stdc_leading_zeros (res_ptr[N - 1]); cnt -= NUM_LEADING_ZEROS; #if N == 2 res_ptr[N - 1] = res_ptr[1] << cnt @@ -82,7 +83,7 @@ __mpn_extract_double (mp_ptr res_ptr, mp_size_t size, } else { - count_leading_zeros (cnt, res_ptr[0]); + cnt = stdc_leading_zeros (res_ptr[0]); if (cnt >= NUM_LEADING_ZEROS) { res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS); diff --git a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c index 1179b1cd23..d3f3476d56 100644 --- a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c +++ b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Convert a `long double' in IEEE854 quad-precision format to a multi-precision integer representing the significand scaled up by its @@ -76,7 +77,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, #if N == 2 if (res_ptr[N - 1] != 0) { - count_leading_zeros (cnt, res_ptr[N - 1]); + cnt = stdc_leading_zeros (res_ptr[N - 1]); cnt -= NUM_LEADING_ZEROS; res_ptr[N - 1] = res_ptr[N - 1] << cnt | (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt)); @@ -85,7 +86,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, } else { - count_leading_zeros (cnt, res_ptr[0]); + cnt = stdc_leading_zeros (res_ptr[0]); if (cnt >= NUM_LEADING_ZEROS) { res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS); @@ -106,7 +107,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, if (res_ptr[j] != 0) break; - count_leading_zeros (cnt, res_ptr[j]); + cnt = stdc_leading_zeros (res_ptr[j]); cnt -= NUM_LEADING_ZEROS; l = N - 1 - j; if (cnt < 0) diff --git a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c index 795d7b4598..d91699c3d0 100644 --- a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c +++ b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c @@ -22,6 +22,7 @@ #include #include #include +#include /* Convert a `long double' in IBM extended format to a multi-precision integer representing the significand scaled up by its number of @@ -133,7 +134,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, #if N == 2 if (res_ptr[N - 1] != 0) { - count_leading_zeros (cnt, res_ptr[N - 1]); + cnt = stdc_leading_zeros (res_ptr[N - 1]); cnt -= NUM_LEADING_ZEROS; res_ptr[N - 1] = res_ptr[N - 1] << cnt | (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt)); @@ -142,7 +143,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, } else { - count_leading_zeros (cnt, res_ptr[0]); + cnt = stdc_leading_zeros (res_ptr[0]); if (cnt >= NUM_LEADING_ZEROS) { res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS); @@ -163,7 +164,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, if (res_ptr[j] != 0) break; - count_leading_zeros (cnt, res_ptr[j]); + cnt = stdc_leading_zeros (res_ptr[j]); cnt -= NUM_LEADING_ZEROS; l = N - 1 - j; if (cnt < 0) diff --git a/sysdeps/ieee754/ldbl-96/ldbl2mpn.c b/sysdeps/ieee754/ldbl-96/ldbl2mpn.c index 07af9791f9..982f427380 100644 --- a/sysdeps/ieee754/ldbl-96/ldbl2mpn.c +++ b/sysdeps/ieee754/ldbl-96/ldbl2mpn.c @@ -22,6 +22,7 @@ #include #include #include +#include /* Convert a `long double' in IEEE854 standard double-precision format to a multi-precision integer representing the significand scaled up by its @@ -67,7 +68,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, if (res_ptr[N - 1] != 0) { - count_leading_zeros (cnt, res_ptr[N - 1]); + cnt = stdc_leading_zeros (res_ptr[N - 1]); if (cnt != 0) { #if N == 2 @@ -82,7 +83,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, } else { - count_leading_zeros (cnt, res_ptr[0]); + cnt = stdc_leading_zeros (res_ptr[0]); res_ptr[N - 1] = res_ptr[0] << cnt; res_ptr[0] = 0; *expt = LDBL_MIN_EXP - 1 - BITS_PER_MP_LIMB - cnt; diff --git a/sysdeps/wordsize-32/divdi3.c b/sysdeps/wordsize-32/divdi3.c index 015494a14f..387022ab14 100644 --- a/sysdeps/wordsize-32/divdi3.c +++ b/sysdeps/wordsize-32/divdi3.c @@ -19,6 +19,7 @@ #include #include #include +#include #if __WORDSIZE != 32 #error This is for 32-bit targets only @@ -113,7 +114,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) { /* 0q = nn / 0D */ - count_leading_zeros (bm, d0); + bm = stdc_leading_zeros (d0); if (bm != 0) { @@ -137,7 +138,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) if (d0 == 0) d0 = 1 / d0; /* Divide intentionally by zero. */ - count_leading_zeros (bm, d0); + bm = stdc_leading_zeros (d0); if (bm == 0) { @@ -202,7 +203,7 @@ __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) { /* 0q = NN / dd */ - count_leading_zeros (bm, d1); + bm = stdc_leading_zeros (d1); if (bm == 0) { /* From (n1 >= d1) /\ (the most significant bit of d1 is set), diff --git a/sysdeps/x86/ldbl2mpn.c b/sysdeps/x86/ldbl2mpn.c index d1dabab938..c41fb8da14 100644 --- a/sysdeps/x86/ldbl2mpn.c +++ b/sysdeps/x86/ldbl2mpn.c @@ -21,6 +21,7 @@ #include #include #include +#include /* Convert a `long double' in IEEE854 standard double-precision format to a multi-precision integer representing the significand scaled up by its @@ -73,7 +74,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, if (res_ptr[N - 1] != 0) { - count_leading_zeros (cnt, res_ptr[N - 1]); + cnt = stdc_leading_zeros (res_ptr[N - 1]); if (cnt != 0) { #if N == 2 @@ -88,7 +89,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, } else if (res_ptr[0] != 0) { - count_leading_zeros (cnt, res_ptr[0]); + cnt = stdc_leading_zeros (res_ptr[0]); res_ptr[N - 1] = res_ptr[0] << cnt; res_ptr[0] = 0; *expt = LDBL_MIN_EXP - 1 - BITS_PER_MP_LIMB - cnt; From patchwork Tue Oct 28 17:08:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122872 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 4DF133858416 for ; Tue, 28 Oct 2025 17:19:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DF133858416 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=SFNxcJjn 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 9D2033858C40 for ; Tue, 28 Oct 2025 17:12:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D2033858C40 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 9D2033858C40 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=1761671524; cv=none; b=uJ9DQU1wzwyFwQ3B5GhQXwxckhg2D0r6X3Nx7Z4zUcG/QdC0SiAOwgflfALojAPh3kFt6YtyL+c570+vxX1mZfyfWq7cq50N4O7PcRl74DIQr5wiPbyjktt6xbDCd/aaRQd4QTwwjQewbSgGu8MUb0H37NjYPrJiXsjy1bYQVw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671524; c=relaxed/simple; bh=98qFPl4OxMY2N7/ercm2oZQZ5XIaLkmiWoNxr5WH6Gs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Zq/NjpoWsqgm7UlV3bCHLIMZ57tefUiKwDfQB0iOk/MT+sTcuLELOGK9FGTPwJ4nHEcQxcPIM6thoNK3oDJafq2YiQsXG05FWymaAgYPNXkMxAYCevC2I3Li6yf/9Oh7Ap4XEvexNaDtHtKLu2s3Sx7FuUk5bCDKkr3JeqxVN4o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D2033858C40 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-33b5a3e8ae2so101451a91.1 for ; Tue, 28 Oct 2025 10:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671523; x=1762276323; 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=LiWhVrs3LbuV6DXgloQ8SskOxTHh9Af6B/gxf+k6+h4=; b=SFNxcJjnaaGEBDjvx2X2IcJa+cLrrXyx4tJrI4Kmg3oAWPMy8GKO/RqTQDLfH1b+rU DmqSzNMTKniM8xjjclDV3S55H941bzPE6t1XzzQUFTwiWF+78r0Jsy7Idj5PM6Et4YyK 4q2X45Yu5PRB5JJPAlyd6EG4/TQqd2Qfx7vpdJ+bLRMKpgPTz+dTBROehiHcX26kGT4i PGpRr3fOqvu4oQWP7qohn9JbH5Ft8EBFkMelnH+IxoV+nFhp2gX0P16wZ++1oYZzIDQL 6beDDN3UG3NQjJej2NQLOiEzGEvPd03eqv7sazGHXxACo5mHdhFv6vyEOmL1WjVdLVMu LLlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671523; x=1762276323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LiWhVrs3LbuV6DXgloQ8SskOxTHh9Af6B/gxf+k6+h4=; b=hmrs4Pw/7IbF7tUa5pUbqCIY4zRnB1IU7mnwB9w1EgrJzFijrvTWxy4p6paFsEhkF2 833cBaeGXDo2MKl8Zym0b+bJFMTYhaxwJzx4I2jG1s3tWYlEm+R8fYm++vQS6E+Hm/3g N0n+ATKkWmDOMRBVf142YtvJXPjYQYVO/hzJJ4QL4y7ZwxiWoBnniGlaWkVP02DOPU1W iXnYaeWVqa3RSe2w7sKDUY4tjSVzOthPQSB0FjjMiHQV6uSBavZouCaAnZxu2Bkg+k1A t+HrMfFK4iIxV1ZwFOouRz+DTtiOvvLpRwW+y3itx0x4ndbhWab+JbwqdpPUepBJb8Hk fh/Q== X-Gm-Message-State: AOJu0Yww7zHJzyxHA8bqjzhovGZL/BgWH92/lSWXCdHCWtzhBaG7jBJC i19aQsXjaSkdw51cDKGdZbzSYdi7bdMX0UPPTSFo8C/OD7JvK85dRQcqSfNCaveSG/vFXzIPZgb yuuAaRxc= X-Gm-Gg: ASbGnctUsYqqHkf7sfr6BApUEQ9UdMmQI1eHuxcZn5L0/vpuwtzYWQIBggOA8nNOcuw z5NfyLdaE5AkQGdFZ7k4P9IT/fEdkKPsERyWRmHi9cpARz7OGlUJyrOD1OJxT8mo4sdzgAEHWqY J5s7dFr0L3sNs7eUQrlGnEMMZQ67YL9xP+0fLr2ouH4y8OtcnCulNiag571WrWxoNegLNMS//EE uKaFu+69YWbZZ+y1xoFrj0CpEI8ZBRRSd++UbCbjhQnMTt8BWYEoafDK7dkwunrldfZ6Vq2S9lb P9sP5/Nskm74oGNXZE1o51bqqQ6YVAIeppD1YvoLyCFDbXZt+wC0oX3+H0yc0BiMxJ2WlWZENe4 eRBCvLG8UeG/BKBwKGGpdBjn7uACIaZY2Fg56cC56bc4LwTZ2JfIPOFGVxQWQD+IdeYbb7yzhwE jg5I2tC8aGKVIyxtUpZbgxqWH2eaJ2uRXVQ7yDdQTPCXNEQA== X-Google-Smtp-Source: AGHT+IHwXkH/MG+XlO+zKG2fC4ORkLLcCQ3CtCOFawakVB+kCq75LdXeSxg0/2OQ9fJQiBgl4thpEQ== X-Received: by 2002:a17:90b:5744:b0:33b:d371:c361 with SMTP id 98e67ed59e1d1-3402869c235mr4730135a91.2.1761671523297; Tue, 28 Oct 2025 10:12:03 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:01 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 04/28] stdlib: Remove mp_clz_tab.c Date: Tue, 28 Oct 2025 14:08:13 -0300 Message-ID: <20251028171141.3208834-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The count_leading_zeros is not used anymore, so there is no need to provide the table for possible usage. The hppa already provides the compat symbol on libgcc-compat.c. --- stdlib/Makefile | 1 - stdlib/mp_clz_tab.c | 36 ------------------------------------ sysdeps/hppa/mp_clz_tab.c | 1 - sysdeps/i386/mp_clz_tab.c | 1 - sysdeps/powerpc/mp_clz_tab.c | 1 - sysdeps/x86_64/mp_clz_tab.c | 1 - 6 files changed, 41 deletions(-) delete mode 100644 stdlib/mp_clz_tab.c delete mode 100644 sysdeps/hppa/mp_clz_tab.c delete mode 100644 sysdeps/i386/mp_clz_tab.c delete mode 100644 sysdeps/powerpc/mp_clz_tab.c delete mode 100644 sysdeps/x86_64/mp_clz_tab.c diff --git a/stdlib/Makefile b/stdlib/Makefile index 8d9a98602c..f2b34852ec 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -506,7 +506,6 @@ routines := \ # routines aux += \ fpioconst \ - mp_clz_tab \ # aux tests-extras += \ diff --git a/stdlib/mp_clz_tab.c b/stdlib/mp_clz_tab.c deleted file mode 100644 index 9084298803..0000000000 --- a/stdlib/mp_clz_tab.c +++ /dev/null @@ -1,36 +0,0 @@ -/* __clz_tab -- support for longlong.h - Copyright (C) 1991-2025 Free Software Foundation, Inc. - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in the GNU MP Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#if 0 -#include -#include "gmp-impl.h" -#endif - -const -unsigned char __clz_tab[] = -{ - 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, -}; diff --git a/sysdeps/hppa/mp_clz_tab.c b/sysdeps/hppa/mp_clz_tab.c deleted file mode 100644 index 52d06383c1..0000000000 --- a/sysdeps/hppa/mp_clz_tab.c +++ /dev/null @@ -1 +0,0 @@ -/* __clz_tab not needed on hppa. */ diff --git a/sysdeps/i386/mp_clz_tab.c b/sysdeps/i386/mp_clz_tab.c deleted file mode 100644 index 860f98cc62..0000000000 --- a/sysdeps/i386/mp_clz_tab.c +++ /dev/null @@ -1 +0,0 @@ -/* __clz_tab not needed on i386. */ diff --git a/sysdeps/powerpc/mp_clz_tab.c b/sysdeps/powerpc/mp_clz_tab.c deleted file mode 100644 index 4b5f29bfe5..0000000000 --- a/sysdeps/powerpc/mp_clz_tab.c +++ /dev/null @@ -1 +0,0 @@ -/* __clz_tab not needed on powerpc. */ diff --git a/sysdeps/x86_64/mp_clz_tab.c b/sysdeps/x86_64/mp_clz_tab.c deleted file mode 100644 index 7b13a394da..0000000000 --- a/sysdeps/x86_64/mp_clz_tab.c +++ /dev/null @@ -1 +0,0 @@ -/* __clz_tab not needed on x86-64. */ From patchwork Tue Oct 28 17:08:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122878 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 569C23858C60 for ; Tue, 28 Oct 2025 17:23:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 569C23858C60 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=cLJ6vtBg X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 001AC3858CD1 for ; Tue, 28 Oct 2025 17:12:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 001AC3858CD1 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 001AC3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1030 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671529; cv=none; b=ISmdr7Shv+doEwVO4yxv+8SbSKfGSjnPc7ObuzpRrWZBCvXRz9eSwNZdOyTFP/VckOeHVt3Y3bPLRjm6nFfWRY7GLTgvfwzjnvMvXkzSUlUf9ps3jZ7jUbs7McsX7h1Mpmx8WU0Y5qDGaeegQs3aIZ5qGsnXRzwWcSwbQyBJq8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671529; c=relaxed/simple; bh=TbIIKrY9lvmjb1V/eTFxIJTTn3JdgD4FcfS9hzixsx0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jxbKQllvK5iZXBp/sNPhoE7sSWxXhJOuZN9p2PuCGTfE/oZyyj1XvfM0QgZShdVz4+qrdvzppepLJ/NfTc1CHnE52QDjruhZ2h/Orza9Xpa/KAxVugT4/BozXVe278yE1pfdXaRWoP4z/mU0lffb09aE2rw7maOouvvcCMVBSfs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 001AC3858CD1 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-33067909400so4682522a91.2 for ; Tue, 28 Oct 2025 10:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671527; x=1762276327; 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=hItehQhCaOF47r1NLKZW6pc9yIrrf1uMcpRLCxXEv2Q=; b=cLJ6vtBgpVfsw/VRNwvgHqsoUreLcUu076bDaSy/YTv3cEsfuk8mLp33lFTLy1aHF8 WmmrpGkurc1dksn6U3N+tovBtH7Q7Qah7M6pDXa+VzdrA2yPA58+o3OW9JHEFGlcwnyJ C5ATBsQo71b1g0EYwCt3p+MgQfQb3mIocbDPHnYPoM4Hjwf6HxoiLhk7EM2DwjbGRlPl wh/BLPX7WBWH3sd54ZS5IbNgzB82KQLfj+sOB3KafVelH6Yo1wUNanULchrMX2M+RXCb DSqmqgrA//A9hyDkrfJoNw47kW1wIBtccMh/6pw14sFz+uLF6lam+dQ4oJbcc1TzG8ek b42w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671527; x=1762276327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hItehQhCaOF47r1NLKZW6pc9yIrrf1uMcpRLCxXEv2Q=; b=oHFuTchlX6Ipx7yVGZT1MtR91aL+Im+3hTUZf9bC61YaYZbt9FSFJFHISf2TZKSj6t G1/iFoNDHueHakmPFYp5PbjG5ugC0Vt09Ja76zh/lBrjNdqrsKudWnGKYY4gfKiEj70g 3ejzaqktr73GGR8k0das47wDb1HL58pURMef/AQoztkriTL3kombw9eEEeN1j7xSMG2B DjztuhXmEOODt3J3CcSyS3aAXvWtLPjc8TW/F5zRT4Mwt6FEJ7BJP1g9i+uR3tsMVjzk cqZNx5PcrY5/caG47z1PaSh9793mWcyqAjtXbn68enYX9EN4Btd1/ulCXddLNUDVAw4m kOuw== X-Gm-Message-State: AOJu0YwxYrMf9NMMvcd9oSqfy2Wyk6A1Dq4n0hor2sdn/E7oqFMRPXS6 EtNaNoVTQIWhBuBQ54kNS4epQEsCl4dFGxYUsVpDz+3Dy4JQ6uSSD5gOM7XYQHqOdsKrGhLJvv+ fAS6zjjc= X-Gm-Gg: ASbGncu/pao/24l2hjtzJx3Iuf9IQyXlP/mmcWTRihhK59Le6/YeyTnO3tDFBjmEz3i +pBo5JmFAmJYFYQyYQjtRpz1cNulN0IFMSI5YxdR0N9eVTkWkmRaNcWgCsiYO5mcMsytErEesIv ig2hQieuKoO7DoERYA7oe6mFOKq1C0eCQQvdiZr56Ac8FyqmFt/TzcsPHffj9poKQbZiCaaP8OD MJ+lVkWwf1rJ4kfxqM1HcPnxscUOQ6Jd6v4lHUpV0rN9ezzBFPiZ70yXN20ZEDFoN/igtkVy7Rl 136OCh9g0HuQpZJdViW/bLYW211HtkNDJTKaGIdUnpTEcdPUqqyShSpd69V+60pSmgYWOteMrF1 utqdjQMR4l6Q2dbp3AR9/nQR674s48ZyGcr8/sIgWYn2OyxMXpthykvNO1X4ZLjRnKrts8zAgCG al30enMwlsE07I/FFfLgE95AeCSx589IFfdIVh7/CsSaTF/Q== X-Google-Smtp-Source: AGHT+IHOEhzGuM8DMNSrhQBy3IP+kDWOd79IX5fVxoxFsPG/klPXjoT0+cOkHbIoX+/1yrY++pLUhg== X-Received: by 2002:a17:90b:4a92:b0:32e:a54a:be53 with SMTP id 98e67ed59e1d1-34027a06f8dmr5356545a91.16.1761671526924; Tue, 28 Oct 2025 10:12:06 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:05 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 05/28] Add gmp-arch and udiv_qrnnd Date: Tue, 28 Oct 2025 14:08:14 -0300 Message-ID: <20251028171141.3208834-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.6 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_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SCC_10_SHORT_WORD_LINES, SCC_20_SHORT_WORD_LINES, SCC_35_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org To enable “longlong.h” removal, the udiv_qrnnd is moved to a gmp-arch.h file. It allows each architecture to implement its own arch-specific optimizations. The generic implementation now uses a static inline, which provides better type checking than the GNU extension to cast the asm constraint (and it works better with clang). Most of the architecture uses the generic implementation, which is expanded from a macro, except for alpha, x86, m68k, sh, and sparc. I kept that alpha, which uses out-of-the-line implementations and x86, where there is no easy way to use the div{q} instruction from C code. For the rest, the compiler generates good enough code. The hppa also provides arch-specific implementations, but they are not routed in “longlong.h” and thus never used. --- soft-fp/soft-fp.h | 19 +- stdio-common/_itoa.c | 7 +- stdio-common/_itowa.c | 7 +- stdlib/Makefile | 1 - stdlib/addmul_1.c | 1 + stdlib/divmod_1.c | 1 + stdlib/mod_1.c | 1 + stdlib/mul_1.c | 1 + stdlib/strtod_l.c | 1 + stdlib/submul_1.c | 1 + stdlib/udiv_qrnnd.c | 10 - sysdeps/alpha/Makefile | 4 + sysdeps/alpha/gmp-arch.h | 2 + sysdeps/generic/gmp-arch.h | 113 +++++++++++ sysdeps/hppa/hppa1.1/udiv_qrnnd.S | 77 -------- sysdeps/hppa/udiv_qrnnd.S | 285 ---------------------------- sysdeps/ieee754/dbl-64/dbl2mpn.c | 1 + sysdeps/ieee754/ldbl-128/ldbl2mpn.c | 1 + sysdeps/ieee754/ldbl-96/ldbl2mpn.c | 1 + sysdeps/wordsize-32/divdi3.c | 10 +- sysdeps/x86/gmp-arch.h | 50 +++++ sysdeps/x86/ldbl2mpn.c | 1 + 22 files changed, 193 insertions(+), 402 deletions(-) delete mode 100644 stdlib/udiv_qrnnd.c create mode 100644 sysdeps/alpha/gmp-arch.h create mode 100644 sysdeps/generic/gmp-arch.h delete mode 100644 sysdeps/hppa/hppa1.1/udiv_qrnnd.S delete mode 100644 sysdeps/hppa/udiv_qrnnd.S create mode 100644 sysdeps/x86/gmp-arch.h diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h index 1f08714831..4c0859fa06 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 08859f0dd0..e9cbcfab3b 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 6443b293a4..2da7489502 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 f2b34852ec..a46f166aeb 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -486,7 +486,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 52411c3d10..a5bf7fd37e 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 b91ab9e593..676145d727 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 74c1f6a521..be3ae3d648 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 225b4917d9..0a04a8eb1e 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 5814475e40..7618adb285 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 3eb4d015f5..0005c2e04e 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 d32796c04d..0000000000 --- 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 39dea0d72c..cae60186c8 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 0000000000..c6e4c8f498 --- /dev/null +++ b/sysdeps/alpha/gmp-arch.h @@ -0,0 +1,2 @@ +#define __EXTERNAL_QRNND 1 +#include diff --git a/sysdeps/generic/gmp-arch.h b/sysdeps/generic/gmp-arch.h new file mode 100644 index 0000000000..623b0ae968 --- /dev/null +++ b/sysdeps/generic/gmp-arch.h @@ -0,0 +1,113 @@ +/* Multiprecision generic functions. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __GMP_ARCH_H +#define __GMP_ARCH_H + +#include + +#define LL_B ((mp_limb_t) 1 << (BITS_PER_MP_LIMB / 2)) + +static __always_inline mp_limb_t +ll_lowpart (mp_limb_t t) +{ + return t & (LL_B - 1); +} + +static __always_inline mp_limb_t +ll_highpart (mp_limb_t t) +{ + return t >> (BITS_PER_MP_LIMB / 2); +} + +/* udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, + denominator) divides a UDWtype, composed by the UWtype integers + HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient + in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less + than DENOMINATOR for correct operation. If, in addition, the most + significant bit of DENOMINATOR must be 1, then the pre-processor symbol + UDIV_NEEDS_NORMALIZATION is defined to 1. */ +#ifndef __EXTERNAL_QRNND +static __always_inline void +udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, + mp_limb_t d) +{ + mp_limb_t d1 = ll_highpart (d), + d0 = ll_lowpart (d), + q1, q0; + mp_limb_t r1, r0, m; + + r1 = n1 % d1; + q1 = n1 / d1; + m = q1 * d0; + r1 = r1 * LL_B | ll_highpart (n0); + if (r1 < m) + { + q1--; + r1 += d; + if (r1 >= d) + if (r1 < m) + { + q1--; + r1 += d; + } + } + r1 -= m; + + r0 = r1 % d1; + q0 = r1 / d1; + m = q0 * d0; + r0 = r0 * LL_B | ll_lowpart (n0); + if (r0 < m) + { + q0--; + r0 += d; + if (r0 >= d) + if (r0 < m) + { + q0--; + r0 += d; + } + } + r0 -= m; + + *q = q1 * LL_B | q0; + *r = r0; +} +# undef UDIV_NEEDS_NORMALIZATION +# define UDIV_NEEDS_NORMALIZATION 1 +#else +extern mp_limb_t __udiv_qrnnd (mp_limb_t *, mp_limb_t, mp_limb_t, mp_limb_t) + attribute_hidden; + +static __always_inline void +udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, + mp_limb_t d) +{ + *q = __udiv_qrnnd (r, n1, n0, d); +} +# undef UDIV_NEEDS_NORMALIZATION +# define UDIV_NEEDS_NORMALIZATION 0 +#endif + +#undef udiv_qrnnd +#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ + udiv_qrnnd_generic (&__q, &__r, __n1, __n0, __d) + + +#endif /* __GMP_ARHC_H */ diff --git a/sysdeps/hppa/hppa1.1/udiv_qrnnd.S b/sysdeps/hppa/hppa1.1/udiv_qrnnd.S deleted file mode 100644 index 2f8101bbd2..0000000000 --- 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 317fcda722..0000000000 --- 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 d69973419b..cacf5da7d8 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 d3f3476d56..fd75db1271 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 982f427380..6c7aadbca2 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 387022ab14..360094134f 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 0000000000..5c8b8830af --- /dev/null +++ b/sysdeps/x86/gmp-arch.h @@ -0,0 +1,50 @@ +/* Multiprecision generic functions. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __GMP_ARCH_H +#define __GMP_ARCH_H + +#include + +static __always_inline void +udiv_qrnnd_x86 (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, + mp_limb_t d) +{ +#ifdef __x86_64__ + asm ("div{q} %4" + : "=a" (*q), + "=d" (*r) + : "0" (n0), + "1" (n1), + "rm" (d)); +#else + asm ("div{l} %4" + : "=a" (*q), + "=d" (*r) + : "0" (n0), + "1" (n1), + "rm" (d)); +#endif +} +#undef UDIV_NEEDS_NORMALIZATION +#define UDIV_NEEDS_NORMALIZATION 0 +#undef udiv_qrnnd +#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ + udiv_qrnnd_x86 (&__q, &__r, __n1, __n0, __d) + +#endif diff --git a/sysdeps/x86/ldbl2mpn.c b/sysdeps/x86/ldbl2mpn.c index c41fb8da14..593c472e8a 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 Tue Oct 28 17:08:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122882 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 AC8843858D37 for ; Tue, 28 Oct 2025 17:28:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC8843858D37 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=CPytiExk X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 362973858412 for ; Tue, 28 Oct 2025 17:12:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 362973858412 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 362973858412 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671532; cv=none; b=R46jKpGc4IT4PdZJMfuw7QyY/dzKDslojzOM56THGNSQN7S3usjKR2VLdWRmL80QLO0ryeijdOG2T8GiXpArF+vLXmsnMkIDaTPs+yh+B8V5+25fSdr1ovfbCKE0jsX3mwlM5lSPUa85zYjbplUdMdZQU7G8FJv3wWVZ1al3Dzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671532; c=relaxed/simple; bh=oM3bzBuX9sO+Hr0wk80vHZUxckJBqi9ADLulbQIkK5o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=u8CPYwH6fatAHx4Bsl66BH5H6anrfVJpg5RAl0sXZwjshCNiZrulYfLpQ+3e5HEbZY/yuOjJadIG9wLUo0VqW6skVt93N1PO0uh5D1ccTt5Lc7banbd6H1n8T9JnioN9G6m7Q+XDYh3mPlNEZLtIXjLDVKPpnteI+u4URHIDZrk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 362973858412 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-781ea2cee3fso5981077b3a.0 for ; Tue, 28 Oct 2025 10:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671531; x=1762276331; 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=KRzQqIeCynOwb9UO4eTBK26RJBD9ACdp2yDIm3ULljM=; b=CPytiExkGXAjZxvO0YWYl5FvobRPZOLeZJqZx1smFOdRal//dHj9cLz0rcYFQEUIjj 5K9VzXMnq63YWzeJPXMsA718D8LnqVXLr/8s5isP/U3aTE+sDXTUlN3kRa5BzPe5BrEn Q55ZzqFPjLzAEIvhFFz83EBwvpKGdBOr7+2iFRmsplsjSP+mWVPw+W0PUOYaOudGWCZp KHeNnoBvl6FafDXPa1qKPQViVLdahkVM+KeRkPyCvq4emQDtqqlgWU4MybDpUUqBwBUz w/72EDTK+F6t9lWTMnspiFINdMTOPsc6imlnPGNGQbU47470XYneaJ8CnewM9qaCjBmm p8Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671531; x=1762276331; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KRzQqIeCynOwb9UO4eTBK26RJBD9ACdp2yDIm3ULljM=; b=bGrKODQSWwFodqkO+NGeBY/nDuXcrnFBa5Af2NXbNBUBeVzTK1uZ4z/ruoNWwObMR/ hIknd8MjOE8UhkoRcjcAsHwwwH0V4hPKY3IVjb2gw+40iTt+c0cjW74Zka+8fxbaqRVy Nl4TSGTeztBocIJO06voTWeWwQr7eSn/2rIsGR1nBkv1+QPxCicu6ti41f9OhudkQFie 131ccvqiBaczFHI0TFdVIo66KLbKNlx0bHN4WsJsN6XC3cF52XzZSKo/ZR5H/KGc10hV rqM6ZA2kFKWYZCRUi7/G0nBxUTH4v6PxUc6i5xU+0fVhdRoRSV9HIe+77dGLRNdguBBp XyGg== X-Gm-Message-State: AOJu0Yx8cNcoxw7b7zrYToqh//WVnJvF5ooGm4TlhqkmTNZFJJgvp93W CUs8ViVmMZWb3W2EQtntm4Al8U1eoN60hBToKBlbG2izIrJ0gWwjQ2JaQ5O9qe60orU8hIf+8B8 3XcgAjDw= X-Gm-Gg: ASbGncs0xIwoE3sVfrM7qWwHwYw0tkf0FEPIbfSIzrVJzjT5GfIAAIc/UGlJRLsj5Le dct2St5KnFCG2lDvskUcsbKQnCjKvjDkvY/KgEDJQ3K48EagzPH6MgSLB+FXiFNbKetnE1s2l6N T9c12kxrU0/iboZl9ehCMHXpkquD7KLD+swkg9J8Y7k9J9utTDJWC5FrchoZuzNO1tSUcLsZmxi HQiz/r/j091w15hNLpWTMcjMLZfMc29ljVS6Z/VWdIkxuhgYKu54oBU5Exscdk0mI0hJ5hzJTt2 +cTJFqfUt23OXKEFSBXpVej+58CtE617pddfn1PsnUoq+H/FYyKjet4Ludfv2dCZP8Gvoc1esct 9Tf+2Os9QdRbqigNEpmDrMnhbzmdKVymrfPMFAsahw8zS7vnwEOrAPt25xTPhRqSJ4G/6/+C2tm GsFZNyoSAU/gVqirYZY6xQ7Jh5nnqQqDW4LR7bcO6WkYHbEA== X-Google-Smtp-Source: AGHT+IEruzMJyHPH9xhyeVxiQQyp73wWqCg5Q7tFZ6j0fAZtmlTEcTdqDLZe0uIpm3IfLJ8wm/X6/w== X-Received: by 2002:a05:6a21:6d98:b0:32a:c8b8:5610 with SMTP id adf61e73a8af0-344d3d4aa30mr5139844637.47.1761671530822; Tue, 28 Oct 2025 10:12:10 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:09 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 06/28] Add add_ssaaaa and sub_ssaaaa to gmp-arch.h Date: Tue, 28 Oct 2025 14:08:15 -0300 Message-ID: <20251028171141.3208834-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org To enable “longlong.h” removal, add_ssaaaa and sub_ssaaaa are moved to gmp-arch.h. The generic implementation now uses a static inline. This provides better type checking than the GNU extension, which casts the asm constraint. It also works better with clang. Most architectures use the generic implementation. This is expanded from a macro. Exceptions are arc, arm, hppa, x86, m68k, powerpc, and sparc. I kept only the x86 optimization, as there is no easy way to emit add{q}. For all others, the compiler generates good enough code. The strongly typed implementation required some changes. I adjusted _FP_W_TYPE, _FP_WS_TYPE, and _FP_I_TYPE to use the same type as mp_limb_t on aarch64, powerpc64le, x86_64, and riscv64. This basically means using “long” instead of “long long.” --- sysdeps/aarch64/sfp-machine.h | 4 +- sysdeps/generic/gmp-arch.h | 35 ++++++++++++- sysdeps/loongarch/sfp-machine.h | 6 +-- .../powerpc/powerpc64/le/fpu/sfp-machine.h | 6 +-- sysdeps/riscv/sfp-machine.h | 6 +-- sysdeps/x86/fpu/sfp-machine.h | 18 ++++--- sysdeps/x86/gmp-arch.h | 52 +++++++++++++++++++ 7 files changed, 109 insertions(+), 18 deletions(-) diff --git a/sysdeps/aarch64/sfp-machine.h b/sysdeps/aarch64/sfp-machine.h index b41a9462df..3468e47db3 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 623b0ae968..3ec144562a 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -110,4 +110,37 @@ udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, udiv_qrnnd_generic (&__q, &__r, __n1, __n0, __d) -#endif /* __GMP_ARHC_H */ +/* add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1, + high_addend_2, low_addend_2) adds two UWtype integers, composed by + HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2 + respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow + (i.e. carry out) is not stored anywhere, and is lost. */ +static __always_inline void +add_ssaaaa_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, + mp_limb_t al, mp_limb_t bh, mp_limb_t bl) +{ + *sl = al + bl; + *sh = (ah + bh) + (*sl < al); +} +#undef add_ssaaaa +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ + add_ssaaaa_generic (&sh, &sl, ah, al, bh, bl) + +/* sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend, + high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers, + composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and + LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE + and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere, + and is lost. */ +static __always_inline void +sub_ddmmss_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, + mp_limb_t al, mp_limb_t bh, mp_limb_t bl) +{ + *sl = al - bl; + *sh = (ah - bh) - (*sl > al); +} +#undef sub_ddmmss +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ + sub_ddmmss_generic (&sh, &sl, ah, al, bh, bl) + +#endif diff --git a/sysdeps/loongarch/sfp-machine.h b/sysdeps/loongarch/sfp-machine.h index 497b550f5c..113d96651b 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 b4b27f95f4..30b7fcf6ed 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 43b2ba10ab..a38edd1e3c 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 5892f4f5fe..cbcedb8621 100644 --- a/sysdeps/x86/fpu/sfp-machine.h +++ b/sysdeps/x86/fpu/sfp-machine.h @@ -8,9 +8,15 @@ typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); #ifdef __x86_64__ # define _FP_W_TYPE_SIZE 64 -# define _FP_W_TYPE unsigned long long -# define _FP_WS_TYPE signed long long -# define _FP_I_TYPE long long +# ifndef __ILP32__ +# define _FP_W_TYPE unsigned long +# define _FP_WS_TYPE signed long +# define _FP_I_TYPE long +# else +# define _FP_W_TYPE unsigned long long +# define _FP_WS_TYPE signed long long +# define _FP_I_TYPE long long +# endif typedef int TItype __attribute__ ((mode (TI))); typedef unsigned int UTItype __attribute__ ((mode (TI))); @@ -45,9 +51,9 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); } while (0) #else # define _FP_W_TYPE_SIZE 32 -# define _FP_W_TYPE unsigned int -# define _FP_WS_TYPE signed int -# define _FP_I_TYPE int +# define _FP_W_TYPE unsigned long int +# define _FP_WS_TYPE signed long int +# define _FP_I_TYPE long int # define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \ __asm__ ("add{l} {%11,%3|%3,%11}\n\t" \ diff --git a/sysdeps/x86/gmp-arch.h b/sysdeps/x86/gmp-arch.h index 5c8b8830af..45f047e1b6 100644 --- a/sysdeps/x86/gmp-arch.h +++ b/sysdeps/x86/gmp-arch.h @@ -47,4 +47,56 @@ udiv_qrnnd_x86 (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, #define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ udiv_qrnnd_x86 (&__q, &__r, __n1, __n0, __d) +static __always_inline void +add_ssaaaa_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, + mp_limb_t al, mp_limb_t bh, mp_limb_t bl) +{ +#ifdef __x86_64__ + asm ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}" + : "=r" (*sh), + "=&r" (*sl) + : "%0" (ah), + "rme" (bh), + "%1" (al), + "rme" (bl)); +#else + asm ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}" + : "=r" (*sh), + "=&r" (*sl) + : "%0" (ah), + "g" (bh), + "%1" (al), + "g" (bl)); +#endif +} +#undef add_ssaaaa +#define add_ssaaaa(__sh, __sl, __ah, __al, __bh, __bl) \ + add_ssaaaa_x86 (&__sh, &__sl, __ah, __al, __bh, __bl) + +static __always_inline void +sub_ddmmss_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, + mp_limb_t al, mp_limb_t bh, mp_limb_t bl) +{ +#ifdef __x86_64__ + asm ("sub{q} {%5,%1|%1,%5}\n\tsbb{q} {%3,%0|%0,%3}" + : "=r" (*sh), + "=&r" (*sl) + : "0" (ah), + "rme" (bh), + "1" (al), + "rme" (bl)); +#else + asm ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}" + : "=r" (*sh), + "=&r" (*sl) + : "0" (ah), + "g" (bh), + "1" (al), + "g" (bl)); +#endif +} +#undef sub_ddmmss +#define sub_ddmmss(__sh, __sl, __ah, __al, __bh, __bl) \ + sub_ddmmss_x86 (&__sh, &__sl, __ah, __al, __bh, __bl) + #endif From patchwork Tue Oct 28 17:08:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122871 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 072913858407 for ; Tue, 28 Oct 2025 17:19:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 072913858407 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=ZXjqr0IM X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id A56733858C60 for ; Tue, 28 Oct 2025 17:12:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A56733858C60 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 A56733858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671535; cv=none; b=mYl4KoBCRZOEEYnKYXc/ryzwA6UBih/vqsAGubxhXftRlq+/gfeCBpe+nT+IX33cJtzdWpsZVCKI0hyEIks9VzS8EvnclfvY1Ee5V7ixYeh0udzjq1Wu+y1HA5FLnT0U5AKOvNmWC82oQcNTI/qppi09XKmWxqHYJL+BbeCpwf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671535; c=relaxed/simple; bh=/ZJBEoPUkjWEVnl08jRlEHQwk7FIq0r+o6jLKXchazo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kXi69D6y1264vKh5tINK3clB/F/ej9OZYZ8FloK+Lq9DuxGXns/3crDR1KUQX4M3sEczTkED/4VI8PZjrP5vkXdtmUSNxyISAIAb+dnYTyMoqp4XoV4wltSIqTiNvLlBfg/JNsOgKYXUMDIwnfkaFs31UcvS8nF1bArhj0XI+Og= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A56733858C60 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-b6cee846998so4238765a12.1 for ; Tue, 28 Oct 2025 10:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671534; x=1762276334; 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=OneusD7v7PJ+Qd2YLZFfWAQO0gFNCjo2XS0vUC+CrVw=; b=ZXjqr0IMZzsgg/qyohPTadUvrcNPR+vJN0l05n0iW9TSE0qNI0InPnbjsd88XxNXiy BUQSFsXHrLX3BHOo+9j9U+Xkvm1vsUhU1ExktT6DMjbx1FVeuBAFp6vafdQX1PVQKQZN PP7NsgKdS2BG4CMW1sblCEKfAme/pKQUZWM33+QHpxO+dWbQ0yx7khI71NFtvgj4SuGo 7ZP8KgiKTqPolrO07GMbddrzz3gZvarDRHgwOZJ3EoUj0EiKjCFAaxJqzaHPDYbr7qUr KuJZ3ZAtdsIhUAB92AU/bUGwTi0/nxaExF254ihVEIN0LRpWGre/IcDhvzS8PMaAfpKI jr0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671534; x=1762276334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OneusD7v7PJ+Qd2YLZFfWAQO0gFNCjo2XS0vUC+CrVw=; b=S97lNRSVGCe9RKbCM0icwm8N8mb7N1V7buH7sh0g+68CjxpLfsJAA8HPjH5iXX+c/s eLksq19F2cbqte8UiY5aOT6UC6UjWrUOB4gxWf251jaOR/hUVvGDGe9UoptAGokjlU1T oB+YN2gmiP3qXQkelND86mQ1WKi0tY0gLAD+m+BIPBWFjHrQbYNbqE/xgzt/3EUHmWCJ dt9Q4qqB6xDBgEw04CvsLxW2ddLDq/3ev/VK7gJGw6Vn+Pun7hC5XBBXv4SAsHIZWPD7 KctDboJRrWCuDbkZg1T3qVi78cjq/7F2+qj7j+NvWKD6FAuxySuDLq7JQhnV66u9aHqA n9hw== X-Gm-Message-State: AOJu0YxJhSPpIQk698OTAcY9JIkJbDGdUW1nIecuTALf1/a/BhBKHY1K nMzhAapKc3hhGPWlyEnVNcJrSyZ0EsfksR1le2tOiNYGO/FEoH9RzlXMIFn7W7j9bqcoVc/haV8 2Jq8quCc= X-Gm-Gg: ASbGnctwwR8Asn7RSkDEA+UH1123p1z3xRJXPyJFYqZmEBZ3hUOtXkukRqxU8529dfg TTe0pOPYqsp6WJ1eAnKMc7cFXbdRdJ1Au1FwAN1KsIJK3V0osfP05kOkfJ8TgjSt1SbNxB4q083 J+fyq5aea6eVTYNjRvcMk7FjBl1/IoIXg+HP6QKlusQ8mARUttOfXmTp2WeGbL23zNwRv9DuK5r oRzCVaJK5rUoROiLqe4N2dHljGrWjHp2EyZf8e3lnTuByr2mOK2SBbTRPEJtag01O1pq5Ye6ymL lHbO4epxJDp6VccTYfz3/4gzP/KshI61MY//mWOB5+D9TgmaRJgrQv2YbHXfteQRyFCNEWRprC+ ofMoTGZQxrn5r0122sya6rYHyPX33kTWCzDu8gEeygwUSHqJ4NaMNrS5mUfdYKG5Z8z8wtqd4/i ozG6QlDwc+rAaLpUfgjGZ3UMDw3KoHtNfejFB6gZ2K8J6LWQ== X-Google-Smtp-Source: AGHT+IG0r1qkgEMGhrlyGNOp7UWkJCnNxCO90jQy+m5Tn4xyvj8SN0eISCDg3VJ/aCaClbu3oZwk5w== X-Received: by 2002:a17:902:c94a:b0:269:b2e5:ee48 with SMTP id d9443c01a7336-294cb5101f1mr53790775ad.52.1761671534161; Tue, 28 Oct 2025 10:12:14 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:13 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 07/28] Add umul_ppmm to gmp-arch.hdoc Date: Tue, 28 Oct 2025 14:08:16 -0300 Message-ID: <20251028171141.3208834-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org To enable “longlong.h” removal, the umul_ppmm is moved to a gmp-arch.h. The generic implementation now uses a static inline, which provides better type checking than the GNU extension to cast the asm constraint (and it works better with clang). Most of the architecture uses the generic implementation, which is expanded from a macro, except for alpha, arm, hppa, x86, m68k, mips, powerpc, and sparc. I kept only x86 optimization, where there is no easy way to emit mul{q}. For the rest, the compiler generates good enough code. --- sysdeps/generic/gmp-arch.h | 40 ++++++++++++++++++++++++++++++++++++++ sysdeps/x86/gmp-arch.h | 21 ++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/sysdeps/generic/gmp-arch.h b/sysdeps/generic/gmp-arch.h index 3ec144562a..f5d6495f2b 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -35,6 +35,46 @@ ll_highpart (mp_limb_t t) return t >> (BITS_PER_MP_LIMB / 2); } +/* umul_ppmm(high_prod, low_prod, multiplier, multiplicand) multiplies two + UWtype integers MULTIPLIER and MULTIPLICAND, and generates a two UWtype + word product in HIGH_PROD and LOW_PROD. */ +static __always_inline void +umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) +{ +#if __WORDSIZE == 32 + uint64_t t0 = (uint64_t)u * v; + *w1 = t0 >> 32; + *w0 = t0; +#else + mp_limb_t ul = ll_lowpart (u); + mp_limb_t uh = ll_highpart (u); + mp_limb_t vl = ll_lowpart (v); + mp_limb_t vh = ll_highpart (v); + + mp_limb_t x0 = ul * vl; + mp_limb_t x1 = ul * vh; + mp_limb_t x2 = uh * vl; + mp_limb_t x3 = uh * vh; + + x1 += ll_highpart (x0); + x1 += x2; + if (x1 < x2) + x3 += LL_B; + + *w1 = x3 + ll_highpart (x1); + *w0 = ll_lowpart (x1) * LL_B + ll_lowpart (x0); +#endif +} +#undef umul_ppmm +#define umul_ppmm(__w1, __w0, __u, __v) \ + ({ \ + __typeof (__w0) __w0t; \ + __typeof (__w1) __w1t; \ + umul_ppmm_generic (&__w1t, &__w0t, __u, __v); \ + __w1 = __w1t; \ + __w0 = __w0t; \ + }) + /* udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, denominator) divides a UDWtype, composed by the UWtype integers HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient diff --git a/sysdeps/x86/gmp-arch.h b/sysdeps/x86/gmp-arch.h index 45f047e1b6..c3aa0f2e3b 100644 --- a/sysdeps/x86/gmp-arch.h +++ b/sysdeps/x86/gmp-arch.h @@ -21,6 +21,27 @@ #include +static __always_inline void +umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) +{ +#ifdef __x86_64__ + asm ("mul{q} %3" + : "=a" (*w0), + "=d" (*w1) + : "%0" (u), + "rm" (v)); +#else + asm ("mul{l} %3" + : "=a" (*w0), + "=d" (*w1) + : "%0" (u), + "rm" (v)); +#endif +} +#undef umul_ppmm +#define umul_ppmm(__w1, __w0, __u, __v) \ + umul_ppmm_generic (&__w1, &__w0, __u, __v) + static __always_inline void udiv_qrnnd_x86 (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, mp_limb_t d) From patchwork Tue Oct 28 17:08:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122885 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 2107B385841C for ; Tue, 28 Oct 2025 17:31:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2107B385841C 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=eo70ch5e X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id 10B163858429 for ; Tue, 28 Oct 2025 17:12:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10B163858429 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 10B163858429 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671543; cv=none; b=Rz/AyRozaDlZpJPI6u89iyxy+Otd4Uq2hBjKuP7p7s1C44UtLq1cXA5N+G64j7uCkcFoV2f01o84iXPGW95oMhmdVXnPxNireUEh/wwpykZFNeLTcGLDB8mk6w20Krc5cAAmYlXJhW+TPgwOUH8pCAFJN+dq5QaDuEzKMZy6P5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671543; c=relaxed/simple; bh=zzj+BbU7WVK4DW2LNAjgH48HDjcUMF2YYIXUQ53nYic=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uWdH8IsRtiQTf91G1FJznbfAJ6u7rjbw2cXUX4K0a3GZI/pnFP+zcrRTONSOWm4NjKX6rzAGGrxtsvePHkEo8UsWd9Lrc/siToa7/yJ/n9h+IC3C0705MBU4vCDOjorZbdVZbV0U58eYgNRvtd5dRJiIofNZdIrb6dFNlL3U0og= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10B163858429 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-33e0008d3b3so6342743a91.3 for ; Tue, 28 Oct 2025 10:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671542; x=1762276342; 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=Besgp240mZE4F/dV49xUMye45FhVDH3anw6XrYd/0ds=; b=eo70ch5eTb1kCinW1AXZr8kty/vH5Bgjz6eLT2MSgTCfebQ6OSJTb317IuszoNsxaS f6VE3zCYvQ0EzUQt+NvecaT2E+Kn2ENlxu861pujqBfzGE0mKTmaviFx8m21Qn3+v/Uo 42pYmpxkmHEu4EpiJjLByU+2IiBP1L3WAIRaNH5SnhmoXKpZd2wceeErrOMin7zeFeQv Rf7FFzPaKMwG4d6ytJ8bgBx7XggDccpmbY/rinD0M9ci6Icnn5D8cW4hQOmJyNM6Nu9n 0B3T3pdfAPwqqrkQjeOte+EgKvdL9w/PGSrr/YbUp1KILHYYYmhjVkPxBFtJn7shqZpb IrIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671542; x=1762276342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Besgp240mZE4F/dV49xUMye45FhVDH3anw6XrYd/0ds=; b=fpcObpg437YmynRq4WYj9n/b34RyvNYouGAR0vEE1E1aFlgMe5UZ8TOyBQVG2E3TcB qnVnS3LGJeVfDCRAQx3CZ8YRohdtLnK2yNOYJ9jl9l6FaVdYKOjoYO9LxSW+eKMfKgBi pFzGSw7f5gOvQsFWaOP0FRvHYVRu9l5Vmxam9JOvQNX/79qzXgUWMJiKxqiN0DGo6wV5 8bPvOhntD+TjCNAZ86qJVzTIrxR8k9Y74LePCvZtKx/sdhB8AwV6Y63B3dAYWmvZB/si htBSlL2cCpd4JSdSS6Js+g7kJocl42Qc20D4GwABiGbjCXBKHhISosmprHuhPAhHjq5g OOpw== X-Gm-Message-State: AOJu0Yz/wGJDOfUdZvYQGys+NF16yXfDrmjT3exMx3ntLSSgmuQIhBSx K8tRfEdZis0ye1Aa0PpvZP1LmoPZ//8AkzmPf7Mpz8eeOhi8rkl3cq7WFlypeq1Vk5f65TPy7Hy UETJceAk= X-Gm-Gg: ASbGncu77jzw940skxi3AWYVRbIt5jEKAWckCLaWapBDKPMJOq8bPoy9ij2T4yRE0YD vXPkOJifQ+nJRsATdoImMm55m2YHP8iO5bhS3fGCb6Au6mi2R3HjZ5nSNAip79rYKNOUAjBBjQu lRGtzmjOG9n4ojf3RgwwvzGxrD/4FL4ws8OeW8ppa4LANLqLHy1O3CFIy6jovI0k/5m1pUXPU5o cBtltpxMFaOVBisA4UmqfumGGj2unfNBipryd57wkzf2Fb7UOVjuf/fvPgmWgGYaGL5vgBM4nc+ a1vsGSNjg4gxBmeT1gLOry3BDIyeylmjEMkskSAQoRegLmarT8egHOO6G6Z0kY4nuG+AwhOPISa K2GuI9QsrvWvC8zL47LMDhgWkbgOmu9zVUR2MBy928REiHBmdMok3KkV7eONu8S77qVH5sxHDnD ZkVRc8KMBEAs9cgIac/Tm6802evda5Gb133xXqBNBqfPXZ6Q== X-Google-Smtp-Source: AGHT+IGYaM1ns9aeBrk5A0wig+dDoM117FQlZjtzZc2LoAyQjEynldog9BIDcg5dOeBlkvEp8cBLvg== X-Received: by 2002:a17:90b:58ef:b0:33b:c5f6:40ef with SMTP id 98e67ed59e1d1-34027bda889mr4916046a91.24.1761671540285; Tue, 28 Oct 2025 10:12:20 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:16 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 08/28] stdlib: Remove longlong.h Date: Tue, 28 Oct 2025 14:08:17 -0300 Message-ID: <20251028171141.3208834-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The gmp-arch.h now provides all the required definitions. --- soft-fp/soft-fp.h | 2 - stdio-common/_itoa.c | 2 - stdio-common/_itowa.c | 2 - stdlib/Makefile | 1 - stdlib/addmul_1.c | 2 - stdlib/divmod_1.c | 2 - stdlib/divrem.c | 1 - stdlib/gmp-impl.h | 2 + stdlib/longlong.h | 1786 ------------------------ stdlib/mod_1.c | 2 - stdlib/mul_1.c | 2 - stdlib/strtod_l.c | 2 - stdlib/submul_1.c | 2 - sysdeps/generic/gmp-arch.h | 5 - sysdeps/ieee754/dbl-64/dbl2mpn.c | 2 - sysdeps/ieee754/ldbl-128/ldbl2mpn.c | 2 - sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c | 1 - sysdeps/ieee754/ldbl-96/ldbl2mpn.c | 2 - sysdeps/wordsize-32/divdi3.c | 2 - sysdeps/x86/gmp-arch.h | 5 - sysdeps/x86/ldbl2mpn.c | 2 - 21 files changed, 2 insertions(+), 1827 deletions(-) delete mode 100644 stdlib/longlong.h diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h index 4c0859fa06..a3a44f8a42 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 e9cbcfab3b..dd9c5715a7 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 2da7489502..5aaf1b9a1e 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 a46f166aeb..4af922fc2b 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -492,7 +492,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 a5bf7fd37e..95b4c60366 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 676145d727..7d833dfd5d 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 889fe3da12..9f54c33e69 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 dea739c44c..3da6d0555e 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 4549f0a55f..0000000000 --- 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 be3ae3d648..a95051d4c4 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 0a04a8eb1e..e53fbeaa79 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 7618adb285..d00a336589 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 0005c2e04e..31a6d4b2e7 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 f5d6495f2b..0860c0b202 100644 --- a/sysdeps/generic/gmp-arch.h +++ b/sysdeps/generic/gmp-arch.h @@ -65,7 +65,6 @@ umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) *w0 = ll_lowpart (x1) * LL_B + ll_lowpart (x0); #endif } -#undef umul_ppmm #define umul_ppmm(__w1, __w0, __u, __v) \ ({ \ __typeof (__w0) __w0t; \ @@ -129,7 +128,6 @@ udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, *q = q1 * LL_B | q0; *r = r0; } -# undef UDIV_NEEDS_NORMALIZATION # define UDIV_NEEDS_NORMALIZATION 1 #else extern mp_limb_t __udiv_qrnnd (mp_limb_t *, mp_limb_t, mp_limb_t, mp_limb_t) @@ -141,7 +139,6 @@ udiv_qrnnd_generic (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, { *q = __udiv_qrnnd (r, n1, n0, d); } -# undef UDIV_NEEDS_NORMALIZATION # define UDIV_NEEDS_NORMALIZATION 0 #endif @@ -162,7 +159,6 @@ add_ssaaaa_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, *sl = al + bl; *sh = (ah + bh) + (*sl < al); } -#undef add_ssaaaa #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ add_ssaaaa_generic (&sh, &sl, ah, al, bh, bl) @@ -179,7 +175,6 @@ sub_ddmmss_generic (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, *sl = al - bl; *sh = (ah - bh) - (*sl > al); } -#undef sub_ddmmss #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ sub_ddmmss_generic (&sh, &sl, ah, al, bh, bl) diff --git a/sysdeps/ieee754/dbl-64/dbl2mpn.c b/sysdeps/ieee754/dbl-64/dbl2mpn.c index cacf5da7d8..50974cfc62 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 fd75db1271..cd0ee1e073 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 d91699c3d0..72714eee2e 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 6c7aadbca2..5826798631 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 360094134f..0269729b96 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 c3aa0f2e3b..64819f1562 100644 --- a/sysdeps/x86/gmp-arch.h +++ b/sysdeps/x86/gmp-arch.h @@ -38,7 +38,6 @@ umul_ppmm_generic (mp_limb_t *w1, mp_limb_t *w0, mp_limb_t u, mp_limb_t v) "rm" (v)); #endif } -#undef umul_ppmm #define umul_ppmm(__w1, __w0, __u, __v) \ umul_ppmm_generic (&__w1, &__w0, __u, __v) @@ -62,9 +61,7 @@ udiv_qrnnd_x86 (mp_limb_t *q, mp_limb_t *r, mp_limb_t n1, mp_limb_t n0, "rm" (d)); #endif } -#undef UDIV_NEEDS_NORMALIZATION #define UDIV_NEEDS_NORMALIZATION 0 -#undef udiv_qrnnd #define udiv_qrnnd(__q, __r, __n1, __n0, __d) \ udiv_qrnnd_x86 (&__q, &__r, __n1, __n0, __d) @@ -90,7 +87,6 @@ add_ssaaaa_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, "g" (bl)); #endif } -#undef add_ssaaaa #define add_ssaaaa(__sh, __sl, __ah, __al, __bh, __bl) \ add_ssaaaa_x86 (&__sh, &__sl, __ah, __al, __bh, __bl) @@ -116,7 +112,6 @@ sub_ddmmss_x86 (mp_limb_t *sh, mp_limb_t *sl, mp_limb_t ah, "g" (bl)); #endif } -#undef sub_ddmmss #define sub_ddmmss(__sh, __sl, __ah, __al, __bh, __bl) \ sub_ddmmss_x86 (&__sh, &__sl, __ah, __al, __bh, __bl) diff --git a/sysdeps/x86/ldbl2mpn.c b/sysdeps/x86/ldbl2mpn.c index 593c472e8a..43a34bbcf7 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 Tue Oct 28 17:08:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122876 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 84B6E385841B for ; Tue, 28 Oct 2025 17:23:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84B6E385841B 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=r8f4j+pX X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 60C7E3858D37 for ; Tue, 28 Oct 2025 17:12:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60C7E3858D37 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 60C7E3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671561; cv=none; b=taAS32XVS8hX1W+jpHz+x28auUgMUQzzrf+jtad6UsUlFx+XDd3eA2XozlUAFB8jVb9MYf3AeTkeNuX3QbBJ9+t44YJ3FhjMhtkPqd7JIHk3OOzLKmkGFPFcsemHNrJJ3jHutw+ivSi+Q3tcbKR7gOr6H+Xe4dp4N7OjJ/lsWns= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671561; c=relaxed/simple; bh=mfnUFt+beIncw+7OPWlafJp8ypNtqm2q8wnzOHUMVVQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wSPKbs1ZSYOufJ/24dSMnX6QocVpqEFRMZW9TbpXvkNmrWKx62j0alnCm6t/e7/TelulBhHvjgbe7IAw3wxoHxyHwjsmGOauoDuZHn7U0pWsVVvKxs9gxTjfoC4oQUWK9vIHQGb9pIVHbumDiFLgPDmrEV3sXKTrt1fNefpVR1c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60C7E3858D37 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-b6cee846998so4239246a12.1 for ; Tue, 28 Oct 2025 10:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671560; x=1762276360; 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=IStJIN9CgGRCEYQHXwcC6H6LEO9U0tRXSNa3cI5x+0k=; b=r8f4j+pXQ3/fRi6O64fGUBmnKiCeErtrK6yrJs8xFmQ1mODbSZrzLBXm7WIfSvAezY 5LV3zJM+BA9PpbXiP09EhpCsAkOZisLS8dS5TwuJVSCpqNj8SC0X6Y9dkTnFpY0hc+vR vnpKy/fveqQ44KEpfxv+4Vx+wxm7745ZndBvCXfMq4wUEHpvBFbVO4Exk0k5hDHrscaX vkAYnRf8iO7kp9V84dh1NC24SK4HR3gmlVduUi9URH869RnnSXEXzjP+OljN/mvleVsz j8Wc+072NPsVyriZn53g9RONV+c7z1sFgbNw6sK6vUgknher2sPGVnDQIRR0GhnSL2Gk 5Rug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671560; x=1762276360; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IStJIN9CgGRCEYQHXwcC6H6LEO9U0tRXSNa3cI5x+0k=; b=dsKBO9Amh49rsrmjcHpws/QkkGAqSNaxOCggqWZmS+9EoAYMToYWcEDw633YqyaJ0f Yvt3d8kLvo6pofRxmNyASAr4L7xfR15LZVjnFalVi986N3fQZZ917MWIBdelQudALcT7 9+eYaK3BfO3//q8LtBjU0Y1owB4I02cvqgZ7I44UA9Z2DjZGYq0iV69W6mHCirurCc1M Ant6PBtqMtiqQuddYOaLp9mElH8BQVHMnJe0DRM4crHTyPs4b82AHBTamC8vK5xARuaB 2vMSbgyRnkST63R6MfAq0CxDzEGlpM0wqPFtnnM3xLUk1zwXOt8ZmQI3XFXtrCHBL7Ge 2GXw== X-Gm-Message-State: AOJu0YxAEOcAn8NVkOy/ekntr+K+GV+VUnRVA5D6tuMqxPRr40cil51G bmJFvYbPhYIYnOhxDW8cmPHLzv16gGYr+A2rLxDEDsv0ia42yM25VK4Pbp1MQfjVexaY4pMBtCO awZY3oF4= X-Gm-Gg: ASbGncueBOKUopjuP/CLG51ERe1U1i3FV70KskMNA1BRo+aQ1L/gmEyK8XpLpMBWtog j1vRkwMUCA4XdVexj9UA7RDeGhizW1afbfnszjVzvduj/7ph7Ryv5m37btKB9lssP0FJ1+wclMv 8/gY6IatAmX/kzu+SRVbSvFKhIR9R0oyNqHhYFW6vqIsWNFdPQbdESjSP/mGma8/Wfox8aOo2iv xfEV+JXR6vFJQVMKNPVCD7ZgCQ+yjKVFu9wimRcdy8vSSteL4CNzq5LqI/yzj8gwM1h+y2nH6BM IALlg+EiQDh3qQmFh2/5COsnZ1WybXAAH1unNese+x1ZQoDG54XcJqcCk8ZOs86440EXgFTadjf jM1vGGNoW3H3W4hsbC813WMCsz974PaoleW1tf+CziU0U//4bboMNcM77LJDLoeP8viVskJWGAY u/yN+N1Dtyi2YNozkfmOuQzoZtFLujir9P/oJvjeT7ZkvxYw== X-Google-Smtp-Source: AGHT+IHWh13Weqt7PQkha8L/4/9r+DzZgX8iqC1TRTc/vot867iOF4Gx0xg/p//6gHfQHVTLksKfFg== X-Received: by 2002:a17:902:cecc:b0:276:842a:f9a7 with SMTP id d9443c01a7336-294cb523d54mr58889135ad.57.1761671559654; Tue, 28 Oct 2025 10:12:39 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:36 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 09/28] math: Don't redirect inlined builtin math functions Date: Tue, 28 Oct 2025 14:08:18 -0300 Message-ID: <20251028171141.3208834-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, 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 | 19 +- math/s_fmax_template.c | 1 - math/s_fmin_template.c | 2 - sysdeps/generic/math-use-builtins-copysign.h | 2 + sysdeps/generic/math-use-builtins.h | 196 ++++++++++++++++++ sysdeps/ieee754/dbl-64/e_hypot.c | 1 - sysdeps/ieee754/dbl-64/e_sqrt.c | 1 - sysdeps/ieee754/dbl-64/s_ceil.c | 1 - sysdeps/ieee754/dbl-64/s_floor.c | 1 - sysdeps/ieee754/dbl-64/s_fma.c | 1 - sysdeps/ieee754/dbl-64/s_fmaf.c | 1 - sysdeps/ieee754/dbl-64/s_llrint.c | 1 - sysdeps/ieee754/dbl-64/s_llround.c | 1 - sysdeps/ieee754/dbl-64/s_logb.c | 2 - sysdeps/ieee754/dbl-64/s_lrint.c | 1 - sysdeps/ieee754/dbl-64/s_lround.c | 1 - sysdeps/ieee754/dbl-64/s_modf.c | 1 - sysdeps/ieee754/dbl-64/s_nearbyint.c | 1 - sysdeps/ieee754/dbl-64/s_rint.c | 1 - sysdeps/ieee754/dbl-64/s_round.c | 2 - sysdeps/ieee754/dbl-64/s_roundeven.c | 1 - sysdeps/ieee754/dbl-64/s_trunc.c | 2 - sysdeps/ieee754/float128/float128_private.h | 1 - sysdeps/ieee754/flt-32/e_sqrtf.c | 1 - sysdeps/ieee754/flt-32/s_ceilf.c | 1 - sysdeps/ieee754/flt-32/s_floorf.c | 1 - sysdeps/ieee754/flt-32/s_llrintf.c | 1 - sysdeps/ieee754/flt-32/s_llroundf.c | 1 - sysdeps/ieee754/flt-32/s_logbf.c | 1 - sysdeps/ieee754/flt-32/s_lrintf.c | 1 - sysdeps/ieee754/flt-32/s_lroundf.c | 1 - sysdeps/ieee754/flt-32/s_modff.c | 1 - sysdeps/ieee754/flt-32/s_nearbyintf.c | 1 - sysdeps/ieee754/flt-32/s_rintf.c | 1 - sysdeps/ieee754/flt-32/s_roundevenf.c | 1 - sysdeps/ieee754/flt-32/s_roundf.c | 1 - sysdeps/ieee754/flt-32/s_truncf.c | 1 - sysdeps/ieee754/ldbl-128/s_ceill.c | 1 - sysdeps/ieee754/ldbl-128/s_copysignl.c | 1 - sysdeps/ieee754/ldbl-128/s_floorl.c | 1 - sysdeps/ieee754/ldbl-128/s_fma.c | 1 - sysdeps/ieee754/ldbl-128/s_fmal.c | 1 - sysdeps/ieee754/ldbl-128/s_llrintl.c | 1 - sysdeps/ieee754/ldbl-128/s_logbl.c | 1 - sysdeps/ieee754/ldbl-128/s_lrintl.c | 1 - sysdeps/ieee754/ldbl-128/s_nearbyintl.c | 1 - sysdeps/ieee754/ldbl-128/s_rintl.c | 1 - sysdeps/ieee754/ldbl-128/s_roundevenl.c | 1 - sysdeps/ieee754/ldbl-128/s_roundl.c | 1 - sysdeps/ieee754/ldbl-128/s_truncl.c | 1 - sysdeps/ieee754/ldbl-128ibm/s_fabsl.c | 1 - sysdeps/ieee754/ldbl-96/s_fabsl.c | 1 - sysdeps/mips/fpu/math-use-builtins-fma.h | 2 +- sysdeps/mips/math-use-builtins-ffs.h | 2 +- sysdeps/mips/sgidefs.h | 3 + sysdeps/powerpc/fpu/e_sqrt.c | 1 - sysdeps/powerpc/fpu/e_sqrtf.c | 1 - sysdeps/unix/mips/sysdep.h | 3 - sysdeps/x86_64/fpu/multiarch/s_modf-avx.c | 4 - sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c | 4 - sysdeps/x86_64/fpu/multiarch/s_modff-avx.c | 4 - sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c | 4 - 62 files changed, 216 insertions(+), 82 deletions(-) diff --git a/include/math.h b/include/math.h index 9ba4708801..0fac2fda84 100644 --- a/include/math.h +++ b/include/math.h @@ -139,25 +139,32 @@ 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) +/* NB: Do not redirect math builtin functions when they are inlined. */ +# include # 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 bdf71096af..87e6ee67df 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 99d25aa5b9..9ff330969f 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 b774931f43..4bca2ee1b1 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 e069b161b1..13b037fb9e 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 29555927ed..799ccbd08e 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 c01f0248c3..95956e44ad 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 3738211360..c401e4c0bf 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 72c426ee59..78ffb51e49 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 d157e8b472..c7ff3cf447 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 7bf9941dd8..26ced15465 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 ec2643dcfe..0745a75666 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 e86d3dcb67..2339b92a16 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 64749bc499..cc6daf53aa 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 980959292e..e4f034283e 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 e92fa5ceed..c7abd1410b 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 90cd8e8c3e..77e0226be9 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 606002d680..b2a6a81517 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 8604733ef9..a9740af444 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 d3b8fcffc5..064773011b 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 9f6b108dbd..f35a1f63e6 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 d2323d6f17..c426770cb6 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 1430bba794..d12cec9472 100644 --- a/sysdeps/ieee754/float128/float128_private.h +++ b/sysdeps/ieee754/float128/float128_private.h @@ -142,7 +142,6 @@ #define libm_alias_ldouble_narrow(from, to) \ libm_alias_float128_narrow (from, to) -#include #undef USE_NEARBYINTL_BUILTIN #define USE_NEARBYINTL_BUILTIN USE_NEARBYINTF128_BUILTIN #undef USE_RINTL_BUILTIN diff --git a/sysdeps/ieee754/flt-32/e_sqrtf.c b/sysdeps/ieee754/flt-32/e_sqrtf.c index 0e29375786..e06a778eed 100644 --- a/sysdeps/ieee754/flt-32/e_sqrtf.c +++ b/sysdeps/ieee754/flt-32/e_sqrtf.c @@ -15,7 +15,6 @@ #include #include #include -#include float __ieee754_sqrtf(float x) diff --git a/sysdeps/ieee754/flt-32/s_ceilf.c b/sysdeps/ieee754/flt-32/s_ceilf.c index 0263552dee..4ff9fe3230 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 a5c38818f1..b0447d73da 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 dab8d22f67..7aba715a48 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 bb92acbc49..849735aa62 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 b027e7b9c2..29316e5787 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 079bc5d70b..a63fb7ba04 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 f31c53136a..50decf6657 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 965136bac9..b5dac7521d 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 5dd0e8f8af..162bcde906 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 fe5258ae61..32afd71e9a 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 2981f365a5..882b55787d 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 eb714e975e..746a7759f4 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 6b36e1d491..cef7c9168d 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 f363d2f898..5040a27325 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 d512d9a1e2..92b8352648 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 02eb663dd5..7c9d518fef 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 01ca556260..bf1b0664d2 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 17ad90ca31..ea253330b3 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 07f5aca347..d9283eab3e 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 59b08aa295..7927155cac 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 e5c0d5adb8..027400d137 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 d76d0155ad..8e2b5bd1fa 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 072ed8ec15..7badd06e85 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 ca3a5527cd..0f935f63dd 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 9a87a463e8..c5e70f33a8 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 2db087e85b..f4c6415521 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 7f26315e84..fabe08f0b3 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 9891bb3a02..19bcf089b3 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 06e97922aa..bc65da7429 100644 --- a/sysdeps/mips/fpu/math-use-builtins-fma.h +++ b/sysdeps/mips/fpu/math-use-builtins-fma.h @@ -19,7 +19,7 @@ ISA, double support can be subsetted. Only FMAF is enabled for this case. */ -#include +#include #if __mips_isa_rev >= 6 # ifdef __mips_single_float diff --git a/sysdeps/mips/math-use-builtins-ffs.h b/sysdeps/mips/math-use-builtins-ffs.h index 2ab6a03a16..4a3b432527 100644 --- a/sysdeps/mips/math-use-builtins-ffs.h +++ b/sysdeps/mips/math-use-builtins-ffs.h @@ -1,3 +1,3 @@ -#include +#include #define USE_FFS_BUILTIN (__mips_isa_rev >= 1) #define USE_FFSLL_BUILTIN (__mips_isa_rev >= 1) diff --git a/sysdeps/mips/sgidefs.h b/sysdeps/mips/sgidefs.h index a8b31905df..4656582782 100644 --- a/sysdeps/mips/sgidefs.h +++ b/sysdeps/mips/sgidefs.h @@ -24,6 +24,9 @@ #undef __ASM_SGIDEFS_H #define __ASM_SGIDEFS_H +#ifndef __mips_isa_rev +# define __mips_isa_rev 0 +#endif /* * And remove any damage it might have already done */ diff --git a/sysdeps/powerpc/fpu/e_sqrt.c b/sysdeps/powerpc/fpu/e_sqrt.c index 9bac5c2bbc..a65e818926 100644 --- a/sysdeps/powerpc/fpu/e_sqrt.c +++ b/sysdeps/powerpc/fpu/e_sqrt.c @@ -20,7 +20,6 @@ #include #include #include -#include double __ieee754_sqrt (double x) diff --git a/sysdeps/powerpc/fpu/e_sqrtf.c b/sysdeps/powerpc/fpu/e_sqrtf.c index 7c33904449..d29a9a7017 100644 --- a/sysdeps/powerpc/fpu/e_sqrtf.c +++ b/sysdeps/powerpc/fpu/e_sqrtf.c @@ -20,7 +20,6 @@ #include #include #include -#include float __ieee754_sqrtf (float x) diff --git a/sysdeps/unix/mips/sysdep.h b/sysdeps/unix/mips/sysdep.h index 5f7706b182..58e7aa2531 100644 --- a/sysdeps/unix/mips/sysdep.h +++ b/sysdeps/unix/mips/sysdep.h @@ -18,9 +18,6 @@ #include #include -#ifndef __mips_isa_rev -# define __mips_isa_rev 0 -#endif #ifdef __ASSEMBLER__ diff --git a/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c b/sysdeps/x86_64/fpu/multiarch/s_modf-avx.c index 0982280d25..9b8b951a97 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 f6fb996f97..1f77386336 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 b2afe1efe3..488f93700c 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 0352c3ea4b..8e49970ffc 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 Tue Oct 28 17:08:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122889 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 024873858435 for ; Tue, 28 Oct 2025 17:34:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 024873858435 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=CJA5qDKm X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id E42F03858C40 for ; Tue, 28 Oct 2025 17:12:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E42F03858C40 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 E42F03858C40 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671566; cv=none; b=ofa0UeEi0BiULCz/+gV0en7hl2enWhkVjZd0tL8aM4YjKGuzD36kqAy+txcwW5Clqm51IlGeMhwfgg57hFf1QWztkZsM4/Lfig1Q/O4KN83ZSFw/X5zs6Bh6rbx3oxDwb20NH92g5AeiRNT87S2va8z+6sag8sSPf1QvGBZ/Q1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671566; c=relaxed/simple; bh=GlNym32cYg8cbx6UHFm9kHQeit0R9MPtavYR8iM6TMQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DZ9WEbAa5oi3eadxloy5aLM1s0qXCsT5lcCDhyAr62599OZ2f4IMI/f5GIqFGK5buMnvUREndSHpj1vECAukhm8C0BrmrynbUjm1D1M+3GrEWr4aqb/686vW33qQEqB2TAo4rhX04TtUDjcbXWirXVfgmTRpBag1jEGLx+vBk3s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E42F03858C40 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-34029c5beabso1313669a91.1 for ; Tue, 28 Oct 2025 10:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671565; x=1762276365; 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=AxG5IXn93wNF2gevuTpcTBO68KZVEo+vnscsMcnIl2g=; b=CJA5qDKmXzxs/ygQQGIZiNj5OXy+5No51+rPk+22eiv0wUg0/+Y0CYyb56ql9ZWQhg jhU+DJXwSZPDMdcUoNUg1yMc8+Om1C4yJdkTY442QEOui/A8gLhBhHO5o2dgbt31vGXE T2rwgqediql29S6pfQzYVQwZghVc5FR90Wgot+t897wi2bqDsDkkG0H2KhWVhaZwU+3c h+qvCfrcVtanECzpHKm96V4kU/jy2SpL6ls08ucCS0vFazG4V6SnTtd4ZwvAiGLPiHiT 4pH8LfRlddkKO6zbKSG8Po96hWU1ITznaQoDIrUymc1wFl5222ypQUgqYvSLIYEx7U4I kCuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671565; x=1762276365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AxG5IXn93wNF2gevuTpcTBO68KZVEo+vnscsMcnIl2g=; b=SW9+EuIDjUcVbMWV8elh3Oq3Cm2IGtFne5xuwp7XfY/2OcKGkzuxdNHBwG1XwuS59S Pb+r5hWUAGiOLFQKq+X2H7GY8vciAODg9dSOItu1LabDZ92K8oHr7v4FM77zMvh1vkth hi1ujyf9W2aycgH6cG1cGUv08/kCuAEbE/4kHMawtM+EHqO1hdaR/Y+sKNEgO5Gar1Xt 2AGbnERtkhPe4gxv6C0zjzYnjw1LuJ4oLi8WbA0p5gyvKCkNyAiKquoDEWjqmGd6IRTF 3KkozpFRpnXYe1VJTByTpOoaKfNUS/8UWQ6AdK2NbC88cU8MHrPep9k6xfRmzHE6Uh6M hwMw== X-Gm-Message-State: AOJu0Yxpm10wHWdf5pW7D44PZXgZfPIp1/tJpzvddsPLKCEa6Yjk2IUt HXlcRhhMYMeMXLS5N5WWeFAdj4gXBFxJkQk7DzAs5e4+RPDhA58C8mjgj8NaO6Ep9GspI0vJiNm f9DHsAQ4= X-Gm-Gg: ASbGncsURPLgLMC85evQfDlTOnHxku7IemLt0rGm30C3C0Vq2TpJWFyrJmb5iXoEkZf DtyvH74nYsfSy/nM8+k19xtG66sOEuWtWjDsyQ4/RJnDP5Xr4NVuIY1i677i8E6paPJVR3ar23S PHx2PL/0AkZgjr6Gw2cJJRgI8xGQTx+V7un7Zx1NOlMdJQ/Z+ox371vzvw7EMl55ppH/GgwZ+Id umcPY/MfPmvCucycVJvwuekinaUwo1E3chW0v3mEGk4POaw9tiMc6nCbTG0NR28u/0Xcml4xTu4 4YcZcSlBGk1DZY4w+E3Hy8fFvt4WadK48aZkCJIS7PWiyllndCdB7A0gZcffdvZjEeEcykCnqpR 0YV7COWi7bhhXrucuzuXweKb7NdYRDo6KJDTYhCgEntjdNTjf9cQsEpjX8zgZrXqikX3vyqKe27 ILcBkSTyb+Cdt9jZphVrrnBGL2GDnQD3IP6I9IF+PLR4DlDg== X-Google-Smtp-Source: AGHT+IEIMAV7JHPeYVaKvWFpgtqp2ROdXkhX15EgsHIGIBslLHr5TKwz3AXMUWsNf2zhrYRGlqulXQ== X-Received: by 2002:a17:90b:4ace:b0:329:e4d1:c20f with SMTP id 98e67ed59e1d1-34027a04283mr4839774a91.9.1761671564639; Tue, 28 Oct 2025 10:12:44 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:42 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 10/28] argp: Expand argp_usage, _option_is_short, and _option_is_end Date: Tue, 28 Oct 2025 14:08:19 -0300 Message-ID: <20251028171141.3208834-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 argp code uses macro redefinitions to avoid duplicating static inline implementations for argp_usage, _option_is_short, and _option_is_end. However, this causes build issues with clang, as some function prototypes are redefined to add the hidden attribute with libc_hidden_proto. To avoid extensive changes to internal headers, just expand the function implementations and avoid the macro redefine tricks. --- argp/argp-xinl.c | 32 ++++++++++++++++++++++++-------- argp/argp.h | 10 +++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/argp/argp-xinl.c b/argp/argp-xinl.c index 37410c0eeb..49088bb851 100644 --- a/argp/argp-xinl.c +++ b/argp/argp-xinl.c @@ -25,19 +25,35 @@ # include #endif -#ifndef __USE_EXTERN_INLINES -# define __USE_EXTERN_INLINES 1 -#endif -#define ARGP_EI -#undef __OPTIMIZE__ -#define __OPTIMIZE__ 1 #include -/* Add weak aliases. */ -#if _LIBC - 0 && defined (weak_alias) +#ifdef _LIBC +void +__argp_usage (const struct argp_state *__state) +{ + __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); +} weak_alias (__argp_usage, argp_usage) + +int +__option_is_short (const struct argp_option *__opt) +{ + if (__opt->flags & OPTION_DOC) + return 0; + else + { + int __key = __opt->key; + return __key > 0 && __key <= UCHAR_MAX && isprint (__key); + } +} weak_alias (__option_is_short, _option_is_short) + +int +__option_is_end (const struct argp_option *__opt) +{ + return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; +} weak_alias (__option_is_end, _option_is_end) #endif diff --git a/argp/argp.h b/argp/argp.h index 4967c876a2..27391402fd 100644 --- a/argp/argp.h +++ b/argp/argp.h @@ -518,17 +518,13 @@ extern void *__argp_input (const struct argp *__restrict __argp, # define __option_is_end _option_is_end # endif -# ifndef ARGP_EI -# define ARGP_EI __extern_inline -# endif - -ARGP_EI void +__extern_inline void __argp_usage (const struct argp_state *__state) { __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE); } -ARGP_EI int +__extern_inline int __NTH (__option_is_short (const struct argp_option *__opt)) { if (__opt->flags & OPTION_DOC) @@ -540,7 +536,7 @@ __NTH (__option_is_short (const struct argp_option *__opt)) } } -ARGP_EI int +__extern_inline int __NTH (__option_is_end (const struct argp_option *__opt)) { return !__opt->key && !__opt->name && !__opt->doc && !__opt->group; From patchwork Tue Oct 28 17:08:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122869 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 580DE3858C20 for ; Tue, 28 Oct 2025 17:16:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 580DE3858C20 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=pe5WJ9Pb X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 2A996385828B for ; Tue, 28 Oct 2025 17:12:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A996385828B 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 2A996385828B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1036 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671569; cv=none; b=Pw5PsZNI3rC7ea339AAgJUUhTdFgE9Og1GNohKNgrktQKkWN3l9xR3lJ0vvXNKYHkHyo6BZCICevOSLJgesoLFl7/uihu1Da00Fp2BcgTViC50CAlwAZfnXZ6Odm7QSRn+wVyFAb/krkLg7gsKvO7H5Gd+wgyfySV2P6dgsMH5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671569; c=relaxed/simple; bh=G9GCS9Q1j3NHTNnhJIQdcMK6j1D+BfCL3C7A8ZETeAQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xbAdyPIk+WA9jV1TvrEM8wYo3sc1Xbu2NaqxZH/z6fgXJAyJgmwNr6UblgKEbEoyvZ9rSZQ02tJmDmOxKUdDePJjy0Kb+nCSXcXCKy14pKL2tguF94+Phim3Zo2ijeNr2sbA2cnpuv0AgqvUqFeIE3vYtXOpxCGekg+QnS5prZ4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A996385828B Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-33d7589774fso5995872a91.0 for ; Tue, 28 Oct 2025 10:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671568; x=1762276368; 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=9XQkD0zYkhT1hpOLEK94GgvVKbNCrzQhqlqFl8f7GaU=; b=pe5WJ9PbUeI1XPIsr20HQogQwnTGPiAR5SP9776WV1rsbYDRkDU7pnV9KyDlimw2GC 2MJYZMlMhcvJwk1pFh+1FVZX0/+YunKDlIZuKm618Qe1KYPh5PGUuejDQxwNKRBHHQd5 fYEeDzaA3iiw8zeUgkU4xHw5JkG7/mjht3e0qFGsD7p6hqx7yN1t4bg3VoECI5FJP8MV vLd42sIyeMWGZrijin47wnhyZciv0fLcX6aDh4trSQMJkydJJWnxRmFC2HFfyHLME9XF FfOZUKZhVxLfB8IgMsnafbF6XyYUk9CyF+4HeUNAAEv8SxHyZwovJbOXJ6WQ7SLx2RW9 4hEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671568; x=1762276368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9XQkD0zYkhT1hpOLEK94GgvVKbNCrzQhqlqFl8f7GaU=; b=d9LgNnqSzmL8W8HxP5/PF39OJ9FWYHc5A5Od3aQKa2WxhRLtHD/42OhxL/c/L6TZ1Q EmbF+jUgfWLSVGGo/BLV37g9Gr3I0QePPU5wYZ6TVlpYwv3p+9yDEGzvajQGv98sYPNl 6BD4xs/7pwMPS88WeQ5cPjRKsWWD7y9NpAuIjav7sh2BAxLbkZiWTlwM1fMDWm+YWgwI 2vzeL79RLkJ4q/Ws0Zh4CI/tQQHxv2LSLGwasO0OzPiQDM/ofTd2kfbzYiSX0Jrw825n dfUKQVG1Xp4fqopM/v07Z3K/MWYQXzHsSKDKzsGzgeBtyWFR/4RiaVoXU2Q7KiVclB+M Tapg== X-Gm-Message-State: AOJu0YzWV4uJ4w+LOR5eN2gyx47NUqEbtaf7LBLVQI41Osbm1xIvJonC iay7z1Hpd4pbwLqeaFASLR0WW3jL9CkJ47M1LBLGGyjA4R2xWlyTafR0qDAM8GhS8gy2KV1f3IN rpX0Ld8o= X-Gm-Gg: ASbGncuKL60VyEuI7It4aBNi+hIYLeV+mYGiOlYDqfictuufe4IimK8qQysG+/rjbl9 b1Y7QnQDCmMjKG4+rJnHxD4FDSIFKlHgh/13PrrF12oP/4VHxZMJ66+Xsh6Q0WRUtyzZdyzRUxs eiqsjYgct0wcrkTRL8FI9q8y2ndz37pJC8c9PXhUxsUXzkJOaQmfsuYQVpkQ+ick/MNqm47ZWQT 0gcfpik1Q0qGLt0FLl6yp+++vcXulc0xrZxVmmht6qb/vcZUKsaqVlgiGsrmLA4tlCFmVVigd8P sTthlchq6XLNuUeYVJPZthIu4+t/36l2DOmbKpcihlTSXqf8wGvPXNUe4nV78S2uxLOSu4FiDZ/ N+fvpTjMJ0DZvyULXUTPboe8/3wySmg4/23KeyqyGmhjKEkbm4MB3I4G3jVcw1A2uWYuaiZkn6a /JylRF6dNUUd/Q6/7DU/q0cQ6Kr3xq0/Ak4tHSOTsq9xN+79MC+pfo+hg0 X-Google-Smtp-Source: AGHT+IEklgc7CoD6Gz3ubiNmtyetMyeEPMMvGVQY3C+JIxo7C4kC7VWY4hb0HErluuzVLjjgZKmu6Q== X-Received: by 2002:a17:90b:3811:b0:33b:b308:7659 with SMTP id 98e67ed59e1d1-34027ab32admr5441165a91.36.1761671567682; Tue, 28 Oct 2025 10:12:47 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:46 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 11/28] argp: Move attribute_hidden to argp-fmtstream.h Date: Tue, 28 Oct 2025 14:08:20 -0300 Message-ID: <20251028171141.3208834-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 internal header redefines the some internal argp functions with attribute_hidden, which triggers clang warning of mismatched attributes. --- argp/Makefile | 7 +++---- argp/argp-fmtstream.h | 18 ++++++++++++------ include/argp-fmtstream.h | 18 ------------------ 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/argp/Makefile b/argp/Makefile index 01eb6b6db8..65d917ad14 100644 --- a/argp/Makefile +++ b/argp/Makefile @@ -47,10 +47,9 @@ tests = \ tst-ldbl-argp \ # tests -CFLAGS-argp-help.c += $(uses-callbacks) -fexceptions $(config-cflags-wno-ignored-attributes) -CFLAGS-argp-parse.c += $(uses-callbacks) $(config-cflags-wno-ignored-attributes) -CFLAGS-argp-fmtstream.c += -fexceptions $(config-cflags-wno-ignored-attributes) -CFLAGS-argp-fs-xinl.c += $(config-cflags-wno-ignored-attributes) +CFLAGS-argp-help.c += $(uses-callbacks) -fexceptions +CFLAGS-argp-parse.c += $(uses-callbacks) +CFLAGS-argp-fmtstream.c += -fexceptions bug-argp1-ARGS = -- --help bug-argp2-ARGS = -- -d 111 --dstaddr 222 -p 333 --peer 444 diff --git a/argp/argp-fmtstream.h b/argp/argp-fmtstream.h index 64d3c0abd5..4e52953f42 100644 --- a/argp/argp-fmtstream.h +++ b/argp/argp-fmtstream.h @@ -107,19 +107,22 @@ __BEGIN_DECLS extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream, size_t __lmargin, size_t __rmargin, - ssize_t __wmargin); + ssize_t __wmargin) + attribute_hidden; extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream, size_t __lmargin, size_t __rmargin, ssize_t __wmargin); /* Flush __FS to its stream, and free it (but don't close the stream). */ -extern void __argp_fmtstream_free (argp_fmtstream_t __fs); +extern void __argp_fmtstream_free (argp_fmtstream_t __fs) + attribute_hidden; extern void argp_fmtstream_free (argp_fmtstream_t __fs); extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs, const char *__fmt, ...) - __attribute__ ((__format__ (printf, 2, 3))); + __attribute__ ((__format__ (printf, 2, 3))) + attribute_hidden; extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs, const char *__fmt, ...) __attribute__ ((__format__ (printf, 2, 3))); @@ -131,7 +134,8 @@ extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str); extern int argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str); extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs, - const char *__str, size_t __len); + const char *__str, size_t __len) + attribute_hidden; extern size_t argp_fmtstream_write (argp_fmtstream_t __fs, const char *__str, size_t __len); @@ -167,9 +171,11 @@ extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs); /* Internal routines. */ extern void _argp_fmtstream_update (argp_fmtstream_t __fs); -extern void __argp_fmtstream_update (argp_fmtstream_t __fs); +extern void __argp_fmtstream_update (argp_fmtstream_t __fs) + attribute_hidden; extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount); -extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount); +extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount) + attribute_hidden; #ifdef __OPTIMIZE__ /* Inline versions of above routines. */ diff --git a/include/argp-fmtstream.h b/include/argp-fmtstream.h index 45c65ce834..69cde22d18 100644 --- a/include/argp-fmtstream.h +++ b/include/argp-fmtstream.h @@ -1,19 +1 @@ -#ifndef _ARGP_FMTSTREAM_H #include - -#ifndef _ISOMAC -extern __typeof (__argp_fmtstream_ensure) __argp_fmtstream_ensure - attribute_hidden; -extern __typeof (__argp_fmtstream_free) __argp_fmtstream_free - attribute_hidden; -extern __typeof (__argp_fmtstream_printf) __argp_fmtstream_printf - attribute_hidden; -extern __typeof (__argp_fmtstream_update) __argp_fmtstream_update - attribute_hidden; -extern __typeof (__argp_fmtstream_write) __argp_fmtstream_write - attribute_hidden; -extern __typeof (__argp_make_fmtstream) __argp_make_fmtstream - attribute_hidden; -#endif - -#endif From patchwork Tue Oct 28 17:08:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122877 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 062F03858417 for ; Tue, 28 Oct 2025 17:23:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 062F03858417 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=F3AsYhpL X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 21FAE3858407 for ; Tue, 28 Oct 2025 17:12:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21FAE3858407 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 21FAE3858407 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1035 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671573; cv=none; b=fMz7GRFI5UshYlneC0xXNs2ypTE0jpSh/7e4RZya3U/VS760zb0jRIVUyHmnA4u8mo23xYtUTWLKwnqle5b/qNEHMOfpETGkfR2ZSIKfJDzW5RA1VBuOz4Su3yKshx2tZyAQ66IVI32gqyvlXgb3+9VHEth7/8KjfmzFpDkvP+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671573; c=relaxed/simple; bh=+1wqDp0rq4zW7yceGWXUbesnDCMz8eaeR+/CW2l32yg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tgnavDgOT93LoaQaX3qbyW7iiPyEH1KOb/b5hHO1tXQ7YX24eVIFOtJlPDwWM8BDbkxTMFMMsvJGttBOJcZQ9jkfSDZslB1kXdfkQU9b/P/vp9QL2tG36qMnUzuishR1IgAtobN9NDCCnkmzuIPjwORnaH9HEu99sHgG7YfyCqA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21FAE3858407 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-33f9aec69b6so8578399a91.1 for ; Tue, 28 Oct 2025 10:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671572; x=1762276372; 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=saTMacaHQs+OqZp+sGYUW6rw8ovd754Sf5l3ZvrhRvM=; b=F3AsYhpLdDuMuKpL8YeGRzKg8qgAlHAk7zbfZvAC4IEqtDz7ka0Fd2B3o99C8YSCSJ UAGgSleEfYEe7tmlP2aOaQKQfxLGkBTjvLzLosmXW3AFqVX+elvE3tN+64oy/Krn0CCV XRHpQSukn/DLAdhVVcd9mZoZQLbNNRqZKv49lRzwgeUBsJbTa+zszjnobL1NiadpTAm9 t/tL6VH96cM56T2c1LqxjO3BURlQpmGNvvIsaiKIUEwizene3gbnhGL77Fggh/B+ISXY Xrxhk5ZAGhurKZcon/93fuV7yrbSVewfc5mjJEq/b+G/TOyRzpsE28ZR5Rjo9ee1T5cC T3dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671572; x=1762276372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=saTMacaHQs+OqZp+sGYUW6rw8ovd754Sf5l3ZvrhRvM=; b=qkUBoD9H2ae0uPsGmCTIScFyJQT83jQS5CC+1hEaxJNNoBThMjAISWn9sExhYsbIao 6ET+YvB4NuwVuWYaVzOavQrAw3twvrlzrjkvenyNOBWFYZ4UWw9w771mW7LpEcpuinsg ac5k4OpZ4nEeS7o3TeOwKeqXhv0fhi65QKQRPv2MFtV14+AZK1DXleklrhLHaj9FOSXN vMx9iZjXW6254Enle9jxHBEM8D7+h8YVSuZLhsqBLobm6ZvbAXFAMJiyW3LA/mlF+vuc VZkqGVFlOkXEvvqEelfgNStvAGuCz7LWeHqcHsstY4F6FrzYFL5xcgmewUcDiXktc+yb /UmA== X-Gm-Message-State: AOJu0YxbSecDbwFN/6h7lw3hIZQw7tD6FCm+yrafKFJRl2EKWwk61Jv3 TmFxLpucmpgXI/ssXVBLKYOjQXG3zIk7yZ4vsGagDoQu5GI2hgksI333JMdQRo7M9HclB8vLX94 lrTx2PRU= X-Gm-Gg: ASbGncsgAIS8gOfgG3nAquGYikyYq0PqrFW+jb3qzSHmtyT2desftubGX0ihzoDNC7B 6FFE4z3dtqNCtwi8rFhuKVIK/7P7DYOf9JkbXlREaJCzd0Ml1cSM/Vfrr6TreZlOvn48AgpV8hJ yBSthmNLAJ6KbCTBDKv+Jnb51SItn+rfnpgEKhYm2Kqv0Sdv2LfdO0O1YpPSFyk6m26355dkBUD 1vM41b5hZUan19AYKFk4/MG4isSS/vR1lsJqtIm0+3y06y/J/y60JWxUR/TiX9DdSKy4klAMNz6 2oJGMzrl7eq5JCr/rsCOl9qOaQFFMpqJ4x2hAy3E2Rns9E4/29j6B8RqTNyKYiZSyuSzteR0JR9 Mu7B/e3GZkJM15ED294onok0pOUMKGvL7qN3v2NTUTxs6KLIcDaQPDXaF2aVi/la12w3l7wK3sh z4xAVX/9Lz93gsVxO8kOXehIJ7Pkpq3pgkTXtuiQDmu0OVJg== X-Google-Smtp-Source: AGHT+IHDz8tQz8vpAhatQInyvSrF/5vQb/NVihlqvUqHIrS22tpPCxVAwiiz9PepkYfPKl3urtVfCA== X-Received: by 2002:a17:90b:58ae:b0:340:2a16:9b4a with SMTP id 98e67ed59e1d1-3402a169bdfmr3136418a91.6.1761671571153; Tue, 28 Oct 2025 10:12:51 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:49 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 12/28] Handle clang -Wignored-attributes on weak aliases Date: Tue, 28 Oct 2025 14:08:21 -0300 Message-ID: <20251028171141.3208834-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 15b44842ae..e40dcbbc78 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 85bfeec8a9..122020db69 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 2cb49f49bc..14a0f2dee8 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 f469b7f25d..242fd4941a 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 2f9453e0d7..5bee0c4311 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 104b5828bf..a572936086 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 df99e4a23d..f7f39fe395 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 435f5a994f..0810c0aa04 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 04d196eee0..e5f297e39e 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 c490730d1f..354665cea8 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 6ce669e103..2bc9836522 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 4d2babe362..36a1e5b628 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 0e19e0c198..d81facfac4 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 d1e945f549..d580582b4d 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 cfd052d7c2..ea57c7d049 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 3683c93e15..6165493c31 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 cd9e4afd80..5690db5a44 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 b9ac6b9640..86e6ca55b7 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 0a7e0b4b3e..f90830f751 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 b283f488e8..dc4bd55514 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 7897c4afaf..c88c91a4d4 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 8baf502185..3e57e319d0 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 609ef42b6a..d8f1562eb4 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 d6a9a6975e..e6b5a1fff4 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 e792d94ebd..d6514ca5d3 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 e7a0029f1d..3ad6dcb0aa 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 f6421e5379..062e7fdc20 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 415905b269..1f41e14193 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 011e92fc1d..dfd413051e 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 ebb06cb14a..d294c3f3fc 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 5307a5b243..901bc3fb54 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 9b4998107f..55982ebeed 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 70fd4138b9..bc39579682 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 da337cb4e1..806e4cec3a 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 4af922fc2b..f10bcf3e05 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -535,18 +535,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 a2408a304f..b16efcb40e 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 d00a336589..3988049f7e 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 2ec5f576cf..966db79725 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 155bfe166d..5b4e9d1cd9 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 d842ae0457..2f30e66df5 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 aac67a9d1c..be567cf573 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 dd2c8182db..ca45ca8ae9 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 a2aa5b1242..7010059833 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 1b01d8fb12..6794de1c2a 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 8d9b7d196e..febb50b605 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 efbc9d42f1..1199f124ed 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 aaf9a6db29..fbfcd4d17d 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 765d69ecc2..8ea4335ac0 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 03a8969e54..2b85fc421a 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 acb1c055fc..29d291e66f 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 9479fb9679..2de7a4cfe9 100644 --- a/sysdeps/aarch64/Makefile +++ b/sysdeps/aarch64/Makefile @@ -66,7 +66,6 @@ endif ifeq ($(subdir),math) CPPFLAGS += -I../soft-fp -CFLAGS-feupdateenv.c += $(config-cflags-wno-ignored-attributes) endif ifeq ($(subdir),misc) diff --git a/sysdeps/aarch64/fpu/fclrexcpt.c b/sysdeps/aarch64/fpu/fclrexcpt.c index 21eb731e29..9f6fc8dd03 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 eb8117c61d..76f68e77ef 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 d6758c9879..f5db20165f 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 79ae5494c6..f1d6ef54e7 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 6a0df368c8..9c1d2114d0 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 cd0c3bcfed..f00437ab5b 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 4690e84f21..6117a46443 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 518a6eb321..9440339c93 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 f057616f7f..46150510da 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 9c4fd6b236..d08dade3c5 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 fbd2c82e2f..0a14c723ca 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 38d41d04de..f99a348624 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 79ba47c3fd..2c1f277653 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 64f14c11c7..3366040c77 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 c721ddc696..ae6f87b44c 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 d0bfe0da43..7ca044c213 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 18d6b329c2..404fcbbbb6 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 410b1c0bcb..1cf84ff6ec 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 d60dc2ef11..dab24198fb 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 1c637c666b..0f6b8b6a5f 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 1861b18eee..9682e4a070 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 f03ecd4da9..d9ec274522 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 8500fe366a..092eaea3e7 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 5d137598f0..601c5a2c11 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 ddc4be78ee..ca7f2a3918 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 49f4136844..f921bba9b0 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 e202356efe..6bf4b0ab7f 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 5fbf14b4be..8db26c21ab 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 c1388b03bd..aeccaa5962 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 cb2f22e319..3ec3acdf13 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 24ee8f74e4..64a7245beb 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 68cdd4069d..84404be4d3 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 dd40926e76..f6c4d31451 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 6a84d0f863..c1efde12d6 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 a21fa8da10..cd99cb22fd 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 60c82b89d9..00e83d2c38 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 557c763941..ba8796b9b9 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 9b48ca6ab2..f7a03871b6 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 86b4228f2f..d5f70458c0 100644 --- a/sysdeps/x86_64/fpu/fclrexcpt.c +++ b/sysdeps/x86_64/fpu/fclrexcpt.c @@ -50,5 +50,5 @@ __feclearexcept (int excepts) return 0; } libm_hidden_def (__feclearexcept) -weak_alias (__feclearexcept, feclearexcept) +static_weak_alias (__feclearexcept, feclearexcept) libm_hidden_def (feclearexcept) diff --git a/sysdeps/x86_64/fpu/fegetenv.c b/sysdeps/x86_64/fpu/fegetenv.c index eea9d6bee7..fa21ec4f86 100644 --- a/sysdeps/x86_64/fpu/fegetenv.c +++ b/sysdeps/x86_64/fpu/fegetenv.c @@ -31,5 +31,5 @@ __fegetenv (fenv_t *envp) return 0; } libm_hidden_def (__fegetenv) -weak_alias (__fegetenv, fegetenv) +static_weak_alias (__fegetenv, fegetenv) libm_hidden_weak (fegetenv) diff --git a/sysdeps/x86_64/fpu/fegetround.c b/sysdeps/x86_64/fpu/fegetround.c index 9537cd3142..a7fc1a8870 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 9a22a2ea77..30e3120596 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 e4e721afff..a7b87efcde 100644 --- a/sysdeps/x86_64/fpu/fesetenv.c +++ b/sysdeps/x86_64/fpu/fesetenv.c @@ -110,5 +110,5 @@ __fesetenv (const fenv_t *envp) return 0; } libm_hidden_def (__fesetenv) -weak_alias (__fesetenv, fesetenv) +static_weak_alias (__fesetenv, fesetenv) libm_hidden_weak (fesetenv) diff --git a/sysdeps/x86_64/fpu/fesetround.c b/sysdeps/x86_64/fpu/fesetround.c index e1ffb3b7a9..8a5f6c425c 100644 --- a/sysdeps/x86_64/fpu/fesetround.c +++ b/sysdeps/x86_64/fpu/fesetround.c @@ -44,5 +44,5 @@ __fesetround (int round) return 0; } libm_hidden_def (__fesetround) -weak_alias (__fesetround, fesetround) +static_weak_alias (__fesetround, fesetround) libm_hidden_weak (fesetround) diff --git a/sysdeps/x86_64/fpu/fraiseexcpt.c b/sysdeps/x86_64/fpu/fraiseexcpt.c index da3a31f4c2..dae0c3bc31 100644 --- a/sysdeps/x86_64/fpu/fraiseexcpt.c +++ b/sysdeps/x86_64/fpu/fraiseexcpt.c @@ -117,5 +117,5 @@ __feraiseexcept (int excepts) return 0; } libm_hidden_def (__feraiseexcept) -weak_alias (__feraiseexcept, feraiseexcept) +static_weak_alias (__feraiseexcept, feraiseexcept) libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/x86_64/fpu/ftestexcept.c b/sysdeps/x86_64/fpu/ftestexcept.c index 39df30fbd2..7e0a097696 100644 --- a/sysdeps/x86_64/fpu/ftestexcept.c +++ b/sysdeps/x86_64/fpu/ftestexcept.c @@ -31,5 +31,5 @@ __fetestexcept (int excepts) return (temp | mxscr) & excepts & FE_ALL_EXCEPT; } libm_hidden_def (__fetestexcept) -weak_alias (__fetestexcept, fetestexcept) +static_weak_alias (__fetestexcept, fetestexcept) libm_hidden_def (fetestexcept) diff --git a/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c b/sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c index 7bb1749a28..4b0c825fc5 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 1361b79e51..890b149ec2 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 5d60cd0548..4514eedcd1 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 ba5297e7c3..cc67b425be 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 df027e314e..5b084e78f7 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 6444ca1d80..0b0bd977de 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 3df2367f93..5a10cccde1 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 bba610394c..b5bee75f38 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 0169f2ac54..096633b7ac 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 1e23608255..0308bacf74 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 3e010d2c15..55b8b690ca 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 86d496ca65..6769bab478 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 559438c1ce..383cf43a07 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 47068ed0e0..ce8f6045b1 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 d4ce187781..19788ffbb5 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 6bd3ad9ddf..f64f6baac4 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 a5403581a3..e78874d302 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 3441ece2b2..517a22b06b 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 4708594d84..cdcf3b2328 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 49f9ed2157..0d078609a5 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 Tue Oct 28 17:08:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122874 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 717333858C60 for ; Tue, 28 Oct 2025 17:20:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 717333858C60 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=AvEJBEC2 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 7E0F23858C25 for ; Tue, 28 Oct 2025 17:12:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E0F23858C25 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 7E0F23858C25 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::433 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671575; cv=none; b=flFCC+IfaZ5XvrwrqgClpvWzCMkixM4KHjf/j/qqUJitD4eC9rtmuWVImtt6GvJDT5r5STdqTWx4C8X9klRMPeLQ0Sry3/oaXsxhiCYb8u6/yLt9bUt7AwbXbKDtWhmLzNjBRs9pUDiRqiXehvvzTnVQPKByQ9cPxFsaj0oR6+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671575; c=relaxed/simple; bh=jw57ErOa+j62wmZ4tOZr9PlrkpIOx7CbPgpMMs3LmG8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RVwaLrq91ZoDEpM6zwDGVEWyuy3HKVbsZD4XfaLnCwDb9Ur4RqmcvGkWtPy1SKtWZBfcyuexk7wuoFcWT3VyrsGOB0ERAINvwYP6msd4I4cqHIGtUHaatwyB6xjJ5HBlY3ESSvU+t/n+vYe0vgPoIIvOmT5KrkF4J5NzCWTCrRU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E0F23858C25 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-7a26ea3bf76so8238371b3a.2 for ; Tue, 28 Oct 2025 10:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671574; x=1762276374; 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=KbFHpQFvMNH7Tq5X2hIWcIgdwR0J7ZSE8Qr9cYZUyt0=; b=AvEJBEC2Pocug5gK7s7jHIkf0aWGw8Z934rooaNCleOgNdOGjcuBiV+wPSKxpXw+Bg YdrGfHviT+WeV/Fq4IC3Ch4Ak6qjBKU6ces+Z/OVgDo0WLOQLunHrGto4YUVwXdkCjdS LOdwiPY+OjC4dV1YZGj075nElLMP2rN/nc60sveOCwK2nCazNRr1vwrVU8YtvLQsYEwn ayJ26/LViKa1SvNWw2RXKrxBg+jM/Lut8tX6p9wKObkfYdDJx6gBfOycLRVSVLXtLUAa VUryRjcjO3jvTjtaMz1YA5tJTzL48FKu1I8Mp7TFTXKZ/F7RctALyYoPSKt1m+a4ZC0x v4zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671574; x=1762276374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KbFHpQFvMNH7Tq5X2hIWcIgdwR0J7ZSE8Qr9cYZUyt0=; b=roBEYKysLl5v8Njl1c2N1yEfoVLK74/9XzuM5yEncQVgny00Y23q3GiZr6THyItioN YcqFdM1Q7JqS+hCuJ8vxQHgEOSO5omDdBr+P5/gIe3KHdmLucJvmfKeZfDGzqCunHBbt pU9FyMX97qoio+3HvWzXPGzx/0TnkZiEbe7vzUZJ4L7aVxwESkArUCvr17qItfYlBoR6 c0iOpTQUMAmeWI3gtw+vwM+R7jMI9Z0prn68gtHf7z5HpoaCKlhkLIbt8QEN0d8HuPfs dgYOz337RngszWRoZZJENts4rO7kSD7T3cLSTPaSfQor4x1cw14nFe6FFi2ya0Gj0ZZI 5xvw== X-Gm-Message-State: AOJu0YwquFWf/A0JSkISdqxTaawh4eq4qKti9Q4KfxY+h+OO+UYCKQSV 6kVgfl08O9fdJE8Ku9RpCs6wYxrvqLqOadgyEADS1evMAvC2X7YVMuOKm+8T3q5fJjsgDAhDAgE kLu3d1AY= X-Gm-Gg: ASbGncsOo7nGKraLvcX5YM3jBMp7bsNw6sMPv+FyCuOhv7vOtBjhfx2abw5MoEpbkyL 79Eh15z31hkmGpJ0AAuf5xeLc8vPrqMK8YtrCn1vSqoNnU+oouv476X7+DbErKePuxsBASX6vlr j9no/EniUX131NxQAXU3OvjmsxqKR5B82zF3paDYm1uNhItUbOjfxW4Gn3l2oCewMZ2/CO+ONuv 6iS4V7bgRAtaZ7N297/nqnGkOObB5VVjksJN7vNw5Ni6LY322yMjFClz8N0KxZhYJB+fXhHTEFQ OmF/BO+rDkrg8HNoAEa135FgpblvFWYgMWbu3Mr/RUcAZL0pwvbAP6Hepfo5dG/3M9KlOqsJf37 QseBhvrZboMuZOHkQ0szynPyy7ScG1xXaxBYwVoF26ZQPdm87MWbme0Yd4X9ulWXLF7rmrcG9Hb +S9W4fRQchbQv6ta6tobtlUYxwylpd8DdELfvACo3neXEQwOHrkUOYB+Xu X-Google-Smtp-Source: AGHT+IHrA+EVfq/Cgu58TtlcQOOgTGGa92oKpx0uXNOMUrXAmTGfAs4C5fYPrjpDx+CiK/MOvcJ5bg== X-Received: by 2002:a17:902:d4c7:b0:262:cd8c:bfa8 with SMTP id d9443c01a7336-294cb525612mr49419385ad.34.1761671574026; Tue, 28 Oct 2025 10:12:54 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:53 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 13/28] nss: Suppress clang -Wstring-plus-int on __nss_shlib_revision definition Date: Tue, 28 Oct 2025 14:08:22 -0300 Message-ID: <20251028171141.3208834-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org clang issues an warning that adding 'unsigned long' to a string does not append to the string. --- nss/nss_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nss/nss_module.c b/nss/nss_module.c index 3cd1940b22..ac94e4d3f0 100644 --- a/nss/nss_module.c +++ b/nss/nss_module.c @@ -41,7 +41,7 @@ pointer manipulation. The "-1" accounts for the trailing NUL included in the sizeof. */ static const char *const __nss_shlib_revision - = LIBNSS_FILES_SO + sizeof("libnss_files.so") - 1; + = &LIBNSS_FILES_SO[sizeof("libnss_files.so") - 1]; /* A single-linked list used to implement a mapping from service names to NSS modules. (Most systems only use five or so modules, so a From patchwork Tue Oct 28 17:08:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122881 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 45A623858412 for ; Tue, 28 Oct 2025 17:27:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45A623858412 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=li2IqVOx X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 50F5A3858417 for ; Tue, 28 Oct 2025 17:12:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50F5A3858417 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 50F5A3858417 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671578; cv=none; b=aWmaibevF7AgxBUsw9GyPNFJMuqpqSS5t8svSLG99AZk7ReKFqfmOYuK8PB/Mm1vvCKZYMywsHZvhw8DMFol8FlPt0vrsPWOlomyC5dQ/srrM9rj++a437xqEz9aX6L5uherfKbek+B/mzMjpZvLvPV4ert+COUmnTxK3iXj0lQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671578; c=relaxed/simple; bh=xLR0Fh4d2OZwFojKiOu8abI2X4GRvAwhcq0l0GtPM2E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Th1jCNG+6gO6siF/gxXRrnWeYPyg1u518WXiLmwmQ5aHObQJKv8+yk13qXI11YZ1U2Cbd9nQGImaSeM1IpZ+9GgGMmCIPRtxR9qyiIoY54J2bVvZFoX7wvukHgBBVNEuHqO7O/49E2SjHcPMYCHuDZst/KbYiLOhHVehV1U4gI0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50F5A3858417 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-7a26ea3bf76so8238447b3a.2 for ; Tue, 28 Oct 2025 10:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671577; x=1762276377; 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=CwSRuBPGOliAujcqeSaVKdbH/Vphlj8vIlmjTme1QDs=; b=li2IqVOxUrKLJP8vTIhPBJ2NBrbBI80zX/C3KlJMuwkNASFT2VbtbPXtVvA06SN37T LvBxNoy37uCBbxaRyoOaYL5CugJjHArPDBmpbAqoGNfbROutrk2WuIRmafPoepHL7vDj 60oYsDcIfPlRL0TFf4JPy9IBV0kADCN4BWi43P89+diwUCBOcFi3SotUCDgK2vC1P79q 7U8hMlvrx8mirIzY7sPYKT5+GGpyezxOPSGADdJIuwH5fn/RQVbY99SPICCKvhS+Dq6n 91xpy0c2R40Kyxg4ZGkvvCRgdSkdR0b9k6Jjs4MF4Uqi6M0OlAR5sR2yEyh42aoOmc7/ gAnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671577; x=1762276377; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CwSRuBPGOliAujcqeSaVKdbH/Vphlj8vIlmjTme1QDs=; b=iS0La2c/oh6c8+26C29sVjQERxWzBiREBMMt4SiNtVdbkHmSxoOqjIzeqr9ZY5WKeR JvTGH93cZqTxEkz6bU6VUvUE4W9jW99U1cyI5XSbWHrayT0y9aHmtQT9+TgkBlimCOev ec5pTl3SXRGxwivvOUfimh8Igzn3q0V1QrxXLM1GDek5lm3QV5Yb//twN5moQfSXiYOe R74g9CeqFA96HkK6hyiZIdmyFMgu3uBuGOK/BayeDxxrIy7kEiRkF2Ys3mO+uaaTb5iI ALBrLfkO45z4fQ+mX4OfMa8p+YxUQIoz4jDJFtMoLS1iCFGvd+F/1KtuYyvSIzGYX+1G w/Lg== X-Gm-Message-State: AOJu0Yy+aPBUf/o7HSts/0mVDUe0ad1ywAHKrY7vErnHxFm+enQHXhyA tDX24K6kLClGz1ZZLJ9W9NjXxVFnJWtOCe980f/hKXNRojRrmVf0aswudMhMj/+we1ib7NGMmy7 oP+lm2MQ= X-Gm-Gg: ASbGncvrWWCYTwS29xUt0U/bV84j20CUM26hnZf/1Im13WPTA5xeCALY5Bk6qqpNF+h 3n8BZpV4CdUHXTwWvorK2Ts5lIXichhOZUIUSgvVlh4xYZVCSaeFAzo1eTnVFs7xoGB3rl9cquh QgZLaW0IkWMtMpO0RlvNstzdEefhYOXsx5g4zu3n4e++EKYVJzGGty6Xa0j8/+BgjuXUkxJheTQ 9WJ6trRLwsKKzTVP//VsrVSSieL425kUETU1V7QxQ13/tDrRWbMpqI9rqTI62QV0wGO28tFxH4I jzSfzsBxgtJgeWKbwzkzdbn7diP7gzTvEux4nvNgI688erx5G8xxOTPCGCdZWfI6Whn+xtsXx1L iap7Va4G/se0N8WmQn+p+jmFC1dtV98J3OYTH1qv/R1goiUT5c+UXw2zLfeTuoR6I/OJnwwj8Vs 4kvVIZdlAkHylvNvVhuuCFa5d+8D4mkONLXh6LEcnf98w/Hr5SutMnoo59 X-Google-Smtp-Source: AGHT+IEfwf/4yULTWRejuzPt8on/XFYtoJwNOCBrlK4Wu5y80eXlayisKEAq2XMxnfwAp2UbIRuPDg== X-Received: by 2002:a05:6a20:914e:b0:344:c5d5:31bb with SMTP id adf61e73a8af0-344d296a7a4mr6508232637.25.1761671577087; Tue, 28 Oct 2025 10:12:57 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:56 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 14/28] string: Use asm alias instead of symbol redirections for stpcpy and mempcpy Date: Tue, 28 Oct 2025 14:08:23 -0300 Message-ID: <20251028171141.3208834-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 Commit 939da411433 added symbols redirections to handle ISO C namespace, however clang do not support to redeclare the function prototype. This patch replaces the symbol redirections by direct asm aliases, as done to handle libcall generation done by compiler on some loop optimizations. Checked on all affected ABIs. --- include/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/string.h b/include/string.h index c26ca0927c..2ea212a401 100644 --- a/include/string.h +++ b/include/string.h @@ -188,8 +188,8 @@ extern __typeof (strsep) strsep attribute_hidden; && !defined NO_MEMPCPY_STPCPY_REDIRECT /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call __mempcpy and __stpcpy if not inlined. */ -extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy"); -extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy"); +__asm__ ("mempcpy = __mempcpy"); +__asm__ ("stpcpy = __stpcpy"); #endif extern void *__memcpy_chk (void *__restrict __dest, From patchwork Tue Oct 28 17:08:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122880 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 435E2385843D for ; Tue, 28 Oct 2025 17:27:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 435E2385843D 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=cK17JscD X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 5E169385840E for ; Tue, 28 Oct 2025 17:13:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E169385840E 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 5E169385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671581; cv=none; b=SR5r6tO0HEGUYkgPOxzJ8TYZNxjxYztCCS6h/SEx3yNMh2Jwx4rYAyWRYib7y3bQzh3gl31j4C6E8j0xmCfmJm/wQg/0NoVTkW5RybDYI1AzX0099LrxS0SAAxHCV9EfWD1dht6CGHjXV2HcCJqikqo645mb8ndWyxNrHHKw0mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671581; c=relaxed/simple; bh=cXO+X5mRB+TnfGZodEApabff8IjoGZjyYVncmak/JNA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BzWQ+k09k0fTOk5XfZbXBIB1JwDE86XNg0938KVjp6Jw0C4TYmrZEIP5s09UyG1S1WDxk0MkMMCj4kzYOn4fszUM/+1Zqj83tveKZGEpiI3xNC4WNCVM+Y3oXcR9GwXIEvjBThYdKQH9iMO6DwLCvBpN03KTWtnr9jlKdhN1iU4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E169385840E Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-33b9dc8d517so5912166a91.0 for ; Tue, 28 Oct 2025 10:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671580; x=1762276380; 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=0R0WiZy2rTK1mJf8AXOdd9T4b6JiC0JcLwnrxujy66Y=; b=cK17JscDgJnGKYNTN9j4s+QQjvdtHPuOWeO4nTHoYP/P5kZ40POyHuCpwnkQpH8Mci BGLu+S7OSg2ThrfpasPAlfAqAOcSXsoOpKRlicUJPZ+CA4z8zuRXtmjei9A0YQEtFKQ0 y5SDYCKK4rCJXyFxuqHEwDhMGSf5iYR2KYb2f+zXW7CVmlQDxr9ARXf+rWuFILsw34MV Jm/Rf0dp1Jv54+qM71m+I5jzQP6fBS9c6rnEaKH7//BVQuQIRpac8mDDuGcAXMdlLPbd pyRp2wbDdCoJgZGPUt+7RgSYJ81epcwulkHhRaYJyn5WkVNbIaOoXjPJLkScMtqLh8gM pPCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671580; x=1762276380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0R0WiZy2rTK1mJf8AXOdd9T4b6JiC0JcLwnrxujy66Y=; b=hZhpIG/AK7eXpXzBaeZGWlnIeShE6nN2ki0BMZuBFH3rg3HTgjGPedLXkOrFLeHBJm TKs2CzMO8D3EGY+EyrgmBT5XkEPg+dBUJUGln8RmgeNC2DEhDimdzHmtV1ubQzIuYv9a VYna46bx2eD+4lsddwjFz3IaCg9s17+Caef0faU2DVXH1ibz+06FNP46OZOlC2z5cqDD JodoaaCwxHZF81x6JiR3t6F3EL+flty2UJH8nG9pq7MmDzaiBflTmEqHzA5zdCXEbn6G 01nXzNOlncyvCJf1fS8VQbWrQE+br0k2yGZ5EQ37+Jj26S8kAziN2z9ekkiXPJUKeqCm sapQ== X-Gm-Message-State: AOJu0YxgEuo/JjuZd4qBrafaXZDv+Y/94cskBVUPvS5R2IBh7I6wDRgl bndRogIHupzKu7sUTnWSfy0bO9FsOpNlOqgsEInz3ME25m4PHWq1ODk82pqISvBT8dPUZb9qi4t IMGavMVY= X-Gm-Gg: ASbGnctvcdZWcpJMk5/RSEZI5lyv58nGhcLT4EA/7DFS5k5tfur9YJNI/qo1+a+C0wm 4rmaHdzUNwH2wVtSrwDjWOaur31YVrfglgcuwaBlO/MQA8HnWN7zZfEVZJBVNRHrpi3Zc05nYkK 8Q0TIgZ6dWdVFXoK1I4xVjlKtkBl+CInVlxA6Co2dMzBBTLQPUIJcvYqtAOc2SlQT+e2+FHLaf2 wL4WPsH4CiQtbU51lv3oYDWRa3ZOc/x4obMJdhIAnOAq6xduFUGTyzACmf2kX9IDF9XPe/JPeoL AOWD9vPo4EFL4AU9vw7b2+gyoVbATAXTFgRwqr12DcyhKAVMlEn7Tc+LwSvQyO9zmr42IhgJMLp EATc69kFEu2u0KIuc1BJUDFu8S5fNxtErayjyVrqtxw3kDwbgj8M7xAvvVFJymzr+YvUVgij7BD +XgI3PSf7oDJiOz4HmBJ31qPw73WLN/I1S5MG2CB9M9V5psfB1MoqA83KO X-Google-Smtp-Source: AGHT+IFo6WcM5H8GmcWePlpTZJQJDP6uN34nmP4ungH+17cES6QDi/ndDBhuFH68xXSJZOIhA3ydzg== X-Received: by 2002:a17:90b:4b11:b0:32e:87fa:d975 with SMTP id 98e67ed59e1d1-34027ab3922mr4936369a91.34.1761671579729; Tue, 28 Oct 2025 10:12:59 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:12:59 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 15/28] x86: Use -mavx instead of -msse2avx Date: Tue, 28 Oct 2025 14:08:24 -0300 Message-ID: <20251028171141.3208834-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org clang supports it from version 19 and onwards, but it should be gated as an option to assembler (either with -Wa or -Xassembler). Add a test for -Wa as well if -msse2avx fully supported by the compiler. --- sysdeps/x86_64/fpu/multiarch/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index 708b14297f..bd887cd59c 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 -DSSE2AVX +CFLAGS-e_exp-avx.c = -mavx -DSSE2AVX +CFLAGS-e_log-avx.c = -mavx -DSSE2AVX +CFLAGS-s_atan-avx.c = -mavx -DSSE2AVX +CFLAGS-s_sin-avx.c = -mavx -DSSE2AVX +CFLAGS-s_tan-avx.c = -mavx -DSSE2AVX +CFLAGS-s_sincos-avx.c = -mavx -DSSE2AVX 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 Tue Oct 28 17:08:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122879 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 5600F385843A for ; Tue, 28 Oct 2025 17:24:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5600F385843A 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=nrx/3eli X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 19E6D3858420 for ; Tue, 28 Oct 2025 17:13:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19E6D3858420 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 19E6D3858420 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1035 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671584; cv=none; b=sXfKB+Ox3LEL8x0DtmQHxpA9VEZoNBqKmc96gksnVbyfcJVtJAX5V33jCkJbDOFd+4rxcdNa+xEYxFKo8p55xSdmvKPLrP0+2YYUDpDgGJqXfDOhJm10YmZ5uDGhJmoMYrr93MmfzPMNcgJPXvVgqHRArN9vQWLxKXIJy5jm0o0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671584; c=relaxed/simple; bh=NFFQ2DiKW8hP+w3i78l7/OaiQ/d8rLfgZ574kj2ikjA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qgb+j9rJM3jhE6zDmFUP9Jn8aBZMc7dLAXVtzKleBlZP5cfopcbPvY+Jo1bZk6jcwosKrk3TV3qVknBSuAj5TwX16GImh98UotwRks1VPFeQnqpdCE3q0Cc5FBKEYguVWehiqNXG6k+urhw2R5kzOk9YazyE7etq+4eAexNt5FQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19E6D3858420 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-33292adb180so6303389a91.3 for ; Tue, 28 Oct 2025 10:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671583; x=1762276383; 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=6lMBXM2Td4qBl8JwK8cnEM+JIhp9TJPasStZhJ1b1Sw=; b=nrx/3elizqzl7PfsT2am0mPPQHmIJsDm/ykO2eDAKd2DHztDpsyx7z9l7crEC6t5Ej NlqY7qap+KO50H/guVyaghHO4aXgnQYPAMlU44ora+R+3PT3mkCUuC9QkmOqQY8J6a// 1QxIHQdVpDXXACW2jZzPotNFTzXmFhshqtXaeagUf+y08pJOUIpRG0nOCJVa+Dm/UJkV 5e4i5PfnMUcVygSlgCfKtjxdE7eKvvkD3U6Sz3nQk7tURW/ToyCuHozg0bOapUxvLL5T hbNX1d0mNfCDL6rL0M3N7j5LdDJyn8+z3W9AA5UwXeL6rTImxbnpU764D1sLrsKwPImz ZbRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671583; x=1762276383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6lMBXM2Td4qBl8JwK8cnEM+JIhp9TJPasStZhJ1b1Sw=; b=BphqJu9JDIcyqJptyHB2BUm9FtSs0PgjcjhlEjdgRhBj5Ia4kTAH4NXqlWclW+MZk/ 8TdTXrqmamwfgUMynISoyBgWGF9VTa/Psyq0DqbLUn4FM2gTyJsNL4rj5un+conmBz5I n6Pw5e154eEwq0C8eylZtinvbIkdxo1c5G4N0WalNT+lblr/DG7wR4126PvlHRKnbdf4 DOj/l1/nqqYwkBU0upxdSolo2CpFf7uZLy9XKa+AlAm6pTNDZxXnle6pjTnFP5efazpm ZrCpuP11WKZaV5SWYG8XEVM6an/31f7Kv72GbuxBpRUg0dW09Sr1+77WGmuNcvZHvVLq oK9Q== X-Gm-Message-State: AOJu0Yzf/svFUWFDNgo/VA7vuHwtiqGepcCSHXFbRcxVmHvduUkf+vn6 g8EWCj8Y55lIMfYqPpKzhymqE/3VULRsRvMAYs7eIUv3ear7Iut4POwxGVI6wgvlRfH52qx0eu0 3bwP+51U= X-Gm-Gg: ASbGncsTu+sAioq2VrNmoJKyiPBosCUvVIPF6TFQ8gtHvD0B/DpOfECoNEnCRa87037 8VBRlzId5SUu+0Bv68MY/f/TIavrl0BGWM/WyVk6fLonbiTfsmG66PUTGNxhYAVgNH/rl9JoUvK OPvw/5QxnliQ11PGt+1LoLmzUw6EHfqlBq4ghxCxexEUl4a830OKiktegK4mKYqaweKZODS1y6Q yvjjEW92IFbjdeIxT+aZP6fuLoguZqdt6akarDcz9B+UbwPeVK0h5ckigLyD89RD1kt/LM9EhEM 8foCrb2f1SwJhanYi/rIn9TiwI9SABCcXpDJL4vKythEa1mDRXLqNN4f2xcIeD6BIa/Mk+g2o7/ ZmNo2eA2D22OJmpGhYHUBbN3kVjZRDdBuLoeCsZ3TCJqbHrFmZ94i8eT+bjNVaJdRJSenv13RwS FBaCvUINRPXZEvgTkr0AzUblNJh4kBrhD5ilRL2YyFIYH+4A== X-Google-Smtp-Source: AGHT+IFSwXfPNHpoFHM9jNSM4EHCCqWzoDtRnYYqbFdECEp1bB27zH5c8u2Ty0P3x28Le0qbYzgE/Q== X-Received: by 2002:a17:90b:2515:b0:340:29be:8afe with SMTP id 98e67ed59e1d1-34029be8b98mr3324747a91.33.1761671582599; Tue, 28 Oct 2025 10:13:02 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:01 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 16/28] x86: math: Use of __libgcc_cmp_return__ iff compiler supports it Date: Tue, 28 Oct 2025 14:08:25 -0300 Message-ID: <20251028171141.3208834-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org clang does not support '__attribute__ ((mode (__libgcc_cmp_return__)))', so use a more close related type instead fo the default 'int'. --- config.h.in | 3 +++ sysdeps/x86/configure | 39 +++++++++++++++++++++++++++++++++++ sysdeps/x86/configure.ac | 18 ++++++++++++++++ sysdeps/x86/fpu/sfp-machine.h | 10 ++++++++- 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/config.h.in b/config.h.in index 5378883060..34da4d047e 100644 --- a/config.h.in +++ b/config.h.in @@ -317,4 +317,7 @@ /* Define if trunc is inlined on x86. */ #undef HAVE_X86_INLINE_TRUNC +/* Define if compiler suport __attribute__ ((mode (__libgcc_cmp_return__))). */ +#undef HAVE_X86_LIBGCC_CMP_RETURN_ATTR + #endif diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure index 2e95277f29..ad205f6975 100644 --- a/sysdeps/x86/configure +++ b/sysdeps/x86/configure @@ -392,6 +392,45 @@ else fi + +conftest_code=" +int __gcc_CMPtype_GCC __attribute__ ((mode (__libgcc_cmp_return__))); +" + +cat > conftest.c <&5 +printf %s "checking for __libgcc_cmp_return__ mode attribute support... " >&6; } +if test ${libc_cv_cc_x86_libgcc_cmp_return_attribute+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $CFLAGS conftest.c -o conftest 1>&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_cc_x86_libgcc_cmp_return_attribute=yes + else + libc_cv_cc_x86_libgcc_cmp_return_attribute=no + fi ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_x86_libgcc_cmp_return_attribute" >&5 +printf "%s\n" "$libc_cv_cc_x86_libgcc_cmp_return_attribute" >&6; } +rm -f conftest* +if test "$libc_cv_cc_x86_libgcc_cmp_return_attribute" = yes; then + printf "%s\n" "#define HAVE_X86_LIBGCC_CMP_RETURN_ATTR 1" >>confdefs.h + +else + printf "%s\n" "#define HAVE_X86_LIBGCC_CMP_RETURN_ATTR 0" >>confdefs.h + +fi + + if test "${libc_cv_cc_no_direct_extern_access}${libc_cv_test_cc_cflags_no_direct_extern_access}" = yes; then libc_cv_protected_data=no fi diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac index f3888e6618..e0500f21b4 100644 --- a/sysdeps/x86/configure.ac +++ b/sysdeps/x86/configure.ac @@ -223,6 +223,24 @@ else AC_DEFINE(HAVE_X86_INLINE_TRUNC, 0) fi + +conftest_code=" +int __gcc_CMPtype_GCC __attribute__ ((mode (__libgcc_cmp_return__))); +" +dnl Check if CC support the __libgcc_cmp_return__ mode attribute +LIBC_TRY_CC_COMMAND([for __libgcc_cmp_return__ mode attribute support], + [$conftest_code], + [$CFLAGS], + libc_cv_cc_x86_libgcc_cmp_return_attribute, + [libc_cv_cc_x86_libgcc_cmp_return_attribute=yes], + [libc_cv_cc_x86_libgcc_cmp_return_attribute=no]) +if test "$libc_cv_cc_x86_libgcc_cmp_return_attribute" = yes; then + AC_DEFINE(HAVE_X86_LIBGCC_CMP_RETURN_ATTR, 1) +else + AC_DEFINE(HAVE_X86_LIBGCC_CMP_RETURN_ATTR, 0) +fi + + dnl If the building compiler enables no direct external data access by dnl default, access to protected data in shared libraries from executables dnl must be compiled with no direct external data access. If the testing diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h index cbcedb8621..9ef85c4e6c 100644 --- a/sysdeps/x86/fpu/sfp-machine.h +++ b/sysdeps/x86/fpu/sfp-machine.h @@ -1,9 +1,17 @@ /* Configure soft-fp for building sqrtf128. Based on sfp-machine.h in libgcc, with soft-float and other irrelevant parts removed. */ +#if HAVE_X86_LIBGCC_CMP_RETURN_ATTR /* The type of the result of a floating point comparison. This must match `__libgcc_cmp_return__' in GCC for the target. */ -typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__))); +typedef int __gcc_CMPtype_GCC __attribute__ ((mode (__libgcc_cmp_return__))); +#else +# if defined __x86_64__ && defined __ILP32__ +typedef long long int __gcc_CMPtype; +#else +typedef long int __gcc_CMPtype; +# endif +#endif #define CMPtype __gcc_CMPtype #ifdef __x86_64__ From patchwork Tue Oct 28 17:08:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122883 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 BF68C385828B for ; Tue, 28 Oct 2025 17:29:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF68C385828B 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=mS0s7uPp X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id CA928385841B for ; Tue, 28 Oct 2025 17:13:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA928385841B 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 CA928385841B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1030 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671587; cv=none; b=L7DiTxg5x4yETFiAnfCXfJu5rXS08rYfG2nknfgWicOgyT1iQO5kLgvQueJTZ3wocBHyHP7ihFUXoIsVCv8Yw+i/VQIstedTAZ0g4/tzyYTtfYyhQHb4Eo/9D181TGbTpnjaCMouPauke9BVaWRufRyOcz1TN8O5Kmpc+2begNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671587; c=relaxed/simple; bh=69J7DUx+Lh+nh7soa4V18sbwdiWUvrvIX5W8YGTqhDM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=l8U7Yo2TMMKYOKcHTQB3TUXy+9w01vNpofjFa1Jmv0lSliWlQpXS2R/ihAXoNzZkmTwAs+I02mGt5OrjqKp2v4Bw6GEyiX9pyucElofzd4URPdie0IfIKzvmmZ4uJAHY9ZaxEZWTzDYglz6gV7H5GqJ+ktJDgjrgUNolCxvhwMo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA928385841B Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-34003f73a05so119701a91.1 for ; Tue, 28 Oct 2025 10:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671585; x=1762276385; 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=k3V3PAvQvVZz05IBmtwDV2Nn8fmJQh80SUpFF2VIa7M=; b=mS0s7uPpuO5LKTTyFRPvG3OCKLKn6aj44T6tCNLnm5vAZwYnqDnAhpjdiLCbMWFTSc W4YkUngdxZZao72pj9FvIAzrbG5e+U8UEIOrap7ElzOClYiyTXx5bKmt48GRmrGBc9tc DSgvp7f0uE1/gKsOWhhZUpTikQsxJ1OKbwIjxPuF3sIR+p66u9Lozn7xFecuXAEDQvaR qSH0SV+boFgxFNlwyRWGEg5dNUFif7z++B+wh+TFW3SST+2SIzEB6ot51YJqybzgYnFa 2K+dEEHdR0oxxURDHViuP9NLpjAjaETk95WXiBayVdLyzmIqJ+Gn90ebiTqMM3fj6r0m CDOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671585; x=1762276385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k3V3PAvQvVZz05IBmtwDV2Nn8fmJQh80SUpFF2VIa7M=; b=EpLY5GLIodcyNqjSgU8YFlXtWfB5HG+NVziNz5jJEuDSgJAIyrVjikZfDlxXFKxRh8 LVZv9KcGE1/G3NxDOBVigwjvAwqKx+KqtO4+QU0Mz2TsXlsI5z5cbGnqbZAR/nM9i82W ao6ihdSIX9/1o3RGNGagUnrHxZI59AUIxYdyXF7d9ZEnS87WG6jsEeLlSyadKbiLlf0I YmAtM6b8W+9sdBvZr/Pc3kc2rv1IHXzVm4wzmvvV5cvaauH4hvUOUqAMA2aKTTlStqcP Jr4+erVzyoKkFmMHNfOhV0XlLG0h3rrYZUiyxp6qJp8A70LyLryVYd5eSF71jnhsRDFY K3GQ== X-Gm-Message-State: AOJu0YwFrlU/DqBRHVc6SzzpXzoAVFXHdUmv5P48wcuv0cttgvpt0AMw 5eXRtPHKSem6POPJwy03RDPf1ft5d76RUwYiVKwJ353pWoV7fir1zNzyT76AWhdlf4mGLy8rJRh I5tkOHDo= X-Gm-Gg: ASbGncsDZMxhR+6eglGyl5f8qMsL4tZWRqYvrO2m0E9AKUFoEN/8/nhVIf74qnrSZE7 KQox5lHgNLDunzfs8srxlTLtRy2lTsXdoxzQXGWpcs4Wzz38t12aKcYXq7bMLxS6E9I35wRFGS4 jA02yIldLBND38ld7TbNSl5rsklWIJW53VMVSg5nCqo/GG7pP+zS8R8RLfdn3BwjtG1SfYccmSa doIQZ5LbW8/gOiZ1ezhWkMR++4z5aa2kfyJlswPk4nxTL4zqWjV8eRK4pNzcvV2e38l2UQu4tWv jB/cy53FJbz6miuVviDP9vgDQj/sPYj9G/M1RP0DOhygbCG9LdmrYiGdFd1JPgzZrbtKQYo/Beo z+7xr2vJYzUZOQn9l8z3zddoIRIueCowiN0qBWkg0I1L6PbhYALMzy00xGJGFJtf/ORjmc2hKJn HX67Wx0BgIbul9va2Vew9pNpC7H75N65WKrT13vCOIfayJmw== X-Google-Smtp-Source: AGHT+IFbRHC4LG6UdwTAc/kZAny5wVDPqgYYhUKSYxOJwLf34fJtI174v/BlRG0EtvYw0t5CglID2w== X-Received: by 2002:a17:90b:586e:b0:31c:39c2:b027 with SMTP id 98e67ed59e1d1-34039650ca6mr14593a91.7.1761671585513; Tue, 28 Oct 2025 10:13:05 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:04 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 17/28] x86: Fix strstr ifunc on clang Date: Tue, 28 Oct 2025 14:08:26 -0300 Message-ID: <20251028171141.3208834-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 e18e6418ae..f669a57689 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 Tue Oct 28 17:08:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122888 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 5F3DC3858291 for ; Tue, 28 Oct 2025 17:34:13 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id B754B385843A for ; Tue, 28 Oct 2025 17:13:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B754B385843A 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 B754B385843A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671592; cv=none; b=pl6f+GfE8ZJW0noRz0CegdRxFVUnJFWLVX4iVUn+ug/v2i7SXmX+xGpKcMrvPXs+AJxh7Iy2NWg2SqpdFj5Ws2NKWSj3Mus80DPaDU1XYmXbc3aPyLwBTS5l4jF3tM1Oq6Q6nAEjni6TElnYNWBxzUBmQKynoNhxNaJkCjqfcoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671592; c=relaxed/simple; bh=vRPItblOS5cMA52l76zBEw56sSRiWUiqfuS6Ru/Zs14=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=iNj2Mw6BvBlBqN4czxsPcerB2QHvlwyiliXtIiihIH1k/Z/0iveoet3Y7UGWJyQYUyV8v57GYMXqvFmfU06E5keMITgPYF/NBHz6vx4+UhqwwO7eWEEnl1Ehoj/akQ67d/gTTPDjr0dwXcniIfZu2ml5xKziQIboImTn9SMaE+E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B754B385843A 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=x5U7hcP9 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-34029a194bcso1327853a91.0 for ; Tue, 28 Oct 2025 10:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671589; x=1762276389; 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=F+tw9Yb0CrKcYa1viXN4MqBP+VRyXUg0WsHrHdmqV0U=; b=x5U7hcP9EQGAy1kwEcivhYH6MaZ7iAk36f+q5JSvST3BvkY/MVGiPmnEu/kV4FZIKb MiJ69CV96XrxiUqXKo782INFX1XwvdUF+bf1w2r9TIc/qaTISDW4xzzevNZBjLRH9ll2 shx+HWmKTBVXwrTjsQP42tUgw4eUURRgOV/QR8pJt8Jcml9H4G6UCsWIgV4uugP/lPbC LAC0PzSLHvzSjSrXPCGJCWPcynU3VbXXfhfkR3ekT6zuedXe118GA9xQD4VotEBx9oh+ 6dolVqPDEoh2AZHw7jtJSWzaG8ObfMQX1ekxFQ6lb62dfbWxS7i7svMf/sMtsTmbOKTq VDvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671589; x=1762276389; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F+tw9Yb0CrKcYa1viXN4MqBP+VRyXUg0WsHrHdmqV0U=; b=uYDmFX7C4p2J+Zb5CbkJkBNAQYe045vMsxlemiSGFRN9ozVyB/xOOM7ytUf3WYU22d rgaeq0ooGgaX7eOBszuhCtkzr4by2LVxZjsh/H49FNrUZnfK9ScBkhSsMya5mkpU3QBs u5WCYFLFxXgWCr7T+PM+Jt2dW/fkBupVcp2sZORKwOol+lyqGK77X7KhY3gIC7sBkU9U Ymm3oN31m3QiYJeo2Ugyv61tg+k7nufSNTVRGM3PqtRjSt7Uh8IV5Ut6FVY4ojlFMfvF Gz28sC8PylLpkEt0xD7/0roxJABvDeqHW7CJ51z2L98VCjeDLflDC6DX1r5CNir5Ht0r dpmA== X-Gm-Message-State: AOJu0YyLJfsuNOswvq1uFEiYlzlIB7v1I/e/Q6HU9SfMn+P5fDrDhx5C 0+kxP1SwKOLvyrwlvcHSDXhOk9EAy+RSgLuwcrB3fJhwAZN8R4klO6v6Brq5CFq55/oDKQjUV2Y FfBZGunA= X-Gm-Gg: ASbGncuEs5Sz2n/6Qj/eSkzr6HEFoEOJ+0KMaSQgO7JSNaHeITozX0CCWg694Up7OyD bsJqQLWzvEuzZ6yqNfkCjmaN9mwLq354M4FHDePNxofODhrpgsnXUY3nVOjadSXT/78Mhxrr0mZ y2jqELUHs6O07Lx8aG1205dD6fxhllQ4cixM6B5OoB5zFyVeRjWPh9QScg1octJRLb/EP8WcZKh RijUpKKUnj18Ym5pxs9cNB4+RAakwdF3Px01TIt+p9WxC527mB/tseJzL0mo+uMN5RauepPUCU0 8vTaboMwEr49ko643IXd7mmTX7HklBQS+J12O6I3lHtKLdt2c8r4r9Sp9plalBAr8I+9wWfR0PT TYb/ed5Op75CFocxW3wRI5/vKho3OeMrmekVdxKUOvQQ2U73Bummg5QAdxxMlMpOJyTKKnq085b nOfvScjNzOil/s3J7RaG6Kfl878PbZVlisynrOifgWFjyRHA== X-Google-Smtp-Source: AGHT+IEuuSMaM62VFeOaMvepEv9DK2WkyoHZ6NPMgQNqOBrO5wHypGtAaasghGPNuN8VYZEqXl5zpg== X-Received: by 2002:a17:90b:4a92:b0:32e:a54a:be53 with SMTP id 98e67ed59e1d1-34027a06f8dmr5360413a91.16.1761671588799; Tue, 28 Oct 2025 10:13:08 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:07 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 18/28] x86: Adapt "%v" usage on clang to emit VEX enconding Date: Tue, 28 Oct 2025 14:08:27 -0300 Message-ID: <20251028171141.3208834-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org clang does not support the %v to select the AVX encoding, nor the '%d' asm contrain, and for AVX build it requires all 3 arguments. This patch add a new internal header, math-inline-asm.h, that adds functions to abstract the inline asm required differences between gcc and clang. --- sysdeps/i386/fpu/fclrexcpt.c | 5 +- sysdeps/i386/fpu/fedisblxcpt.c | 5 +- sysdeps/i386/fpu/feenablxcpt.c | 5 +- sysdeps/i386/fpu/fegetenv.c | 3 +- sysdeps/i386/fpu/fegetmode.c | 3 +- sysdeps/i386/fpu/feholdexcpt.c | 5 +- sysdeps/i386/fpu/fesetenv.c | 6 +-- sysdeps/i386/fpu/fesetexcept.c | 6 +-- sysdeps/i386/fpu/fesetmode.c | 6 +-- sysdeps/i386/fpu/fesetround.c | 7 ++- sysdeps/i386/fpu/feupdateenv.c | 3 +- sysdeps/i386/fpu/fgetexcptflg.c | 5 +- sysdeps/i386/fpu/fsetexcptflg.c | 5 +- sysdeps/i386/fpu/ftestexcept.c | 3 +- sysdeps/i386/setfpucw.c | 7 ++- sysdeps/x86/fpu/fenv_private.h | 43 ++++++++--------- sysdeps/x86/fpu/math-inline-asm.h | 79 +++++++++++++++++++++++++++++++ sysdeps/x86/fpu/math_private.h | 8 ++-- sysdeps/x86/fpu/sfp-machine.h | 4 +- sysdeps/x86/fpu/test-fenv-sse-2.c | 21 ++------ sysdeps/x86_64/fpu/fclrexcpt.c | 5 +- sysdeps/x86_64/fpu/fedisblxcpt.c | 5 +- sysdeps/x86_64/fpu/feenablxcpt.c | 5 +- sysdeps/x86_64/fpu/fegetenv.c | 12 +++-- sysdeps/x86_64/fpu/fegetmode.c | 3 +- sysdeps/x86_64/fpu/feholdexcpt.c | 10 ++-- sysdeps/x86_64/fpu/fesetenv.c | 9 ++-- sysdeps/x86_64/fpu/fesetexcept.c | 7 ++- sysdeps/x86_64/fpu/fesetmode.c | 6 +-- sysdeps/x86_64/fpu/fesetround.c | 5 +- sysdeps/x86_64/fpu/feupdateenv.c | 4 +- sysdeps/x86_64/fpu/fgetexcptflg.c | 5 +- sysdeps/x86_64/fpu/fraiseexcpt.c | 18 ++----- sysdeps/x86_64/fpu/fsetexcptflg.c | 5 +- sysdeps/x86_64/fpu/ftestexcept.c | 5 +- 35 files changed, 202 insertions(+), 131 deletions(-) create mode 100644 sysdeps/x86/fpu/math-inline-asm.h diff --git a/sysdeps/i386/fpu/fclrexcpt.c b/sysdeps/i386/fpu/fclrexcpt.c index 39bcf3de59..5f586dae37 100644 --- a/sysdeps/i386/fpu/fclrexcpt.c +++ b/sysdeps/i386/fpu/fclrexcpt.c @@ -19,6 +19,7 @@ #include #include #include +#include int __feclearexcept (int excepts) @@ -44,13 +45,13 @@ __feclearexcept (int excepts) unsigned int xnew_exc; /* Get the current MXCSR. */ - __asm__ ("%vstmxcsr %0" : "=m" (xnew_exc)); + xnew_exc = stmxcsr_inline_asm (); /* Clear the relevant bits. */ xnew_exc &= ~excepts; /* Put the new data in effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (xnew_exc)); + ldmxcsr_inline_asm (xnew_exc); } /* Success. */ diff --git a/sysdeps/i386/fpu/fedisblxcpt.c b/sysdeps/i386/fpu/fedisblxcpt.c index a2dfa8e4c9..6d65ebc052 100644 --- a/sysdeps/i386/fpu/fedisblxcpt.c +++ b/sysdeps/i386/fpu/fedisblxcpt.c @@ -19,6 +19,7 @@ #include #include #include +#include int fedisableexcept (int excepts) @@ -41,11 +42,11 @@ fedisableexcept (int excepts) unsigned int xnew_exc; /* Get the current control word. */ - __asm__ ("%vstmxcsr %0" : "=m" (xnew_exc)); + xnew_exc = stmxcsr_inline_asm (); xnew_exc |= excepts << 7; - __asm__ ("%vldmxcsr %0" : : "m" (xnew_exc)); + ldmxcsr_inline_asm (xnew_exc); } return old_exc; diff --git a/sysdeps/i386/fpu/feenablxcpt.c b/sysdeps/i386/fpu/feenablxcpt.c index fa1d82a4b6..c4a54583ee 100644 --- a/sysdeps/i386/fpu/feenablxcpt.c +++ b/sysdeps/i386/fpu/feenablxcpt.c @@ -19,6 +19,7 @@ #include #include #include +#include int feenableexcept (int excepts) @@ -41,11 +42,11 @@ feenableexcept (int excepts) unsigned int xnew_exc; /* Get the current control word. */ - __asm__ ("%vstmxcsr %0" : "=m" (xnew_exc)); + xnew_exc = stmxcsr_inline_asm (); xnew_exc &= ~(excepts << 7); - __asm__ ("%vldmxcsr %0" : : "m" (xnew_exc)); + ldmxcsr_inline_asm (xnew_exc); } return old_exc; diff --git a/sysdeps/i386/fpu/fegetenv.c b/sysdeps/i386/fpu/fegetenv.c index 5b35577151..12829e1549 100644 --- a/sysdeps/i386/fpu/fegetenv.c +++ b/sysdeps/i386/fpu/fegetenv.c @@ -19,6 +19,7 @@ #include #include #include +#include int __fegetenv (fenv_t *envp) @@ -30,7 +31,7 @@ __fegetenv (fenv_t *envp) __asm__ ("fldenv %0" : : "m" (*envp)); if (CPU_FEATURE_USABLE (SSE)) - __asm__ ("%vstmxcsr %0" : "=m" (envp->__eip)); + envp->__eip = stmxcsr_inline_asm (); /* Success. */ return 0; diff --git a/sysdeps/i386/fpu/fegetmode.c b/sysdeps/i386/fpu/fegetmode.c index 8b109072f5..1ee1c11a54 100644 --- a/sysdeps/i386/fpu/fegetmode.c +++ b/sysdeps/i386/fpu/fegetmode.c @@ -20,12 +20,13 @@ #include #include #include +#include int fegetmode (femode_t *modep) { _FPU_GETCW (modep->__control_word); if (CPU_FEATURE_USABLE (SSE)) - __asm__ ("%vstmxcsr %0" : "=m" (modep->__mxcsr)); + modep->__mxcsr = stmxcsr_inline_asm (); return 0; } diff --git a/sysdeps/i386/fpu/feholdexcpt.c b/sysdeps/i386/fpu/feholdexcpt.c index f6f6b70dd4..2f1fa503b9 100644 --- a/sysdeps/i386/fpu/feholdexcpt.c +++ b/sysdeps/i386/fpu/feholdexcpt.c @@ -19,6 +19,7 @@ #include #include #include +#include int __feholdexcept (fenv_t *envp) @@ -33,12 +34,12 @@ __feholdexcept (fenv_t *envp) unsigned int xwork; /* Get the current control word. */ - __asm__ ("%vstmxcsr %0" : "=m" (envp->__eip)); + envp->__eip = stmxcsr_inline_asm (); /* Set all exceptions to non-stop and clear them. */ xwork = (envp->__eip | 0x1f80) & ~0x3f; - __asm__ ("%vldmxcsr %0" : : "m" (xwork)); + ldmxcsr_inline_asm (xwork); } return 0; diff --git a/sysdeps/i386/fpu/fesetenv.c b/sysdeps/i386/fpu/fesetenv.c index e6b276a0fc..0305eb5146 100644 --- a/sysdeps/i386/fpu/fesetenv.c +++ b/sysdeps/i386/fpu/fesetenv.c @@ -21,6 +21,7 @@ #include #include #include +#include /* All exceptions, including the x86-specific "denormal operand" @@ -79,8 +80,7 @@ __fesetenv (const fenv_t *envp) if (CPU_FEATURE_USABLE (SSE)) { - unsigned int mxcsr; - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm (); if (envp == FE_DFL_ENV) { @@ -111,7 +111,7 @@ __fesetenv (const fenv_t *envp) else mxcsr = envp->__eip; - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } /* Success. */ diff --git a/sysdeps/i386/fpu/fesetexcept.c b/sysdeps/i386/fpu/fesetexcept.c index 876bde233f..20ab75becd 100644 --- a/sysdeps/i386/fpu/fesetexcept.c +++ b/sysdeps/i386/fpu/fesetexcept.c @@ -18,6 +18,7 @@ #include #include +#include int fesetexcept (int excepts) @@ -32,14 +33,13 @@ fesetexcept (int excepts) if (CPU_FEATURE_USABLE (SSE)) { /* Get the control word of the SSE unit. */ - unsigned int mxcsr; - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm (); /* Set relevant flags. */ mxcsr |= excepts; /* Put the new data in effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } else { diff --git a/sysdeps/i386/fpu/fesetmode.c b/sysdeps/i386/fpu/fesetmode.c index ee61ca1cec..0616cabc45 100644 --- a/sysdeps/i386/fpu/fesetmode.c +++ b/sysdeps/i386/fpu/fesetmode.c @@ -20,6 +20,7 @@ #include #include #include +#include /* All exceptions, including the x86-specific "denormal operand" exception. */ @@ -36,8 +37,7 @@ fesetmode (const femode_t *modep) _FPU_SETCW (cw); if (CPU_FEATURE_USABLE (SSE)) { - unsigned int mxcsr; - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm (); /* Preserve SSE exception flags but restore other state in MXCSR. */ mxcsr &= FE_ALL_EXCEPT_X86; @@ -47,7 +47,7 @@ fesetmode (const femode_t *modep) mxcsr |= FE_ALL_EXCEPT_X86 << 7; else mxcsr |= modep->__mxcsr & ~FE_ALL_EXCEPT_X86; - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } return 0; } diff --git a/sysdeps/i386/fpu/fesetround.c b/sysdeps/i386/fpu/fesetround.c index e87d794319..e3e16e87b1 100644 --- a/sysdeps/i386/fpu/fesetround.c +++ b/sysdeps/i386/fpu/fesetround.c @@ -19,6 +19,7 @@ #include #include #include +#include int __fesetround (int round) @@ -37,12 +38,10 @@ __fesetround (int round) /* If the CPU supports SSE we set the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) { - unsigned int xcw; - - __asm__ ("%vstmxcsr %0" : "=m" (xcw)); + unsigned int xcw = stmxcsr_inline_asm (); xcw &= ~0x6000; xcw |= round << 3; - __asm__ ("%vldmxcsr %0" : : "m" (xcw)); + ldmxcsr_inline_asm (xcw); } return 0; diff --git a/sysdeps/i386/fpu/feupdateenv.c b/sysdeps/i386/fpu/feupdateenv.c index 9e1ad97118..d56276f2ce 100644 --- a/sysdeps/i386/fpu/feupdateenv.c +++ b/sysdeps/i386/fpu/feupdateenv.c @@ -19,6 +19,7 @@ #include #include #include +#include int __feupdateenv (const fenv_t *envp) @@ -31,7 +32,7 @@ __feupdateenv (const fenv_t *envp) /* If the CPU supports SSE we test the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) - __asm__ ("%vstmxcsr %0" : "=m" (xtemp)); + xtemp = stmxcsr_inline_asm (); temp = (temp | xtemp) & FE_ALL_EXCEPT; diff --git a/sysdeps/i386/fpu/fgetexcptflg.c b/sysdeps/i386/fpu/fgetexcptflg.c index 36dd297cdc..bcba833381 100644 --- a/sysdeps/i386/fpu/fgetexcptflg.c +++ b/sysdeps/i386/fpu/fgetexcptflg.c @@ -19,6 +19,7 @@ #include #include #include +#include int @@ -34,10 +35,8 @@ __fegetexceptflag (fexcept_t *flagp, int excepts) /* If the CPU supports SSE, we clear the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) { - unsigned int sse_exc; - /* Get the current MXCSR. */ - __asm__ ("%vstmxcsr %0" : "=m" (sse_exc)); + unsigned int sse_exc = stmxcsr_inline_asm (); *flagp |= sse_exc & excepts & FE_ALL_EXCEPT; } diff --git a/sysdeps/i386/fpu/fsetexcptflg.c b/sysdeps/i386/fpu/fsetexcptflg.c index b78d1dcd3c..9616fec52e 100644 --- a/sysdeps/i386/fpu/fsetexcptflg.c +++ b/sysdeps/i386/fpu/fsetexcptflg.c @@ -18,6 +18,7 @@ #include #include +#include int __fesetexceptflag (const fexcept_t *flagp, int excepts) @@ -50,13 +51,13 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts) __asm__ ("fldenv %0" : : "m" (temp)); /* And now similarly for SSE. */ - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + mxcsr = stmxcsr_inline_asm (); /* Clear or set relevant flags. */ mxcsr ^= (mxcsr ^ *flagp) & excepts; /* Put the new data in effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } else { diff --git a/sysdeps/i386/fpu/ftestexcept.c b/sysdeps/i386/fpu/ftestexcept.c index 51abfd3917..0869582d0a 100644 --- a/sysdeps/i386/fpu/ftestexcept.c +++ b/sysdeps/i386/fpu/ftestexcept.c @@ -19,6 +19,7 @@ #include #include #include +#include int __fetestexcept (int excepts) @@ -31,7 +32,7 @@ __fetestexcept (int excepts) /* If the CPU supports SSE we test the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) - __asm__ ("%vstmxcsr %0" : "=m" (xtemp)); + xtemp = stmxcsr_inline_asm (); return (temp | xtemp) & excepts & FE_ALL_EXCEPT; } diff --git a/sysdeps/i386/setfpucw.c b/sysdeps/i386/setfpucw.c index 8438c7ed75..b48892b414 100644 --- a/sysdeps/i386/setfpucw.c +++ b/sysdeps/i386/setfpucw.c @@ -21,6 +21,7 @@ #include #include #include +#include void __setfpucw (fpu_control_t set) @@ -40,14 +41,12 @@ __setfpucw (fpu_control_t set) /* If the CPU supports SSE, we set the MXCSR as well. */ if (CPU_FEATURE_USABLE (SSE)) { - unsigned int xnew_exc; - /* Get the current MXCSR. */ - __asm__ ("%vstmxcsr %0" : "=m" (xnew_exc)); + unsigned int xnew_exc = stmxcsr_inline_asm (); xnew_exc &= ~((0xc00 << 3) | (FE_ALL_EXCEPT << 7)); xnew_exc |= ((set & 0xc00) << 3) | ((set & FE_ALL_EXCEPT) << 7); - __asm__ ("%vldmxcsr %0" : : "m" (xnew_exc)); + ldmxcsr_inline_asm (xnew_exc); } } diff --git a/sysdeps/x86/fpu/fenv_private.h b/sysdeps/x86/fpu/fenv_private.h index c9b573cacd..2bd20ee992 100644 --- a/sysdeps/x86/fpu/fenv_private.h +++ b/sysdeps/x86/fpu/fenv_private.h @@ -4,6 +4,7 @@ #include #include #include +#include /* This file is used by both the 32- and 64-bit ports. The 64-bit port has a field in the fenv_t for the mxcsr; the 32-bit port does not. @@ -21,11 +22,10 @@ static __always_inline void libc_feholdexcept_sse (fenv_t *e) { - unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm ();; e->__mxcsr = mxcsr; mxcsr = (mxcsr | 0x1f80) & ~0x3f; - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } static __always_inline void @@ -42,10 +42,9 @@ libc_feholdexcept_387 (fenv_t *e) static __always_inline void libc_fesetround_sse (int r) { - unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm ();; mxcsr = (mxcsr & ~0x6000) | (r << 3); - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } static __always_inline void @@ -60,11 +59,10 @@ libc_fesetround_387 (int r) static __always_inline void libc_feholdexcept_setround_sse (fenv_t *e, int r) { - unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm ();; e->__mxcsr = mxcsr; mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | (r << 3); - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } /* Set both rounding mode and precision. A convenience function for use @@ -95,8 +93,7 @@ libc_feholdexcept_setround_387_53bit (fenv_t *e, int r) static __always_inline int libc_fetestexcept_sse (int e) { - unsigned int mxcsr; - asm volatile ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm (); return mxcsr & e & FE_ALL_EXCEPT; } @@ -111,7 +108,7 @@ libc_fetestexcept_387 (int ex) static __always_inline void libc_fesetenv_sse (fenv_t *e) { - asm volatile ("%vldmxcsr %0" : : "m" (e->__mxcsr)); + ldmxcsr_inline_asm (e->__mxcsr); } static __always_inline void @@ -129,13 +126,13 @@ static __always_inline int libc_feupdateenv_test_sse (fenv_t *e, int ex) { unsigned int mxcsr, old_mxcsr, cur_ex; - asm volatile ("%vstmxcsr %0" : "=m" (mxcsr)); + mxcsr = stmxcsr_inline_asm (); cur_ex = mxcsr & FE_ALL_EXCEPT; /* Merge current exceptions with the old environment. */ old_mxcsr = e->__mxcsr; mxcsr = old_mxcsr | cur_ex; - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); /* Raise SIGFPE for any new exceptions since the hold. Expect that the normal environment has all exceptions masked. */ @@ -180,11 +177,10 @@ libc_feupdateenv_387 (fenv_t *e) static __always_inline void libc_feholdsetround_sse (fenv_t *e, int r) { - unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm ();; e->__mxcsr = mxcsr; mxcsr = (mxcsr & ~0x6000) | (r << 3); - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } static __always_inline void @@ -214,10 +210,9 @@ libc_feholdsetround_387_53bit (fenv_t *e, int r) static __always_inline void libc_feresetround_sse (fenv_t *e) { - unsigned int mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm ();; mxcsr = (mxcsr & ~0x6000) | (e->__mxcsr & 0x6000); - asm volatile ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); } static __always_inline void @@ -307,13 +302,13 @@ static __always_inline void libc_feholdexcept_setround_sse_ctx (struct rm_ctx *ctx, int r) { unsigned int mxcsr, new_mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + mxcsr = stmxcsr_inline_asm (); new_mxcsr = ((mxcsr | 0x1f80) & ~0x603f) | (r << 3); ctx->env.__mxcsr = mxcsr; if (__glibc_unlikely (mxcsr != new_mxcsr)) { - asm volatile ("%vldmxcsr %0" : : "m" (new_mxcsr)); + ldmxcsr_inline_asm (new_mxcsr); ctx->updated_status = true; } else @@ -404,13 +399,13 @@ libc_feholdsetround_sse_ctx (struct rm_ctx *ctx, int r) { unsigned int mxcsr, new_mxcsr; - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + mxcsr = stmxcsr_inline_asm (); new_mxcsr = (mxcsr & ~0x6000) | (r << 3); ctx->env.__mxcsr = mxcsr; if (__glibc_unlikely (new_mxcsr != mxcsr)) { - asm volatile ("%vldmxcsr %0" : : "m" (new_mxcsr)); + ldmxcsr_inline_asm (new_mxcsr); ctx->updated_status = true; } else diff --git a/sysdeps/x86/fpu/math-inline-asm.h b/sysdeps/x86/fpu/math-inline-asm.h new file mode 100644 index 0000000000..1b002d0314 --- /dev/null +++ b/sysdeps/x86/fpu/math-inline-asm.h @@ -0,0 +1,79 @@ +/* Math inline asm compat layer + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_INLINE_ASM +#define _MATH_INLINE_ASM + +#include + +/* clang does not support the %v to select the AVX encoding, nor the '%d' asm + contrain, and for AVX build it requires all 3 arguments. */ +#ifdef __clang__ +#if defined __AVX__ || defined SSE2AVX +# define VPREFIX "v" +# define VROUND_ARG ", %0" +# else +# define VPREFIX "" +# define VROUND_ARG "" +# endif +# define VARGPREFIX "%" +#else +# define VPREFIX "%v" +# define VARGPREFIX "%d" +# define VROUND_ARG "" +#endif + +__extern_always_inline double +trunc_inline_asm (double x) +{ + asm (VPREFIX "roundsd $11, " VARGPREFIX "1, %0" VROUND_ARG : "=v" (x) + : "v" (x)); + return x; +} + +__extern_always_inline float +truncf_inline_asm (float x) +{ + asm (VPREFIX "roundss $11, " VARGPREFIX "1, %0" VROUND_ARG : "=v" (x) + : "v" (x)); + return x; +} + +static __always_inline unsigned int +stmxcsr_inline_asm (void) +{ + unsigned int mxcsr; + asm volatile (VPREFIX "stmxcsr %0" : "=m" (mxcsr)); + return mxcsr; +} + +static __always_inline void +ldmxcsr_inline_asm (unsigned int mxcsr) +{ + asm volatile (VPREFIX "ldmxcsr %0" : : "m" (mxcsr)); +} + +static __always_inline float +divss_inline_asm (float x, float y) +{ + asm volatile (VPREFIX "divss %1, " VARGPREFIX "0" VROUND_ARG + : "+x" (x) : "x" (y)); + return x; +} + +#endif diff --git a/sysdeps/x86/fpu/math_private.h b/sysdeps/x86/fpu/math_private.h index bba085a578..47de90bcec 100644 --- a/sysdeps/x86/fpu/math_private.h +++ b/sysdeps/x86/fpu/math_private.h @@ -20,8 +20,10 @@ #define X86_MATH_PRIVATE_H 1 #include +#include #include_next + __extern_always_inline long double __NTH (__ieee754_atan2l (long double y, long double x)) { @@ -36,8 +38,7 @@ __trunc (double x) #if HAVE_X86_INLINE_TRUNC || !defined __SSE4_1__ return trunc (x); #else - asm ("%vroundsd $11, %d1, %0" : "=v" (x) : "v" (x)); - return x; + return trunc_inline_asm (x); #endif } @@ -47,8 +48,7 @@ __truncf (float x) #if HAVE_X86_INLINE_TRUNC || !defined __SSE4_1__ return truncf (x); #else - asm ("%vroundss $11, %d1, %0" : "=v" (x) : "v" (x)); - return x; + return truncf_inline_asm (x); #endif } diff --git a/sysdeps/x86/fpu/sfp-machine.h b/sysdeps/x86/fpu/sfp-machine.h index 9ef85c4e6c..3ec3185f8c 100644 --- a/sysdeps/x86/fpu/sfp-machine.h +++ b/sysdeps/x86/fpu/sfp-machine.h @@ -1,6 +1,8 @@ /* Configure soft-fp for building sqrtf128. Based on sfp-machine.h in libgcc, with soft-float and other irrelevant parts removed. */ +#include + #if HAVE_X86_LIBGCC_CMP_RETURN_ATTR /* The type of the result of a floating point comparison. This must match `__libgcc_cmp_return__' in GCC for the target. */ @@ -55,7 +57,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); # define FP_INIT_ROUNDMODE \ do { \ - __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw)); \ + _fcw = stmxcsr_inline_asm (); \ } while (0) #else # define _FP_W_TYPE_SIZE 32 diff --git a/sysdeps/x86/fpu/test-fenv-sse-2.c b/sysdeps/x86/fpu/test-fenv-sse-2.c index d12009bb81..cf93a5919d 100644 --- a/sysdeps/x86/fpu/test-fenv-sse-2.c +++ b/sysdeps/x86/fpu/test-fenv-sse-2.c @@ -24,33 +24,20 @@ #include #include #include - -static uint32_t -get_sse_mxcsr (void) -{ - uint32_t temp; - __asm__ __volatile__ ("%vstmxcsr %0" : "=m" (temp)); - return temp; -} - -static void -set_sse_mxcsr (uint32_t val) -{ - __asm__ __volatile__ ("%vldmxcsr %0" : : "m" (val)); -} +#include static void set_sse_mxcsr_bits (uint32_t mask, uint32_t bits) { - uint32_t mxcsr = get_sse_mxcsr (); + uint32_t mxcsr = stmxcsr_inline_asm (); mxcsr = (mxcsr & ~mask) | bits; - set_sse_mxcsr (mxcsr); + ldmxcsr_inline_asm (mxcsr); } static int test_sse_mxcsr_bits (const char *test, uint32_t mask, uint32_t bits) { - uint32_t mxcsr = get_sse_mxcsr (); + uint32_t mxcsr = stmxcsr_inline_asm (); printf ("Testing %s: mxcsr = %x\n", test, mxcsr); if ((mxcsr & mask) == bits) { diff --git a/sysdeps/x86_64/fpu/fclrexcpt.c b/sysdeps/x86_64/fpu/fclrexcpt.c index d5f70458c0..1c70a9da98 100644 --- a/sysdeps/x86_64/fpu/fclrexcpt.c +++ b/sysdeps/x86_64/fpu/fclrexcpt.c @@ -17,6 +17,7 @@ . */ #include +#include int __feclearexcept (int excepts) @@ -38,13 +39,13 @@ __feclearexcept (int excepts) __asm__ ("fldenv %0" : : "m" (temp)); /* And the same procedure for SSE. */ - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + mxcsr = stmxcsr_inline_asm (); /* Clear the relevant bits. */ mxcsr &= ~excepts; /* And put them into effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); /* Success. */ return 0; diff --git a/sysdeps/x86_64/fpu/fedisblxcpt.c b/sysdeps/x86_64/fpu/fedisblxcpt.c index dab9ad19c2..38bbdb4f45 100644 --- a/sysdeps/x86_64/fpu/fedisblxcpt.c +++ b/sysdeps/x86_64/fpu/fedisblxcpt.c @@ -17,6 +17,7 @@ . */ #include +#include int fedisableexcept (int excepts) @@ -35,11 +36,11 @@ fedisableexcept (int excepts) __asm__ ("fldcw %0" : : "m" (new_exc)); /* And now the same for the SSE MXCSR register. */ - __asm__ ("%vstmxcsr %0" : "=m" (new)); + new = stmxcsr_inline_asm (); /* The SSE exception masks are shifted by 7 bits. */ new |= excepts << 7; - __asm__ ("%vldmxcsr %0" : : "m" (new)); + ldmxcsr_inline_asm (new); return old_exc; } diff --git a/sysdeps/x86_64/fpu/feenablxcpt.c b/sysdeps/x86_64/fpu/feenablxcpt.c index 828b2b247a..848e2d0eae 100644 --- a/sysdeps/x86_64/fpu/feenablxcpt.c +++ b/sysdeps/x86_64/fpu/feenablxcpt.c @@ -17,6 +17,7 @@ . */ #include +#include int feenableexcept (int excepts) @@ -35,11 +36,11 @@ feenableexcept (int excepts) __asm__ ("fldcw %0" : : "m" (new_exc)); /* And now the same for the SSE MXCSR register. */ - __asm__ ("%vstmxcsr %0" : "=m" (new)); + new = stmxcsr_inline_asm (); /* The SSE exception masks are shifted by 7 bits. */ new &= ~(excepts << 7); - __asm__ ("%vldmxcsr %0" : : "m" (new)); + ldmxcsr_inline_asm (new); return old_exc; } diff --git a/sysdeps/x86_64/fpu/fegetenv.c b/sysdeps/x86_64/fpu/fegetenv.c index fa21ec4f86..2b996d6d57 100644 --- a/sysdeps/x86_64/fpu/fegetenv.c +++ b/sysdeps/x86_64/fpu/fegetenv.c @@ -17,15 +17,17 @@ . */ #include +#include int __fegetenv (fenv_t *envp) { - __asm__ ("fnstenv %0\n" - /* fnstenv changes the exception mask, so load back the - stored environment. */ - "fldenv %0\n" - "%vstmxcsr %1" : "=m" (*envp), "=m" (envp->__mxcsr)); + asm volatile ("fnstenv %0\n" + /* fnstenv changes the exception mask, so load back the + stored environment. */ + "fldenv %0" + : "=m" (*envp)); + envp->__mxcsr = stmxcsr_inline_asm (); /* Success. */ return 0; diff --git a/sysdeps/x86_64/fpu/fegetmode.c b/sysdeps/x86_64/fpu/fegetmode.c index 39d124a6d8..6c1c1f1f00 100644 --- a/sysdeps/x86_64/fpu/fegetmode.c +++ b/sysdeps/x86_64/fpu/fegetmode.c @@ -18,11 +18,12 @@ #include #include +#include int fegetmode (femode_t *modep) { _FPU_GETCW (modep->__control_word); - __asm__ ("%vstmxcsr %0" : "=m" (modep->__mxcsr)); + modep->__mxcsr = stmxcsr_inline_asm (); return 0; } diff --git a/sysdeps/x86_64/fpu/feholdexcpt.c b/sysdeps/x86_64/fpu/feholdexcpt.c index 30e3120596..959f9c4a6c 100644 --- a/sysdeps/x86_64/fpu/feholdexcpt.c +++ b/sysdeps/x86_64/fpu/feholdexcpt.c @@ -17,6 +17,7 @@ . */ #include +#include int __feholdexcept (fenv_t *envp) @@ -25,14 +26,13 @@ __feholdexcept (fenv_t *envp) /* Store the environment. Recall that fnstenv has a side effect of masking all exceptions. Then clear all exceptions. */ - __asm__ ("fnstenv %0\n\t" - "%vstmxcsr %1\n\t" - "fnclex" - : "=m" (*envp), "=m" (envp->__mxcsr)); + asm volatile ("fnstenv %0" : "=m" (*envp)); + envp->__mxcsr = stmxcsr_inline_asm (); + asm volatile ("fnclex" : "=m" (*envp)); /* Set the SSE MXCSR register. */ mxcsr = (envp->__mxcsr | 0x1f80) & ~0x3f; - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/fesetenv.c b/sysdeps/x86_64/fpu/fesetenv.c index a7b87efcde..d719186f21 100644 --- a/sysdeps/x86_64/fpu/fesetenv.c +++ b/sysdeps/x86_64/fpu/fesetenv.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include @@ -35,8 +36,8 @@ __fesetenv (const fenv_t *envp) values which we do not want to come from the saved environment. Therefore, we get the current environment and replace the values we want to use from the environment specified by the parameter. */ - __asm__ ("fnstenv %0\n" - "%vstmxcsr %1" : "=m" (temp), "=m" (temp.__mxcsr)); + asm volatile ("fnstenv %0" : "=m" (temp)); + temp.__mxcsr = stmxcsr_inline_asm (); if (envp == FE_DFL_ENV) { @@ -103,8 +104,8 @@ __fesetenv (const fenv_t *envp) temp.__mxcsr = envp->__mxcsr; } - __asm__ ("fldenv %0\n" - "%vldmxcsr %1" : : "m" (temp), "m" (temp.__mxcsr)); + asm volatile ("fldenv %0" : "=m" (temp)); + ldmxcsr_inline_asm (temp.__mxcsr); /* Success. */ return 0; diff --git a/sysdeps/x86_64/fpu/fesetexcept.c b/sysdeps/x86_64/fpu/fesetexcept.c index 91d5270f8e..943d1136f0 100644 --- a/sysdeps/x86_64/fpu/fesetexcept.c +++ b/sysdeps/x86_64/fpu/fesetexcept.c @@ -17,15 +17,14 @@ . */ #include +#include int fesetexcept (int excepts) { - unsigned int mxcsr; - - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr =stmxcsr_inline_asm (); mxcsr |= excepts & FE_ALL_EXCEPT; - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/fesetmode.c b/sysdeps/x86_64/fpu/fesetmode.c index 2b35d7e719..5f393200ea 100644 --- a/sysdeps/x86_64/fpu/fesetmode.c +++ b/sysdeps/x86_64/fpu/fesetmode.c @@ -17,6 +17,7 @@ . */ #include +#include #include /* All exceptions, including the x86-specific "denormal operand" @@ -27,8 +28,7 @@ int fesetmode (const femode_t *modep) { fpu_control_t cw; - unsigned int mxcsr; - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + unsigned int mxcsr = stmxcsr_inline_asm (); /* Preserve SSE exception flags but restore other state in MXCSR. */ mxcsr &= FE_ALL_EXCEPT_X86; @@ -45,6 +45,6 @@ fesetmode (const femode_t *modep) mxcsr |= modep->__mxcsr & ~FE_ALL_EXCEPT_X86; } _FPU_SETCW (cw); - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/fesetround.c b/sysdeps/x86_64/fpu/fesetround.c index 8a5f6c425c..6b8480c3f3 100644 --- a/sysdeps/x86_64/fpu/fesetround.c +++ b/sysdeps/x86_64/fpu/fesetround.c @@ -17,6 +17,7 @@ . */ #include +#include int __fesetround (int round) @@ -36,10 +37,10 @@ __fesetround (int round) /* And now the MSCSR register for SSE, the precision is at different bit positions in the different units, we need to shift it 3 bits. */ - asm ("%vstmxcsr %0" : "=m" (mxcsr)); + mxcsr = stmxcsr_inline_asm (); mxcsr &= ~ 0x6000; mxcsr |= round << 3; - asm ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); return 0; } diff --git a/sysdeps/x86_64/fpu/feupdateenv.c b/sysdeps/x86_64/fpu/feupdateenv.c index 0e26b92af5..5148543529 100644 --- a/sysdeps/x86_64/fpu/feupdateenv.c +++ b/sysdeps/x86_64/fpu/feupdateenv.c @@ -17,6 +17,7 @@ . */ #include +#include int __feupdateenv (const fenv_t *envp) @@ -25,7 +26,8 @@ __feupdateenv (const fenv_t *envp) unsigned int xtemp; /* Save current exceptions. */ - __asm__ ("fnstsw %0\n\t%vstmxcsr %1" : "=m" (temp), "=m" (xtemp)); + asm volatile ("fnstsw %0" : "=m" (temp)); + xtemp = stmxcsr_inline_asm (); temp = (temp | xtemp) & FE_ALL_EXCEPT; /* Install new environment. */ diff --git a/sysdeps/x86_64/fpu/fgetexcptflg.c b/sysdeps/x86_64/fpu/fgetexcptflg.c index a7b500b600..ec7324b829 100644 --- a/sysdeps/x86_64/fpu/fgetexcptflg.c +++ b/sysdeps/x86_64/fpu/fgetexcptflg.c @@ -17,6 +17,7 @@ . */ #include +#include int fegetexceptflag (fexcept_t *flagp, int excepts) @@ -25,8 +26,8 @@ fegetexceptflag (fexcept_t *flagp, int excepts) unsigned int mxscr; /* Get the current exceptions for the x87 FPU and SSE unit. */ - __asm__ ("fnstsw %0\n" - "%vstmxcsr %1" : "=m" (temp), "=m" (mxscr)); + __asm__ ("fnstsw %0" : "=m" (temp)); + mxscr = stmxcsr_inline_asm (); *flagp = (temp | mxscr) & FE_ALL_EXCEPT & excepts; diff --git a/sysdeps/x86_64/fpu/fraiseexcpt.c b/sysdeps/x86_64/fpu/fraiseexcpt.c index dae0c3bc31..f0a1d8282b 100644 --- a/sysdeps/x86_64/fpu/fraiseexcpt.c +++ b/sysdeps/x86_64/fpu/fraiseexcpt.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -29,23 +30,12 @@ __feraiseexcept (int excepts) /* First: invalid exception. */ if ((FE_INVALID & excepts) != 0) - { - /* One example of an invalid operation is 0.0 / 0.0. */ - float f = 0.0; - - __asm__ __volatile__ ("%vdivss %0, %d0 " : "+x" (f)); - (void) &f; - } + /* One example of an invalid operation is 0.0 / 0.0. */ + divss_inline_asm (0.0f, 0.0f); /* Next: division by zero. */ if ((FE_DIVBYZERO & excepts) != 0) - { - float f = 1.0; - float g = 0.0; - - __asm__ __volatile__ ("%vdivss %1, %d0" : "+x" (f) : "x" (g)); - (void) &f; - } + divss_inline_asm (1.0f, 0.0f); /* Next: overflow. */ if ((FE_OVERFLOW & excepts) != 0) diff --git a/sysdeps/x86_64/fpu/fsetexcptflg.c b/sysdeps/x86_64/fpu/fsetexcptflg.c index 34ea24c061..aa74487814 100644 --- a/sysdeps/x86_64/fpu/fsetexcptflg.c +++ b/sysdeps/x86_64/fpu/fsetexcptflg.c @@ -17,6 +17,7 @@ . */ #include +#include #include int @@ -44,13 +45,13 @@ fesetexceptflag (const fexcept_t *flagp, int excepts) __asm__ ("fldenv %0" : : "m" (temp)); /* And now similarly for SSE. */ - __asm__ ("%vstmxcsr %0" : "=m" (mxcsr)); + mxcsr = stmxcsr_inline_asm (); /* Clear or set relevant flags. */ mxcsr ^= (mxcsr ^ *flagp) & excepts; /* Put the new data in effect. */ - __asm__ ("%vldmxcsr %0" : : "m" (mxcsr)); + ldmxcsr_inline_asm (mxcsr); /* Success. */ return 0; diff --git a/sysdeps/x86_64/fpu/ftestexcept.c b/sysdeps/x86_64/fpu/ftestexcept.c index 7e0a097696..bf35fd819d 100644 --- a/sysdeps/x86_64/fpu/ftestexcept.c +++ b/sysdeps/x86_64/fpu/ftestexcept.c @@ -17,6 +17,7 @@ . */ #include +#include int __fetestexcept (int excepts) @@ -25,8 +26,8 @@ __fetestexcept (int excepts) unsigned int mxscr; /* Get current exceptions. */ - __asm__ ("fnstsw %0\n" - "%vstmxcsr %1" : "=m" (temp), "=m" (mxscr)); + asm volatile ("fnstsw %0" : "=m" (temp)); + mxscr = stmxcsr_inline_asm (); return (temp | mxscr) & excepts & FE_ALL_EXCEPT; } From patchwork Tue Oct 28 17:08:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122886 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 EDD5D3858435 for ; Tue, 28 Oct 2025 17:32:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EDD5D3858435 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=USzlCs8J X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 17C4F3858CD1 for ; Tue, 28 Oct 2025 17:13:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 17C4F3858CD1 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 17C4F3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1036 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671593; cv=none; b=rrlZqYITI+pD0zSfnLd5YkPNOSHVYpVaMhby8F8lQwPYbhjVj7m7beSiy7B1j+NFtt/FCmL5LeN5IlfaC0ASHQAkIcifXgpifGvIts3XkgmblhiWLmRbCbFZIf++XTkTyQKCg9wnU0damYuFyIn17P+wkxBOvqVn3NgztQDGfDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671593; c=relaxed/simple; bh=4+GdOge/8NQoT0RcHmjKh05PWSvE0fHsX65yLahLyV0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FGcQc1yPgM2syMrv0A2UoJBvsLq1ruqggMvf7uWmxHNrhjRJXymnlp4aLll51qWc32o3+pDpK77G1wF3wXDP4JehZokxFdanaj3eFTxS0B45/dDuR+DHh6z8oz9/4qRtJzfaUp/J/D5kaojEQFOdTid0AKwzpRWvaWywpJdKC/M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17C4F3858CD1 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-33e27cda4d7so127916a91.0 for ; Tue, 28 Oct 2025 10:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671592; x=1762276392; 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=LoxBPDSr5Tz15jZX2HcGvxEAO3rqQoBiPyhkjKyA0JI=; b=USzlCs8JhsLL49VTuhrl6kOZeHYcaSkRguVEP24pywUsQ8/+CMB6E4Gcx7gKADeQNo d2HeR3Cp6NIgAsc4094yCZIWZjpjzTngrxChjOhW/jpj4IwIt65W5xPuA6ni6pY2OWG1 ZEpoc5vXqM80f6Ple8R5CakyVPsi2XQYx2Xwj2IAgOkr0B4YR/lJka/L2IR/oGMRIoa5 mYT3q9X6rjuFemuRM+XfUZAi2GOOVLQbHiyeQfkf2HBssBUb7QPWDF8jVTBFOPVCjODs odJZqkA6Tgbp8+bJlR/t77ZiTVWxgHKkCswfCDa/5jS72rxfW+oN3wGK9KcWzL9/88U8 LI7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671592; x=1762276392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LoxBPDSr5Tz15jZX2HcGvxEAO3rqQoBiPyhkjKyA0JI=; b=WLdw02EfWzDeL9QsxygvSDKbHqtm9zHlQB73uBRmbDTCgSEtSmE/Ps2+ZmOKbigT/D LvkDUz4LBSqxxm6kwsnr6RSHIKvSnBl3FeNqNfuHtlb173aqd4HdwFpgbw5Ws8/cITmc Xmsvz370iP5XBxOg0tPAh89j8bLD4PP1EHTvykVFpI0pVmKAo5BoEmK24ujBQcAmcrE+ d4KiZPcCA19ayS/DiNmw2A1t4ySaEvPevUvjaLO15gg7kbrpLyReB7DXDIN4nId5/i20 PM5W5X5pgGQA2HPt4Y0ixj9G6vubpTXIs67MyRcCrfapAWp99rrFNEkzliJpwtz7dqSV ssbA== X-Gm-Message-State: AOJu0YyaiSOrBR9md0Ln/JtwX00J7f0MBOPy5ZRhIsVPiSvxffMh6yZN jHydMD9jw+mtkjpFY1mQ/n/+qzGqtHGXA/A+zU8N23HDi8tAGQEBmhIH668FTSGLfYMWW+EqVJz oHK6WRVM= X-Gm-Gg: ASbGnctk4f+D6AoIwprwtygmRFMJQJcg773fvJ8v76UzPIgeD82E0/riZJAPU20IlX5 v7KYLprSWfLsGuaWw3sL6ZVG28pTDbaI7KnX1Hr4ndsGYqjA4VyMW1dcDYv8z2s0peHjl+ZQgc8 mIn7Z0eDEtovKA8SZYVMXQ/QbFHWAi+8kZUj6yIyKmwU7jJWj4rUVOgkYhD3drsR7nQV5+R1eM9 2acA2E8Mc0x+3uDTopc3KKmZOLQB8S6a6aXH53EZ/u5ucCoBSyUr0fRLJa1sSIPLIW9P0aXNtLv 26fCCBOeMWYvbNjqbhttDXnf9tfZpU3kw+TuNwhAlWmaenig6W9PAg7sWdUGJJpQKNl6IZgaS7j 3q7iH8DMYS9yk1gBmM+Iur7DwSaD/UPu5s0MgkxxP5YT9avaQddW18z3+xQ3t8SfMasUIWn9ynH WPC4lkAZR1FFXPh3M7hlqSkmscEDxdOIV6efSgyz+x1hP9jg== X-Google-Smtp-Source: AGHT+IFnOYzslNiGYZ31i8im3eh9MwPHSPxTOsPfDd0lj3UhRRNjHegIWQkkSR3QmejhZOJJdXf69A== X-Received: by 2002:a17:90b:4ec5:b0:32e:8ff9:d124 with SMTP id 98e67ed59e1d1-34028736b54mr4783110a91.15.1761671591761; Tue, 28 Oct 2025 10:13:11 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:10 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 19/28] x86: Fix THREAD_GSCOPE_RESET_FLAG build on clang Date: Tue, 28 Oct 2025 14:08:28 -0300 Message-ID: <20251028171141.3208834-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org clang does not support __seg_fs in asm constraint. --- sysdeps/x86_64/nptl/tls.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h index abfeb88054..809d90875a 100644 --- a/sysdeps/x86_64/nptl/tls.h +++ b/sysdeps/x86_64/nptl/tls.h @@ -198,13 +198,27 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80, # define THREAD_GSCOPE_FLAG_UNUSED 0 # define THREAD_GSCOPE_FLAG_USED 1 # define THREAD_GSCOPE_FLAG_WAIT 2 + +/* clang does not support __seg_fs in asm constraint. */ +# ifdef __clang__ +# define XCHGL_GSCOPE(__r) \ + asm volatile ("xchgl %%fs:%c1, %0" \ + : "=r" (__r) \ + : "i" (offsetof (struct pthread, header.gscope_flag)), \ + "0" (THREAD_GSCOPE_FLAG_UNUSED) \ + : "memory") +# else +# define XCHGL_GSCOPE(__r) \ + asm volatile ("xchgl %1, %0" \ + : "=r" (__r) \ + : "m" (((struct pthread __seg_fs *)0)->header.gscope_flag), \ + "0" (THREAD_GSCOPE_FLAG_UNUSED)) +# endif + # define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res; \ - asm volatile ("xchgl %1, %0" \ - : "=r" (__res) \ - : "m" (((struct pthread __seg_fs *)0)->header.gscope_flag), \ - "0" (THREAD_GSCOPE_FLAG_UNUSED)); \ + XCHGL_GSCOPE (__res); \ if (__res == THREAD_GSCOPE_FLAG_WAIT) \ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ } \ From patchwork Tue Oct 28 17:08:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122870 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 48D173858427 for ; Tue, 28 Oct 2025 17:16:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 48D173858427 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=BASmXOg/ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 1C09C3858D1E for ; Tue, 28 Oct 2025 17:13:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C09C3858D1E 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 1C09C3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1034 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671596; cv=none; b=XJXJLqd9v+SjlcbB9/HM0dRkSCPIXwdd5KGegwkj4VU+mZSEQ9TMEi5eUTfaEN87tLESlTMo/f17tN4OlLHcnJk6QR/yUUofxqC14rcpLNtaf6ykvrNLkkhgJAN5jVCRzHe0Znb1JTJMeObBQN0Q0+NUONxJgBZArkr6HhtTEjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671596; c=relaxed/simple; bh=51E14Ap/QEW7/Ueej2MUPEYgELP2YT0Z+40adNtwYAg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JKeqaNg1f2m8mex+I4csDk8jq8jF13Nn8EjV7/Hd4D2WoMQ1MwZiZMJmuHTUv+l/5VBD63hTA93ooak+lZOuiMiEDFwKEAM1l2Qu3VQ+qBxlwQFXelriuohA3YYFEU05iRvDV4tvQm86UIh1opqiQT20zpCfqh076DWDD4bDS5c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C09C3858D1E Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-3307de086d8so5686818a91.2 for ; Tue, 28 Oct 2025 10:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671594; x=1762276394; 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=dHxutnjaSjehT+uE0vrLLehTW7YHmY53wRmwii/UkOU=; b=BASmXOg/OvAQA3cIEWw7afhHG1RZhnx+a6qut/MnWgqXszFoKj5BLhyGoN4mEEpQ5Q P2jvZenXTiprKG0U5M6lCA43jpVSxdYyH+gVwWhsLYzPOB8FRmqyXAqCcp9LtPWXwJL7 iqAchSaeYZtdn2rGVNMOW/lSuuk4bVt6DgZd/+QKca1unJS+tyIwJjeFkguzyW881Qjd WnCeGZ0vLPkn9ftMo3438wfEvl7TzudZedy7/8zKplwGHMhgkcB3tXQFp2NpkmxoYXI7 GjbqGK9AAB5+iuyX0D8TaV0VEl0sbq4PCZMlMiKeqsJGY2tmRUKt0UtM3aUpsoPz8eGk LnFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671594; x=1762276394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dHxutnjaSjehT+uE0vrLLehTW7YHmY53wRmwii/UkOU=; b=xCkG3eCnwhdfkD5UJUw6yhvg8rMx9V6Uw0Stb9iC63rYQo0AvRq9NP/7zFvzDVnJ6f 6EBAZm3KFsFRJC8hP1Fc3WtQ6rnFDUyAq49ct2QA7RGR09mefa+Fm03xJZ1KfGQ+y6Te hyVHpnfjX0eOFTfXf9FQiS2ULQzlZSEjRV1aq4uof4vDpXKSzdzhgSnH39Qh7y4wVdYf rtNYsWGBRVlyKoXe3J7QfZwWLbPxrqNQ4/7BOpm6u22mvrLjyQSEOdroqzu9UNz6tTcm cWsHA09GTLJ5TRmHVEiz7M7l3MAzZJT+fLjp8vCVRcyE0RR//oqFtR96yGXkImU4pugv dzOA== X-Gm-Message-State: AOJu0YyR/Cv/Isah9qIU5qABM99kOAj1VO7RndB7N87XBThC5Rax3CGa x79lFsbA6YwckjEdRxkXoDuHiFL4NN6HBex5FdWjDc5GqvAfuuhivuqLGTEObJJh+N+LDFVV1Iv i2GM1fcs= X-Gm-Gg: ASbGncvq1m+T71KeSQhfs94jeCPk/9FqjyWD8lroDMuZuoeM8ZM3mNaMMYKI/buWHCI pklNsbllmeQn3O6ONRXQG1VE43F7Z4ZWGE+CwwAzSitNlk2i8qm6DSnMTcy3Cxaj3kArIBvW140 Nuj8jhao2FdCBms2+lH35xQ3AKQL7IwxaLUsYQ2H/FkEOJQZVKIGIlCdh7fXTUl2JBVXc22PFm0 TfsH5g4hjLj3Wx1R1kuTdd6tPLF57MEEk3vr9vfOe6HqdU+9l70d7ldfmdTwN7EolQ4vV9fuot4 Ogk70So0o6mQvkPd1SXTYoRNocTS6OCcXnc3eEHC1NL9alQyOtCehAA49W4NuL8cE3l9M2Y/k5Q dMwy/NnKuHDG/nm6UBUbYq7yA3t5aesujfAlcSE6C+ZIClXbRQGTCInWMB1TKUNLYBwxq5r2jBr /01THYEf8E6RQhfQMzX/bU7LaCvqw3E2TpTq1zzyXSpYOEhw== X-Google-Smtp-Source: AGHT+IE219OIfsQclwtV/K4KEx/R55uWQ8taGeWOCe4XkO3cSg9PqKBb0ID0reW9L6c5+gWDfjlQtA== X-Received: by 2002:a17:90b:4f48:b0:338:3e6f:2d63 with SMTP id 98e67ed59e1d1-340279e5c59mr5192716a91.6.1761671594404; Tue, 28 Oct 2025 10:13:14 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:13 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 20/28] aarch64: Use NO_MATH_REDIRECT on pow_advsimd.c Date: Tue, 28 Oct 2025 14:08:29 -0300 Message-ID: <20251028171141.3208834-21-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org clang does not optimize the fma calls, instead issuing __fma. --- sysdeps/aarch64/fpu/pow_advsimd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sysdeps/aarch64/fpu/pow_advsimd.c b/sysdeps/aarch64/fpu/pow_advsimd.c index e5bb4f0306..6437df411a 100644 --- a/sysdeps/aarch64/fpu/pow_advsimd.c +++ b/sysdeps/aarch64/fpu/pow_advsimd.c @@ -17,6 +17,7 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT #include "v_math.h" /* Defines parameters of the approximation and scalar fallback. */ From patchwork Tue Oct 28 17:08:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122887 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 62F073858417 for ; Tue, 28 Oct 2025 17:32:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62F073858417 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=LtMa3tPS X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 634393858418 for ; Tue, 28 Oct 2025 17:13:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 634393858418 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 634393858418 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1034 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671600; cv=none; b=DfqnUa5l6DFlXEO4KXvY3u+kmIvfm77z2k8B3SXVJgWgQ+dQQAXdYk8MXWcv5ogzkJy4C/xfFkQHHKo0qUyh1j2xTMXsfVrmfyyOaWYkh4awbvHEr2YqS0mpzLZuK4xZSv4zwxx1fhYVIs1KNR0dUkS9xDX0T5FVplOH8VYnBXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671600; c=relaxed/simple; bh=GF2vb550yes/B8RDf0dSEZCpgRXxmiw9jn3wWCE+wY0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YIx8rrlEVq3NF6iIGZqcthYILdeV88BS8t6/sI8QxYGnrqknCMQmGkv4WSSeFlJkgG4Skpa+6hOhYxSMLKYXR2qTutpl5NlvRryOATyNbP909nGlfFBsol+bEeeGnX+WCP1lKP988IcxcD00Hn+Sbpu7q+NhlMqJx24+YtvmLrk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 634393858418 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-33d962c0e9aso112378a91.0 for ; Tue, 28 Oct 2025 10:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671598; x=1762276398; 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=9F1sdRwNp5of4dcXXjQKNtK12tVv9ZmpD0yaocDx2lw=; b=LtMa3tPSw1IrTa0II0U/JLpzkkrBm8fq7LJhJd9151T2f6h9/rQavUk1tTrWSFSjMF efiHpSdyaKfR9IyUwnu6o46r2SxhljbxdQWljpZKF27o7LYUEbgxK6R+98Ql8Y6pWH9c 7rPXCiopnfukbZidlXdHgf4TAYHd9OOpwweiTIhJxbi2IOnfpwtFUqqMNyh2gYJE2JKr JL193Q9fTxU8JCYSUx8vQr+HZcmruVWdRHoqotu979HYsaJ5sdeEpcU5gP9K5d5DYlUH B5rFTwy/b/s0Y7yKdgA5tqwIdUSDMCX2Y5iBEIUvY3SeN38TDMlSAmY4C9nLHBlsmFH9 zmyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671598; x=1762276398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9F1sdRwNp5of4dcXXjQKNtK12tVv9ZmpD0yaocDx2lw=; b=otncNRZi+Eiob7x4WfI+wfLeE9lGToDVVg+xD5LcTDHJQT6BojM04JwLjCcdmtLncO QC6yXoez7rMnzKCU+tuDH3xx9Oc/ZPWWnfW/i99UVRVWnd7KgVML4PiM4gAHiprVlsrq oq3Wvdteq/iq6R/JxrJdIdMP3Wgt6TnGUoh0OgiEG7A2OQWhv7zT7MDoQhQRmP+hRlaB QqV/Jfs/3zz5EP+vZCoLyK482K6MHVc23PkyKBbTk+zhaEzOkj9RwEd3mxm+H48v7twF WbibYwpFH7XA2euShZEP7JQlnK0v2rIB+kxLmqR5kt3RV7tfw57YRG53RUytCPliNUk3 xGTw== X-Gm-Message-State: AOJu0YwziGA29MKF9ZhdWjpn+CZ+CARziqEuBA9Ss4MSkLJXo2iuPthg feXtG2FT2YTrSIxAquz2Ne3SNXtDQH1J7xN6K/LvT1/e2IA7G5vN49Te5bHVYROcqEX5kta5IOM HHAZZZTo= X-Gm-Gg: ASbGnctgFtpVxDwLoBCq/9eDprbl7vM0xKAXnjNKWjaqDwaAKwMhANMhF30NKvx+/HJ 90iURk6TCmyQeh0Mb8C7aJJA9rLmrPDPK+NKBBpfaB3AoJ79In1fCHiP0gYwbfakQrX+jwaiTof 3xgCTQK+ttwgBWlVBeuPqJYz7c0eV7DiTAI9HfhvahxOf1+X9cNfNDCPxFrR5gIfGefz5VTKXU7 Mgs96Poz5dvhWJ/G/+rrxmFBJ0pIbBMJJf3hnhVotyrY7+/gpcdulWcm1KAPgSPk0YxmXOySCG9 l7H4zKe4afrFiLiX6s/WXsnf8a/trogjlYDgBY9hpLfYP7xKKUKD8giNIyUvrwstgGfJu0bmJUK D4pH1Ix2UW/v01gUco+nIDwzqT9sP8ON1F/zo7al6G5Jdu2sX6nCrg4aKsRYgOubX4sA75zcne9 dysvledSY+tAssvTwczxQbQ6tyshOZrWsM6JoHmjq1eIk1Sw== X-Google-Smtp-Source: AGHT+IGr7iUOCcRWyFsV2k0VcpBDs3gtfxPQu+aVzm0ClDZC+lL/AMqdUG8yuDKfS73BacSz9UpFzw== X-Received: by 2002:a17:90b:2547:b0:32e:7277:9a81 with SMTP id 98e67ed59e1d1-3403963d7dcmr27654a91.4.1761671597689; Tue, 28 Oct 2025 10:13:17 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:16 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 21/28] Annotate swtich fall-through Date: Tue, 28 Oct 2025 14:08:30 -0300 Message-ID: <20251028171141.3208834-22-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_FILL_THIS_FORM_SHORT 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 default to warning for missing fall-through and it does not support all comment-like annotation that gcc does. Use C23 [[fallthrough]] annotation instead. proper attribute instead. --- elf/dl-exception.c | 4 ++-- elf/dl-find_object.h | 2 +- elf/dl-lookup.c | 2 +- elf/ldconfig.c | 2 +- elf/rtld.c | 4 ++-- iconv/gconv_charset.c | 2 +- iconvdata/cns11643.h | 2 +- inet/ruserpass.c | 2 +- intl/Makefile | 3 ++- locale/programs/charmap-kw.h | 8 ++++---- locale/programs/charmap.c | 4 ++-- locale/programs/locfile-kw.h | 6 +++--- locale/programs/repertoire.c | 4 ++-- malloc/mcheck-impl.c | 2 +- misc/mntent_r.c | 4 ++-- nis/nis_call.c | 2 +- nptl/pthread_mutex_trylock.c | 2 +- nptl/pthread_mutex_unlock.c | 2 +- nss/digits_dots.c | 2 +- nss/nss_hash.c | 6 +++--- posix/execvpe.c | 1 + posix/fnmatch.c | 2 +- posix/regex_internal.h | 2 +- posix/wordexp.c | 4 ++-- resolv/base64.c | 2 +- resolv/ns_ttl.c | 8 ++++---- resolv/nss_dns/dns-host.c | 4 ++-- resolv/res_hconf.c | 1 + resolv/res_query.c | 6 +++--- stdio-common/printf-parsemb.c | 2 +- stdio-common/vfscanf-internal.c | 4 ++-- sunrpc/svc_tcp.c | 2 +- sunrpc/svc_unix.c | 2 +- sunrpc/xdr.c | 12 ++++++------ sysdeps/aarch64/fpu/fpu_control.h | 1 + sysdeps/ieee754/ldbl-96/e_lgammal_r.c | 4 ++++ sysdeps/x86/cpu-features.c | 6 +++--- sysdeps/x86/readelflib.c | 2 +- sysdeps/x86_64/dl-machine.h | 4 ++-- time/strftime_l.c | 4 ++-- time/strptime_l.c | 4 ++-- 41 files changed, 75 insertions(+), 67 deletions(-) diff --git a/elf/dl-exception.c b/elf/dl-exception.c index 3bdb69662a..f5b88ac0f9 100644 --- a/elf/dl-exception.c +++ b/elf/dl-exception.c @@ -134,7 +134,7 @@ _dl_exception_create_format (struct dl_exception *exception, const char *objname ++p; break; } - /* Fall through. */ + [[fallthrough]]; case 'x': length += INT_WIDTH / 4; break; @@ -219,7 +219,7 @@ _dl_exception_create_format (struct dl_exception *exception, const char *objname ++p; break; } - /* FALLTHROUGH */ + [[fallthrough]]; default: _dl_fatal_printf ("Fatal error:" " invalid format in exception string\n"); diff --git a/elf/dl-find_object.h b/elf/dl-find_object.h index d9d75c4ad9..92be53fb14 100644 --- a/elf/dl-find_object.h +++ b/elf/dl-find_object.h @@ -136,7 +136,7 @@ _dl_find_object_from_map (struct link_map *l, atomic_store_relaxed (&result->sframe, (void *) (ph->p_vaddr + l->l_addr)); read_seg |= 2; - /* Fall through. */ + [[fallthrough]]; default: break; } diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index c32362da4c..7bf8dfbe2f 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -490,7 +490,7 @@ do_lookup_x (const char *undef_name, unsigned int new_hash, } break; } - /* FALLTHROUGH */ + [[fallthrough]]; case STB_GLOBAL: /* Global definition. Just what we need. */ result->s = sym; diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 39b154c72c..a83f256df2 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -1151,7 +1151,7 @@ parse_conf_include (const char *config_file, unsigned int lineno, case GLOB_NOSPACE: errno = ENOMEM; - /* Fall through. */ + [[fallthrough]]; case GLOB_ABORTED: if (opt_verbose) error (0, errno, _("%s:%u: cannot read directory %s"), diff --git a/elf/rtld.c b/elf/rtld.c index 8b472e9c0c..299f8dd60e 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -2755,10 +2755,10 @@ print_statistics_item (const char *title, hp_timing_t time, { case 3: *wp++ = *cp++; - /* Fall through. */ + [[fallthrough]]; case 2: *wp++ = *cp++; - /* Fall through. */ + [[fallthrough]]; case 1: *wp++ = '.'; *wp++ = *cp++; diff --git a/iconv/gconv_charset.c b/iconv/gconv_charset.c index 89de93d689..ecf419b093 100644 --- a/iconv/gconv_charset.c +++ b/iconv/gconv_charset.c @@ -47,7 +47,7 @@ find_suffix (char *s) { case '/': slash_count++; - /* Fallthrough */ + [[fallthrough]]; case ',': suffix_term = &s[i]; } diff --git a/iconvdata/cns11643.h b/iconvdata/cns11643.h index d4b6f2b433..8c2c3071d5 100644 --- a/iconvdata/cns11643.h +++ b/iconvdata/cns11643.h @@ -220,7 +220,7 @@ ucs4_to_cns11643 (uint32_t wch, unsigned char *s, size_t avail) if (cp[0] != '\0') break; /* Let's try the other planes. */ - /* Fall through. */ + [[fallthrough]]; case 0x3400 ... 0x4dff: case 0x9f9d ... 0x9fa5: /* Let's try the other planes. */ diff --git a/inet/ruserpass.c b/inet/ruserpass.c index 903fc966fd..be4e024203 100644 --- a/inet/ruserpass.c +++ b/inet/ruserpass.c @@ -125,7 +125,7 @@ next: case DEFAULT: usedefault = 1; - /* FALL THROUGH */ + [[fallthrough]]; case MACHINE: if (!usedefault) { diff --git a/intl/Makefile b/intl/Makefile index 5aa42597f5..1d9365e241 100644 --- a/intl/Makefile +++ b/intl/Makefile @@ -159,7 +159,8 @@ $(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out CPPFLAGS += -D'LOCALEDIR="$(localedir)"' \ -D'LOCALE_ALIAS_PATH="$(localedir)"' \ - -Wno-unused-but-set-variable + -Wno-unused-but-set-variable \ + -Wno-implicit-fallthrough BISONFLAGS = --yacc --no-lines --name-prefix=__gettext --output $(inst_localedir)/locale.alias: locale.alias $(+force) diff --git a/locale/programs/charmap-kw.h b/locale/programs/charmap-kw.h index 505b364d88..3ae6f2f6f0 100644 --- a/locale/programs/charmap-kw.h +++ b/locale/programs/charmap-kw.h @@ -104,19 +104,19 @@ hash (register const char *str, register size_t len) switch (hval) { default: - hval += asso_values[(unsigned char)str[8]]; - /*FALLTHROUGH*/ + hval += asso_values[(unsigned char)str[8]]; + [[fallthrough]]; case 8: case 7: case 6: case 5: hval += asso_values[(unsigned char)str[4]]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 4: case 3: case 2: hval += asso_values[(unsigned char)str[1]]; - /*FALLTHROUGH*/ + [[fallthrough]]; case 1: hval += asso_values[(unsigned char)str[0]]; break; diff --git a/locale/programs/charmap.c b/locale/programs/charmap.c index 7768a7a7fc..6927f9be7e 100644 --- a/locale/programs/charmap.c +++ b/locale/programs/charmap.c @@ -548,7 +548,7 @@ character sets with locking states are not supported")); state = 4; continue; } - /* FALLTHROUGH */ + [[fallthrough]] ; case 5: if (nowtok != tok_charcode) @@ -712,7 +712,7 @@ only WIDTH definitions are allowed to follow the CHARMAP definition")); state = 95; continue; } - /* Fall through. */ + [[fallthrough]] ; case 96: if (nowtok != tok_number) diff --git a/locale/programs/locfile-kw.h b/locale/programs/locfile-kw.h index 9460a43ab1..dd7ea27615 100644 --- a/locale/programs/locfile-kw.h +++ b/locale/programs/locfile-kw.h @@ -105,18 +105,18 @@ hash (register const char *str, register size_t len) { default: hval += asso_values[(unsigned char)str[8]]; - /*FALLTHROUGH*/ + [[fallthrough]] ; case 8: case 7: case 6: case 5: hval += asso_values[(unsigned char)str[4]]; - /*FALLTHROUGH*/ + [[fallthrough]] ; case 4: case 3: case 2: hval += asso_values[(unsigned char)str[1]]; - /*FALLTHROUGH*/ + [[fallthrough]] ; case 1: hval += asso_values[(unsigned char)str[0]]; break; diff --git a/locale/programs/repertoire.c b/locale/programs/repertoire.c index 7ed8c915dd..591d952fad 100644 --- a/locale/programs/repertoire.c +++ b/locale/programs/repertoire.c @@ -206,7 +206,7 @@ argument to <%s> must be a single character"), /* Otherwise we start reading the character definitions. */ state = 2; - /* FALLTHROUGH */ + [[fallthrough]] ; case 2: /* We are now are in the body. Each line @@ -254,7 +254,7 @@ argument to <%s> must be a single character"), state = 4; continue; } - /* FALLTHROUGH */ + [[fallthrough]] ; case 5: /* We expect a value of the form or where diff --git a/malloc/mcheck-impl.c b/malloc/mcheck-impl.c index a874211e78..6f60c8fa34 100644 --- a/malloc/mcheck-impl.c +++ b/malloc/mcheck-impl.c @@ -389,7 +389,7 @@ __mcheck_initialize (void (*func) (enum mcheck_status), bool in_pedantic) case -1: /* Called before the first malloc was called. */ __debug_free (__debug_malloc (0)); - /* FALLTHROUGH */ + [[fallthrough]] ; case 0: /* Called through the initializer hook. */ __malloc_debug_enable (MALLOC_MCHECK_HOOK); diff --git a/misc/mntent_r.c b/misc/mntent_r.c index f36c2f534e..26e8ade30e 100644 --- a/misc/mntent_r.c +++ b/misc/mntent_r.c @@ -167,10 +167,10 @@ get_mnt_entry (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) { case 0: mp->mnt_freq = 0; - /* Fall through. */ + [[fallthrough]] ; case 1: mp->mnt_passno = 0; - /* Fall through. */ + [[fallthrough]] ; case 2: break; } diff --git a/nis/nis_call.c b/nis/nis_call.c index f77ecec709..357bfadbbc 100644 --- a/nis/nis_call.c +++ b/nis/nis_call.c @@ -324,7 +324,7 @@ __do_niscall3 (dir_binding *dbp, u_long prog, xdrproc_t xargs, caddr_t req, } /* Yes, the missing break is correct. If we doesn't have to start a callback, look if we have to search another server */ - /* Fall through. */ + [[fallthrough]] ; case NIS_LOOKUP: case NIS_ADD: case NIS_MODIFY: diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index dbb8fcc754..bba550683b 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -68,7 +68,7 @@ ___pthread_mutex_trylock (pthread_mutex_t *mutex) case PTHREAD_MUTEX_TIMED_NP: FORCE_ELISION (mutex, goto elision); - /*FALL THROUGH*/ + [[fallthrough]] ; case PTHREAD_MUTEX_ADAPTIVE_NP: case PTHREAD_MUTEX_ERRORCHECK_NP: if (lll_trylock (mutex->__data.__lock) != 0) diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c index 60bea80d20..ef224c09e5 100644 --- a/nptl/pthread_mutex_unlock.c +++ b/nptl/pthread_mutex_unlock.c @@ -319,7 +319,7 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr) if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid) || (mutex->__data.__lock & ~ PTHREAD_MUTEX_PRIO_CEILING_MASK) == 0) return EPERM; - /* FALLTHROUGH */ + [[fallthrough]] ; case PTHREAD_MUTEX_PP_NORMAL_NP: case PTHREAD_MUTEX_PP_ADAPTIVE_NP: diff --git a/nss/digits_dots.c b/nss/digits_dots.c index e27c57233b..7de92344ca 100644 --- a/nss/digits_dots.c +++ b/nss/digits_dots.c @@ -230,7 +230,7 @@ __nss_hostname_digits_dots_context (struct resolv_context *ctx, addr_size = IN6ADDRSZ; break; } - /* FALLTHROUGH */ + [[fallthrough]] ; case AF_INET: /* This is not possible. We cannot represent an IPv6 address diff --git a/nss/nss_hash.c b/nss/nss_hash.c index a0bec72668..f20ff59f26 100644 --- a/nss/nss_hash.c +++ b/nss/nss_hash.c @@ -52,13 +52,13 @@ __nss_hash (const void *keyarg, size_t len) case 0: /* h starts out as zero so no need to include the multiply. */ h = *key++; - /* FALLTHROUGH */ + [[fallthrough]]; case 3: HASHC; - /* FALLTHROUGH */ + [[fallthrough]]; case 2: HASHC; - /* FALLTHROUGH */ + [[fallthrough]]; case 1: HASHC; /* FALLTHROUGH */ diff --git a/posix/execvpe.c b/posix/execvpe.c index 20a178c1d3..52115055df 100644 --- a/posix/execvpe.c +++ b/posix/execvpe.c @@ -149,6 +149,7 @@ __execvpe_common (const char *file, char *const argv[], char *const envp[], up finding no executable we can use, we want to diagnose that we did find one but were denied access. */ got_eacces = true; + [[fallthrough]] ; case ENOENT: case ESTALE: case ENOTDIR: diff --git a/posix/fnmatch.c b/posix/fnmatch.c index 32ad3ff23a..0828509e6a 100644 --- a/posix/fnmatch.c +++ b/posix/fnmatch.c @@ -61,7 +61,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags); #endif #ifdef _LIBC -# if __GNUC__ >= 7 +# if (__GNUC__ >= 7) || (__clang_major__ >= 10) # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) diff --git a/posix/regex_internal.h b/posix/regex_internal.h index 722da1b7d2..6664ec6fd8 100644 --- a/posix/regex_internal.h +++ b/posix/regex_internal.h @@ -834,7 +834,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx) #endif /* RE_ENABLE_I18N */ #ifdef _LIBC -# if __GNUC__ >= 7 +# if (__GNUC__ >= 7) || (__clang_major__ >= 10) # define FALLTHROUGH __attribute__ ((__fallthrough__)) # else # define FALLTHROUGH ((void) 0) diff --git a/posix/wordexp.c b/posix/wordexp.c index a69b732801..88058278b0 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -783,7 +783,7 @@ parse_arith (char **word, size_t *word_length, size_t *max_length, case '(': ++paren_depth; - /* Fall through. */ + [[fallthrough]] ; default: expr = w_addchar (expr, &expr_length, &expr_maxlen, words[*offset]); if (expr == NULL) @@ -2103,7 +2103,7 @@ parse_backtick (char **word, size_t *word_length, size_t *max_length, case '\'': squoting = 1 - squoting; - /* Fall through. */ + [[fallthrough]] ; default: comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]); if (comm == NULL) diff --git a/resolv/base64.c b/resolv/base64.c index 11463235c8..b09292e067 100644 --- a/resolv/base64.c +++ b/resolv/base64.c @@ -275,7 +275,7 @@ b64_pton (char const *src, u_char *target, size_t targsize) return (-1); ch = *src++; /* Skip the = */ /* Fall through to "single trailing =" case. */ - /* FALLTHROUGH */ + [[fallthrough]] ; case 3: /* Valid, means two bytes of info */ /* diff --git a/resolv/ns_ttl.c b/resolv/ns_ttl.c index d29d9dc00c..e29be12920 100644 --- a/resolv/ns_ttl.c +++ b/resolv/ns_ttl.c @@ -113,13 +113,13 @@ ns_parse_ttl(const char *src, u_long *dst) { ch = toupper(ch); switch (ch) { case 'W': tmp *= 7; - /* Fall through. */ + [[fallthrough]] ; case 'D': tmp *= 24; - /* Fall through. */ + [[fallthrough]] ; case 'H': tmp *= 60; - /* Fall through. */ + [[fallthrough]] ; case 'M': tmp *= 60; - /* Fall through. */ + [[fallthrough]] ; case 'S': break; default: goto einval; } diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 14da73ee1d..d8856653d8 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -235,7 +235,7 @@ gethostbyname3_context (struct resolv_context *ctx, case EMFILE: case ENFILE: h_errno = NETDB_INTERNAL; - /* Fall through. */ + [[fallthrough]] ; case ECONNREFUSED: case ETIMEDOUT: status = NSS_STATUS_UNAVAIL; @@ -444,7 +444,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, case EMFILE: case ENFILE: h_errno = NETDB_INTERNAL; - /* Fall through. */ + [[fallthrough]] ; case ECONNREFUSED: case ETIMEDOUT: status = NSS_STATUS_UNAVAIL; diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c index 186af81690..760de69664 100644 --- a/resolv/res_hconf.c +++ b/resolv/res_hconf.c @@ -146,6 +146,7 @@ arg_trimdomain_list (const char *fname, int line_num, const char *args) free (buf); return NULL; } + [[fallthrough]] ; default: break; } diff --git a/resolv/res_query.c b/resolv/res_query.c index bd55453552..1eb2287fee 100644 --- a/resolv/res_query.c +++ b/resolv/res_query.c @@ -277,7 +277,7 @@ __res_context_query (struct resolv_context *ctx, const char *name, || (hp2->rcode == NOERROR && ntohs (hp2->ancount) != 0)) goto success; - /* FALLTHROUGH */ + [[fallthrough]] ; case REFUSED: default: RES_SET_H_ERRNO(statp, NO_RECOVERY); @@ -477,7 +477,7 @@ __res_context_search (struct resolv_context *ctx, switch (statp->res_h_errno) { case NO_DATA: got_nodata++; - /* FALLTHROUGH */ + [[fallthrough]] ; case HOST_NOT_FOUND: /* keep trying */ break; @@ -487,7 +487,7 @@ __res_context_search (struct resolv_context *ctx, got_servfail++; break; } - /* FALLTHROUGH */ + [[fallthrough]] ; default: /* anything else implies that we're done */ done++; diff --git a/stdio-common/printf-parsemb.c b/stdio-common/printf-parsemb.c index a7ba52a9fa..21625036d7 100644 --- a/stdio-common/printf-parsemb.c +++ b/stdio-common/printf-parsemb.c @@ -272,7 +272,7 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn, if (*format != L_('l')) break; ++format; - /* FALLTHROUGH */ + [[fallthrough]] ; case L_('L'): /* doubles are long doubles, and ints are long long ints. */ case L_('q'): diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c index c6361f74e0..0870a42c4e 100644 --- a/stdio-common/vfscanf-internal.c +++ b/stdio-common/vfscanf-internal.c @@ -915,7 +915,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, break; } - /* FALLTHROUGH */ + [[fallthrough]]; case L_('C'): if (width == -1) width = 1; @@ -1258,7 +1258,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, } break; } - /* FALLTHROUGH */ + [[fallthrough]] ; case L_('S'): { diff --git a/sunrpc/svc_tcp.c b/sunrpc/svc_tcp.c index 663b34a71c..948c22978c 100644 --- a/sunrpc/svc_tcp.c +++ b/sunrpc/svc_tcp.c @@ -334,7 +334,7 @@ readtcp (char *xprtptr, char *buf, int len) case -1: if (errno == EINTR) continue; - /*FALLTHROUGH*/ + [[fallthrough]]; case 0: goto fatal_err; default: diff --git a/sunrpc/svc_unix.c b/sunrpc/svc_unix.c index c97880c012..c8559ea265 100644 --- a/sunrpc/svc_unix.c +++ b/sunrpc/svc_unix.c @@ -440,7 +440,7 @@ readunix (char *xprtptr, char *buf, int len) case -1: if (errno == EINTR) continue; - /*FALLTHROUGH*/ + [[fallthrough]] ; case 0: goto fatal_err; default: diff --git a/sunrpc/xdr.c b/sunrpc/xdr.c index a76094d6da..e8752a3e52 100644 --- a/sunrpc/xdr.c +++ b/sunrpc/xdr.c @@ -113,7 +113,7 @@ xdr_int (XDR *xdrs, int *ip) return FALSE; } *ip = (int) l; - /* Fall through. */ + [[fallthrough]] ; case XDR_FREE: return TRUE; } @@ -153,7 +153,7 @@ xdr_u_int (XDR *xdrs, u_int *up) return FALSE; } *up = (u_int) (u_long) l; - /* Fall through. */ + [[fallthrough]] ; case XDR_FREE: return TRUE; } @@ -508,7 +508,7 @@ xdr_enum (XDR *xdrs, enum_t *ep) return FALSE; } *ep = l; - /* Fall through. */ + [[fallthrough]] ; case XDR_FREE: return TRUE; @@ -631,7 +631,7 @@ xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize) (void) __fxprintf (NULL, "%s: %s", __func__, _("out of memory\n")); return FALSE; } - /* Fall through. */ + [[fallthrough]] ; case XDR_ENCODE: return xdr_opaque (xdrs, sp, nodesize); @@ -752,7 +752,7 @@ xdr_string (XDR *xdrs, char **cpp, u_int maxsize) { return TRUE; /* already free */ } - /* fall through... */ + [[fallthrough]] ; case XDR_ENCODE: if (sp == NULL) return FALSE; @@ -792,7 +792,7 @@ xdr_string (XDR *xdrs, char **cpp, u_int maxsize) return FALSE; } sp[size] = 0; - /* Fall through. */ + [[fallthrough]] ; case XDR_ENCODE: return xdr_opaque (xdrs, sp, size); diff --git a/sysdeps/aarch64/fpu/fpu_control.h b/sysdeps/aarch64/fpu/fpu_control.h index a93dbf5efa..2ed6ba6b52 100644 --- a/sysdeps/aarch64/fpu/fpu_control.h +++ b/sysdeps/aarch64/fpu/fpu_control.h @@ -20,6 +20,7 @@ #define _AARCH64_FPU_CONTROL_H #include +#include /* Macros for accessing the FPCR and FPSR. */ diff --git a/sysdeps/ieee754/ldbl-96/e_lgammal_r.c b/sysdeps/ieee754/ldbl-96/e_lgammal_r.c index d4fd7f5272..7e373201ee 100644 --- a/sysdeps/ieee754/ldbl-96/e_lgammal_r.c +++ b/sysdeps/ieee754/ldbl-96/e_lgammal_r.c @@ -402,12 +402,16 @@ __ieee754_lgammal_r (long double x, int *signgamp) { case 7: z *= (y + 6.0); /* FALLTHRU */ + [[fallthrough]] ; case 6: z *= (y + 5.0); /* FALLTHRU */ + [[fallthrough]] ; case 5: z *= (y + 4.0); /* FALLTHRU */ + [[fallthrough]] ; case 4: z *= (y + 3.0); /* FALLTHRU */ + [[fallthrough]] ; case 3: z *= (y + 2.0); /* FALLTHRU */ r += __ieee754_logl (z); diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index c696a4d1f7..d3409a5b3f 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -798,7 +798,7 @@ init_cpu_features (struct cpu_features *cpu_features) processor. */ if (stepping > 0xc) break; - /* Fall through. */ + [[fallthrough]] ; case INTEL_BIGCORE_SKYLAKE: /* Disable Intel TSX and enable RTM_ALWAYS_ABORT for processors listed in: @@ -937,7 +937,7 @@ disable_tsx: non-temporal on all Skylake servers. */ cpu_features->preferred[index_arch_Avoid_Non_Temporal_Memset] |= bit_arch_Avoid_Non_Temporal_Memset; - /* fallthrough */ + [[fallthrough]] ; case INTEL_BIGCORE_COMETLAKE: case INTEL_BIGCORE_SKYLAKE: case INTEL_BIGCORE_KABYLAKE: @@ -1091,7 +1091,7 @@ disable_tsx: /* Yongfeng and Shijidadao mircoarch tuning. */ case 0x5b: cpu_features->cachesize_non_temporal_divisor = 2; - /* fallthrough */ + [[fallthrough]] ; case 0x6b: cpu_features->preferred[index_arch_AVX_Fast_Unaligned_Load] &= ~bit_arch_AVX_Fast_Unaligned_Load; diff --git a/sysdeps/x86/readelflib.c b/sysdeps/x86/readelflib.c index acb25d710b..9b9d626176 100644 --- a/sysdeps/x86/readelflib.c +++ b/sysdeps/x86/readelflib.c @@ -44,7 +44,7 @@ process_elf_file (const char *file_name, const char *lib, int *flag, case EM_386: if (elf_header->e_ident[EI_CLASS] == ELFCLASS32) break; - /* Fall through. */ + [[fallthrough]] ; default: error (0, 0, _("%s is for unknown machine %d.\n"), file_name, elf_header->e_machine); diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index 572a1a7395..c765ca14da 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -313,7 +313,7 @@ and creates an unsatisfiable circular dependency.\n", { case R_X86_64_JUMP_SLOT: map->l_has_jump_slot_reloc = true; - /* fallthrough */ + [[fallthrough]]; case R_X86_64_GLOB_DAT: *reloc_addr = value; break; @@ -422,7 +422,7 @@ and creates an unsatisfiable circular dependency.\n", /* Set to symbol size plus addend. */ value = sym->st_size; # endif - /* Fall through. */ + [[fallthrough]]; case R_X86_64_32: value += reloc->r_addend; *(unsigned int *) reloc_addr = value; diff --git a/time/strftime_l.c b/time/strftime_l.c index 5cb5f5d213..307e7e8fd6 100644 --- a/time/strftime_l.c +++ b/time/strftime_l.c @@ -1093,7 +1093,7 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, #if !defined _NL_CURRENT && HAVE_STRFTIME format_char = L_('p'); #endif - /* FALLTHROUGH */ + [[fallthrough]] ; case L_('p'): if (change_case) @@ -1433,7 +1433,7 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format, case L_('\0'): /* GNU extension: % at end of format. */ --f; - /* Fall through. */ + [[fallthrough]] ; default: /* Unknown format; output the format, including the '%', since this is most likely the right thing to do if a diff --git a/time/strptime_l.c b/time/strptime_l.c index f5e2f4f5d1..7e6f974aeb 100644 --- a/time/strptime_l.c +++ b/time/strptime_l.c @@ -552,7 +552,7 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, s.decided = raw; } #endif - /* Fall through. */ + [[fallthrough]] ; case 'D': /* Match standard day format. */ if (!recursive (HERE_D_FMT)) @@ -706,7 +706,7 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, s.decided = raw; } #endif - /* Fall through. */ + [[fallthrough]] ; case 'T': if (!recursive (HERE_T_FMT)) return NULL; From patchwork Tue Oct 28 17:08:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122884 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 190AD385840B for ; Tue, 28 Oct 2025 17:31:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 190AD385840B 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=nDA1pcWM 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 29875385841C for ; Tue, 28 Oct 2025 17:13:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 29875385841C 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 29875385841C 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=1761671602; cv=none; b=MDGQrMZgrDkoB4Zy3M8J73QwuIVN4X3Q1wmELhp/xnRhHpD4BgyAuDGF8d4vfHs1n4bAtYIOY47aQL9JuYPes3FCwBDdlW2+fOP/2CWu2RPFmlP/dV5UwiFxeDRpUn0eaS55bsTHr0+C7Y0wZYfsuDJsl4lXOHQCivLpacFsaws= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671602; c=relaxed/simple; bh=SUpbjy2L0zljR9HzNO0JBHadInqaK+JvpzCPZ78qPp4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jzgX/W2oWxIy4YiOiYHfdVlcyEk7vcylhs3A9OVrtm+5PZWpZESgLmQ8pD7SzOwn4aqBUmxXO6JPk42VrcBK5OTs14rj3YOBgJkFHRZoewzE21dOg/t1tL8EX3xsZlrjRh0ExjJnee3Etmq/o8CfVlaYIJZHFEJ5kfmyzo8hlHk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29875385841C Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-33e27cda4d7so128126a91.0 for ; Tue, 28 Oct 2025 10:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671601; x=1762276401; 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=zrWXZUAiImfhf3ZxuXItOCxPz9Y7XjDkCRkm026WPQM=; b=nDA1pcWMY9gc3YynYTk+p9o7I+zpqPcgmyHrYEHNGUJXPY64TdfNzATpTxX3AH7cx+ pgQppAw+9bfJXWQcB2Um82c5u1QCWq+1xMZzbr2GQ4qjErl6mT2Lgmc1QTktboYW/Bks iyAMOA8AJQQg3k4WCIru2qCGPrfTtlr7yirtK+npqHbLIWByszbekRtr8V0+sBfeJ5u3 5UztIC+UJD0FTFhPqg3I40GbcJKepfPo2YWnx1egdYwmF9c7jxidVkX/kFS5w45z9J5/ BSPiy1MViQwvYpx8tqhRPadXct6FkntLDz7udT88oTjHdhzPY1ExVz6BiS0CIRXDMgKs 6ckQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671601; x=1762276401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zrWXZUAiImfhf3ZxuXItOCxPz9Y7XjDkCRkm026WPQM=; b=TSeie8z5BkTkP+Iot09QPQkjusRbx+Noobte6I1LhUymlnxHcv0o77WDJxsudTsHUW qOj5vTYl8IO4htVM+REqOHIP1p7giBNpx8ORRWCFVP6VP59dgq6fxE9adrxkJmqHOnUu wUvlYx45XRIBPXWbBYsvIn4gijvpxprQE+GElrJOqGgLE3643XGMUqh/d13Zs3ml5jAm 1KeDKodcIjOymX04ci2cTCNYtOU2wgFFMIFfXWIPGATMAsr9uKY2RfILUCUgKE4cHBgr howB9EaLv4Ih6iRR7yrD/XQgdzayBJqCEFE4bZ1PeskBoFkLB+P6lPXzoFYL7o9jyMe9 HzXg== X-Gm-Message-State: AOJu0Yxnc2Jwryb8sbI7yhOP4ileGTZPZP38Epr2YA5KPeiYSbbffUVF eOe/UVGSK5l+LHInnzCQRVgQBhxIBiysg4xhs+3NCega/GyTZiM4yCkOboWqDKdNewVCm0IJNKc eukmooUU= X-Gm-Gg: ASbGncvOHFz6/jIoXHP2SsWqJEXfqUhL59hOGOOT2CP4eoX5qAK9plkeSb/nHPO/lAf 6xbESclYDXPaVVgRqNlMTUAG26aLbcoooR1T4ciLNifdKPg+M/XXGPkYwQgBqGCDahxjtj7Uiww a3L2iOAFgTaTTazVTiUNCN8QpfEU7iSaxXV9CpgoU2tlDk/tDBmB3E5l2/DJnEqfReU8PJxlQEm bPvWaksmVuWyR9YWi/5DMTsnxeVad07xq72c8RjbUAg3PNEVUzCx9C+JVyv34EpgNesXftBMofO IF1jmMkPe2HoaxLpMMWsdV3lWDh0gCLWQZ7csU7TG4owWbqa7POWGBnpU7FZPPKMjNo+hVZ3pp3 GNGeEMA6O3rwEzZgcnPRGhCrAzIW8j2RTHunUXhSA38rXVQps7NRp93ceqfyQKVNz+EF+POmfxA rbWkF0WrTluQuOaHmtLhliXF44MFZytEMapKvHz3q3y84D7w== X-Google-Smtp-Source: AGHT+IFH4H8QYoZjDVUTa42Qs0swDnSRz/FWQeOnCeZ9JdTzZvYaV4eh9sm8RXxkpRAl5AKy80P6Pw== X-Received: by 2002:a17:90b:260b:b0:327:53f0:6368 with SMTP id 98e67ed59e1d1-3403963d6c8mr25178a91.2.1761671600790; Tue, 28 Oct 2025 10:13:20 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:19 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 22/28] Supress unused command arguments warning with clang Date: Tue, 28 Oct 2025 14:08:31 -0300 Message-ID: <20251028171141.3208834-23-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 20 issues an warning for the unused '-c' argument used to create errlist-data-aux-shared.S, errlist-data-aux.S, siglist-aux-shared.S, and siglist-aux.S. Filter out the '-c' from the $(compile-command.c). --- stdio-common/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdio-common/Makefile b/stdio-common/Makefile index 806e4cec3a..ddffe653e9 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -498,11 +498,11 @@ include ../Rules # than 2.29 it might generate object sizes different than the expected ones. $(objpfx)errlist-data-aux-shared.S: errlist-data-gen.c $(make-target-directory) - $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S + $(filter-out -c,$(compile-command.c)) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S $(objpfx)errlist-data-aux.S: errlist-data-gen.c $(make-target-directory) - $(compile-command.c) $(pie-default) $(no-stack-protector) -S + $(filter-out -c,$(compile-command.c)) $(pie-default) $(no-stack-protector) -S ifndef no_deps -include $(objpfx)errlist-data-aux.S.d $(objpfx)errlist-data-aux-shared.S.d @@ -514,11 +514,11 @@ $(addprefix $(objpfx)errlist-data, $(object-suffixes-noshared)): \ $(objpfx)siglist-aux-shared.S: siglist-gen.c $(make-target-directory) - $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S + $(filter-out -c,$(compile-command.c)) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S $(objpfx)siglist-aux.S: siglist-gen.c $(make-target-directory) - $(compile-command.c) $(pie-default) $(no-stack-protector) -S + $(filter-out -c,$(compile-command.c)) $(pie-default) $(no-stack-protector) -S ifndef no_deps -include $(objpfx)siglist-aux.S.d $(objpfx)siglist-aux-shared.S.d From patchwork Tue Oct 28 17:08:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122890 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 A2A483858C54 for ; Tue, 28 Oct 2025 17:34:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2A483858C54 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=KbFSkkYz X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 93D56385843D for ; Tue, 28 Oct 2025 17:13:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93D56385843D 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 93D56385843D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671605; cv=none; b=V1QQBeNwLYzpQfzW3buHvs5okT/c23tS77DBRxzFVCFIVHhgL/ClVVtjqHQh4zS+3lGA/Vs39UbvDni7a/DV8uEu6060+y86SfqcyzMsriwy0IIpo4QXJOIN8aYQz3q5fMac5grs6sIHMRPG+GCK0T8ACDf70dCxzJQdHNwUkLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671605; c=relaxed/simple; bh=44t6j6/95xcwINJeGi5lTQutBf+CU1Xu6WmMR7YtqJM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=IfInqVjI3efj4Sm4f88GfKoqQEGZV4rLPcMsvQX8AEhZmBGpdmsLwYReRw7LLdQO4bq6LjuZvA0fOSXH2E1x9/8SLp2A4PzcTAD174qyGXDUQ67woGMXWnTovzAMhAGEfhzzkYjPhkDvI/u4grjzNb5FkXEf+UDahVXcHXIIn9o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93D56385843D Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-340299fe579so1436055a91.2 for ; Tue, 28 Oct 2025 10:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671604; x=1762276404; 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=/le2nfut7YV9tzDbBB92s1yFugEA9+wSjvPDs4j1URY=; b=KbFSkkYz2JwaUw5bwjP7DFROkaLm7wG34ABmb/Am6KDMePZIfmb9akBmz4BQwJ2VDK pOxGAc5+3yCbASwZUIb9dAav4W1GcLVQAFXNcCnH+W8vIAS1xORTrxP7BiMLItrykBbk iO8Sn4TX02d64M9U+xSf+3kNIlxGvP3H8FjCBPwfRO1M8LK11Tk889k5dFTv1CY9xQQx fSnEPbHEmnlFWE27NAQPOp/KtNZKUfdKC0apQ6y8YiimT8z+3Gm35MWCh0Ov4RHgjFn3 lUyTNmpXFbDBPzEPwSVIQEcwtD2rPZN5ptUhBSMHecHCM2hneIpJt+wec/XLlJ6oz68w V2kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671604; x=1762276404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/le2nfut7YV9tzDbBB92s1yFugEA9+wSjvPDs4j1URY=; b=L399as0ACxzIGTjgYnVlAu7EUOBqFdEGMGFPDDBcEnIE/X9cOyYMqd/35G2WFPWgMT mgE3J2fnv3pOrHjXGXEOBhJLSyJk1So/BdfN9st9VmoptehXHmiOw5OSyANMxP+8DUHr Gl7Uaibm8EA8YwIgvllkwRtW75EzIpD8qfS2Kk55vfK9V7pG6/XtIEumYPaSWlK0oHE+ y2j4IHCw/mf/JYplAq7pRKbRYatPKWOvsJvAbEPapSG/1HNpoMoSkVwdzxf7ejwt8Z/G lJQzB7Skrdv5L9dFnR7EuUoMZ9jPKSCD7j1RUO5ruBMwmx7fahEaacLF9X93HQPc5GlK S5IA== X-Gm-Message-State: AOJu0YzsxLSi0RzYZMyHm7c01MmHk5kYaZaKoVzXaIPjzP7sC1g8D/n9 oOOYgXHSvsDDn3qcBr9KcOoV8egVIdyNttVp5UyC4cif+/yxxiylfyjiqYRUXviLkqtx9mbaYb6 PqZBUoXk= X-Gm-Gg: ASbGnctx3X1FopIxsc6PVh2hBttQpKmE0qtBliFxHeNiv6STCMxqUwY9BR3JvgpM4AB /8GIy13tghXcSFUkGZfDUsiBpZuNp/EkRvuOqrHvmR4lokKMf1swllf/CfD//qV0myv7Gcoch7O oyFIDeJUnkO2AWZ8WLrUH+Nv6hv7rnizxvjtAMb7n73NKyiyN/RhMaEpumU02qWRpOFesrfkk/b VfzGdHkc/hKo5FBanoXJp8bFI2JlSHwh3qqsZkFQn4EUD5znCz+AkmAeqm1kym1z2Vlox69t/aF gMwFNy7R/gJ+wMeVwHkalBqIMAPaq9Cg+XtWjpT9KueSwSZRQZfHSCqc4nI2CAV576B9vuInyYK pzFtzV0lezgu0hAMLLVv/55PipcpZgdQEPjA9fh5ntuknxS+LXo2POgrgqa7dfHE4OTiryefwux 25wEa2WKqIME095AsXQgo7CT90IEXJJttiPOv2C2j7lLnifg== X-Google-Smtp-Source: AGHT+IFg+TzrzTFKHvjSmCWfVcFrl5Jb22xA4oQ0ccfdNXjpytoNfwU/c3e2ausPbCrnKv7DpAYp8A== X-Received: by 2002:a17:90b:3c08:b0:33e:1ed8:334d with SMTP id 98e67ed59e1d1-34027a09e32mr5290322a91.16.1761671603818; Tue, 28 Oct 2025 10:13:23 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:22 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 23/28] Enable --no-undefined-version by default Date: Tue, 28 Oct 2025 14:08:32 -0300 Message-ID: <20251028171141.3208834-24-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 Recent lld version default to --no-undefined-version, which triggers errors when building multiple libraries. For ld.so on x86_64 it fails with: ld.lld: error: version script assignment of 'GLIBC_2.4' to symbol '__stack_chk_guard' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '__nptl_set_robust_list_avail' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '__pointer_chk_guard' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_PRIVATE' to symbol '_dl_starting_up' failed: symbol not defined While for libc.so: ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_clearerr' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fgetc' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fileno' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_freopen' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fscanf' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_fseek' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_peekc_unlocked' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stderr_' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stdin_' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_stdout_' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_pclose' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_perror' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_rewind' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_scanf' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_setbuf' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_setlinebuf' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_wdefault_setbuf' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '_IO_wfile_setbuf' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '__ctype32_tolower' failed: symbol not defined ld.lld: error: version script assignment of 'GLIBC_2.17' to symbol '__ctype32_toupper' failed: symbol not defined ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors) The version script is created with multiple missing symbols to simplify the build for multiple ABIs, each of which may have different symbols. For instance, __stack_chk_guard is defined by default. This avoids requiring each ABI to add this symbol to its version script, depending on the stack protector ABI it uses. The libc.so warnings do show unused symbols being defined (like _IO_clearerr), which might trigger potential errors depending on how symbols are exported. However, since we already have ABI checks for missing and extra symbols, the linker's extra checks are not really necessary. The --no-undefined-version is the default for ld.bfd. --- Makerules | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makerules b/Makerules index 7714888cdc..caa1e43faa 100644 --- a/Makerules +++ b/Makerules @@ -508,7 +508,9 @@ ifeq ($(build-shared),yes) map-file = $(firstword $($(@F:.so=-map)) \ $(addprefix $(common-objpfx), \ $(filter $(@F:.so=.map),$(version-maps)))) -load-map-file = $(map-file:%=-Wl,--version-script=%) +# The map version is created with multiple symbols that might not be +# exported depending of the ABI. +load-map-file = $(map-file:%=-Wl,--version-script=%) -Wl,--undefined-version endif # Compiler arguments to use to link a shared object with libc and From patchwork Tue Oct 28 17:08:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122875 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 95045385843A for ; Tue, 28 Oct 2025 17:21:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95045385843A 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=LU3/zOAO X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 6C2F73858419 for ; Tue, 28 Oct 2025 17:13:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C2F73858419 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 6C2F73858419 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671608; cv=none; b=KE3ZwkIDGhT+WDx3mvx8ttCvM7GBkAGKQqV7Wg1o1k0Vh3+ni2bBjywpwyLADmPeZ7N/Y3zYLzI9zSrC+HofQsv8IddHsgpPP7o5C4egXc3AU0VOdlhNJHGkm65boxhf/PAKDG4X1Kw1UY86/TojE63u4yTFIR6Tn0rxe0r2dOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671608; c=relaxed/simple; bh=5j8otjTJy8ruULs1PwiCMb8LKb/GJZ5JhLqrQ/DsrwY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aJkMVA1ArYqmAsJIxEqxnV3hBBvQVc+f7wrlpZoDorXOd5rDupCG0PnbOU3nDG1IIvIeomqeqHVe7++vKgtbJ4LA4qKHq1v2DrBRpdX9mPgjUo1niP0yeruUs9nIBJ5TZ5vXPWIP//xzu7AQZmn8POjs4AyN4X7kHqXbG/mJJnM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C2F73858419 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-33d896debe5so6958649a91.0 for ; Tue, 28 Oct 2025 10:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671607; x=1762276407; 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=hBX9HDCcJNjoFDTKwAUg8HkKMStHfXsN3erqsh+Zn3k=; b=LU3/zOAOWPUCHdJN2w2hDZeoWTXaPvvO4kUm68XRw9mngdhiLOZwVkYa1mNNGJa42u oKK6EhAe79zSeC1c/lxpWObqiZmijBSm5WwnLVOc67M/nFyYWTojg4DTColaNs2yvq+s cVufdg6VuzHaTHzKQKyg2xRcexj0v/n35eGzzuLwsi49HmJEu7g668YtjNnfoCTBJ9ed FPGabDvsZJvEm6w1jSJgi9syR/4/OB4tMcbnxeMpZv4lKJJjTGF61cSmi/RegqlL+0YQ rXcIyeaON6qfohmGFoPvjlG9+4RnqrqMM4m9hy/70EE2g4dHAIipfFTv8HL5Xw9ZWdc9 ufUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671607; x=1762276407; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hBX9HDCcJNjoFDTKwAUg8HkKMStHfXsN3erqsh+Zn3k=; b=OB4ED9EjSiIz0S/hIObnnSWN8c8A4hC2BF06KOgVc+y6d6UAYQKw+5OWFwVQPyaMnG tBfg0qb5ca/qQ8oG0b3Dfx2sk+d0vFDdv5EsGsC/pF4cQug2NQbqjnNk91TIcpdbZ0sP fq3LH4NkiXW7Nw+dk3D0unIOYoXMx9fAhdMse5Rt2Rd/QILh+O20Pd0w0ECkMnPNPEu4 B7gs+hFAlpSN/uavnH2Vnmr/SZ7MNWCjNUcK8VjI1COAVVrGGbXiaDhr/3bkJjb2OhTL TYuKLURe9qxoZ0VTcCgedGlb+fUGfcDcutSw9qGl+1rIanfYg/xDn3SOexh5jWlQvam/ ymLg== X-Gm-Message-State: AOJu0YyMqnUf7F/oDoyEM3DE7gxKFbQ8IXrF7un07ovHRSi/q4/xwRH2 C30AlgKa4ugZCUtkDjBDjWM4pmXKNPK59A6QalYgwq0mV9l2bk7Oqw3mJe5Ib2xKZvsxJl2iE1M ShaH8mBw= X-Gm-Gg: ASbGncuJmTXMH27doQ8/Y/qJQ8mmsx6tdKx8IiI2ehA0c8o0tlCV+j+jIwZBcYgjB7Q zCqWFSLIhYqUjshFPlAS4z8c8+RcZ+83CHETmPjoE2X09XYHn42E/xd22K0153q4z0b+xCZ4bHC 31gs4W3ptnoqZ5QkDKUKVarDMw7JYuGse1KWRiqp2W7Pew32lcDL/9NIl2PhgkpvzoaHIxTkltk ZWZtMoR4vjnQ5Xj7eEPuThzn7bphWHmuyuFyY5QdkGaZJ2y2mzNQWJ1qpp0al7FJrmEO9rsU2wk 2NqHkhPw26JoEFV+NfoIgYfDZ1lRiWG7zzzg03EZOVbN709gYt78C4/wAyBFavoAgWWA47UQlB2 TIiHD9Ko26BHGn2u8/+Y/bu03skSVFwmdOO24cojyaL7T2B5/JL+boo/4SYQmOgjGGW4J3Le+Al YfBqP3Tatqm8ScAiGHCHiZm5Hs1JPhrOQg0b7CLZvpdWWsIA== X-Google-Smtp-Source: AGHT+IHUwgD0KjtK72daVZdhQXuSKezX3mwd/lQOCHbucQcgS/0UIk7bQURqK56v1CeMvYQKNv4jAw== X-Received: by 2002:a17:90b:35c4:b0:33b:ae39:c297 with SMTP id 98e67ed59e1d1-340279f5bf4mr5514316a91.16.1761671607103; Tue, 28 Oct 2025 10:13:27 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:25 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 24/28] Enable --enable-fortify-source with clang Date: Tue, 28 Oct 2025 14:08:33 -0300 Message-ID: <20251028171141.3208834-25-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 41c15689ee..f86320cadb 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 74b7c86add..999b6aa393 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 5a676f858d..dd21fe6241 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1487,6 +1487,14 @@ rtld-stubbed-symbols = \ realloc \ # rtld-stubbed-symbols +# These symbols might be emitted by the compiler when fortify is enabled +# (through builtins). +rtld-stubbed-symbols += \ + __GI___vfprintf_chk \ + __GI___vsprintf_chk \ + __GI___vsyslog_chk \ + # rtld-stubbed-symbols + ifeq ($(have-ssp),yes) # rtld is not built with the stack protector, so these references will # go away in the rebuilds. diff --git a/include/arpa/inet.h b/include/arpa/inet.h index 3db8f1a96f..7650e1acb5 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 e6ad4d4663..1110ce49f2 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 bbb052f192..9758bf4b55 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 88bf073c9c..0cf0e76db1 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 491a263777..762b289184 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 7fcbd272ac..dd6af7e4c8 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 00b1b93342..f3b8a8cf87 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 181a746949..67a38d8c34 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 376ab5a936..c1a4736951 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 bf32625736..6abb0d2697 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 cc476ebcfd..0919bc9779 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 2bc9836522..f946cd311b 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 53bb334259..b7414e7b43 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 2f30e66df5..7c0245452b 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 1115e4c0a7..58398d33a5 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 d458da7903..f880a55e0b 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 197b149d0f..e08ae3aa28 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 Tue Oct 28 17:08:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122891 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 4AC093858405 for ; Tue, 28 Oct 2025 17:35:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4AC093858405 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=CUzfq7q6 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id E97A43858C20 for ; Tue, 28 Oct 2025 17:13:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E97A43858C20 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 E97A43858C20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671612; cv=none; b=iMekmUBu7pIwti/bAoF1UBnXLuh80dEzgSN9rpHWbv09p7457crsz6ppxE4pE20Qyhag8/MGs3624m0h3hr0RXl8Oj3IAFurqdH6g1kF9BTHHOcKqZ5axfrbD34SqJNkXZF9fqgz6XAKzX/QqZ5XfKnMrGnQE2759MfFfaRAHqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671612; c=relaxed/simple; bh=G1SR83B2N60h44OsXgBJgqLWWHIycWCKqy7e65G01d0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XIvC0IdijbJMctzdsoR9l0F+PYzliKRqmD9S2haM5YS5z4hhugnNh5UseYSrFUqEqnXAmzqkT79UxlrAltZcEOnZF4HYmQ2/RSYZH/wmNuPHl3PtYnA2MlSuu23TIiQX+2WAp9MxHgG4U2Ts25f8+l064trX6DQ1WNMHu3XsqVw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E97A43858C20 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-33bbc4e81dfso6704852a91.1 for ; Tue, 28 Oct 2025 10:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671610; x=1762276410; 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=Ud6UdavpVGPf5IVSnN5cQxGXdu12BeaX/DBWX7So3uQ=; b=CUzfq7q6z2p4ou/A0DJ5imbs3DN5FnDVEnye9+owhFmGjN9EQTKiQFotho65P+l3kY 1kDpMyEE7WTZfpZMPo84hyGu33mYhNelO8qAVJgIubtZhoIk6qipWVGR1D8hSYvfGigT vkbUJRtJHTL09wXyDFxGS2wLGT4wBfH6tKV3notSUSNyF8x0buTEPiC30oggaBxWjorU QrSEExivLJ51Gz6pI/ofOEkEGUboOgS/B36iuh/vpQWPqZU9tLFNKoUt4//Ok2/jfQ2u pNs2K9eIRx/WU4XJqaCxCVQegORP5PuENa8AlZArQ61gT/EzAbmzSANBermCZ4KeZlcj mCHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671610; x=1762276410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ud6UdavpVGPf5IVSnN5cQxGXdu12BeaX/DBWX7So3uQ=; b=OvuV5JlJV91vJno9uEBBWihhbTfifqku5dPJzH111iBP2J/FEwwUkACM0UV7hEK4kK W/4j8Fvp0duUfwE9Q+ls9y7sAxF/sAzyLUKCyc0nVvI/3VxTz+YxyeGU6nC8TAlkD9M9 fYOxsKU9T7xxkpO4XOi/NlRDYUbgS+zyrjoZcxcf9WHvpaR5VWBsNzRs8eqrKuUBhqA+ teMpXylTivog34ry9lmL65vYUcNyroHjjwnKuFv/qQjG7RNhhG6ZvQKHnldtA1OG+GVc yMMLnzUUVnRVu+i1iDisa81NESdS7/veMSxWTmOBPpLKjgeTS9ls1Ot6S6bJLIKb/UJ9 8n1Q== X-Gm-Message-State: AOJu0Yz4tOJdO+buOanpmOLRsXz735+hL6gS4eU+l71U2/d6aQUpYanf FZBesUBOVPh6biHVWC7qU+XteioF9Eb+P7UgjydyOtLuUf3OB5HOXvrCmgS48FDWSxRwgkGoSrl d3TXx+oU= X-Gm-Gg: ASbGnctGWiR4M22smVRTRC92KbHwj5vNKpmiyCUfb/8/HJu2RqosiI7rvsFzLnswGgo Ah8r0APaOUwoYlJvGFjY6KdI015L6iJHvVH823qpNeJh/4kGvQYzboMUGIDj2ziVqR3gaHZKx5X i1GOb39viE547bbguk/mucrI48osxE8Q1RL8IZtYFvJg6ayn6P0Zrmg+dx+e80vk8o6cncpfO3l c2pg+Ee7nSRex1EVMRhijct5bFgGYGMY6oZDfe2JLrE5VP9zAHse0W7Z/j4dE6OovrwU5+xC1Mv bvd/ud4eIjGp6978n4h1m1JDXkeOsPCV34EjDix2Mb6ixp+Jl8Pgq4pdWjGtpF6KVQxWOP+ABoP /3pRZ9pM+QLjEItrc2f57cwp0+VS+9ZPG4BX+tBBZdZ24DiZav+PEKwNvAAlq/88y2CV+erCZBm ERsrZz+aQP9e9G60dAMmLoXMGHNLilV1ac3JiblGt0fxTVVJrYx0NgiTvj X-Google-Smtp-Source: AGHT+IGyjQcKuxA/avX3bgpIsjoSg7hn9wSwq7x78LQmUeekiPZhoaLROYg26+J81A/esXR6q+jcEQ== X-Received: by 2002:a17:90b:53c3:b0:32e:5cba:ae26 with SMTP id 98e67ed59e1d1-34027bc93cdmr5137327a91.23.1761671610039; Tue, 28 Oct 2025 10:13:30 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:29 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 25/28] Filter out internal abort during ld.so build Date: Tue, 28 Oct 2025 14:08:34 -0300 Message-ID: <20251028171141.3208834-26-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org clang might generate an abort call when cleanup functions (set by __attribute__ ((cleanup)) calls functions not marked as nothrow. The hurd already provides abort for the loader at sysdeps/mach/hurd/dl-sysdep.c, and adding it rtld-stubbed-symbols triggers duplicate symbols. --- configure | 4 ++++ configure.ac | 3 +++ elf/Makefile | 7 +++++++ sysdeps/mach/hurd/configure | 2 ++ sysdeps/mach/hurd/configure.ac | 2 ++ 5 files changed, 18 insertions(+) diff --git a/configure b/configure index 122020db69..3c926be3ec 100755 --- a/configure +++ b/configure @@ -8915,6 +8915,7 @@ libc_cv_localstatedir=$localstatedir libc_cv_gcc_unwind_find_fde=no libc_cv_idn=no pthread_in_libc=yes +abort_in_ld=no # Iterate over all the sysdep directories we will use, running their # configure fragments. @@ -9468,6 +9469,9 @@ if test "$pthread_in_libc" = yes; then fi +config_vars="$config_vars +abort-in-ld = $abort_in_ld"; + ac_config_files="$ac_config_files config.make Makefile" ac_config_commands="$ac_config_commands default" diff --git a/configure.ac b/configure.ac index 14a0f2dee8..890f1b1c9c 100644 --- a/configure.ac +++ b/configure.ac @@ -1916,6 +1916,7 @@ libc_cv_localstatedir=$localstatedir libc_cv_gcc_unwind_find_fde=no libc_cv_idn=no pthread_in_libc=yes +abort_in_ld=no # Iterate over all the sysdep directories we will use, running their # configure fragments. @@ -2181,6 +2182,8 @@ if test "$pthread_in_libc" = yes; then fi AC_SUBST(pthread_in_libc) +LIBC_CONFIG_VAR([abort-in-ld],[$abort_in_ld]); + AC_CONFIG_FILES([config.make Makefile]) AC_CONFIG_COMMANDS([default],[[ case $CONFIG_FILES in *config.make*) diff --git a/elf/Makefile b/elf/Makefile index dd21fe6241..e95747c795 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1495,6 +1495,13 @@ rtld-stubbed-symbols += \ __GI___vsyslog_chk \ # rtld-stubbed-symbols +ifeq (no,$(abort-in-ld)) +# clang might generate an abort call for cleanup functions. +rtld-stubbed-symbols += \ + __GI_abort \ + # rtld-stubbed-symbols +endif + ifeq ($(have-ssp),yes) # rtld is not built with the stack protector, so these references will # go away in the rebuilds. diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure index 6ca3bab511..743bad5fcb 100644 --- a/sysdeps/mach/hurd/configure +++ b/sysdeps/mach/hurd/configure @@ -220,4 +220,6 @@ fi # Hurd has libpthread as a separate library. pthread_in_libc=no +# Hurd already provides abort implementation for the loader +abort_in_ld=yes diff --git a/sysdeps/mach/hurd/configure.ac b/sysdeps/mach/hurd/configure.ac index 1695e94ecc..6d33feed0e 100644 --- a/sysdeps/mach/hurd/configure.ac +++ b/sysdeps/mach/hurd/configure.ac @@ -48,3 +48,5 @@ fi # Hurd has libpthread as a separate library. pthread_in_libc=no +# Hurd already provides abort implementation for the loader +abort_in_ld=yes From patchwork Tue Oct 28 17:08:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122894 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 261FB3857B90 for ; Tue, 28 Oct 2025 17:38:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 261FB3857B90 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=qtT3wOC1 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 8F4123858421 for ; Tue, 28 Oct 2025 17:13:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F4123858421 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 8F4123858421 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=1761671615; cv=none; b=iogQ2bbkoQIhDUhcMzKYdC0YjIxeeTRgOGgPNViH/A5GGKPH5xuod7FI/4R7O5iDWzCBDdo7TjaWETIpRe7Er2iOXiY1IxWcCBBIlO0yNOvVUIKPpLZn7UCSFvUw+ZnGLqmDmLZ9GbFiu+xeO4G2+JHp8aW20p8uRGXSiJopOTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671615; c=relaxed/simple; bh=c0tWCqTT57a+PpFvoDvgrf5b1LwDkhQworf+YMtAXRE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wxZCfEgLZsguQjsH924eV8EAMeAdagTaHaTT2FSjehQCFINC5GZ+xTrHQeox2NDG6ZnD2RrP/eruJ1d30JK+fNEKSzmhkKFJyIXWVB3/77FhMiSYyIp1U6DsVxGc2yoC5qLUfo++0gY3adiAqkR6WP3KInmuJUwzchG3BjScJ1Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F4123858421 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-33bda2306c5so5505834a91.0 for ; Tue, 28 Oct 2025 10:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671613; x=1762276413; 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=lO2HAH2YheiZohSqj/ytUfz5pVDhtm8g1GMDJc8rIx4=; b=qtT3wOC1ZfLl/m0RrYtuGb1bd/G6IsM1DqWIQ21GkrgkphTxJ4PI1QA3m8ZUiApKoo pNjX/1QvQnC5fDhsYBDAZiF0quslzjJPQssjWINr6CpM405RiVcxPgiHR4Prarj+B55I C4xtBYTBRDjz2YLABz2e3sg1zzlMjXmAKj2rio0J5m53HEF1E3Giia7X+0RLsaZ6paRL IKXxuJj1pANI4a8tsIpBjuT3cotFWwu8Gss3LhodAJSlV9adqznLEedTwpMLDHr8DdPi sdG+l4K8iB2QKNobRr9AmHLrABpiA9SuXmPCYztRxuYYdRwE6xlurSAW9hsRwMwWyEAg ktJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671613; x=1762276413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lO2HAH2YheiZohSqj/ytUfz5pVDhtm8g1GMDJc8rIx4=; b=oKIm2P9YkctHNDos1AFmlM7VbH6EgLzaDU2WNn+YwcdOxkuUOwO7S5NtWfWurh3/kD wZ3JqMWY7uPK5IdIiIaj6Q0x070/YeYRTVeiXT59ZG9CVtW7S4kzyx+uKgemYXTsDuzr ZRJxWbzPqO8YKZaCKVVnNfZkMHc9kBbR6f+VQvYZuHLCsNbcU5FleTcOvJvY6kJAgOaA 3xvZd8aNrKmiBhSeOcx3RSfnwYq60IT4sKHaToCUdxSQIcNG2iN1+v3Ogv81ZSoZVFV1 Wxri3dXa3ocv6w0uQVdlyosMTA0diUJDAb22WgQIrzlAzrKfJBuy9krD+uHdI2HbYeGb UOiQ== X-Gm-Message-State: AOJu0YzflnNZTDt4hK164F6Qb+sEpyqaNj4K6aj1YyS9GfiaUTthcELt UEFngjfzruAIv/DAFXOpbREkGPskafzwWwuj5ukDPO8Rnu3M1iwrX/8ZHKf/nXBgfWS9+hqSXen Upu3bsZM= X-Gm-Gg: ASbGncsrOWzOarRFkPaYDR/ajr54PqxC17ZiCHaOzszR0yBtwYf8+LI09GXxk1m3t+z 1gE6aw0s6K35t6IPgcmKWWriv6/qjIqIiaLXhltKd22Ap1b/r81iRD2bCTX9sTJsfdEt0KMT9s4 Y076hmOv/9F/ho0jzcmz3xx9jySY/7oa96sHT90haHbehYnC/mshACQu51Y4Th0b6CF0JovkZXC teJLKl5vVH1Rc17ZT2UXeAWQiSSYzChCxTp+2BwP5XYR37qcFmRiPgs2QxNcaPGUQ+yM6cXRQ6y 4hf4CnxHNJs3GtWLnYato7SmDu/SA+6S9K8DybiqqgrBT321roB7LU5CPY6a1kqiX7XMrfLc7w9 gT8xnuU1aWXC4IwocHK4V2MaNqOikISLdQvU/HoeBtifJ6RTNPPxgY0nGlg/o9vilFUhdJiud9G 6EGDKGEtqKNCTlGibF/hqW4ifCCtqiaz8uPpdJcuyaqoLCKw== X-Google-Smtp-Source: AGHT+IEbksZOD7GwlJ0UsdZFH0dbMDyB1IvYYbTbsFULqyReJsIjSiWg2++CkqFHr5p/S/LV5wGc9w== X-Received: by 2002:a17:90b:4d0b:b0:339:f09b:d36f with SMTP id 98e67ed59e1d1-34027bdd7bfmr4875250a91.28.1761671612768; Tue, 28 Oct 2025 10:13:32 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:32 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 26/28] math: Handle fabsf128 !__USE_EXTERN_INLINES Date: Tue, 28 Oct 2025 14:08:35 -0300 Message-ID: <20251028171141.3208834-27-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 0fac2fda84..a6d211af75 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 2c1f277653..9d64f15040 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 Tue Oct 28 17:08:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122893 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 883963858280 for ; Tue, 28 Oct 2025 17:38:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 883963858280 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=X4EPV3nI X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id 396353858408 for ; Tue, 28 Oct 2025 17:13:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 396353858408 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 396353858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671617; cv=none; b=oV4DLTsnzA6975qE1Gk7Of8d+NOi2/ifXvg3DwLIMHvJV8ybBOtiyDvFzIpP1o+Pt22Iu5aDQjj2DUI4bp1dhh/rMDGRuLQBZfpIiCqw+cn1J/Sih5u6WPOv6d48RLN6A6f+HEF8Q/4wyPbPB3+N0obbQIcgdquI978xcCD73CU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671617; c=relaxed/simple; bh=1Toy7WZyiy+t0geTQ4SlAS/aI3zp05LI67wonjgqY8Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rDPZQR1Nh72pW6/wHbMEoxg+pxjUVSOzNUmHUVUpau0SPNJwc9mSd4Xk5/oLm3he17IF5+EkbtKbaU3caX5Sj0wgIV75lliHOaZ2aDf7HG+b7226kZyeyJYmYv/fomHPdWEBEqtOxtEH7a09MYzeVWWKB0J5jp230pdzdV2JY/o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 396353858408 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-34029c5beabso1314615a91.1 for ; Tue, 28 Oct 2025 10:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671616; x=1762276416; 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=4PFfMtQA7M8ZWfgViwYuSMrubYcRSH+bmsAk3vodOwE=; b=X4EPV3nI5GeCNGhd3HpzHPnKc2D9GlIjX+a/wI80+1a5wAOLpc2xr0UOHITM/aPuV0 5qwTqdo/YfMSJgisUEMSTBwtpZm30UZ+y60ji8boe2weWuc/gLLMPSsNHMaQxu+PsJ+1 5JhoTmu9Oaia/atwk/z7mIMqtuHI21YhKNTuX2NX2iLdIsqVPidHky0nnPgTeXEmT9X2 B2aJeIppzDBKBzognqI4dTNHN846xqOYKMRNDo4y+QZN9AWvkKq4jK4SL0OaS3IL3rav fSCcYomXGQKp9zQ4CqAJjtUh9ADImHdnGCE98tlIVmc75UNKpmKGgd3rkQjwcnZfU97b gkmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671616; x=1762276416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4PFfMtQA7M8ZWfgViwYuSMrubYcRSH+bmsAk3vodOwE=; b=rjApc5DUoAXRMXLT+CbxGsxt3S9gFKRl97krc0MfFo9HH6F7ldaj6PTFqDF1PBR9cA PUSmnvoMwaKv3u/+deII/NK4CNW/CjJ7v1qfbQ5Zh9TiUPE2UCfgwqwlYUiQRT3EFPua LATOzxg+UB1FYFL0GKZq8UM/L4rbhTXzXcGuF8+mfCjugfMKTJdgdYNFAcn8o3xX96gl 2HjorZhfg7nCYgPSf4XbPysd9ozkEQ+xJWAuBa+i0uQWIdGwFbaT5FJz9QEzNX6psdsM GHM/CQ2YZsgVeIex5Q3RqlDKCmbALbR5xlmFT/nipBB6nA1LSNlncRVMPZpn/vJ93one tnSg== X-Gm-Message-State: AOJu0YwU1erujm8/Fvx5EIWCGI8ztIVwrmLEIBK9IJxwJZ1xekySlLAC HzLzqOrTgie8jC1/NKzVH46/WZB7fWUXHLCVMAr7lGG7QHQQrZBgOWGv7y0PgMv9eWha7lLRe6n fc8wNS3Y= X-Gm-Gg: ASbGncsfCRuRUPWsVHivTiXuXJqh06eYEm58PQaDWyKfZHnSkqY1Se2Os6Ur1R3qDlF Ev3dP2ws/+0HPJOnKq6CoezQdf5K6p7/sCOK0vNXTRCGGQ1ifTteG6uu+/9gfe/w5l6WCbNLDTZ vy0+sdaxDf9FXUc5CSpI6PARx4Z+Ql0GVL0W0Jj8ZcdXWyJxmhhAslmGCn1Ich6MdBVBsjCVOXj XdW0tUQDCh4wRD1WqRQwd4vyuPjCdsU00Buv5ssh/+JAszUjMZZiyJFcrdRZ/JuHStq526YUt7B seLn1MVxfaLreKLeFWnWM5C+mHd9VL3MxFyFTAlfQ5BcFNV2mUKOQL2KG8w8NnG/WkYYxzBVuoy ikrEO/4uBpg8RikRS6bMAZFVXObBxybZQ+pLHaUFaG7d8jY6SIyTacngo9C8L2CP7IyXkKuQtLg ZawyVKqSgRknaeAs2KOOg0rjeJi6gnAczV5q3vWVXVZ9KfQw== X-Google-Smtp-Source: AGHT+IFxbEcECza/9oqi+KzMr80ERONukf6iYYrhh1NtA1J26cLRrmT4l/eshHC0FrJEOUJR8GmUow== X-Received: by 2002:a17:90b:2e50:b0:32e:3830:65d5 with SMTP id 98e67ed59e1d1-34027c1c551mr5132265a91.36.1761671615840; Tue, 28 Oct 2025 10:13:35 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:34 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 27/28] configure: remove overly restrictive check for clang Date: Tue, 28 Oct 2025 14:08:36 -0300 Message-ID: <20251028171141.3208834-28-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 | 4 ++-- configure.ac | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 244f7613d8..b4348ac51b 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,11 @@ Major new features: * The ISO C23 memalignment function has been added. +* Initial support for building with clang has been added. It requires + at least clang version 18, aarch64-linux-gnu or x86_64-linux-gnu + targets, and libgcc compatible runtime (including libgcc_s.so for + pthread cancellation and backtrace runtime support). + Deprecated and removed features, and other changes affecting compatibility: * Support for dumped heaps has been removed - malloc_set_state() now always diff --git a/configure b/configure index 3c926be3ec..a21ce56302 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 ; @@ -7642,7 +7642,7 @@ else case e in #( extern char *strstr (const char *, const char *) __asm ("my_strstr"); char *foo (const char *a, const char *b) { - return __builtin_strstr (a, b); + return strstr (a, b); } EOF if { ac_try='${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null' diff --git a/configure.ac b/configure.ac index 890f1b1c9c..29c45632fd 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], @@ -1474,7 +1474,7 @@ 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); + return strstr (a, b); } EOF dnl From patchwork Tue Oct 28 17:08:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 122892 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 1EA133857BBA for ; Tue, 28 Oct 2025 17:37:22 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id DC4883858C54 for ; Tue, 28 Oct 2025 17:13:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC4883858C54 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 DC4883858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671622; cv=none; b=JBdWtmqO9+vosmto1wUZDPS97NaqbrP4ZMSCb6wZy5+eOXxGQU8zCulll4AK7aneYP1xWAA4niwv3Eqh5tK0mVmJ6HtL95ywEtzfgqPI84P2b71QM+MLWP+AZ16F//EzeoPVR1TB6EQI5Mx5NXqvKoDb+YEe84aECrG5E6hCHoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761671622; c=relaxed/simple; bh=FVAviCk38PmKqArCT4fD/oNNdJMh76uRMDhJjofrZL4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RflYU54son2drfllKelYv2emcO9Hle4LOGhrv3fU1RZICSHvr5xIdnXlmAg5/dXTIbM5DZVRpEyib/UlL29Q/kg+D3S0oW8Pk3i464moyy9YgnP0VTNR0NpzsiZibtuuIUkW8dTH1E5CbC9vTXzaxIQPlLyodbSzBi5qthvoVcc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC4883858C54 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=s2jIbwqX Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-33b9dc8d517so5912791a91.0 for ; Tue, 28 Oct 2025 10:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761671619; x=1762276419; 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=Ykngqy2hAwz74+vUnOFwqAMpLYmxgP/6g3w4EXpfCHE=; b=s2jIbwqXwkVCLBd947JYh4Yl0qgdzbBWMDTaHrmL8nL0+Z2UxBjfSL44AmLzXFGQJe rbyAYWYHCwJ4D5kDGP5iPSFB4bCjtEow4vGxeBM40ceE5NMF5XMezb/ynbK6E2xtduum jIYbHUygzkPUpMHKbpKxWCA36pUjEKhleurAXMaPJMMa1WsH3l0UW1T54AUU4BD7phrc N1MgJFuvwejAOBkSVEZTr9P8tO++Q1/pCrmI6kxS8G0DEKSZmVQjtMQv0KCKMEmffXjR Qe7+gwsIe1qscAT70Q2iMqnWEYxIwRWPsquXoVSCKI76lRXNxUR4k1fAHMQWWqCx90/r YHVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761671619; x=1762276419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ykngqy2hAwz74+vUnOFwqAMpLYmxgP/6g3w4EXpfCHE=; b=Af0lDgfxKMOWKCfIby9Us5pmYt3KqLlznskTuvyEp5M2YMJrrrdFPEynmgboES9IR0 DFx4Hh7HyHTD/z6Veahx+78XBSl9Jnqdd9mmmwSY3AJkju0c4qeIWrcKvBErfjlRS1Kt mExypG9979PCMCGU++33x1w5gcGjUBs8IxamTbAhXZK5BqsIz4GzJAgrpsSpgCY6jJzw IXI7wGqlrtYff9nhrYpDlPDqyt0tqc7qlZOFVhA0MpFsoyeUhLsYosYLdej4CcX2iuH1 /D+qM3OxZI66kp/RXOM/EDWJ6nddX2jgMuLgVgfO6qEGxgbhFKwyUjQshvJniwoYyAPz S2Fg== X-Gm-Message-State: AOJu0YxezlIX5TX1aeMvx6bHNSIl8ae7kHR9+JVdRfZg30sx2kxb8F5H S8EXijq/GEstBuqcvs7wkFxKOOUOskpDj6BqXpUnngoL2fOk2gbcYmTrJgerfy6oDBOF3iSyamv IN+J30bY= X-Gm-Gg: ASbGncswmEfepokmE6fAneXHaSNyrKB5OxhizrjVGWQRR/RAa4fVKCKS1AXFZytdwuT 7aFjJHwrXgmcemTtW3BH8fTCM5AM9ywvRS0AqWqmsU6/2TDhTcqtcGHTDEjepjPzyc+tCNOE1kT 8D3dCSH+w0xj2YtV1WIw6o2gItg0LKhwllHVBn4Tr7ZfD1GgXZOBlJcV3wyabExQZK5+DtZUzIZ /gcwW5k++JjNUfUFQDyKGb+2vdZdDJPSLgqKluMl1IIXm66/IvVAu90V6hc7RrjWS8s64elLc5v HL8KxrG7MatI8HINzzXxNH7H/zOyKYc3mWfnB/e4OjzE6uUb9dzmjdTgywIqQtg8/A5+xexwD1B QSMwvjzMEMj3Tt9/O+Xpx6bRenKiUBPs8OjKi5o//JG3UimFOjtrzP1MTShAlO3wNQT/CggIRDi gByCJxuyjgVbiTI4aGZ/bCxdkHcL9QTxJmQKaai1MNM9BVzw== X-Google-Smtp-Source: AGHT+IFi/Qgmt+XhGJU2D4SZkynEeVpzvA6fFIwB9hKoR6TE4uAr7xsI9ut0yVfa2pmOhpeDBOxltQ== X-Received: by 2002:a17:90b:2252:b0:336:bfce:3b48 with SMTP id 98e67ed59e1d1-34027a06decmr4953025a91.9.1761671618762; Tue, 28 Oct 2025 10:13:38 -0700 (PDT) Received: from ubuntu-vm.. (201-27-233-27.dsl.telesp.net.br. [201.27.233.27]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3402a5ba7fesm1410779a91.9.2025.10.28.10.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Oct 2025 10:13:37 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Sam James , Collin Funk , "H . J . Lu" Subject: [PATCH v2 28/28] aarch64: Fix tst-ifunc-arg-4 on clang-18 Date: Tue, 28 Oct 2025 14:08:37 -0300 Message-ID: <20251028171141.3208834-29-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> References: <20251028171141.3208834-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, 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 It issues: ../sysdeps/aarch64/tst-ifunc-arg-4.c:39:1: error: unused function 'resolver' [-Werror,-Wunused-function] 39 | resolver (uint64_t arg0, const uint64_t arg1[]) | ^~~~~~~~ 1 error generated. clang-19 and onwards do not trigger the warning. --- sysdeps/aarch64/tst-ifunc-arg-4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/aarch64/tst-ifunc-arg-4.c b/sysdeps/aarch64/tst-ifunc-arg-4.c index c95ef9ebb3..9536d1e8e0 100644 --- a/sysdeps/aarch64/tst-ifunc-arg-4.c +++ b/sysdeps/aarch64/tst-ifunc-arg-4.c @@ -35,7 +35,7 @@ two (void) } /* Resolver function. */ -static void * +static __attribute_used__ void * resolver (uint64_t arg0, const uint64_t arg1[]) { uint64_t hwcap2 = __ifunc_hwcap (_IFUNC_ARG_AT_HWCAP2, arg0, arg1);