[libc] Remove hardcoded sizeof in __barrier_type.h (#153718)

This PR modifies the static_asserts checking the expected sizes in
__barrier_type.h, so that we can guarantee that our internal
implementation fits the public header.
This commit is contained in:
Mikhail R. Gadelha 2025-08-21 14:37:56 +02:00 committed by GitHub
parent 5af7263d42
commit 2b1dcf5383
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,14 +36,19 @@ public:
int wait();
};
static_assert(
sizeof(Barrier) == sizeof(pthread_barrier_t),
"The public pthread_barrier_t type cannot accommodate the internal "
"barrier type.");
static_assert(sizeof(Barrier) <= sizeof(pthread_barrier_t),
"The public pthread_barrier_t type cannot accommodate the "
"internal barrier type.");
static_assert(alignof(Barrier) == alignof(pthread_barrier_t),
"The public pthread_barrier_t type has a different alignment "
"than the internal barrier type.");
static_assert(alignof(Barrier) <= alignof(pthread_barrier_t),
"The public pthread_barrier_t type has insufficient alignment "
"for the internal barrier type.");
static_assert(sizeof(CndVar) <= 24,
"CndVar size exceeds the size in __barrier_type.h");
static_assert(sizeof(Mutex) <= 24,
"Mutex size exceeds the size in __barrier_type.h");
} // namespace LIBC_NAMESPACE_DECL