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

Add mallinfo2 support #2228

Merged
merged 2 commits into from Jun 10, 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 @@ -2650,6 +2650,9 @@ fn test_linux(target: &str) {
// FIXME: CI's kernel header version is old.
"sockaddr_can" => true,

// Requires glibc 2.33 or newer.
"mallinfo2" => true,

_ => false,
}
});
Expand Down Expand Up @@ -2853,6 +2856,9 @@ fn test_linux(target: &str) {
// FIXME: This needs musl 1.2.2 or later.
"gettid" if musl => true,

// Needs glibc 2.33 or later.
"mallinfo2" => true,

_ => false,
}
});
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux-gnu.txt
Expand Up @@ -546,6 +546,7 @@ glob_t
globfree
globfree64
mallinfo
mallinfo2
malloc_usable_size
mallopt
nl_mmap_hdr
Expand Down
14 changes: 14 additions & 0 deletions src/unix/linux_like/linux/gnu/mod.rs
Expand Up @@ -128,6 +128,19 @@ s! {
pub keepcost: ::c_int,
}

pub struct mallinfo2 {
pub arena: ::size_t,
pub ordblks: ::size_t,
pub smblks: ::size_t,
pub hblks: ::size_t,
pub hblkhd: ::size_t,
pub usmblks: ::size_t,
pub fsmblks: ::size_t,
pub uordblks: ::size_t,
pub fordblks: ::size_t,
pub keepcost: ::size_t,
}

pub struct nlmsghdr {
pub nlmsg_len: u32,
pub nlmsg_type: u16,
Expand Down Expand Up @@ -1281,6 +1294,7 @@ extern "C" {
) -> ::c_int;
pub fn sched_getcpu() -> ::c_int;
pub fn mallinfo() -> ::mallinfo;
pub fn mallinfo2() -> ::mallinfo2;
pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t;
pub fn getpwent_r(
pwd: *mut ::passwd,
Expand Down