Skip to content

Commit

Permalink
Auto merge of #2529 - devnexen:fbsd_vmtotal, r=JohnTitor
Browse files Browse the repository at this point in the history
freebsd add vmtotal sysctl query
  • Loading branch information
bors committed Nov 16, 2021
2 parents 3e36a07 + 8bcbec2 commit 69b86ab
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libc-test/build.rs
Expand Up @@ -1865,6 +1865,7 @@ fn test_freebsd(target: &str) {
"sys/user.h",
"sys/utsname.h",
"sys/uuid.h",
"sys/vmmeter.h",
"sys/wait.h",
"libprocstat.h",
"syslog.h",
Expand Down Expand Up @@ -2053,6 +2054,8 @@ fn test_freebsd(target: &str) {
// Added in in FreeBSD 13.0 (r367776 and r367287)
"SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,

"VM_TOTAL" if Some(11) == freebsd_ver => true,

_ => false,
}
});
Expand Down Expand Up @@ -2084,6 +2087,9 @@ fn test_freebsd(target: &str) {
// `ptrace_sc_ret` is not available in FreeBSD 11
"ptrace_sc_ret" if Some(11) == freebsd_ver => true,

// obsolete version
"vmtotal" if Some(11) == freebsd_ver => true,

_ => false,
}
});
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/freebsd.txt
Expand Up @@ -1249,6 +1249,7 @@ VDISCARD
VDSUSP
VERASE2
VLNEXT
VM_TOTAL
VSTATUS
VREPRINT
VWERASE
Expand Down Expand Up @@ -1808,6 +1809,7 @@ utimensat
utmpx
utrace
vm_size_t
vmtotal
wait4
waitid
xallocx
Expand Down
20 changes: 20 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -462,6 +462,24 @@ s! {
pub sem_otime: ::time_t,
pub sem_ctime: ::time_t,
}

pub struct vmtotal {
pub t_vm: u64,
pub t_avm: u64,
pub t_rm: u64,
pub t_arm: u64,
pub t_vmshr: u64,
pub t_avmshr: u64,
pub t_rmshr: u64,
pub t_armshr: u64,
pub t_free: u64,
pub t_rq: i16,
pub t_dw: i16,
pub t_pw: i16,
pub t_sl: i16,
pub t_sw: i16,
pub t_pad: [u16; 3],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1089,6 +1107,8 @@ pub const TIOCSIG: ::c_uint = 0x2004745f;
pub const TIOCM_DCD: ::c_int = 0x40;
pub const H4DISC: ::c_int = 0x7;

pub const VM_TOTAL: ::c_int = 1;

pub const BIOCSETFNR: ::c_ulong = 0x80104282;

pub const FIODGNAME: ::c_ulong = 0x80106678;
Expand Down

0 comments on commit 69b86ab

Please sign in to comment.