From 323183311f50cbe154da86699b5a5f8c5f2ce6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sun, 3 Sep 2023 12:52:45 -0300 Subject: [PATCH] src: {apple,freebsd,unknown,windows}: Add governor function for SystemExt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/apple/cpu.rs | 6 +++++- src/apple/system.rs | 7 ++++++- src/freebsd/cpu.rs | 6 +++++- src/freebsd/system.rs | 8 ++++++-- src/unknown/cpu.rs | 6 +++++- src/unknown/system.rs | 8 ++++++-- src/windows/cpu.rs | 6 +++++- src/windows/system.rs | 8 ++++++-- 8 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/apple/cpu.rs b/src/apple/cpu.rs index 1fe7bc287..638f4fd29 100644 --- a/src/apple/cpu.rs +++ b/src/apple/cpu.rs @@ -1,7 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::sys::utils::{get_sys_value, get_sys_value_by_name}; -use crate::{CpuExt, CpuRefreshKind}; +use crate::{CpuExt, CpuRefreshKind, GovernorKind}; use libc::{c_char, c_void, host_processor_info, mach_port_t, mach_task_self}; use std::mem; @@ -170,6 +170,10 @@ impl CpuExt for Cpu { fn brand(&self) -> &str { &self.brand } + + fn governor(&self) -> GovernorKind { + GovernorKind::default() + } } pub(crate) unsafe fn get_cpu_frequency() -> u64 { diff --git a/src/apple/system.rs b/src/apple/system.rs index b4eeeda44..6559a04b8 100644 --- a/src/apple/system.rs +++ b/src/apple/system.rs @@ -6,7 +6,8 @@ use crate::sys::process::*; use crate::sys::utils::{get_sys_value, get_sys_value_by_name}; use crate::{ - CpuRefreshKind, Disks, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, SystemExt, User, + CpuRefreshKind, Disks, GovernorKind, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, + SystemExt, User, }; #[cfg(all(target_os = "macos", not(feature = "apple-sandbox")))] @@ -346,6 +347,10 @@ impl SystemExt for System { &self.cpus.global_cpu } + fn governor(&self) -> GovernorKind { + GovernorKind::default() + } + fn cpus(&self) -> &[Cpu] { &self.cpus.cpus } diff --git a/src/freebsd/cpu.rs b/src/freebsd/cpu.rs index 6946b6a7e..d6774d1df 100644 --- a/src/freebsd/cpu.rs +++ b/src/freebsd/cpu.rs @@ -3,7 +3,7 @@ use crate::sys::utils::{ get_sys_value_array, get_sys_value_by_name, get_sys_value_str_by_name, init_mib, VecSwitcher, }; -use crate::{CpuExt, CpuRefreshKind}; +use crate::{CpuExt, CpuRefreshKind, GovernorKind}; use libc::{c_int, c_ulong}; @@ -171,6 +171,10 @@ impl CpuExt for Cpu { fn brand(&self) -> &str { "" } + + fn governor(&self) -> GovernorKind { + GovernorKind::default() + } } pub(crate) fn physical_core_count() -> Option { diff --git a/src/freebsd/system.rs b/src/freebsd/system.rs index bccb6ad1b..af6c8677f 100644 --- a/src/freebsd/system.rs +++ b/src/freebsd/system.rs @@ -2,8 +2,8 @@ use crate::{ sys::{component::Component, Cpu, Process}, - CpuRefreshKind, Disks, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, SystemExt, - User, + CpuRefreshKind, Disks, GovernorKind, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, + SystemExt, User, }; use std::cell::UnsafeCell; @@ -210,6 +210,10 @@ impl SystemExt for System { &self.cpus.global_cpu } + fn governor(&self) -> GovernorKind { + GovernorKind::default() + } + fn cpus(&self) -> &[Cpu] { &self.cpus.cpus } diff --git a/src/unknown/cpu.rs b/src/unknown/cpu.rs index 72b9be447..caa59a6d7 100644 --- a/src/unknown/cpu.rs +++ b/src/unknown/cpu.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::CpuExt; +use crate::{CpuExt, GovernorKind}; #[doc = include_str!("../../md_doc/cpu.md")] pub struct Cpu {} @@ -31,4 +31,8 @@ impl CpuExt for Cpu { fn brand(&self) -> &str { "" } + + fn governor(&self) -> GovernorKind { + GovernorKind::default() + } } diff --git a/src/unknown/system.rs b/src/unknown/system.rs index a8da84e5a..85d56436f 100644 --- a/src/unknown/system.rs +++ b/src/unknown/system.rs @@ -2,8 +2,8 @@ use crate::{ sys::{component::Component, Cpu, Process}, - CpuRefreshKind, Disks, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, SystemExt, - User, + CpuRefreshKind, Disks, GovernorKind, LoadAvg, Networks, Pid, ProcessRefreshKind, RefreshKind, + SystemExt, User, }; use std::collections::HashMap; @@ -74,6 +74,10 @@ impl SystemExt for System { &self.global_cpu } + fn governor(&self) -> GovernorKind { + GovernorKind::default() + } + fn cpus(&self) -> &[Cpu] { &[] } diff --git a/src/windows/cpu.rs b/src/windows/cpu.rs index 3a998868e..8b1c1d746 100644 --- a/src/windows/cpu.rs +++ b/src/windows/cpu.rs @@ -1,7 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::sys::tools::KeyHandler; -use crate::{CpuExt, CpuRefreshKind, LoadAvg}; +use crate::{CpuExt, CpuRefreshKind, GovernorKind, LoadAvg}; use std::collections::HashMap; use std::io::Error; @@ -332,6 +332,10 @@ impl CpuExt for Cpu { fn brand(&self) -> &str { &self.brand } + + fn governor(&self) -> GovernorKind { + GovernorKind::default() + } } impl Cpu { diff --git a/src/windows/system.rs b/src/windows/system.rs index 17466e9d0..29b1240fa 100644 --- a/src/windows/system.rs +++ b/src/windows/system.rs @@ -1,8 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::{ - CpuRefreshKind, Disks, LoadAvg, Networks, Pid, ProcessExt, ProcessRefreshKind, RefreshKind, - SystemExt, User, + CpuRefreshKind, Disks, GovernorKind, LoadAvg, Networks, Pid, ProcessExt, ProcessRefreshKind, + RefreshKind, SystemExt, User, }; use winapi::um::winreg::HKEY_LOCAL_MACHINE; @@ -369,6 +369,10 @@ impl SystemExt for System { self.cpus.global_cpu() } + fn governor(&self) -> GovernorKind { + GovernorKind::default() + } + fn cpus(&self) -> &[Cpu] { self.cpus.cpus() }