On Thu, Sep 26, 2024 at 08:34:45PM +1000, Nathaniel Shead wrote:
> --- a/libgcc/gthr-posix.h
> +++ b/libgcc/gthr-posix.h
> @@ -44,6 +44,21 @@ see the files COPYING3 and COPYING.RUNTIME respectively.
> If not, see
> # endif
> #endif
>
> +#ifdef __has_attribute
> +# if __has_attribute(__always_inline__)
> +# define __GTHREAD_ALWAYS_INLINE __attribute__((__always_inline__))
> +# endif
> +#endif
> +#ifndef __GTHREAD_ALWAYS_INLINE
> +# define __GTHREAD_ALWAYS_INLINE
> +#endif
> +
> +#ifdef __cplusplus
> +# define __GTHREAD_INLINE inline __GTHREAD_ALWAYS_INLINE
> +#else
> +# define __GTHREAD_INLINE static inline
> +#endif
Thanks.
> @@ -182,22 +197,29 @@ __gthrw(pthread_setschedparam)
>
> #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
>
> -static volatile int __gthread_active = -1;
> +#pragma GCC visibility push(hidden)
> +__GTHREAD_INLINE volatile int *
> +__gthread_active (void)
> +{
> + static volatile int __gthread_active_var = -1;
> + return &__gthread_active_var;
> +}
> +#pragma GCC visibility pop
I think something like the above
> -static void
> +__GTHREAD_INLINE void
> __gthread_trigger (void)
> {
> - __gthread_active = 1;
> + *__gthread_active () = 1;
> }
>
> -static inline int
> +__GTHREAD_INLINE int
> __gthread_active_p (void)
> {
> static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
> static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
is needed also around this one.
> @@ -257,13 +279,15 @@ __gthrw2(__gthrw_(__pthread_key_create),
> # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
> #endif
>
> -static inline int
> +#pragma GCC visibility push(hidden)
> +__GTHREAD_INLINE int
> __gthread_active_p (void)
> {
> static void *const __gthread_active_ptr
> = __extension__ (void *) >HR_ACTIVE_PROXY;
> return __gthread_active_ptr != 0;
> }
> +#pragma GCC visibility pop
And this one but you've added it to that one already.
Otherwise LGTM for the libgcc side, will defer to Jon for libstdc++ side.
Jakub