Implemente finish (not finished yet), fix ucontext for windows
This commit is contained in:
committed by
François Autin
parent
3457f67a7c
commit
dc49951bab
@ -1,8 +1,6 @@
|
||||
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
use libc::{ucontext_t, getcontext, setcontext, makecontext};
|
||||
|
||||
/// Safe wrapper for ucontext_t struct of linux-gnu libc
|
||||
///
|
||||
/// setcontext and getcontext are unsafe function, this wrap unsafe libc functions
|
||||
@ -13,7 +11,7 @@ use libc::{ucontext_t, getcontext, setcontext, makecontext};
|
||||
#[derive(PartialEq)]
|
||||
pub struct UContextT {
|
||||
#[cfg(not(target_os = "windows"))] // struct non disponible sur la libc sur windows
|
||||
pub buf: ucontext_t,
|
||||
pub buf: lib::ucontext_t,
|
||||
pub stackBottom: Vec<i8>
|
||||
}
|
||||
|
||||
@ -22,7 +20,7 @@ impl UContextT {
|
||||
|
||||
pub fn new() -> Self {
|
||||
let mut context = MaybeUninit::<ucontext_t>::uninit();
|
||||
unsafe { getcontext(context.as_mut_ptr()) };
|
||||
unsafe { lib::getcontext(context.as_mut_ptr()) };
|
||||
Self {
|
||||
buf: unsafe { context.assume_init() },
|
||||
stackBottom: Vec::default(),
|
||||
@ -34,7 +32,7 @@ impl UContextT {
|
||||
/// Use `man getcontext` for more informations
|
||||
pub fn get_context(&mut self) -> i32 {
|
||||
unsafe {
|
||||
getcontext(&mut self.buf)
|
||||
lib::getcontext(&mut self.buf)
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,13 +41,13 @@ impl UContextT {
|
||||
/// Use `man setcontext` for more informations
|
||||
pub fn set_context(&mut self) -> i32 {
|
||||
unsafe {
|
||||
setcontext(&self.buf)
|
||||
lib::setcontext(&self.buf)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_context(&mut self, func: extern "C" fn(), args: i32) {
|
||||
unsafe {
|
||||
makecontext(&mut self.buf, func, args)
|
||||
lib::makecontext(&mut self.buf, func, args)
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +57,9 @@ impl UContextT {
|
||||
impl UContextT {
|
||||
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
Self {
|
||||
stackBottom: Vec::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_context(&mut self) {
|
||||
|
Reference in New Issue
Block a user