]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgfortran: Bugfix if not define HAVE_ATOMIC_FETCH_ADD
authorLipeng Zhu <lipeng.zhu@intel.com>
Fri, 5 Jan 2024 01:43:26 +0000 (20:43 -0500)
committerH.J. Lu <(no_default)>
Mon, 15 Jan 2024 13:22:07 +0000 (05:22 -0800)
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

index 862daca1f2291a305d124342b925ddefc3b1a5b6..59bc19ee815f1ee78c0e8ca69f2e0f3c38d88f60 100644 (file)
@@ -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
 }