Skip to content

Commit 2b1dcf5

Browse files
[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.
1 parent 5af7263 commit 2b1dcf5

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

libc/src/__support/threads/linux/barrier.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ class Barrier {
3636
int wait();
3737
};
3838

39-
static_assert(
40-
sizeof(Barrier) == sizeof(pthread_barrier_t),
41-
"The public pthread_barrier_t type cannot accommodate the internal "
42-
"barrier type.");
43-
44-
static_assert(alignof(Barrier) == alignof(pthread_barrier_t),
45-
"The public pthread_barrier_t type has a different alignment "
46-
"than the internal barrier type.");
39+
static_assert(sizeof(Barrier) <= sizeof(pthread_barrier_t),
40+
"The public pthread_barrier_t type cannot accommodate the "
41+
"internal barrier type.");
42+
43+
static_assert(alignof(Barrier) <= alignof(pthread_barrier_t),
44+
"The public pthread_barrier_t type has insufficient alignment "
45+
"for the internal barrier type.");
46+
47+
static_assert(sizeof(CndVar) <= 24,
48+
"CndVar size exceeds the size in __barrier_type.h");
49+
50+
static_assert(sizeof(Mutex) <= 24,
51+
"Mutex size exceeds the size in __barrier_type.h");
4752

4853
} // namespace LIBC_NAMESPACE_DECL
4954

0 commit comments

Comments
 (0)