Skip to content

Commit 1f69c1d

Browse files
Port sysinfo to x32
1 parent 2abfdb4 commit 1f69c1d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/sys/sysinfo.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ use crate::errno::Errno;
1010
#[repr(transparent)]
1111
pub struct SysInfo(libc::sysinfo);
1212

13+
// The fields are c_ulong on 32-bit linux, u64 on 64-bit linux; x32's ulong is u32
14+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
15+
type mem_blocks_t = u64;
16+
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
17+
type mem_blocks_t = libc::c_ulong;
18+
1319
impl SysInfo {
1420
/// Returns the load average tuple.
1521
///
@@ -58,7 +64,7 @@ impl SysInfo {
5864
self.scale_mem(self.0.freeram)
5965
}
6066

61-
fn scale_mem(&self, units: libc::c_ulong) -> u64 {
67+
fn scale_mem(&self, units: mem_blocks_t) -> u64 {
6268
units as u64 * self.0.mem_unit as u64
6369
}
6470
}

0 commit comments

Comments
 (0)