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: 82734 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 1982F3858403 for ; Fri, 22 Dec 2023 02:16:45 +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+patchwork=sourceware.org@gcc.gnu.org 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 }