Skip to content

Commit

Permalink
dragonflybsd build fix for core affinity. (AFLplusplus#753)
Browse files Browse the repository at this point in the history
supporting most of linux sched api here.
  • Loading branch information
devnexen authored and addisoncrump committed Aug 30, 2022
1 parent 98cc70b commit c82070c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libafl/src/bolts/core_affinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,24 +193,29 @@ pub fn parse_core_bind_arg(args: &str) -> Result<Vec<usize>, 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<Vec<CoreId>, 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;
Expand Down

0 comments on commit c82070c

Please sign in to comment.