Skip to content

Commit 8bcbec2

Browse files
committed
freebsd add vmtotal sysctl query
1 parent 4f74e6e commit 8bcbec2

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

libc-test/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,7 @@ fn test_freebsd(target: &str) {
18651865
"sys/user.h",
18661866
"sys/utsname.h",
18671867
"sys/uuid.h",
1868+
"sys/vmmeter.h",
18681869
"sys/wait.h",
18691870
"libprocstat.h",
18701871
"syslog.h",
@@ -2053,6 +2054,8 @@ fn test_freebsd(target: &str) {
20532054
// Added in in FreeBSD 13.0 (r367776 and r367287)
20542055
"SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,
20552056

2057+
"VM_TOTAL" if Some(11) == freebsd_ver => true,
2058+
20562059
_ => false,
20572060
}
20582061
});
@@ -2084,6 +2087,9 @@ fn test_freebsd(target: &str) {
20842087
// `ptrace_sc_ret` is not available in FreeBSD 11
20852088
"ptrace_sc_ret" if Some(11) == freebsd_ver => true,
20862089

2090+
// obsolete version
2091+
"vmtotal" if Some(11) == freebsd_ver => true,
2092+
20872093
_ => false,
20882094
}
20892095
});

libc-test/semver/freebsd.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ VDISCARD
12491249
VDSUSP
12501250
VERASE2
12511251
VLNEXT
1252+
VM_TOTAL
12521253
VSTATUS
12531254
VREPRINT
12541255
VWERASE
@@ -1808,6 +1809,7 @@ utimensat
18081809
utmpx
18091810
utrace
18101811
vm_size_t
1812+
vmtotal
18111813
wait4
18121814
waitid
18131815
xallocx

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,24 @@ s! {
462462
pub sem_otime: ::time_t,
463463
pub sem_ctime: ::time_t,
464464
}
465+
466+
pub struct vmtotal {
467+
pub t_vm: u64,
468+
pub t_avm: u64,
469+
pub t_rm: u64,
470+
pub t_arm: u64,
471+
pub t_vmshr: u64,
472+
pub t_avmshr: u64,
473+
pub t_rmshr: u64,
474+
pub t_armshr: u64,
475+
pub t_free: u64,
476+
pub t_rq: i16,
477+
pub t_dw: i16,
478+
pub t_pw: i16,
479+
pub t_sl: i16,
480+
pub t_sw: i16,
481+
pub t_pad: [u16; 3],
482+
}
465483
}
466484

467485
s_no_extra_traits! {
@@ -1080,6 +1098,8 @@ pub const TIOCSIG: ::c_uint = 0x2004745f;
10801098
pub const TIOCM_DCD: ::c_int = 0x40;
10811099
pub const H4DISC: ::c_int = 0x7;
10821100

1101+
pub const VM_TOTAL: ::c_int = 1;
1102+
10831103
pub const BIOCSETFNR: ::c_ulong = 0x80104282;
10841104

10851105
pub const FIODGNAME: ::c_ulong = 0x80106678;

0 commit comments

Comments
 (0)