From 2b1dcf53832752a6855243d9579e18439aa2846a Mon Sep 17 00:00:00 2001 From: "Mikhail R. Gadelha" Date: Thu, 21 Aug 2025 14:37:56 +0200 Subject: [PATCH] [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. --- libc/src/__support/threads/linux/barrier.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libc/src/__support/threads/linux/barrier.h b/libc/src/__support/threads/linux/barrier.h index f0655bfc52a1..a632aa45b2aa 100644 --- a/libc/src/__support/threads/linux/barrier.h +++ b/libc/src/__support/threads/linux/barrier.h @@ -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