Skip to content

Commit 4c8c9bf

Browse files
committed
freebsd subset of memstat api addition
1 parent 8b6bfd7 commit 4c8c9bf

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

libc-test/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,7 @@ fn test_freebsd(target: &str) {
18971897
"machine/elf.h",
18981898
"machine/reg.h",
18991899
"malloc_np.h",
1900+
"memstat.h",
19001901
"mqueue.h",
19011902
"net/bpf.h",
19021903
"net/if.h",
@@ -2256,6 +2257,10 @@ fn test_freebsd(target: &str) {
22562257
// `shm_largepage_conf` was introduced in FreeBSD 13.
22572258
"shm_largepage_conf" if Some(13) > freebsd_ver => true,
22582259

2260+
// Those are private types
2261+
"memory_type" => true,
2262+
"memory_type_list" => true,
2263+
22592264
_ => false,
22602265
}
22612266
});

libc-test/semver/freebsd.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,14 @@ mallocx
16701670
memmem
16711671
memrchr
16721672
memset_s
1673+
memstat_get_name
1674+
memstat_mtl_alloc
1675+
memstat_mtl_find
1676+
memstat_mtl_first
1677+
memstat_mtl_free
1678+
memstat_mtl_geterror
1679+
memstat_mtl_next
1680+
memstat_strerror
16731681
mincore
16741682
mkdirat
16751683
mkfifoat

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,15 @@ s! {
998998
pub alloc_policy: ::c_int,
999999
__pad: [::c_int; 10],
10001000
}
1001+
1002+
pub struct memory_type {
1003+
__priva: [::uintptr_t; 32],
1004+
__privb: [::uintptr_t; 26],
1005+
}
1006+
1007+
pub struct memory_type_list {
1008+
__priv: [::uintptr_t; 2],
1009+
}
10011010
}
10021011

10031012
s_no_extra_traits! {
@@ -4369,6 +4378,22 @@ extern "C" {
43694378
) -> ::c_int;
43704379
}
43714380

4381+
#[link(name = "memstat")]
4382+
extern "C" {
4383+
pub fn memstat_strerror(error: ::c_int) -> *const ::c_char;
4384+
pub fn memstat_mtl_alloc() -> *mut memory_type_list;
4385+
pub fn memstat_mtl_first(list: *mut memory_type_list) -> *mut memory_type;
4386+
pub fn memstat_mtl_next(mtp: *mut memory_type) -> *mut memory_type;
4387+
pub fn memstat_mtl_find(
4388+
list: *mut memory_type_list,
4389+
allocator: ::c_int,
4390+
name: *const ::c_char,
4391+
) -> *mut memory_type;
4392+
pub fn memstat_mtl_free(list: *mut memory_type_list);
4393+
pub fn memstat_mtl_geterror(list: *mut memory_type_list) -> ::c_int;
4394+
pub fn memstat_get_name(mtp: *const memory_type) -> *const ::c_char;
4395+
}
4396+
43724397
#[link(name = "kvm")]
43734398
extern "C" {
43744399
pub fn kvm_dpcpu_setcpu(kd: *mut ::kvm_t, cpu: ::c_uint) -> ::c_int;

0 commit comments

Comments
 (0)