Skip to content

apple add malloc_zone_t definition for x86_64 only. #2425

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

Merged
merged 1 commit into from
Sep 28, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/semver/macos-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ __darwin_x86_exception_state64
__darwin_x86_float_state64
__darwin_x86_thread_state64
__darwin_xmm_reg
malloc_introspection_t
4 changes: 4 additions & 0 deletions src/unix/bsd/apple/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ s! {
pub bh_datalen: u32,
pub bh_hdrlen: ::c_ushort,
}

pub struct malloc_zone_t {
__private: [::uintptr_t; 18], // FIXME: keeping private for now
}
}

s_no_extra_traits! {
Expand Down
6 changes: 6 additions & 0 deletions src/unix/bsd/apple/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
pub type boolean_t = ::c_int;

s! {
pub struct malloc_zone_t {
__private: [::uintptr_t; 18], // FIXME: needs arm64 auth pointers support
}
}

cfg_if! {
if #[cfg(libc_align)] {
mod align;
Expand Down
68 changes: 68 additions & 0 deletions src/unix/bsd/apple/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,74 @@ s! {
pub struct __darwin_xmm_reg {
pub __xmm_reg: [::c_char; 16],
}

pub struct malloc_introspection_t {
_private: [::uintptr_t; 16], // FIXME: keeping private for now
}

pub struct malloc_zone_t {
_reserved1: *mut ::c_void,
_reserved2: *mut ::c_void,
pub size: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
ptr: *const ::c_void,
) -> ::size_t>,
pub malloc: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
size: ::size_t,
) -> *mut ::c_void>,
pub calloc: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
num_items: ::size_t,
size: ::size_t,
) -> *mut ::c_void>,
pub valloc: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
size: ::size_t
) -> *mut ::c_void>,
pub free: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
ptr: *mut ::c_void
)>,
pub realloc: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
ptr: *mut ::c_void,
size: ::size_t,
) -> *mut ::c_void>,
pub destroy: Option<unsafe extern "C" fn(zone: *mut malloc_zone_t)>,
pub zone_name: *const ::c_char,
pub batch_malloc: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
size: ::size_t,
results: *mut *mut ::c_void,
num_requested: ::c_uint,
) -> ::c_uint>,
pub batch_free: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
to_be_freed: *mut *mut ::c_void,
num_to_be_freed: ::c_uint,
)>,
pub introspect: *mut malloc_introspection_t,
pub version: ::c_uint,
pub memalign: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
alignment: ::size_t,
size: ::size_t,
) -> *mut ::c_void>,
pub free_definite_size: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
ptr: *mut ::c_void,
size: ::size_t
)>,
pub pressure_relief: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
goal: ::size_t,
) -> ::size_t>,
pub claimed_address: Option<unsafe extern "C" fn(
zone: *mut malloc_zone_t,
ptr: *mut ::c_void,
) -> ::boolean_t>,
}
}

cfg_if! {
Expand Down
7 changes: 5 additions & 2 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ pub type vm_statistics_data_t = vm_statistics;
pub type vm_statistics64_t = *mut vm_statistics64;
pub type vm_statistics64_data_t = vm_statistics64;

pub type task_t = mach_port_t;

pub type sysdir_search_path_enumeration_state = ::c_uint;

pub type CCStatus = i32;
Expand Down Expand Up @@ -741,8 +743,9 @@ s! {
pub bytes_free: ::size_t,
}

pub struct malloc_zone_t {
__private: [::uintptr_t; 18], // FIXME: keeping private for now
pub struct vm_range_t {
pub address: ::vm_address_t,
pub size: ::vm_size_t,
}

// sched.h
Expand Down