Remove num_cpus dependency (#717)

* Remove num_cpus dependency

* Fix build, remove more num_cpus
This commit is contained in:
Dominik Maier 2022-08-03 07:49:32 +02:00 committed by GitHub
parent b2a1e03703
commit 12052b5f1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 7 additions and 28 deletions

View File

@ -16,7 +16,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
num_cpus = "1.0"
which = "4.1"
xz = "0.1.0"
flate2 = "1.0.22"

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/" }

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/" }

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/" }

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/" }

View File

@ -23,7 +23,6 @@ mimalloc = { version = "*", default-features = false }
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
num_cpus = "1.0"
[lib]
name = "libfuzzer_libmozjpeg"

View File

@ -19,7 +19,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/", features = ["default"] }

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/", features = ["std", "derive", "llmp_compression", "introspection"] }

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/", features = ["std", "derive", "llmp_compression", "introspection"] }

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/", features = ["std", "derive", "llmp_compression", "introspection"] }

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/" }

View File

@ -22,4 +22,3 @@ mimalloc = { version = "*", default-features = false }
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
num_cpus = "1.0"

View File

@ -23,7 +23,6 @@ mimalloc = { version = "*", default-features = false }
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
num_cpus = "1.0"
cmake = "0.1"
which = "4.1"
symcc_libafl = {path = "../../../libafl_concolic/symcc_libafl"}

View File

@ -24,4 +24,3 @@ mimalloc = { version = "*", default-features = false }
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
num_cpus = "1.0"

View File

@ -17,7 +17,6 @@ debug = true
[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
which = { version = "4.0.2" }
num_cpus = "1.0"
[dependencies]
libafl = { path = "../../libafl/", features = ["default", "rand_trait"] }

View File

@ -13,7 +13,7 @@ categories = ["development-tools::testing", "emulators", "embedded", "os", "no-s
[features]
default = ["std", "derive", "llmp_compression", "rand_trait", "fork"]
std = ["serde_json", "serde_json/std", "hostname", "nix", "serde/std", "bincode", "wait-timeout", "regex", "byteorder", "once_cell", "uuid", "tui_monitor", "ctor", "backtrace", "num_cpus"] # print, env, launcher ... support
std = ["serde_json", "serde_json/std", "hostname", "nix", "serde/std", "bincode", "wait-timeout", "regex", "byteorder", "once_cell", "uuid", "tui_monitor", "ctor", "backtrace"] # print, env, launcher ... support
derive = ["libafl_derive"] # provide derive(SerdeAny) macro.
fork = [] # uses the fork() syscall to spawn children, instead of launching a new command, if supported by the OS (has no effect on Windows, no_std).
rand_trait = ["rand_core"] # If set, libafl's rand implementations will implement `rand::Rng`
@ -43,7 +43,6 @@ rustversion = "1.0"
[dev-dependencies]
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
num_cpus = "^1.13.1" # cpu count, for llmp example
serial_test = "0.8"
[dependencies]
@ -60,7 +59,6 @@ postcard = { version = "1.0", features = ["alloc"] } # no_std compatible serde s
bincode = {version = "1.3", optional = true }
static_assertions = "1.1.0"
num_enum = { version = "0.5.7", default-features = false }
num_cpus = { version = "^1.13.1", optional = true }
typed-builder = "0.10.0" # Implement the builder pattern at compiletime
ahash = { version = "0.7", default-features=false, features=["compile-time-rng"] } # The hash function already used in hashbrown
intervaltree = { version = "0.2.7", default-features = false, features = ["serde"] }

View File

@ -518,6 +518,7 @@ fn set_for_current_helper(core_id: CoreId) -> Result<(), Error> {
#[cfg(target_vendor = "apple")]
mod apple {
use core::ptr::addr_of_mut;
use std::thread::available_parallelism;
use crate::Error;
@ -528,7 +529,6 @@ mod apple {
thread_policy_flavor_t, thread_policy_t, thread_t, KERN_NOT_SUPPORTED, KERN_SUCCESS,
THREAD_AFFINITY_POLICY, THREAD_AFFINITY_POLICY_COUNT,
};
use num_cpus;
#[repr(C)]
struct thread_affinity_policy_data_t {
@ -547,7 +547,7 @@ mod apple {
#[allow(clippy::unnecessary_wraps)]
pub fn get_core_ids() -> Result<Vec<CoreId>, Error> {
Ok((0..(num_cpus::get()))
Ok((0..(usize::from(available_parallelism()?)))
.into_iter()
.map(|n| CoreId { id: n })
.collect::<Vec<_>>())
@ -591,18 +591,14 @@ mod apple {
#[cfg(test)]
mod tests {
use super::*;
use std::thread::available_parallelism;
// #[test]
// fn test_num_cpus() {
// println!("Num CPUs: {}", num_cpus::get());
// println!("Num Physical CPUs: {}", num_cpus::get_physical());
// }
use super::*;
#[test]
fn test_get_core_ids() {
let set = get_core_ids().unwrap();
assert_eq!(set.len(), num_cpus::get());
assert_eq!(set.len(), usize::from(available_parallelism().unwrap()));
}
#[test]