diff --git a/libc-test/build.rs b/libc-test/build.rs index dab69ecf..c0fda5aa 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -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"); diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 45fa03f9..89c2433b 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -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; +} diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index fc82c71e..aea629a2 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -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; }