Fixed ucontext & libc

This commit is contained in:
François Autin 2023-03-08 14:09:07 +01:00
parent 8c6ef4e131
commit 8889d43f9d
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C

View File

@ -11,7 +11,7 @@ use std::mem::MaybeUninit;
#[derive(PartialEq)] #[derive(PartialEq)]
pub struct UContextT { pub struct UContextT {
#[cfg(not(target_os = "windows"))] // struct non disponible sur la libc sur windows #[cfg(not(target_os = "windows"))] // struct non disponible sur la libc sur windows
pub buf: lib::ucontext_t, pub buf: libc::ucontext_t,
pub stackBottom: Vec<i8> pub stackBottom: Vec<i8>
} }
@ -19,8 +19,8 @@ pub struct UContextT {
impl UContextT { impl UContextT {
pub fn new() -> Self { pub fn new() -> Self {
let mut context = MaybeUninit::<ucontext_t>::uninit(); let mut context = MaybeUninit::<libc::ucontext_t>::uninit();
unsafe { lib::getcontext(context.as_mut_ptr()) }; unsafe { libc::getcontext(context.as_mut_ptr()) };
Self { Self {
buf: unsafe { context.assume_init() }, buf: unsafe { context.assume_init() },
stackBottom: Vec::default(), stackBottom: Vec::default(),
@ -32,7 +32,7 @@ impl UContextT {
/// Use `man getcontext` for more informations /// Use `man getcontext` for more informations
pub fn get_context(&mut self) -> i32 { pub fn get_context(&mut self) -> i32 {
unsafe { unsafe {
lib::getcontext(&mut self.buf) libc::getcontext(&mut self.buf)
} }
} }
@ -41,13 +41,13 @@ impl UContextT {
/// Use `man setcontext` for more informations /// Use `man setcontext` for more informations
pub fn set_context(&mut self) -> i32 { pub fn set_context(&mut self) -> i32 {
unsafe { unsafe {
lib::setcontext(&self.buf) libc::setcontext(&self.buf)
} }
} }
pub fn make_context(&mut self, func: extern "C" fn(), args: i32) { pub fn make_context(&mut self, func: extern "C" fn(), args: i32) {
unsafe { unsafe {
lib::makecontext(&mut self.buf, func, args) libc::makecontext(&mut self.buf, func, args)
} }
} }