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 subset of memstat api addition #2998

Merged
merged 1 commit into from Nov 19, 2022
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
5 changes: 5 additions & 0 deletions libc-test/build.rs
Expand Up @@ -1897,6 +1897,7 @@ fn test_freebsd(target: &str) {
"machine/elf.h",
"machine/reg.h",
"malloc_np.h",
"memstat.h",
"mqueue.h",
"net/bpf.h",
"net/if.h",
Expand Down Expand Up @@ -2256,6 +2257,10 @@ fn test_freebsd(target: &str) {
// `shm_largepage_conf` was introduced in FreeBSD 13.
"shm_largepage_conf" if Some(13) > freebsd_ver => true,

// Those are private types
"memory_type" => true,
"memory_type_list" => true,

_ => false,
}
});
Expand Down
8 changes: 8 additions & 0 deletions libc-test/semver/freebsd.txt
Expand Up @@ -1670,6 +1670,14 @@ mallocx
memmem
memrchr
memset_s
memstat_get_name
memstat_mtl_alloc
memstat_mtl_find
memstat_mtl_first
memstat_mtl_free
memstat_mtl_geterror
memstat_mtl_next
memstat_strerror
mincore
mkdirat
mkfifoat
Expand Down
25 changes: 25 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -998,6 +998,15 @@ s! {
pub alloc_policy: ::c_int,
__pad: [::c_int; 10],
}

pub struct memory_type {
__priva: [::uintptr_t; 32],
__privb: [::uintptr_t; 26],
}

pub struct memory_type_list {
__priv: [::uintptr_t; 2],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -4369,6 +4378,22 @@ extern "C" {
) -> ::c_int;
}

#[link(name = "memstat")]
extern "C" {
pub fn memstat_strerror(error: ::c_int) -> *const ::c_char;
pub fn memstat_mtl_alloc() -> *mut memory_type_list;
pub fn memstat_mtl_first(list: *mut memory_type_list) -> *mut memory_type;
pub fn memstat_mtl_next(mtp: *mut memory_type) -> *mut memory_type;
pub fn memstat_mtl_find(
list: *mut memory_type_list,
allocator: ::c_int,
name: *const ::c_char,
) -> *mut memory_type;
pub fn memstat_mtl_free(list: *mut memory_type_list);
pub fn memstat_mtl_geterror(list: *mut memory_type_list) -> ::c_int;
pub fn memstat_get_name(mtp: *const memory_type) -> *const ::c_char;
}

#[link(name = "kvm")]
extern "C" {
pub fn kvm_dpcpu_setcpu(kd: *mut ::kvm_t, cpu: ::c_uint) -> ::c_int;
Expand Down