-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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] fix build errors #95600
Merged
Merged
[libc] fix build errors #95600
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libc Author: Schrodinger ZHU Yifan (SchrodingerZhu) ChangesFull diff: https://github.com/llvm/llvm-project/pull/95600.diff 2 Files Affected:
diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index 7e8e2ddfac9b1..c6474673de85a 100644
--- a/libc/src/__support/macros/attributes.h
+++ b/libc/src/__support/macros/attributes.h
@@ -42,7 +42,7 @@
#define LIBC_CONSTINIT
#endif
-#ifdef __clang__
+#if defined(__clang__) && __has_attribute(preferred_type)
#define LIBC_PREFERED_TYPE(TYPE) [[clang::preferred_type(TYPE)]]
#else
#define LIBC_PREFERED_TYPE(TYPE)
diff --git a/libc/src/__support/threads/linux/rwlock.h b/libc/src/__support/threads/linux/rwlock.h
index 5db0590fd6aa0..1778995cf3766 100644
--- a/libc/src/__support/threads/linux/rwlock.h
+++ b/libc/src/__support/threads/linux/rwlock.h
@@ -370,8 +370,9 @@ class RwLock {
public:
LIBC_INLINE constexpr RwLock(Role preference = Role::Reader,
bool is_pshared = false)
- : is_pshared(is_pshared), preference(static_cast<unsigned>(preference)),
- state(0), writer_tid(0), queue() {}
+ : is_pshared(is_pshared),
+ preference(static_cast<unsigned>(preference) & 1u), state(0),
+ writer_tid(0), queue() {}
[[nodiscard]]
LIBC_INLINE LockResult try_read_lock() {
|
a6e874a
to
3d77326
Compare
Should be good now. Sorry for the noise. |
michaelrj-google
approved these changes
Jun 14, 2024
michaelrj-google
approved these changes
Jun 14, 2024
I am now merging this without waiting for ARM/RISCV build, since RwLock are not enabled on ARM(32) and RISC-V anyway. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bitfield conversion problem tested at: https://godbolt.org/z/dxjhs5Ghr