From a4070deee13ff7b07c9b2f37c073265e1df2b53d Mon Sep 17 00:00:00 2001 From: "Dongjia \"toka\" Zhang" Date: Mon, 17 Jun 2024 18:19:44 +0200 Subject: [PATCH] fix win build (#2321) Co-authored-by: Your Name --- utils/desyscall/build.rs | 2 +- utils/desyscall/src/lib.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/utils/desyscall/build.rs b/utils/desyscall/build.rs index fa1e076458..26c2a18712 100644 --- a/utils/desyscall/build.rs +++ b/utils/desyscall/build.rs @@ -4,7 +4,7 @@ use std::env; fn main() { if cfg!(not(target_os = "linux")) { - println!("Not supported!"); + println!("cargo:warning=Not supported!"); return; } diff --git a/utils/desyscall/src/lib.rs b/utils/desyscall/src/lib.rs index 76320ee9c7..d8ba74e37a 100644 --- a/utils/desyscall/src/lib.rs +++ b/utils/desyscall/src/lib.rs @@ -1,13 +1,20 @@ +#[cfg(target_os = "linux")] use std::{mem::MaybeUninit, sync::Once}; +#[cfg(target_os = "linux")] use libc::{c_int, c_void}; +#[cfg(target_os = "linux")] use meminterval::IntervalTree; +#[cfg(target_os = "linux")] pub mod file; +#[cfg(target_os = "linux")] pub mod mmap; +#[cfg(target_os = "linux")] pub type Pointer = *mut c_void; +#[cfg(target_os = "linux")] #[derive(Debug, Clone)] pub struct Mapping { prot: c_int, @@ -15,18 +22,21 @@ pub struct Mapping { mapped: bool, } +#[cfg(target_os = "linux")] pub struct Context { enabled: bool, mappings: IntervalTree, exit_hook: Option>, } +#[cfg(target_os = "linux")] impl Default for Context { fn default() -> Self { Self::new() } } +#[cfg(target_os = "linux")] impl Context { #[must_use] pub fn new() -> Self { @@ -76,6 +86,7 @@ impl Context { } } +#[cfg(target_os = "linux")] extern "C" { fn __libafl_raw_exit_group(status: c_int); } @@ -84,6 +95,7 @@ extern "C" { /// # Safety /// Call to function using syscalls #[no_mangle] +#[cfg(target_os = "linux")] pub unsafe extern "C" fn _exit(status: c_int) { let ctx = Context::get();