]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix broken bootstrap on FreeBSD.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Fri, 9 Jan 2026 21:00:07 +0000 (22:00 +0100)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Fri, 9 Jan 2026 21:03:21 +0000 (22:03 +0100)
As analyzed by Steve, on freebsd __gthread_t is a pointer type.
I thought it the cleanest solution to remove the #ifdef in gfc_unit,
make the "self" member a intptr_t and cast the return value of
__gthread_t to that type.

PR fortran/123512

libgfortran/ChangeLog:

* io/io.h: Change type of self to intptr_t.
* io/async.h (LOCK_UNIT): Cast __gthread_self () to intptr_t.
(TRYLOCK_UNIT): Likewise.
(OWN_THREAD_ID): Likewise.

libgfortran/io/async.h
libgfortran/io/io.h

index c4451f28f3188862d722b858824657f91e043960..596b6d6f5f71e6c0d83ac3d427417037e83e921e 100644 (file)
 
 #define LOCK_UNIT(unit) do {           \
     LOCK (&(unit)->lock);              \
-    (unit)->self = __gthread_self ();  \
+    (unit)->self = (intptr_t) __gthread_self ();       \
   } while (0)
 
 #ifdef __GTHREAD_RWLOCK_INIT
    unlocking; the only use for this is checking for recursion.  */
 
 #define LOCK_UNIT(unit) do {                                   \
-  if (__gthread_active_p ()) {                                 \
-    LOCK (&(unit)->lock); (unit)->self = __gthread_self ();    \
-  } else {                                                     \
-    (unit)->self = 1;                                          \
-  }                                                            \
+    if (__gthread_active_p ()) {                                       \
+      LOCK (&(unit)->lock); (unit)->self = (intptr_t) __gthread_self (); \
+    } else {                                                           \
+      (unit)->self = 1;                                                        \
+    }                                                                  \
   } while(0)
 #else
 
       if (__gthread_active_p ()) {                             \
        res = __gthread_mutex_trylock (&(unit)->lock);          \
        if (!res)                                               \
-         (unit)->self = __gthread_self ();                     \
+         (unit)->self = (intptr_t) __gthread_self ();          \
       }                                                                \
       else {                                                   \
        res = (unit)->self;                                     \
@@ -555,7 +555,7 @@ extern __thread gfc_unit *thread_unit;
    to be 1.  */
 
 #ifdef __GTHREADS_CXX0X
-#define OWN_THREAD_ID (__gthread_active_p () ? __gthread_self () : 1)
+#define OWN_THREAD_ID (__gthread_active_p () ? (intptr_t) __gthread_self () : 1)
 #else
 #define OWN_THREAD_ID 1
 #endif
index ebb2252966815125a0ffc4c552e24de8baa2d662..7928c196f63f2dd32af25612a5716577265f6678 100644 (file)
@@ -728,11 +728,7 @@ typedef struct gfc_unit
   int last_char;
   bool has_size;
   GFC_IO_INT size_used;
-#ifdef __GTHREADS_CXX0X
-  __gthread_t self;
-#else
-  int self;
-#endif
+  intptr_t self;
 }
 gfc_unit;