diff --git a/libc-test/build.rs b/libc-test/build.rs index a3626937..cdfe3584 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -163,6 +163,7 @@ fn main() { cfg.header("sys/sendfile.h"); cfg.header("sys/vfs.h"); cfg.header("sys/syscall.h"); + cfg.header("sys/sysinfo.h"); if !musl { cfg.header("linux/netlink.h"); cfg.header("linux/magic.h"); diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32.rs index 3a295cc7..0b1f8d24 100644 --- a/src/unix/notbsd/android/b32.rs +++ b/src/unix/notbsd/android/b32.rs @@ -102,6 +102,23 @@ s! { pub f_flags: ::uint32_t, pub f_spare: [::uint32_t; 4], } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 8], + } } pub const SYS_gettid: ::c_long = 224; diff --git a/src/unix/notbsd/android/b64.rs b/src/unix/notbsd/android/b64.rs index 98b643f0..e9beff44 100644 --- a/src/unix/notbsd/android/b64.rs +++ b/src/unix/notbsd/android/b64.rs @@ -112,6 +112,23 @@ s! { pub f_flags: ::uint64_t, pub f_spare: [::uint64_t; 4], } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 0], + } } pub const SYS_gettid: ::c_long = 178; diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index a6611d17..b12fa51f 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -172,6 +172,23 @@ s! { pub l_pid: ::pid_t, pad: [::c_long; 4], } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 8], + } } pub const BUFSIZ: ::c_uint = 8192; diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 104feef3..0631495e 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -56,6 +56,23 @@ s! { pub l_len: ::off_t, pub l_pid: ::pid_t, } + + pub struct sysinfo { + pub uptime: ::c_ulong, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub __reserved: [::c_char; 256], + } } pub const BUFSIZ: ::c_uint = 1024; diff --git a/src/unix/notbsd/linux/other/b32/mod.rs b/src/unix/notbsd/linux/other/b32/mod.rs index b39ff683..afa8a845 100644 --- a/src/unix/notbsd/linux/other/b32/mod.rs +++ b/src/unix/notbsd/linux/other/b32/mod.rs @@ -66,6 +66,23 @@ s! { pub struct sigset_t { __val: [::c_ulong; 32], } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 8], + } } pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; diff --git a/src/unix/notbsd/linux/other/b64/mod.rs b/src/unix/notbsd/linux/other/b64/mod.rs index 663b0933..ccf99881 100644 --- a/src/unix/notbsd/linux/other/b64/mod.rs +++ b/src/unix/notbsd/linux/other/b64/mod.rs @@ -14,6 +14,23 @@ s! { pub struct sigset_t { __val: [::c_ulong; 16], } + + pub struct sysinfo { + pub uptime: ::c_long, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub _f: [::c_char; 0], + } } pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 86142cf4..42d68537 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -652,6 +652,8 @@ pub const LOG_PERROR: ::c_int = 0x20; pub const PIPE_BUF: usize = 4096; +pub const SI_LOAD_SHIFT: ::c_uint = 16; + f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; @@ -800,6 +802,7 @@ extern { pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn sysinfo (info: *mut ::sysinfo) -> ::c_int; pub fn sched_getcpu() -> ::c_int; }