nptl: Check alignment of pthread structs

Report assertion failure if the alignment of external pthread structs is
lower than the internal version.  This triggers on type mismatches like
in BZ #33632.

Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
This commit is contained in:
Wilco Dijkstra 2025-12-04 15:17:25 +00:00
parent f9bb6bcff6
commit 83dd79dffb
1 changed files with 5 additions and 3 deletions

View File

@ -698,9 +698,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) \