Skip to content

Commit 4fe0474

Browse files
committed
apple: Port mcontext and ucontext to the new layout
1 parent eab4196 commit 4fe0474

File tree

17 files changed

+166
-54
lines changed

17 files changed

+166
-54
lines changed

src/new/apple/alibc/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/new/apple/alibc/signal.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//! Header: `signal.h`
2+
//!
3+
//! https://github.com/apple-oss-distributions/Libc/blob/main/include/signal.h
4+
5+
pub use crate::sys::signal::*;

src/new/apple/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Entrypoint for Apple headers, usually found as part of the xcode SDK.
2+
3+
pub(crate) mod xnu;
4+
pub(crate) use xnu::*;
5+
6+
pub(crate) mod alibc {
7+
pub(crate) mod signal;
8+
}
9+
10+
pub(crate) use alibc::*;

src/new/apple/xnu/arm/_mcontext.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! Header: `arm/_mcontext.h`
2+
//!
3+
//! https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/arm/_mcontext.h
4+
5+
pub use crate::mach::machine::_structs::*;
6+
7+
s! {
8+
pub struct __darwin_mcontext64 {
9+
pub __es: __darwin_arm_exception_state64,
10+
pub __ss: __darwin_arm_thread_state64,
11+
pub __ns: __darwin_arm_neon_state64,
12+
}
13+
}
14+
15+
pub type mcontext_t = *mut __darwin_mcontext64;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pub use crate::mach::machine::_structs::*;
2+
3+
s! {
4+
pub struct __darwin_mcontext64 {
5+
pub __es: __darwin_x86_exception_state64,
6+
pub __ss: __darwin_x86_thread_state64,
7+
pub __fs: __darwin_x86_float_state64,
8+
}
9+
}
10+
11+
pub type mcontext_t = *mut __darwin_mcontext64;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//! Header: `arm/_structs.h`
2+
//!
3+
//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/arm/_structs.h
4+
5+
#[cfg(target_arch = "arm")]
6+
use crate::prelude::*;
7+
8+
s! {
9+
pub struct __darwin_arm_exception_state64 {
10+
pub __far: u64,
11+
pub __esr: u32,
12+
pub __exception: u32,
13+
}
14+
15+
pub struct __darwin_arm_thread_state64 {
16+
pub __x: [u64; 29],
17+
pub __fp: u64,
18+
pub __lr: u64,
19+
pub __sp: u64,
20+
pub __pc: u64,
21+
pub __cpsr: u32,
22+
pub __pad: u32,
23+
}
24+
25+
#[cfg(target_arch = "aarch64")]
26+
pub struct __darwin_arm_neon_state64 {
27+
pub __v: [crate::__uint128_t; 32],
28+
pub __fpsr: u32,
29+
pub __fpcr: u32,
30+
}
31+
32+
#[cfg(target_arch = "arm")]
33+
#[repr(align(16))]
34+
pub struct __darwin_arm_neon_state64 {
35+
opaque: [c_char; (32 * 16) + (2 * size_of::<u32>())]
36+
}
37+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! Header: `mach/machine/_structs.h`
2+
3+
cfg_if! {
4+
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
5+
pub use crate::mach::i386::_structs::*;
6+
} else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] {
7+
pub use crate::mach::arm::_structs::*;
8+
} else {
9+
// Unsupported arch
10+
}
11+
}

src/new/apple/xnu/mach/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pub(crate) mod arm {
2+
pub(crate) mod _structs;
3+
}
4+
5+
pub(crate) mod i386 {
6+
pub(crate) mod _structs;
7+
}
8+
9+
pub(crate) mod machine {
10+
pub(crate) mod _structs;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! Header: `machine/_mcontext.h`
2+
3+
cfg_if! {
4+
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
5+
pub use crate::i386::_mcontext::*;
6+
} else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] {
7+
pub use crate::arm::_mcontext::*;
8+
} else {
9+
// Unsupported arch
10+
}
11+
}

0 commit comments

Comments
 (0)