Add thread save and restore processor context

This commit is contained in:
Quentin Legot
2023-03-09 12:08:33 +01:00
committed by François Autin
parent 0c3af96b78
commit 26b75ffe8d
5 changed files with 87 additions and 55 deletions

View File

@ -1,5 +1,5 @@
// use std::mem::MaybeUninit;
use std::mem::MaybeUninit;
/// Safe wrapper for ucontext_t struct of linux-gnu libc
///
@ -12,10 +12,11 @@
pub struct UContextT {
#[cfg(not(target_os = "windows"))] // struct non disponible sur la libc sur windows
pub buf: libc::ucontext_t,
pub stackBottom: Vec<i8>
pub stack_bottom: Vec<i8>
}
#[cfg(not(target_os = "windows"))]
#[allow(unused)] // Temporary as we currently doesn't use this structure (this structure may disapear in a near future)
impl UContextT {
pub fn new() -> Self {
@ -23,7 +24,7 @@ impl UContextT {
unsafe { libc::getcontext(context.as_mut_ptr()) };
Self {
buf: unsafe { context.assume_init() },
stackBottom: Vec::default(),
stack_bottom: Vec::default(),
}
}