Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GuillaumeGomez/sysinfo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: bytebeamio/sysinfo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.26.9-bugfixes
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 4 commits
  • 4 files changed
  • 3 contributors

Commits on Jan 10, 2023

  1. Update use of libc::timespec to prepare for future libc version

    In a future release of the `libc` crate, `libc::timespec` will contain
    private padding fields on `*-linux-musl` targets and so the struct will
    no longer be able to be created using the literal initialization syntax.
    
    Update the use of `libc::timespec` to create a value by calling
    `std::mem::zeroed()` which works with both current versions of `libc`
    as well as the future version which contains that change.
    wesleywiser authored and GuillaumeGomez committed Jan 10, 2023

    Unverified

    No user is associated with the committer email.
    Copy the full SHA
    07bdd62 View commit details
  2. Copy the full SHA
    b75356b View commit details
  3. Copy the full SHA
    9e6661d View commit details

Commits on Jan 18, 2025

  1. Copy the full SHA
    f2f31f1 View commit details
Showing with 13 additions and 8 deletions.
  1. +4 −0 CHANGELOG.md
  2. +1 −1 Cargo.toml
  3. +7 −3 src/linux/cpu.rs
  4. +1 −4 src/linux/system.rs
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.26.9

* Linux: Improve compatibility with upcoming `libc` changes for musl targets.

# 0.26.8

* Add `ProcessExt::session_id` method.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sysinfo"
version = "0.26.8"
version = "0.26.9"
authors = ["Guillaume Gomez <guillaume1.gomez@gmail.com>"]

description = "Library to get system information such as processes, CPUs, disks, components and networks"
10 changes: 7 additions & 3 deletions src/linux/cpu.rs
Original file line number Diff line number Diff line change
@@ -72,7 +72,6 @@ impl CpusWrapper {
let buf = BufReader::new(f);

self.need_cpus_update = false;
let mut i: usize = 0;
let first = self.cpus.is_empty();
let mut it = buf.split(b'\n');
let (vendor_id, brand) = if first {
@@ -106,6 +105,7 @@ impl CpusWrapper {
);
}
if first || !only_update_global_cpu {
let mut num_cpus: usize = 0;
while let Some(Ok(line)) = it.next() {
if &line[..3] != b"cpu" {
break;
@@ -131,7 +131,7 @@ impl CpusWrapper {
));
} else {
parts.next(); // we don't want the name again
self.cpus[i].set(
self.cpus[num_cpus].set(
parts.next().map(to_u64).unwrap_or(0),
parts.next().map(to_u64).unwrap_or(0),
parts.next().map(to_u64).unwrap_or(0),
@@ -145,7 +145,11 @@ impl CpusWrapper {
);
}

i += 1;
num_cpus += 1;
}
for cpu in &mut self.cpus[num_cpus..] {
cpu.cpu_usage = 0.0;
cpu.frequency = 0;
}
}
}
5 changes: 1 addition & 4 deletions src/linux/system.rs
Original file line number Diff line number Diff line change
@@ -81,11 +81,8 @@ fn boot_time() -> u64 {
}
}
// Either we didn't find "btime" or "/proc/stat" wasn't available for some reason...
let mut up = libc::timespec {
tv_sec: 0,
tv_nsec: 0,
};
unsafe {
let mut up: libc::timespec = std::mem::zeroed();
if libc::clock_gettime(libc::CLOCK_BOOTTIME, &mut up) == 0 {
up.tv_sec as u64
} else {