[libc-commits] [libc] 2b1dcf5 - [libc] Remove hardcoded sizeof in __barrier_type.h (#153718)
via libc-commits
libc-commits at lists.llvm.org
Thu Aug 21 05:38:00 PDT 2025
Author: Mikhail R. Gadelha
Date: 2025-08-21T09:37:56-03:00
New Revision: 2b1dcf53832752a6855243d9579e18439aa2846a
URL: https://github.com/llvm/llvm-project/commit/2b1dcf53832752a6855243d9579e18439aa2846a
DIFF: https://github.com/llvm/llvm-project/commit/2b1dcf53832752a6855243d9579e18439aa2846a.diff
LOG: [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.
Added:
Modified:
libc/src/__support/threads/linux/barrier.h
Removed:
################################################################################
diff --git a/libc/src/__support/threads/linux/barrier.h b/libc/src/__support/threads/linux/barrier.h
index f0655bfc52a10..a632aa45b2aa2 100644
--- a/libc/src/__support/threads/linux/barrier.h
+++ b/libc/src/__support/threads/linux/barrier.h
@@ -36,14 +36,19 @@ class Barrier {
int wait();
};
-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
diff erent alignment "
- "than 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 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
More information about the libc-commits
mailing list