Fixed ucontext & libc

This commit is contained in:
François Autin 2023-03-08 14:09:07 +01:00
parent dc49951bab
commit 69e1a3e444
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)]
pub struct UContextT {
#[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>
}
@ -19,8 +19,8 @@ pub struct UContextT {
impl UContextT {
pub fn new() -> Self {
let mut context = MaybeUninit::<ucontext_t>::uninit();
unsafe { lib::getcontext(context.as_mut_ptr()) };
let mut context = MaybeUninit::<libc::ucontext_t>::uninit();
unsafe { libc::getcontext(context.as_mut_ptr()) };
Self {
buf: unsafe { context.assume_init() },
stackBottom: Vec::default(),
@ -32,7 +32,7 @@ impl UContextT {
/// Use `man getcontext` for more informations
pub fn get_context(&mut self) -> i32 {
unsafe {
lib::getcontext(&mut self.buf)
libc::getcontext(&mut self.buf)
}
}
@ -41,13 +41,13 @@ impl UContextT {
/// Use `man setcontext` for more informations
pub fn set_context(&mut self) -> i32 {
unsafe {
lib::setcontext(&self.buf)
libc::setcontext(&self.buf)
}
}
pub fn make_context(&mut self, func: extern "C" fn(), args: i32) {
unsafe {
lib::makecontext(&mut self.buf, func, args)
libc::makecontext(&mut self.buf, func, args)
}
}