Skip to content

Commit 74384c2

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 1f2b2ba commit 74384c2

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
@@ -71,6 +71,25 @@ s! {
7171
__unused1: Padding<c_ulong>,
7272
__unused2: Padding<c_ulong>,
7373
}
74+
75+
// FIXME(f128): __reserved is meant to be an array of `long double`s. That
76+
// requires native support for `f128`. This is currently missing.
77+
pub struct mcontext_t {
78+
pub fault_address: c_ulong,
79+
pub regs: [c_ulong; 31],
80+
pub sp: c_ulong,
81+
pub pc: c_ulong,
82+
pub pstate: c_ulong,
83+
__reserved: Padding<[i128; 256]>,
84+
}
85+
86+
pub struct ucontext_t {
87+
pub uc_flags: c_ulong,
88+
pub uc_link: *mut crate::ucontext_t,
89+
pub uc_stack: crate::stack_t,
90+
pub uc_sigmask: crate::sigset_t,
91+
pub uc_mcontext: crate::mcontext_t,
92+
}
7493
}
7594

7695
// 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
@@ -51,4 +51,16 @@ s! {
5151
__unused1: Padding<c_ulong>,
5252
__unused2: Padding<c_ulong>,
5353
}
54+
55+
pub struct mcontext_t {
56+
pub regs: [c_ulong; 32],
57+
}
58+
59+
pub struct ucontext_t {
60+
pub uc_flags: c_ulong,
61+
pub uc_link: *mut crate::ucontext_t,
62+
pub uc_stack: crate::stack_t,
63+
pub uc_sigmask: crate::sigset_t,
64+
pub uc_mcontext: crate::mcontext_t,
65+
}
5466
}

src/fuchsia/x86_64.rs

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,34 @@ use crate::prelude::*;
77
)]
88
pub type __u64 = c_ulonglong;
99

10+
pub type gregset_t = [c_ulonglong; 23];
11+
pub type fpregset_t = *mut _fpstate;
12+
1013
s! {
14+
pub struct _fpstate {
15+
pub cwd: c_ushort,
16+
pub swd: c_ushort,
17+
pub ftw: c_ushort,
18+
pub fop: c_ushort,
19+
pub rip: c_ulonglong,
20+
pub rdp: c_ulonglong,
21+
pub mxcsr: c_uint,
22+
pub mxcr_mask: c_uint,
23+
pub _st: [__c_anonymous__fpstate__st; 8],
24+
pub _xmm: [__c_anonymous__fpstate__xmm; 16],
25+
padding: Padding<[c_uint; 24]>,
26+
}
27+
28+
pub struct __c_anonymous__fpstate__st {
29+
pub significand: [c_ushort; 4],
30+
pub exponent: c_ushort,
31+
padding: Padding<[c_ushort; 3]>,
32+
}
33+
34+
pub struct __c_anonymous__fpstate__xmm {
35+
pub element: [c_uint; 4],
36+
}
37+
1138
pub struct stat {
1239
pub st_dev: crate::dev_t,
1340
pub st_ino: crate::ino_t,
@@ -55,7 +82,18 @@ s! {
5582
}
5683

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

6199
#[deprecated(
@@ -73,15 +111,6 @@ s! {
73111
__unused1: Padding<c_long>,
74112
__unused2: Padding<c_long>,
75113
}
76-
77-
pub struct ucontext_t {
78-
pub uc_flags: c_ulong,
79-
pub uc_link: *mut ucontext_t,
80-
pub uc_stack: crate::stack_t,
81-
pub uc_mcontext: mcontext_t,
82-
pub uc_sigmask: crate::sigset_t,
83-
__private: [u8; 512],
84-
}
85114
}
86115

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

0 commit comments

Comments
 (0)