Skip to content

Commit 7e3a151

Browse files
committed
Add ucontext struct for Linux/x86
1 parent b57e312 commit 7e3a151

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ fn main() {
132132

133133
if linux {
134134
cfg.header("mqueue.h");
135+
cfg.header("ucontext.h");
135136
cfg.header("sys/signalfd.h");
136137
cfg.header("sys/xattr.h");
137138
cfg.header("sys/ipc.h");

src/unix/notbsd/linux/other/b32/x86.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,27 @@ pub const SO_SNDTIMEO: ::c_int = 21;
1818

1919
pub const FIOCLEX: ::c_ulong = 0x5451;
2020
pub const FIONBIO: ::c_ulong = 0x5421;
21+
22+
s! {
23+
24+
pub struct mcontext_t {
25+
__private: [u32; 22]
26+
}
27+
28+
pub struct ucontext_t {
29+
pub uc_flags: ::c_ulong,
30+
pub uc_link: *mut ucontext_t,
31+
pub uc_stack: ::stack_t,
32+
pub uc_mcontext: mcontext_t,
33+
pub uc_sigmask: ::sigset_t,
34+
__private: [u8; 112],
35+
}
36+
37+
}
38+
39+
extern {
40+
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
41+
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
42+
pub fn makecontext(ucp: *mut ucontext_t, func: extern fn (), argc: ::c_int, ...);
43+
pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int;
44+
}

src/unix/notbsd/linux/other/b64/x86_64.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,29 @@ s! {
7979
pub struct pthread_attr_t {
8080
__size: [u64; 7]
8181
}
82+
83+
}
84+
85+
s! {
86+
87+
pub struct mcontext_t {
88+
__private: [u64; 32],
89+
}
90+
91+
pub struct ucontext_t {
92+
pub uc_flags: ::c_ulong,
93+
pub uc_link: *mut ucontext_t,
94+
pub uc_stack: ::stack_t,
95+
pub uc_mcontext: mcontext_t,
96+
pub uc_sigmask: ::sigset_t,
97+
__private: [u8; 512],
98+
}
99+
100+
}
101+
102+
extern {
103+
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
104+
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
105+
pub fn makecontext(ucp: *mut ucontext_t, func: extern fn (), argc: ::c_int, ...);
106+
pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int;
82107
}

0 commit comments

Comments
 (0)