public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: Lipeng Zhu <lipeng.zhu@intel.com>, <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>
Subject: Re: [PATCH] libgfortran: Bugfix if not define HAVE_ATOMIC_FETCH_ADD
Date: Wed, 3 Jan 2024 12:12:58 +0100	[thread overview]
Message-ID: <d2d7e33b-7d0f-4ff3-bfe5-524c968fd2c0@codesourcery.com> (raw)
In-Reply-To: <20231222023605.3894839-1-lipeng.zhu@intel.com>

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 <lipeng.zhu@intel.com>

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ße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

  reply	other threads:[~2024-01-03 11:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22  2:36 Lipeng Zhu
2024-01-03 11:12 ` Tobias Burnus [this message]
2024-01-03 22:04   ` Jerry D
2024-01-04  2:18   ` Lipeng Zhu
2024-01-05  1:43     ` [PATCH v2] " Lipeng Zhu
2024-01-10 11:52       ` Richard Earnshaw
2024-01-11  3:05         ` Lipeng Zhu
2024-01-11 12:38       ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2d7e33b-7d0f-4ff3-bfe5-524c968fd2c0@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongjiu.lu@intel.com \
    --cc=jakub@redhat.com \
    --cc=lipeng.zhu@intel.com \
    --cc=pan.deng@intel.com \
    --cc=rep.dot.nop@gmail.com \
    --cc=thomas@codesourcery.com \
    --cc=tianyou.li@intel.com \
    --cc=tkoenig@netcologne.de \
    --cc=wangyang.guo@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).