From patchwork Wed Sep 28 18:19:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1510 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f2ce:0:0:0:0:0 with SMTP id d14csp308692wrp; Wed, 28 Sep 2022 11:20:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sMSPu1ZoI048Ru8ASoI82mlv5VMNgnOCI8TFQqhgti9Ue8oVcnyztyWzu4Di/B/HCJiuJ X-Received: by 2002:a05:6402:d5a:b0:457:b705:3280 with SMTP id ec26-20020a0564020d5a00b00457b7053280mr9371855edb.201.1664389238902; Wed, 28 Sep 2022 11:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664389238; cv=none; d=google.com; s=arc-20160816; b=Lu+kvF+LMPrRazRoKI0bD+TDyuDEmh4pYRIEoQjvLqyeTAxN7psuu1c35Y5ouuHBfm NfH0/h5zs177RHn2Mm8EGMMugP+P8nLdub0RhZ8dk4IDd5PuTzl/g3bo7UTZgknLG9YV QYt9p5gh1wC84bPI1Zi5mlqjHXly7czXScAzXfAhXso1ejYeMceijRkXfehkx5V29Aiw 8o39JsozFj2uX5HOTcyMTi9VTOD5vR7QPW5DjfdBcL/81HBth5bnq2j+3BBhJrpepNNi zO+z5PzV/NF9G4NOQjMH4BmX636UJXiX+FHaMFppLUaMlFboweNuGFyipn6vNHE5DFqX Bq+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:in-reply-to:mime-version:references:message-id :subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=6jNr1REq4JsgVZMS57qpp+JTguW+d1Ddi2C3AjMLffU=; b=nR1C8y22SXZ9V+jWA2x8r1F1d3mNF2GmzDSjykJyA2k3a1y+t80QkIFBz+TKdSnq32 GWfZabZjlbKLMostQQNz/sD6BeGpI3f3Ecb9X5XgM+4+k69BdKWFu2IFJRDcQbdTAXQv KO/ezIwoJNGXYMylTOgyJXHd/8CQCIt1MBWESmMEQq4/pDS9NeeOmCa5KxCYfF6GXvdr GFKfBjRqfKVKbCIQmAy+jpJeJhip4WE1fRrzIVwPcMoR6Omvj4BPETkT/R+YluI1iMNy i5BTM8SGoM6qAfxrhRBcSGgKtEKcRimkS14iPWfB7WKAyVCg9jfqsl1nS7xm3Rvt9/Ky IITQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fCy+hp2k; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n22-20020a170906725600b007824cd8d165si4796355ejk.577.2022.09.28.11.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 11:20:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fCy+hp2k; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1715B3857347 for ; Wed, 28 Sep 2022 18:20:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1715B3857347 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664389237; bh=6jNr1REq4JsgVZMS57qpp+JTguW+d1Ddi2C3AjMLffU=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fCy+hp2kTfP5qFMBLim/fXS6m1nxU0xDN9HT8e9ADbzK41FZpyrZoybgx2dA3j9pv uY0DGMP0E8mhmuXgOoWhc5oAxVdxYMeTTbBX7pHU1JvD39T5oGT/kkXxg/WCj3Qd74 BsUZJQJhxa/+JkU1Ef6M1OlkgRKynn6WW0Y6OuPA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4EF783858016 for ; Wed, 28 Sep 2022 18:19:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4EF783858016 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-382-gNePXfvWMKqRitSjb5WDPQ-1; Wed, 28 Sep 2022 14:19:49 -0400 X-MC-Unique: gNePXfvWMKqRitSjb5WDPQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDBE13C11EA3; Wed, 28 Sep 2022 18:19:48 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EA60C15BA4; Wed, 28 Sep 2022 18:19:48 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 28SIJjLn3884686 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Sep 2022 20:19:45 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28SIJiPK3884685; Wed, 28 Sep 2022 20:19:44 +0200 Date: Wed, 28 Sep 2022 20:19:43 +0200 To: Joseph Myers , Bruce Korb , Jason Merrill Subject: [PATCH] fixincludes: Fix up powerpc floatn.h tweaks [PR107059] Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745238610489652596?= X-GMAIL-MSGID: =?utf-8?q?1745238610489652596?= Hi! On Wed, Sep 28, 2022 at 12:23:31AM +0000, Joseph Myers wrote: > In general the changes match those made by fixincludes, though I think > the ones in sysdeps/powerpc/bits/floatn.h, where the header tests > __LDBL_MANT_DIG__ == 113 or uses #elif, wouldn't match the existing > fixincludes patterns. You're right, missed that. The header has: /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */ # if __HAVE_FLOAT128 # if __LDBL_MANT_DIG__ == 113 && defined __cplusplus typedef long double _Float128; # define __CFLOAT128 _Complex long double # elif !__GNUC_PREREQ (7, 0) || defined __cplusplus /* The type _Float128 exist for powerpc only since GCC 7.0. */ typedef __float128 _Float128; /* Add a typedef for older GCC and C++ compilers which don't natively support _Complex _Float128. */ typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__))); # define __CFLOAT128 __cfloat128 # else # define __CFLOAT128 _Complex _Float128 # endif # endif and my current rules don't do anything about that. The following patch fixes that. I've run additionally MACRO_LIST=`pwd`/../gcc/macro_list TARGET_MACHINE=x86_64-pc-linux-gnu ../fixincludes/fixinc.sh /tmp/include-fixed `echo /usr/src/libc | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta` in the builddir/fixincludes directory where /usr/src/libc is latest glibc trunk checkout and seems the remaining defined __cplusplus cases in the floatn.h and floatn-common.h headers are ok or acceptable. The remaining cases are: #if __GNUC_PREREQ (7, 0) && !defined __cplusplus # define __HAVE_FLOATN_NOT_TYPEDEF 1 #else # define __HAVE_FLOATN_NOT_TYPEDEF 0 #endif which is IMHO ok because this is only used in tgmath.h or tgmath-like math.h stuff which is C only, as C++ doesn't have _Generic. Another case are the following 3 snippets: # if !__GNUC_PREREQ (7, 0) || defined __cplusplus # error "_Float128X supported but no constant suffix" # else # define __f128x(x) x##f128x # endif ... # if !__GNUC_PREREQ (7, 0) || defined __cplusplus # error "_Float128X supported but no complex type" # else # define __CFLOAT128X _Complex _Float128x # endif ... # if !__GNUC_PREREQ (7, 0) || defined __cplusplus # error "_Float128x supported but no type" # endif but as no target has _Float128x right now and don't see it coming soon, it isn't a big deal (on the glibc side it is of course ok to adjust those). OT, besides floatn.h and floatn-common.h headers, the only one remaining in /tmp/include-fixed is sysdeps/arm/unwind.h, perhaps -#if defined(linux) || defined(__NetBSD__) +#if defined(__linux__) || defined(__NetBSD__) should be done in that header (and libgcc/config/arm/unwind-arm.h too). Ok for trunk? BTW, we have some multi-arch related issue with fixincludes too, apparently fixincludes never worked properly on multi-arch (aka Debian/Ubuntu) :(. 2022-09-28 Jakub Jelinek PR bootstrap/107059 * inclhack.def (glibc_cxx_floatn_2): Handle #elif the same as #if. (glibc_cxx_floatn_4): New. * fixincl.x: Regenerated. * tests/base/bits/floatn.h: Regenerated. Jakub --- gcc/inclhack.def.jj 2022-09-27 12:29:21.309769836 +0200 +++ gcc/inclhack.def 2022-09-28 19:56:07.222783768 +0200 @@ -2060,11 +2060,11 @@ fix = { fix = { hackname = glibc_cxx_floatn_2; files = bits/floatn.h, bits/floatn-common.h, "*/bits/floatn.h", "*/bits/floatn-common.h"; - select = "^([ \t]*#[ \t]*if !__GNUC_PREREQ \\(7, 0\\) \\|\\| )defined __cplusplus\n" + select = "^([ \t]*#[ \t]*(el)?if !__GNUC_PREREQ \\(7, 0\\) \\|\\| )defined __cplusplus\n" "(([ \t]*/\\*[^\n]*\\*/\n)?" "[ \t]*typedef[ \t]+[^\n]*[ \t]+_Float(16|32|64|128)x?([ \t]+__attribute__ \\(\\(__mode__ \\(__HF__\\)\\)\\))?;)"; c_fix = format; - c_fix_arg = "%1(defined __cplusplus && !__GNUC_PREREQ (13, 0))\n%2"; + c_fix_arg = "%1(defined __cplusplus && !__GNUC_PREREQ (13, 0))\n%3"; test_text = <<-EOT # if !__GNUC_PREREQ (7, 0) || defined __cplusplus typedef float _Float16 __attribute__ ((__mode__ (__HF__))); @@ -2072,6 +2072,10 @@ fix = { # if !__GNUC_PREREQ (7, 0) || defined __cplusplus typedef __float128 _Float128; # endif + # if 0 + # elif !__GNUC_PREREQ (7, 0) || defined __cplusplus + typedef __float128 _Float128; + # endif EOT; }; @@ -2110,6 +2114,22 @@ fix = { # endif EOT; }; + +fix = { + hackname = glibc_cxx_floatn_4; + files = bits/floatn.h, "*/bits/floatn.h"; + select = "^([ \t]*#[ \t]*if __LDBL_MANT_DIG__ == 113 && )defined __cplusplus\n" + "(([ \t]*/\\*[^\n]*\\*/\n)?" + "[ \t]*typedef[ \t]+[^\n]*[ \t]+_Float128;)"; + c_fix = format; + c_fix_arg = "%1defined __cplusplus && !__GNUC_PREREQ (13, 0)\n%2"; + test_text = <<-EOT + # if __LDBL_MANT_DIG__ == 113 && defined __cplusplus + typedef long double _Float128; + # define __CFLOAT128 _Complex long double + # endif + EOT; +}; /* glibc-2.3.5 defines pthread mutex initializers incorrectly, * so we replace them with versions that correspond to the --- gcc/fixincl.x.jj 2022-09-27 12:29:21.328769578 +0200 +++ gcc/fixincl.x 2022-09-28 19:56:15.990125976 +0200 @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed September 27, 2022 at 12:21:44 PM by AutoGen 5.18.16 + * It has been AutoGen-ed September 28, 2022 at 07:56:15 PM by AutoGen 5.18.16 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Tue Sep 27 12:21:44 CEST 2022 +/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Sep 28 19:56:15 CEST 2022 * * You must regenerate it. Use the ./genfixes script. * @@ -15,7 +15,7 @@ * certain ANSI-incompatible system header files which are fixed to work * correctly with ANSI C and placed in a directory that GNU C will search. * - * This file contains 270 fixup descriptions. + * This file contains 271 fixup descriptions. * * See README for more information. * @@ -4167,7 +4167,7 @@ tSCC zGlibc_Cxx_Floatn_2List[] = * content selection pattern - do fix if pattern found */ tSCC zGlibc_Cxx_Floatn_2Select0[] = - "^([ \t]*#[ \t]*if !__GNUC_PREREQ \\(7, 0\\) \\|\\| )defined __cplusplus\n\ + "^([ \t]*#[ \t]*(el)?if !__GNUC_PREREQ \\(7, 0\\) \\|\\| )defined __cplusplus\n\ (([ \t]*/\\*[^\n\ ]*\\*/\n\ )?[ \t]*typedef[ \t]+[^\n\ @@ -4183,7 +4183,7 @@ static tTestDesc aGlibc_Cxx_Floatn_2Test static const char* apzGlibc_Cxx_Floatn_2Patch[] = { "format", "%1(defined __cplusplus && !__GNUC_PREREQ (13, 0))\n\ -%2", +%3", (char*)NULL }; /* * * * * * * * * * * * * * * * * * * * * * * * * * @@ -4233,6 +4233,46 @@ static const char* apzGlibc_Cxx_Floatn_3 /* * * * * * * * * * * * * * * * * * * * * * * * * * * + * Description of Glibc_Cxx_Floatn_4 fix + */ +tSCC zGlibc_Cxx_Floatn_4Name[] = + "glibc_cxx_floatn_4"; + +/* + * File name selection pattern + */ +tSCC zGlibc_Cxx_Floatn_4List[] = + "bits/floatn.h\0*/bits/floatn.h\0"; +/* + * Machine/OS name selection pattern + */ +#define apzGlibc_Cxx_Floatn_4Machs (const char**)NULL + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zGlibc_Cxx_Floatn_4Select0[] = + "^([ \t]*#[ \t]*if __LDBL_MANT_DIG__ == 113 && )defined __cplusplus\n\ +(([ \t]*/\\*[^\n\ +]*\\*/\n\ +)?[ \t]*typedef[ \t]+[^\n\ +]*[ \t]+_Float128;)"; + +#define GLIBC_CXX_FLOATN_4_TEST_CT 1 +static tTestDesc aGlibc_Cxx_Floatn_4Tests[] = { + { TT_EGREP, zGlibc_Cxx_Floatn_4Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Glibc_Cxx_Floatn_4 + */ +static const char* apzGlibc_Cxx_Floatn_4Patch[] = { + "format", + "%1defined __cplusplus && !__GNUC_PREREQ (13, 0)\n\ +%2", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * * Description of Glibc_Mutex_Init fix */ tSCC zGlibc_Mutex_InitName[] = @@ -10998,9 +11038,9 @@ static const char* apzX11_SprintfPatch[] * * List of all fixes */ -#define REGEX_COUNT 308 +#define REGEX_COUNT 309 #define MACH_LIST_SIZE_LIMIT 187 -#define FIX_COUNT 270 +#define FIX_COUNT 271 /* * Enumerate the fixes @@ -11106,6 +11146,7 @@ typedef enum { GLIBC_CXX_FLOATN_1_FIXIDX, GLIBC_CXX_FLOATN_2_FIXIDX, GLIBC_CXX_FLOATN_3_FIXIDX, + GLIBC_CXX_FLOATN_4_FIXIDX, GLIBC_MUTEX_INIT_FIXIDX, GLIBC_STDINT_FIXIDX, GLIBC_STRNCPY_FIXIDX, @@ -11779,6 +11820,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { GLIBC_CXX_FLOATN_3_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aGlibc_Cxx_Floatn_3Tests, apzGlibc_Cxx_Floatn_3Patch, 0 }, + { zGlibc_Cxx_Floatn_4Name, zGlibc_Cxx_Floatn_4List, + apzGlibc_Cxx_Floatn_4Machs, + GLIBC_CXX_FLOATN_4_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aGlibc_Cxx_Floatn_4Tests, apzGlibc_Cxx_Floatn_4Patch, 0 }, + { zGlibc_Mutex_InitName, zGlibc_Mutex_InitList, apzGlibc_Mutex_InitMachs, GLIBC_MUTEX_INIT_TEST_CT, FD_MACH_ONLY, --- gcc/tests/base/bits/floatn.h.jj 2022-09-28 19:59:27.625087388 +0200 +++ gcc/tests/base/bits/floatn.h 2022-09-28 19:56:30.855465791 +0200 @@ -45,6 +45,10 @@ typedef float _Float16 __attribute__ ((_ # if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) typedef __float128 _Float128; # endif +# if 0 +# elif !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0)) +typedef __float128 _Float128; +# endif #endif /* GLIBC_CXX_FLOATN_2_CHECK */ @@ -72,3 +76,11 @@ typedef _Complex float __cfloat128 __att # define __CFLOAT64 _Complex _Float64 # endif #endif /* GLIBC_CXX_FLOATN_3_CHECK */ + + +#if defined( GLIBC_CXX_FLOATN_4_CHECK ) +# if __LDBL_MANT_DIG__ == 113 && defined __cplusplus && !__GNUC_PREREQ (13, 0) +typedef long double _Float128; +# define __CFLOAT128 _Complex long double +# endif +#endif /* GLIBC_CXX_FLOATN_4_CHECK */