Skip to content

Commit 9f799ad

Browse files
committed
fuchsia: fix bits/signal.h types
Fix definition of types in x86_64. `mcontext_t` provided opaque field. `ucontext_t` had a slightly wrong definition. New records have been introduced. They are particular to `mcontext_t`. Add definitions in AArch64 and RISC-V64. They were missing. They are different for all three target architectures. These are declared in [1]. [1]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/bits/signal.h
1 parent 4bd6e8b commit 9f799ad

3 files changed

Lines changed: 70 additions & 10 deletions

File tree

src/fuchsia/aarch64.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ s! {
7272
__unused1: Padding<c_ulong>,
7373
__unused2: Padding<c_ulong>,
7474
}
75+
76+
// FIXME(f128): __reserved is meant to be an array of `long double`s. That
77+
// requires native support for `f128`. This is currently missing.
78+
pub struct mcontext_t {
79+
pub fault_address: c_ulong,
80+
pub regs: [c_ulong; 31],
81+
pub sp: c_ulong,
82+
pub pc: c_ulong,
83+
pub pstate: c_ulong,
84+
__reserved: Padding<[i128; 256]>,
85+
}
86+
87+
pub struct ucontext_t {
88+
pub uc_flags: c_ulong,
89+
pub uc_link: *mut crate::ucontext_t,
90+
pub uc_stack: crate::stack_t,
91+
pub uc_sigmask: crate::sigset_t,
92+
pub uc_mcontext: crate::mcontext_t,
93+
}
7594
}
7695

7796
// From https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/bits/signal.h;l=20-21;drc=0827b18ab9540c46f8037f407d17ea15a79e9ba7

src/fuchsia/riscv64.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,16 @@ s! {
5252
__unused1: Padding<c_ulong>,
5353
__unused2: Padding<c_ulong>,
5454
}
55+
56+
pub struct mcontext_t {
57+
pub regs: [c_ulong; 32],
58+
}
59+
60+
pub struct ucontext_t {
61+
pub uc_flags: c_ulong,
62+
pub uc_link: *mut crate::ucontext_t,
63+
pub uc_stack: crate::stack_t,
64+
pub uc_sigmask: crate::sigset_t,
65+
pub uc_mcontext: crate::mcontext_t,
66+
}
5567
}

src/fuchsia/x86_64.rs

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,34 @@ pub type wchar_t = i32;
99
)]
1010
pub type __u64 = c_ulonglong;
1111

12+
pub type gregset_t = [c_ulonglong; 23];
13+
pub type fpregset_t = *mut _fpstate;
14+
1215
s! {
16+
pub struct _fpstate {
17+
pub cwd: c_ushort,
18+
pub swd: c_ushort,
19+
pub ftw: c_ushort,
20+
pub fop: c_ushort,
21+
pub rip: c_ulonglong,
22+
pub rdp: c_ulonglong,
23+
pub mxcsr: c_uint,
24+
pub mxcr_mask: c_uint,
25+
pub _st: [__c_anonymous__fpstate__st; 8],
26+
pub _xmm: [__c_anonymous__fpstate__xmm; 16],
27+
padding: Padding<[c_uint; 24]>,
28+
}
29+
30+
pub struct __c_anonymous__fpstate__st {
31+
pub significand: [c_ushort; 4],
32+
pub exponent: c_ushort,
33+
padding: Padding<[c_ushort; 3]>,
34+
}
35+
36+
pub struct __c_anonymous__fpstate__xmm {
37+
pub element: [c_uint; 4],
38+
}
39+
1340
pub struct stat {
1441
pub st_dev: crate::dev_t,
1542
pub st_ino: crate::ino_t,
@@ -57,7 +84,18 @@ s! {
5784
}
5885

5986
pub struct mcontext_t {
60-
__private: [u64; 32],
87+
pub gregs: crate::gregset_t,
88+
pub fpregs: crate::fpregset_t,
89+
__reserved1: Padding<[c_ulonglong; 8]>,
90+
}
91+
92+
pub struct ucontext_t {
93+
pub uc_flags: c_ulong,
94+
pub uc_link: *mut ucontext_t,
95+
pub uc_stack: crate::stack_t,
96+
pub uc_mcontext: crate::mcontext_t,
97+
pub uc_sigmask: crate::sigset_t,
98+
__fpregs_mem: [c_ulong; 64],
6199
}
62100

63101
#[deprecated(
@@ -75,15 +113,6 @@ s! {
75113
__unused1: Padding<c_long>,
76114
__unused2: Padding<c_long>,
77115
}
78-
79-
pub struct ucontext_t {
80-
pub uc_flags: c_ulong,
81-
pub uc_link: *mut ucontext_t,
82-
pub uc_stack: crate::stack_t,
83-
pub uc_mcontext: mcontext_t,
84-
pub uc_sigmask: crate::sigset_t,
85-
__private: [u8; 512],
86-
}
87116
}
88117

89118
// offsets in user_regs_structs, from sys/reg.h

0 commit comments

Comments
 (0)