Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freebsd add vmtotal sysctl query #2529

Merged
merged 1 commit into from Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -1080,6 +1098,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