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

via libc-commits libc-commits at lists.llvm.org
Thu Aug 14 17:33:24 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Mikhail R. Gadelha (mikhailramalho)

<details>
<summary>Changes</summary>

This PR removes the hardcoded values for the sizeof(LIBC_NAMESPACE::CndVar) and sizeof(LIBC_NAMESPACE::Mutex) and replaces them with the actual calls to sizeof. Fixes compilation error in 32-bit systems.

---
Full diff: https://github.com/llvm/llvm-project/pull/153718.diff


1 Files Affected:

- (modified) libc/include/llvm-libc-types/__barrier_type.h (+6-3) 


``````````diff
diff --git a/libc/include/llvm-libc-types/__barrier_type.h b/libc/include/llvm-libc-types/__barrier_type.h
index 59712619e917d..23593372af56e 100644
--- a/libc/include/llvm-libc-types/__barrier_type.h
+++ b/libc/include/llvm-libc-types/__barrier_type.h
@@ -9,13 +9,16 @@
 #ifndef LLVM_LIBC_TYPES__BARRIER_TYPE_H
 #define LLVM_LIBC_TYPES__BARRIER_TYPE_H
 
+#include "src/__support/threads/CndVar.h"
+#include "src/__support/threads/mutex.h"
+
 typedef struct __attribute__((aligned(8 /* alignof (Barrier) */))) {
   unsigned expected;
   unsigned waiting;
   bool blocking;
-  char entering[24 /* sizeof (CndVar) */];
-  char exiting[24 /* sizeof (CndVar) */];
-  char mutex[24 /* sizeof (Mutex) */];
+  char entering[sizeof(LIBC_NAMESPACE::CndVar)];
+  char exiting[sizeof(LIBC_NAMESPACE::CndVar)];
+  char mutex[sizeof(LIBC_NAMESPACE::Mutex)];
 } __barrier_type;
 
 #endif // LLVM_LIBC_TYPES__BARRIER_TYPE_H

``````````

</details>


https://github.com/llvm/llvm-project/pull/153718


More information about the libc-commits mailing list