From patchwork Fri Dec 22 02:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lipeng Zhu X-Patchwork-Id: 182512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp824601dyi; Thu, 21 Dec 2023 19:20:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeoJmdanW5kzoGcV8HHRmgAZ3Tr838ObEunQeYMfpIBKnn//hNWuw+L51WI9WJu+/cHOq5 X-Received: by 2002:a05:620a:108a:b0:77e:fba3:757e with SMTP id g10-20020a05620a108a00b0077efba3757emr772405qkk.118.1703215227993; Thu, 21 Dec 2023 19:20:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703215227; cv=pass; d=google.com; s=arc-20160816; b=hZTo1UV51QrViWl2bOz+w/czOfGSunub18qoW13Zrq4DX3cHyMfOdMDULqQoBmHWkr Csta92NbnLEyz31xUbTO/VzRUZAFt0MNhq1mTk8KTFs4fHYH3ax5yjg/UlzL9EUXTZea ujl1s2PhtjA5Eff2InG1H3wG4QJr6kBJBHmA9heEEQjg5sSZEPYhKSzUlSVPVaywtGmr Z/STv7feYGYCiGNk0m8DM2rjCkIS3zusdCtRVSVCVjo1LO2Fc+XG4UdiWkaxR0/7Y3N1 /zHKQua9YqahJLhkrLlAUJywKjksZbp5sPv1DTO7HzQO/u9+ZS3ewB1xLvbysWM3ELbI ckwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=U76q/QwXXaaCpIHrclnkmFR0d6Dbf2V7EfYEtFEn7lw=; fh=knZxdD9i8OODME1tGmMxOVgFb5ol5782lqm1V+GDnqU=; b=jnNI2JH6UTT1mS/VGM2R33MEJ8DilsspBzkbEfknGO511pKSGAZiOoMp+wiB9dZA1c 5Kig5JtDnvhI4WaWDGQKBxyNGjYWIAgw0YlM00ek1bN4/P9eZr9nfn5FOREdQgsORzdx TmksIDt0/uwfA1GTn3+sqKYAuwaUhlgFbxgUGyIFPzuFuJLSrMJ7EElarPxTu3cT9hy3 dYrSAjsZbT51FASgY1vc+PKSnoXHyFJ4uaiNoe+WOYiLISwy066YXHntTtXReWiskefX FWVaPFy3UP3mfo/fIjOs+v2GAf4HU1fMpRIhaW3LsMBo9e95cAH79OJVY1gGBG2iAwWQ 0Mdw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KlSM10Ju; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u21-20020a05620a455500b0077a565e3fedsi4027408qkp.118.2023.12.21.19.20.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 19:20:27 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KlSM10Ju; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8136E3858420 for ; Fri, 22 Dec 2023 02:16:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by sourceware.org (Postfix) with ESMTPS id 0A20F3858D33; Fri, 22 Dec 2023 02:16:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A20F3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0A20F3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703211387; cv=none; b=MvizBlfnzYwSUZq5lR2zXnqop1MftVhmBMKAAlxfvZGAzbbJpNWl33cSVCRsUYiHfqso/75q0agP5LPWZKGxAmOsnRcDKoyXn4+mTy5wYDEb40iq2ICbjuL4ckJv0OrdbtfXFfkLBDfFgUvsxN4XN1pj1yQKEriGQkO1mguHtNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703211387; c=relaxed/simple; bh=kG/yJFINfmgim2+Ar2Ut/OVpKsXDcw+gCa1onSHv5yQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=hHujJL8YDf3GVqryr6sV3Up6i4sfKk4NkC9bREAyzm0svGncxC3jz7iDV0HbDRpz3LShVPJZhb2Gzo8IR4jnernFW2+EjbLMg3EoiRyvIFMHcODPo2NiTSsSUUwFh7IXD8Kc09ltYW2t8R1VL+Xqr8FS9dumDdoFmeolhwGsyGI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703211386; x=1734747386; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=kG/yJFINfmgim2+Ar2Ut/OVpKsXDcw+gCa1onSHv5yQ=; b=KlSM10Ju4HiEf9iY1I6FVNv7pA7MELbjLyreHW5LUZ7/HEDSsY0/vVEw TOPs4t81IVSdeu943/gqz0FCop8HQzf9iwvLsk6SYzfEavO2j/d6TT7n2 q0jvOZ3bFjSSws6TX5vxk2l3ftseRZvKXhrCXyX3ciilS0asjefYvZ7Lw T3hji+osuqE1SdcuZxSh7pQQEW3t1a050CBWQRGZYWwEEXHIuq6bCKN4K ywjqGybW2sKl8uplFzq8vUiHjNHJvd+ZV/YpN3WxlAiNphy0obZKK7Hlp dYaj//z+UfZZGNkuD190zh/q4/BKn/vdr/XfDgWub9O7dba2hiTrbJoP7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="2900797" X-IronPort-AV: E=Sophos;i="6.04,294,1695711600"; d="scan'208";a="2900797" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2023 18:16:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10931"; a="867516895" X-IronPort-AV: E=Sophos;i="6.04,294,1695711600"; d="scan'208";a="867516895" Received: from linux-pnp-server-26.sh.intel.com ([10.239.146.135]) by FMSMGA003.fm.intel.com with ESMTP; 21 Dec 2023 18:16:17 -0800 From: Lipeng Zhu To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: rep.dot.nop@gmail.com, tkoenig@netcologne.de, jakub@redhat.com, Richard.Earnshaw@arm.com, thomas@codesourcery.com, hongjiu.lu@intel.com, tianyou.li@intel.com, pan.deng@intel.com, wangyang.guo@intel.com, Lipeng Zhu Subject: [PATCH] libgfortran: Bugfix if not define HAVE_ATOMIC_FETCH_ADD Date: Thu, 21 Dec 2023 21:36:06 -0500 Message-Id: <20231222023605.3894839-1-lipeng.zhu@intel.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785950611304075168 X-GMAIL-MSGID: 1785950611304075168 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 --- 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 }