diff --git a/fuzzers/frida_libpng/Cargo.toml b/fuzzers/frida_libpng/Cargo.toml index 6e07c286b0..a8c97f87ea 100644 --- a/fuzzers/frida_libpng/Cargo.toml +++ b/fuzzers/frida_libpng/Cargo.toml @@ -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" diff --git a/fuzzers/fuzzbench/Cargo.toml b/fuzzers/fuzzbench/Cargo.toml index f9c4786331..2f04bcecbc 100644 --- a/fuzzers/fuzzbench/Cargo.toml +++ b/fuzzers/fuzzbench/Cargo.toml @@ -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/" } diff --git a/fuzzers/fuzzbench_text/Cargo.toml b/fuzzers/fuzzbench_text/Cargo.toml index 34016661a3..be001046be 100644 --- a/fuzzers/fuzzbench_text/Cargo.toml +++ b/fuzzers/fuzzbench_text/Cargo.toml @@ -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/" } diff --git a/fuzzers/fuzzbench_weighted/Cargo.toml b/fuzzers/fuzzbench_weighted/Cargo.toml index 8032eb4cd8..369aefd31e 100644 --- a/fuzzers/fuzzbench_weighted/Cargo.toml +++ b/fuzzers/fuzzbench_weighted/Cargo.toml @@ -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/" } diff --git a/fuzzers/libafl_atheris/Cargo.toml b/fuzzers/libafl_atheris/Cargo.toml index 305da0712a..1d6aad2e4c 100644 --- a/fuzzers/libafl_atheris/Cargo.toml +++ b/fuzzers/libafl_atheris/Cargo.toml @@ -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/" } diff --git a/fuzzers/libfuzzer_libmozjpeg/Cargo.toml b/fuzzers/libfuzzer_libmozjpeg/Cargo.toml index 5f88f746e7..5f33d3cd12 100644 --- a/fuzzers/libfuzzer_libmozjpeg/Cargo.toml +++ b/fuzzers/libfuzzer_libmozjpeg/Cargo.toml @@ -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" diff --git a/fuzzers/libfuzzer_libpng/Cargo.toml b/fuzzers/libfuzzer_libpng/Cargo.toml index b83d307119..f1c8108f55 100644 --- a/fuzzers/libfuzzer_libpng/Cargo.toml +++ b/fuzzers/libfuzzer_libpng/Cargo.toml @@ -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"] } diff --git a/fuzzers/libfuzzer_libpng_accounting/Cargo.toml b/fuzzers/libfuzzer_libpng_accounting/Cargo.toml index 0b9f519794..618510eee1 100644 --- a/fuzzers/libfuzzer_libpng_accounting/Cargo.toml +++ b/fuzzers/libfuzzer_libpng_accounting/Cargo.toml @@ -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"] } diff --git a/fuzzers/libfuzzer_libpng_ctx/Cargo.toml b/fuzzers/libfuzzer_libpng_ctx/Cargo.toml index 834fd1835d..99aa4df38c 100644 --- a/fuzzers/libfuzzer_libpng_ctx/Cargo.toml +++ b/fuzzers/libfuzzer_libpng_ctx/Cargo.toml @@ -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"] } diff --git a/fuzzers/libfuzzer_libpng_launcher/Cargo.toml b/fuzzers/libfuzzer_libpng_launcher/Cargo.toml index 6194388bbd..7ddfe5599c 100644 --- a/fuzzers/libfuzzer_libpng_launcher/Cargo.toml +++ b/fuzzers/libfuzzer_libpng_launcher/Cargo.toml @@ -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"] } diff --git a/fuzzers/libfuzzer_reachability/Cargo.toml b/fuzzers/libfuzzer_reachability/Cargo.toml index ace305d460..e42a09953f 100644 --- a/fuzzers/libfuzzer_reachability/Cargo.toml +++ b/fuzzers/libfuzzer_reachability/Cargo.toml @@ -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/" } diff --git a/fuzzers/libfuzzer_stb_image/Cargo.toml b/fuzzers/libfuzzer_stb_image/Cargo.toml index ed9abf9ac2..517f27255b 100644 --- a/fuzzers/libfuzzer_stb_image/Cargo.toml +++ b/fuzzers/libfuzzer_stb_image/Cargo.toml @@ -21,5 +21,4 @@ libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_e mimalloc = { version = "*", default-features = false } [build-dependencies] -cc = { version = "1.0", features = ["parallel"] } -num_cpus = "1.0" +cc = { version = "1.0", features = ["parallel"] } \ No newline at end of file diff --git a/fuzzers/libfuzzer_stb_image_concolic/fuzzer/Cargo.toml b/fuzzers/libfuzzer_stb_image_concolic/fuzzer/Cargo.toml index 9d4e50f64e..69af8736cd 100644 --- a/fuzzers/libfuzzer_stb_image_concolic/fuzzer/Cargo.toml +++ b/fuzzers/libfuzzer_stb_image_concolic/fuzzer/Cargo.toml @@ -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"} diff --git a/fuzzers/libfuzzer_stb_image_sugar/Cargo.toml b/fuzzers/libfuzzer_stb_image_sugar/Cargo.toml index d22130ee61..c35a92d101 100644 --- a/fuzzers/libfuzzer_stb_image_sugar/Cargo.toml +++ b/fuzzers/libfuzzer_stb_image_sugar/Cargo.toml @@ -24,4 +24,3 @@ mimalloc = { version = "*", default-features = false } [build-dependencies] cc = { version = "1.0", features = ["parallel"] } -num_cpus = "1.0" diff --git a/fuzzers/tutorial/Cargo.toml b/fuzzers/tutorial/Cargo.toml index bfa70641f2..6a696d46e1 100644 --- a/fuzzers/tutorial/Cargo.toml +++ b/fuzzers/tutorial/Cargo.toml @@ -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"] } diff --git a/libafl/Cargo.toml b/libafl/Cargo.toml index ac61f5e702..888ed8a4f0 100644 --- a/libafl/Cargo.toml +++ b/libafl/Cargo.toml @@ -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"] } diff --git a/libafl/src/bolts/core_affinity.rs b/libafl/src/bolts/core_affinity.rs index b158fb0085..2dcbc98bf7 100644 --- a/libafl/src/bolts/core_affinity.rs +++ b/libafl/src/bolts/core_affinity.rs @@ -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, Error> { - Ok((0..(num_cpus::get())) + Ok((0..(usize::from(available_parallelism()?))) .into_iter() .map(|n| CoreId { id: n }) .collect::>()) @@ -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]