From: Thomas Koenig Date: Fri, 9 Jan 2026 21:00:07 +0000 (+0100) Subject: Fix broken bootstrap on FreeBSD. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a98b1a6ac91cb1aa0f89f7dcdb9c35daa88c2a1;p=thirdparty%2Fgcc.git Fix broken bootstrap on FreeBSD. 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. --- diff --git a/libgfortran/io/async.h b/libgfortran/io/async.h index c4451f28f31..596b6d6f5f7 100644 --- a/libgfortran/io/async.h +++ b/libgfortran/io/async.h @@ -248,7 +248,7 @@ #define LOCK_UNIT(unit) do { \ LOCK (&(unit)->lock); \ - (unit)->self = __gthread_self (); \ + (unit)->self = (intptr_t) __gthread_self (); \ } while (0) #ifdef __GTHREAD_RWLOCK_INIT @@ -390,11 +390,11 @@ 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 @@ -430,7 +430,7 @@ 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 diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index ebb22529668..7928c196f63 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -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;