Skip to content

Commit

Permalink
Auto merge of #2998 - devnexen:memstat_fbsd_api, r=JohnTitor
Browse files Browse the repository at this point in the history
freebsd subset of memstat api addition
  • Loading branch information
bors committed Nov 19, 2022
2 parents 0b2b101 + 4c8c9bf commit cea201b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
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

0 comments on commit cea201b

Please sign in to comment.