-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(android/aarch64): use libc::ucontext_t from Android NDK
#5189
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,7 +63,10 @@ s! { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub uc_flags: c_ulong, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub uc_link: *mut ucontext_t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub uc_stack: crate::stack_t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub uc_sigmask: crate::sigset_t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* The kernel adds extra padding after uc_sigmask to match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * glibc sigset_t on ARM64. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| __padding: Padding<[c_char; 128 - size_of::<crate::sigset_t>()]>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub uc_mcontext: mcontext_t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -85,12 +88,33 @@ s! { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s_no_extra_traits! { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub union __c_anonymous_uc_sigmask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uc_sigmask: crate::sigset_t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uc_sigmask64: crate::sigset64_t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[repr(align(16))] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub struct max_align_t { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| priv_: [f32; 8], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cfg_if! { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if #[cfg(feature = "extra_traits")] { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| impl PartialEq for __c_anonymous_uc_sigmask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unsafe { self.uc_sigmask == other.uc_sigmask } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this sound and correct if the 64-bit sigmask was initialised in the union?
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| impl Eq for __c_anonymous_uc_sigmask {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| impl hash::Hash for __c_anonymous_uc_sigmask { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn hash<H: hash::Hasher>(&self, state: &mut H) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unsafe { self.uc_sigmask.hash(state) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, not sure we can do this with unions, without some guarantee they are the same size.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code was simply borrowed from the ARM module: libc/src/unix/linux_like/android/b32/arm.rs Lines 59 to 73 in a8e2958
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. x86_64 has same layout: libc/src/unix/linux_like/android/b64/x86_64/mod.rs Lines 170 to 184 in a8e2958
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub const O_DIRECT: c_int = 0x10000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub const O_DIRECTORY: c_int = 0x4000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub const O_NOFOLLOW: c_int = 0x8000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this subtracting sigset_t (32 bit?), but the comment refers to ARM64?
This calculation seems weird for either 32-bit or 64-bit, and might need further comments:
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://android.googlesource.com/platform/bionic/+/refs/tags/ndk-r29/libc/include/sys/ucontext.h#102
