Message ID | 20240105014325.1490280-1-lipeng.zhu@intel.com |
---|---|
State | New |
Headers | show |
Series | [v2] libgfortran: Bugfix if not define HAVE_ATOMIC_FETCH_ADD | expand |
On 05/01/2024 01:43, Lipeng Zhu wrote: > 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 <lipeng.zhu@intel.com> Has this been committed yet? R. > --- > 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 > } >
On 1/10/2024 7:52 PM, Richard Earnshaw wrote: > On 05/01/2024 01:43, Lipeng Zhu wrote: >> 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 <lipeng.zhu@intel.com> > > Has this been committed yet? > > R. Hi Richard, The patch is waiting for community's review. Hi Tobias, Any concern about this patch? Best Regards, 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 >> } >
On Thu, Jan 04, 2024 at 08:43:26PM -0500, Lipeng Zhu wrote: > 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 <lipeng.zhu@intel.com> LGTM. Jakub
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 }
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 <lipeng.zhu@intel.com> --- libgfortran/io/io.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)