[PATCH] nptl: Check alignment of pthread structs

H.J. Lu hjl.tools@gmail.com
Mon Nov 17 22:27:10 GMT 2025


On Mon, Nov 17, 2025 at 7:02 PM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
>
> Assert if the alignment of external pthread structs is lower than

     Did you mean "higher"?
> the internal version.
>
> Tested on AArch64, OK for commit?
>
> ---
>
> diff --git a/sysdeps/nptl/pthreadP.h b/sysdeps/nptl/pthreadP.h
> index 3c9a14c3d6f8b3eb076be3495bb2222ff0dc2aad..f98cdf4769bcfe320117c6dcefb11a5a9ba0e7a6 100644
> --- a/sysdeps/nptl/pthreadP.h
> +++ b/sysdeps/nptl/pthreadP.h
> @@ -714,9 +714,11 @@ check_stacksize_attr (size_t st)
>    _Static_assert (sizeof (type) == size,                               \
>                   "sizeof (" #type ") != " #size)
>
> -#define ASSERT_PTHREAD_INTERNAL_SIZE(type, internal)                   \
> -  _Static_assert (sizeof ((type) { { 0 } }).__size >= sizeof (internal),\
> -                 "sizeof (" #type ".__size) < sizeof (" #internal ")")
> +#define ASSERT_PTHREAD_INTERNAL_SIZE(type, internal)                       \
> +  { _Static_assert (sizeof ((type) { { 0 } }).__size >= sizeof (internal),  \
> +                   "sizeof (" #type ".__size) < sizeof (" #internal ")");  \
> +    _Static_assert (_Alignof (type) >= _Alignof (internal),                \
> +                   "_Aignof (" #type ") < _Alignof (" #internal ")"); }
>
>  #define ASSERT_PTHREAD_STRING(x) __STRING (x)
>  #define ASSERT_PTHREAD_INTERNAL_OFFSET(type, member, offset)           \
>


-- 
H.J.


More information about the Libc-alpha mailing list