[PATCH] htl: move c11 symbols into libc.

Samuel Thibault samuel.thibault@aquilenet.fr
Fri Nov 21 14:12:14 GMT 2025


gfleury, le ven. 21 nov. 2025 11:10:02 +0200, a ecrit:
> thrd_{create,detach,exit,join}.
> mtx_{init,destroy,lock,trylock,unlock,timeelock}.
> cnd_{broadcast,destroy,init,signal,timewait,wait,destroy}
> tss_{create,delete,get,set}.
> call_once.
> 
> For *mtx_timedlock* and *cnd_timedwait*, I kept the default implementation
> because we don't seem to have TIMESIZE 64 check like in nptl

Indeed, we don't plan to implement it.

> diff --git a/sysdeps/pthread/call_once.c b/sysdeps/pthread/call_once.c
> index 9c0eb397..2b34bef8 100644
> --- a/sysdeps/pthread/call_once.c
> +++ b/sysdeps/pthread/call_once.c
> @@ -30,11 +30,14 @@ __call_once (once_flag *flag, void (*func)(void))
>  		  "alignof (once_flag) != alignof (pthread_once_t)");
>    __pthread_once ((pthread_once_t *) flag, func);
>  }
> -#if PTHREAD_IN_LIBC
> +#ifndef __PTHREAD_HTL
>  versioned_symbol (libc, __call_once, call_once, GLIBC_2_34);
>  # if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_28, GLIBC_2_34)
>  compat_symbol (libpthread, __call_once, call_once, GLIBC_2_28);
>  # endif
> -#else /* !PTHREAD_IN_LIBC */
> -strong_alias (__call_once, call_once)
> +#else /* __PTHREAD_HTL */
> +versioned_symbol (libc, __call_once, call_once, GLIBC_2_43);
> +# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_32, GLIBC_2_43)
> +compat_symbol (libpthread, __call_once, call_once, GLIBC_2_32);
> +#endif
>  #endif

As I mentioned, instead of duplicating the logic, better introduce a
sysdeps/{htl,nptl}/c11-threads.h header that introduce

C11_THREADS_INTRODUCED GLIBC_2_28
C11_THREADS_IN_LIBC GLIBC_2_34

C11_THREADS_INTRODUCED GLIBC_2_32
C11_THREADS_IN_LIBC GLIBC_2_43

and you can replace GLIBC_2_28 and GLIBC_2_34 with them.

> diff --git a/sysdeps/pthread/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c
> index f0529d8f..802a85b9 100644
> --- a/sysdeps/pthread/cnd_timedwait.c
> +++ b/sysdeps/pthread/cnd_timedwait.c
> @@ -16,10 +16,11 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> +#include <shlib-compat.h>
>  #include "thrd_priv.h"
>  
>  int
> -cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
> +__cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
>  	       const struct timespec* restrict time_point)
>  {
>    int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond,
> @@ -27,3 +28,12 @@ cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
>  					   time_point);
>    return thrd_err_map (err_code);
>  }
> +
> +#ifdef __PTHREAD_HTL
> +versioned_symbol (libc, __cnd_timedwait, cnd_timedwait, GLIBC_2_43);
> +# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_32, GLIBC_2_43)
> +compat_symbol (libpthread, __cnd_timedwait, cnd_timedwait, GLIBC_2_32);
> +#endif

Here the same logic still applies.

> +#else
> +strong_alias (__cnd_timedwait, cnd_timedwait)
> +#endif

And you don't need the #else part. NPTL will use its own version anyway.

And same for mtx_timedlock.c

Samuel


More information about the Libc-alpha mailing list