From 1f69c1da2facf7d5d14d290081d58813744c687e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 27 Dec 2020 18:00:29 +0100 Subject: Port sysinfo to x32 --- src/sys/sysinfo.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/sys') diff --git a/src/sys/sysinfo.rs b/src/sys/sysinfo.rs index f4b82798..222a2fc0 100644 --- a/src/sys/sysinfo.rs +++ b/src/sys/sysinfo.rs @@ -10,6 +10,12 @@ use crate::errno::Errno; #[repr(transparent)] pub struct SysInfo(libc::sysinfo); +// The fields are c_ulong on 32-bit linux, u64 on 64-bit linux; x32's ulong is u32 +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +type mem_blocks_t = u64; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +type mem_blocks_t = libc::c_ulong; + impl SysInfo { /// Returns the load average tuple. /// @@ -58,7 +64,7 @@ impl SysInfo { self.scale_mem(self.0.freeram) } - fn scale_mem(&self, units: libc::c_ulong) -> u64 { + fn scale_mem(&self, units: mem_blocks_t) -> u64 { units as u64 * self.0.mem_unit as u64 } } -- cgit v1.2.3