From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id DC3383858C2F; Wed, 3 Jan 2024 11:13:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC3383858C2F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC3383858C2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.141.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704280390; cv=none; b=sohJ+eWPXt7r0HZ12ggqC7qdwLJKGqEobzlt0hCDuIk2kH+r83YJYkNXTLvKEyZipL3qexyH86+jwnl2tbcS9rS62flw0MSULx0BtjGJuMFeZSCl6jYsAAtVrmJ2Rbl80WehX/yap7sxJBSyj2rZE9nVxS2oAaPKDD/hT4ToGGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704280390; c=relaxed/simple; bh=B1Kr78gjzZyfLmOhcQxPYlMyiw31X7thBNa2GyeQ4wI=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=dmbrgHKGbpOHRqUXX0LWSIxGQiN3HjZIPkoFrDGm5BWLYBi7x22ml5mGDFAyMMIhdCQmoYMUEW8BJIc+Q5ONcH2hgsmRl5Hy62k3nY0Zsmt/KTAWsO8T9zNRSuS3BdRddN9ijMnLROT3xb16X4UguLResKv5acTIfPf2rDTogzI= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: njqocCfJSHCfeEUloz7qiQ== X-CSE-MsgGUID: eYmFLlOJSES75rSISfKMcQ== X-IronPort-AV: E=Sophos;i="6.04,327,1695715200"; d="scan'208";a="30067230" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 03 Jan 2024 03:13:05 -0800 IronPort-SDR: 4GMqEK5L9XHN8VOOH2h7BK3lrBJfPf45xKs68zrH84o787GEwdSDxx45Uu272+SWS3gPdxH8hW Vt80kN4YUXqmD2vt04hTg+6wHEVOpGmcKVAXnwUIJU57OU4gUDkfyFzNr/WD1SfpsU7Q/xZCHl P3C2VPu6nP2g6ZU41pwfwxP8O+cVZik1YGYAsZBIyepzPYj1AXN+RSQQ2k0IcXPsUkPUBoYc9U +SYDFqPtUYD3i71CRvWmKJSGOdOuRNep48QT/jcZehK6vl5vs+AFzPAXYmcVB3vg1+nh4AOWqd zyw= Message-ID: Date: Wed, 3 Jan 2024 12:12:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] libgfortran: Bugfix if not define HAVE_ATOMIC_FETCH_ADD Content-Language: en-US To: Lipeng Zhu , , CC: , , , , , , , , References: <20231222023605.3894839-1-lipeng.zhu@intel.com> From: Tobias Burnus In-Reply-To: <20231222023605.3894839-1-lipeng.zhu@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 22.12.23 03:36, Lipeng Zhu wrote: > This patch try to fix the bug when HAVE_ATOMIC_FETCH_ADD is > not defined in dec_waiting_unlocked function. > > libgfortran/ChangeLog: > > * io/io.h (dec_waiting_unlocked): Use > __gthread_rwlock_wrlock/__gthread_rwlock_unlock or > __gthread_mutex_lock/__gthread_mutex_unlock functions > to replace WRLOCK and RWUNLOCK macros. > > Signed-off-by: Lipeng Zhu The change looks good to me + I assume it will work, but have not tested it myself. Downside is that it slightly breaks with the abstraction done with all the macros, but it seems to be the simplest solution. What is really missing - and should be included in the commit message (before the ChangeLog block) - is the following information: As io.h does not include async.h, the WRLOCK and RWUNLOCK macros are undefined. (Or something similar in other words.) I think that helps others when looking at "git log" and wondering *why* that change was needed. Thanks, Tobias > libgfortran/io/io.h | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h > index 15daa0995b1..c7f0f7d7d9e 100644 > --- a/libgfortran/io/io.h > +++ b/libgfortran/io/io.h > @@ -1020,9 +1020,15 @@ dec_waiting_unlocked (gfc_unit *u) > #ifdef HAVE_ATOMIC_FETCH_ADD > (void) __atomic_fetch_add (&u->waiting, -1, __ATOMIC_RELAXED); > #else > - WRLOCK (&unit_rwlock); > +#ifdef __GTHREAD_RWLOCK_INIT > + __gthread_rwlock_wrlock (&unit_rwlock); > + u->waiting--; > + __gthread_rwlock_unlock (&unit_rwlock); > +#else > + __gthread_mutex_lock (&unit_rwlock); > u->waiting--; > - RWUNLOCK (&unit_rwlock); > + __gthread_mutex_unlock (&unit_rwlock); > +#endif > #endif > } ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955