Add ucontext struct for Linux/x86

This commit is contained in:
Philipp Matthias Schaefer 2016-02-22 20:11:01 +01:00
parent b57e3126c3
commit 7e3a151289
3 changed files with 50 additions and 0 deletions

View File

@ -132,6 +132,7 @@ fn main() {
if linux {
cfg.header("mqueue.h");
cfg.header("ucontext.h");
cfg.header("sys/signalfd.h");
cfg.header("sys/xattr.h");
cfg.header("sys/ipc.h");

View File

@ -18,3 +18,27 @@ pub const SO_SNDTIMEO: ::c_int = 21;
pub const FIOCLEX: ::c_ulong = 0x5451;
pub const FIONBIO: ::c_ulong = 0x5421;
s! {
pub struct mcontext_t {
__private: [u32; 22]
}
pub struct ucontext_t {
pub uc_flags: ::c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: ::stack_t,
pub uc_mcontext: mcontext_t,
pub uc_sigmask: ::sigset_t,
__private: [u8; 112],
}
}
extern {
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
pub fn makecontext(ucp: *mut ucontext_t, func: extern fn (), argc: ::c_int, ...);
pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int;
}

View File

@ -79,4 +79,29 @@ s! {
pub struct pthread_attr_t {
__size: [u64; 7]
}
}
s! {
pub struct mcontext_t {
__private: [u64; 32],
}
pub struct ucontext_t {
pub uc_flags: ::c_ulong,
pub uc_link: *mut ucontext_t,
pub uc_stack: ::stack_t,
pub uc_mcontext: mcontext_t,
pub uc_sigmask: ::sigset_t,
__private: [u8; 512],
}
}
extern {
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
pub fn makecontext(ucp: *mut ucontext_t, func: extern fn (), argc: ::c_int, ...);
pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int;
}