diff --git a/src/core/utils/sys/usage.rs b/src/core/utils/sys/usage.rs index 423cc8fa..a84ffdc1 100644 --- a/src/core/utils/sys/usage.rs +++ b/src/core/utils/sys/usage.rs @@ -1,10 +1,8 @@ -use std::{fs::File, io::Read, str}; - use nix::sys::resource::Usage; #[cfg(unix)] use nix::sys::resource::{UsageWho, getrusage}; -use crate::{Error, Result, arrayvec::ArrayVec, expected}; +use crate::{Result, expected}; pub fn virt() -> Result { Ok(statm_bytes()? @@ -46,6 +44,10 @@ pub fn statm_bytes() -> Result> { #[cfg(target_os = "linux")] #[inline] pub fn statm() -> Result> { + use std::{fs::File, io::Read, str}; + + use crate::{Error, arrayvec::ArrayVec}; + File::open("/proc/self/statm") .map_err(Error::from) .and_then(|mut fp| { @@ -66,7 +68,7 @@ pub fn statm() -> Result> { #[cfg(not(target_os = "linux"))] #[inline] -pub fn statm() -> Result { Err!("proc_pid_statm(5) only available on linux systems") } +pub fn statm() -> Result> { Ok([0, 0, 0, 0, 0, 0].into_iter()) } #[cfg(unix)] pub fn usage() -> Result { getrusage(UsageWho::RUSAGE_SELF).map_err(Into::into) } @@ -86,4 +88,6 @@ pub fn thread_usage() -> Result { getrusage(UsageWho::RUSAGE_THREAD).map_ target_os = "freebsd", target_os = "openbsd" )))] -pub fn thread_usage() -> Result { Ok(Usage::default()) } +pub fn thread_usage() -> Result { + unimplemented!("RUSAGE_THREAD available on this platform") +}