-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[libc] Remove hardcoded sizeof in __barrier_type.h #153718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc] Remove hardcoded sizeof in __barrier_type.h #153718
Conversation
Signed-off-by: Mikhail R. Gadelha <[email protected]>
@llvm/pr-subscribers-libc Author: Mikhail R. Gadelha (mikhailramalho) ChangesThis 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:
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
|
Sorry, this is a non-starter. The public header files in |
Signed-off-by: Mikhail R. Gadelha <[email protected]>
Yeah, more importantly, the headers are intended for C language. C++ namespace cannot work here. |
I am leaning to use __mutex_type |
Got it, I'll try to find another solution. |
Signed-off-by: Mikhail R. Gadelha <[email protected]>
Folks, I've changed the I'll update the PR title before we land it, if this is accepted. The PR summary was updated. |
ping |
Signed-off-by: Mikhail R. Gadelha <[email protected]>
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.