use crate::sys::cpu::{CpusWrapper, get_physical_core_count};
use crate::sys::ffi;
use crate::sys::process::{compute_cpu_usage, refresh_procs};
use crate::sys::utils::get_all_utf8_data;
use crate::{
Cpu, CpuRefreshKind, Error, LoadAvg, MemoryRefreshKind, Pid, Process, ProcessRefreshKind,
ProcessesToUpdate,
};
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::time::Duration;
mod cpu;
mod info;
mod info_methods;
mod inner;
mod memory;
mod process;
mod state;
use self::info::InfoType;
#[cfg(target_os = "android")]
use self::info::get_system_info_android;
#[cfg(not(target_os = "android"))]
use self::info::get_system_info_linux;
use self::info::read_table;
use self::info::system_info_as_list;
pub(crate) use self::state::SystemInfo;
#[cfg(test)]
mod tests;
declare_signals! {
libc::c_int,
Signal::Hangup => libc::SIGHUP,
Signal::Interrupt => libc::SIGINT,
Signal::Quit => libc::SIGQUIT,
Signal::Illegal => libc::SIGILL,
Signal::Trap => libc::SIGTRAP,
Signal::Abort => libc::SIGABRT,
Signal::IOT => libc::SIGIOT,
Signal::Bus => libc::SIGBUS,
Signal::FloatingPointException => libc::SIGFPE,
Signal::Kill => libc::SIGKILL,
Signal::User1 => libc::SIGUSR1,
Signal::Segv => libc::SIGSEGV,
Signal::User2 => libc::SIGUSR2,
Signal::Pipe => libc::SIGPIPE,
Signal::Alarm => libc::SIGALRM,
Signal::Term => libc::SIGTERM,
Signal::Child => libc::SIGCHLD,
Signal::Continue => libc::SIGCONT,
Signal::Stop => libc::SIGSTOP,
Signal::TSTP => libc::SIGTSTP,
Signal::TTIN => libc::SIGTTIN,
Signal::TTOU => libc::SIGTTOU,
Signal::Urgent => libc::SIGURG,
Signal::XCPU => libc::SIGXCPU,
Signal::XFSZ => libc::SIGXFSZ,
Signal::VirtualAlarm => libc::SIGVTALRM,
Signal::Profiling => libc::SIGPROF,
Signal::Winch => libc::SIGWINCH,
Signal::IO => libc::SIGIO,
Signal::Poll => libc::SIGPOLL,
Signal::Power => libc::SIGPWR,
Signal::Sys => libc::SIGSYS,
}
#[doc = "Returns the signals supported on this system. Used by [`Process::kill_with`][crate::Process::kill_with]."]
pub const SUPPORTED_SIGNALS: &[crate::Signal] = supported_signals();
#[doc = "Minimum interval used internally by `sinf` when refreshing CPU time. The value differs between operating systems."]
pub const MINIMUM_CPU_UPDATE_INTERVAL: Duration = Duration::from_millis(200);
pub(crate) struct SystemInner {
process_list: HashMap<Pid, Process>,
mem_total: u64,
mem_free: u64,
mem_available: u64,
mem_buffers: u64,
mem_page_cache: u64,
mem_shmem: u64,
mem_slab_reclaimable: u64,
swap_total: u64,
swap_free: u64,
info: SystemInfo,
cpus: CpusWrapper,
}