[PATCH 2/4] Add generic <thread_pointer.h>

Michael Jeanson mjeanson@efficios.com
Tue Jan 7 16:06:27 GMT 2025


On 2025-01-07 08:09, Florian Weimer wrote:
> It uses the GCC built-in.  Based on the exixsting THREAD_SELF
> definition, this version is suitable for:
> 
>   aarch64
>   alpha
>   arc
>   arm
>   s390
>   s390x
> 
> It also builds on all mips and sh variants with current GCC.  We can
> use it there as well for now, and add custom <thread_pointer.h>
> headers once if it proves necessary.
> ---
>  sysdeps/generic/thread_pointer.h | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
>  create mode 100644 sysdeps/generic/thread_pointer.h
> 
> diff --git a/sysdeps/generic/thread_pointer.h b/sysdeps/generic/thread_pointer.h
> new file mode 100644
> index 0000000000..7c2faf0218
> --- /dev/null
> +++ b/sysdeps/generic/thread_pointer.h
> @@ -0,0 +1,28 @@
> +/* __thread_pointer definition.  Generic version using GCC built-in.
> +   Copyright (C) 2021-2025 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library.  If not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _SYS_THREAD_POINTER_H
> +#define _SYS_THREAD_POINTER_H
> +
> +static inline void *
> +__thread_pointer (void)
> +{
> +  return __builtin_thread_pointer ();
> +}
> +
> +#endif /* _SYS_THREAD_POINTER_H */

The previous patch in the series already moves a generic implementation:

  sysdeps/{nptl => }/thread_pointer.h

It should just move it to 'generic' instead to avoid duplication.

Thanks,

Michael



More information about the Libc-alpha mailing list