fix win build (#2321)

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
Dongjia "toka" Zhang 2024-06-17 18:19:44 +02:00 committed by GitHub
parent 7792d87e32
commit a4070deee1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -4,7 +4,7 @@ use std::env;
fn main() { fn main() {
if cfg!(not(target_os = "linux")) { if cfg!(not(target_os = "linux")) {
println!("Not supported!"); println!("cargo:warning=Not supported!");
return; return;
} }

View File

@ -1,13 +1,20 @@
#[cfg(target_os = "linux")]
use std::{mem::MaybeUninit, sync::Once}; use std::{mem::MaybeUninit, sync::Once};
#[cfg(target_os = "linux")]
use libc::{c_int, c_void}; use libc::{c_int, c_void};
#[cfg(target_os = "linux")]
use meminterval::IntervalTree; use meminterval::IntervalTree;
#[cfg(target_os = "linux")]
pub mod file; pub mod file;
#[cfg(target_os = "linux")]
pub mod mmap; pub mod mmap;
#[cfg(target_os = "linux")]
pub type Pointer = *mut c_void; pub type Pointer = *mut c_void;
#[cfg(target_os = "linux")]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Mapping { pub struct Mapping {
prot: c_int, prot: c_int,
@ -15,18 +22,21 @@ pub struct Mapping {
mapped: bool, mapped: bool,
} }
#[cfg(target_os = "linux")]
pub struct Context { pub struct Context {
enabled: bool, enabled: bool,
mappings: IntervalTree<Pointer, Mapping>, mappings: IntervalTree<Pointer, Mapping>,
exit_hook: Option<Box<dyn FnMut(i32)>>, exit_hook: Option<Box<dyn FnMut(i32)>>,
} }
#[cfg(target_os = "linux")]
impl Default for Context { impl Default for Context {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
} }
} }
#[cfg(target_os = "linux")]
impl Context { impl Context {
#[must_use] #[must_use]
pub fn new() -> Self { pub fn new() -> Self {
@ -76,6 +86,7 @@ impl Context {
} }
} }
#[cfg(target_os = "linux")]
extern "C" { extern "C" {
fn __libafl_raw_exit_group(status: c_int); fn __libafl_raw_exit_group(status: c_int);
} }
@ -84,6 +95,7 @@ extern "C" {
/// # Safety /// # Safety
/// Call to function using syscalls /// Call to function using syscalls
#[no_mangle] #[no_mangle]
#[cfg(target_os = "linux")]
pub unsafe extern "C" fn _exit(status: c_int) { pub unsafe extern "C" fn _exit(status: c_int) {
let ctx = Context::get(); let ctx = Context::get();