From ebfe414a27d280cbc51b2397c5ff0dd69806827d Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Tue, 30 Aug 2022 02:37:17 +0100 Subject: [PATCH] dragonflybsd build fix for core affinity. (#753) supporting most of linux sched api here. --- libafl/src/bolts/core_affinity.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libafl/src/bolts/core_affinity.rs b/libafl/src/bolts/core_affinity.rs index 38ce99efa2..deee4ed85d 100644 --- a/libafl/src/bolts/core_affinity.rs +++ b/libafl/src/bolts/core_affinity.rs @@ -193,24 +193,29 @@ pub fn parse_core_bind_arg(args: &str) -> Result, Error> { // Linux Section -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonfly"))] #[inline] fn get_core_ids_helper() -> Result, Error> { linux::get_core_ids() } -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonfly"))] #[inline] fn set_for_current_helper(core_id: CoreId) -> Result<(), Error> { linux::set_for_current(core_id) } -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(any(target_os = "android", target_os = "linux", target_os = "dragonfly"))] mod linux { use alloc::{string::ToString, vec::Vec}; use std::mem; + #[cfg(target_os = "dragonfly")] + use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity, CPU_ISSET, CPU_SET}; + #[cfg(not(target_os = "dragonfly"))] use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity, CPU_ISSET, CPU_SET, CPU_SETSIZE}; + #[cfg(target_os = "dragonfly")] + const CPU_SETSIZE: libc::c_int = 256; use super::CoreId; use crate::Error;