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: 185186 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5966328dyb; Thu, 4 Jan 2024 17:27:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGRgJN2vc1NltngD+UQnFPhp6WO0PfZrIAamoIQWtxfv2pVMLEfGopF7wfIDpsGBU4LLo2 X-Received: by 2002:a05:6214:e82:b0:680:c22a:4e96 with SMTP id hf2-20020a0562140e8200b00680c22a4e96mr1733142qvb.130.1704418020527; Thu, 04 Jan 2024 17:27:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704418020; cv=pass; d=google.com; s=arc-20160816; b=YlH1ezNE/6vb4tMH8uH2vY8O9yfx5jCCLEN+PJ7cj7GxpOekOwcqWdmy1fbqtjUJJ5 ufhspnRh6aSyEAWv8XvHbYfdPRa+Pn7GWiyuStDdPrcCwhBSOrXIKVacFUESsZ++p3vq 0VNdECLN47J8iZlndn7+K3en12ljwfJsme+Ol9CGrWNDsBbb/vpmv1SzuB9GP3f8krMy n8FD5w/z6B/zpv8e/+gniGGXFDPrsnoyWMOMw0fmb15FZBDClzJhqAD+Q2y2chYnA87j 46NzOGTxk3AKYdfMKwc81weAhPz8Ep4r+9LroiaAH9PsWG41mll5j90OYoxnmJERkolw Ysmg== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=sRXbYhZMYD0JnGW4HCO2PwLTvlRxyR4tGSL2mh6C32Y=; fh=fQoFQB8WqSsPYTvFFIgbtg6iqacXYJpmNYPkXOJeIDA=; b=JKcOydRw11rfwRlMtG//jElsA9v+TGTEVbV6L4i/f+ErCvWOJf1+JuSvd9LgNirCnL jFi4w72JMX7mxSRjVJYZiuCpj4wNwsYeYimcOaMB8J5T1nhbB7DGr9aui01yVQ2CPjKa xx6m18VqUkIxWS5qfVPe4n+l4KjoEs3rQVLugYr/W65JAkh4EvrAJgYG+JOFg6khdyd9 3PGWWJE3AhdwthwZ+3WC9JZ+bVx8W+J0JCx+7RrR5oZbUD+1Jt2/e/wu97RXTFitZfO+ j56Y4r2amCbO9dSx4HYZ1Tu5gnndp+psdiMcBnjTIo37vNemK0QE/OfuX2EHm0XZq2xz C8Uw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mfYfVtzr; 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 b10-20020a0c9b0a000000b006804af29168si708330qve.533.2024.01.04.17.27.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 17:27:00 -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=mfYfVtzr; 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 3AD513857C69 for ; Fri, 5 Jan 2024 01:27:00 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785950611304075168 X-GMAIL-MSGID: 1787211830464377761 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 }