From patchwork Fri Jan 5 01:43:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lipeng Zhu X-Patchwork-Id: 1882685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mfYfVtzr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T5m5F2flsz1ydb for ; Fri, 5 Jan 2024 12:26:39 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F369385840A for ; Fri, 5 Jan 2024 01:26:37 +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 [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id B8711385840A; Fri, 5 Jan 2024 01:26:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8711385840A 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 B8711385840A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.31 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704417972; cv=none; b=V8CAS1euZ25loOW5EdmFEGYnJHfNaC6LCODZbDiWEfilvxNoVwGiMMNBZcFh1vCtQnNBzl1j4BwkBo5WG7HedeUh/jont1IeEp/una7xlTQA8lm3RwcDZOI2W/hUvboRiQmC0M8ztWmjpZClImeGfzP9fwBp16+MnKMO9lLkl/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704417972; c=relaxed/simple; bh=C4kG4mW5tKd4nPpHaqOSNFcqdTNnPCd8ckgRfHpzM10=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=JZavEv384LDCDEJm6P7KOA/ri175v7IDwUz6g6WSfTVpQJrBH+m6zlaJ0R7q4kngCDhZeTR+sAsWJYUt2qOm5cNfdnxXF5LQpk4gqjzKXVr/+yU4mNpOrNx+1jmzmkAxem5moXdE8tWgNS5cb+TKKPklruTVFN8GYFTo1pCj6y8= 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=1704417969; x=1735953969; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C4kG4mW5tKd4nPpHaqOSNFcqdTNnPCd8ckgRfHpzM10=; b=mfYfVtzrGsHeYQlMDYOTp7OhB9fDrt7XoFyQw3aZ/sMQ9IlKXQ+bNWhZ Lce52j3nqCSkr80P0JyMB0MphSlViQ24q1beHmLEe0kKFV0CPI2pTQy/P hQ2jTGIGg5NiL1EJ5C4DTK+EsTA+k83uF0OpmAFXJA1zqmz9QVB0ZRkfb //JPsTEZQyJjlq3NYRQOUPtYTu8Yd3uuTVjzgANC4g10HzHAdhaaRwan0 L1kjYLtXCjkkNuq3YglfpCixjhLymKxTWRDGlfqZoe1qWaHslPGQuHj5U kEynOPenNn0lT0x1RfuPmk5vVdXZoMj4xjiiCafRuTfiTSw0UG5BMX+Es g==; X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="461710850" X-IronPort-AV: E=Sophos;i="6.04,332,1695711600"; d="scan'208";a="461710850" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2024 17:25:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="850991833" X-IronPort-AV: E=Sophos;i="6.04,332,1695711600"; d="scan'208";a="850991833" Received: from linux-pnp-server-26.sh.intel.com ([10.239.146.135]) by fmsmga004.fm.intel.com with ESMTP; 04 Jan 2024 17:25:49 -0800 From: Lipeng Zhu To: tobias@codesourcery.com Cc: Richard.Earnshaw@arm.com, fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org, hongjiu.lu@intel.com, jakub@redhat.com, pan.deng@intel.com, rep.dot.nop@gmail.com, thomas@codesourcery.com, tianyou.li@intel.com, tkoenig@netcologne.de, wangyang.guo@intel.com, Lipeng Zhu Subject: [PATCH v2] libgfortran: Bugfix if not define HAVE_ATOMIC_FETCH_ADD Date: Thu, 4 Jan 2024 20:43:26 -0500 Message-Id: <20240105014325.1490280-1-lipeng.zhu@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 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+incoming=patchwork.ozlabs.org@gcc.gnu.org This patch try to fix the bug when HAVE_ATOMIC_FETCH_ADD is not defined in dec_waiting_unlocked function. As io.h does not include async.h, the WRLOCK and RWUNLOCK macros are undefined. 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 }