Skip to content

apple add mach_vm_map, mmap does not provide custom alignment so #2283

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
Jul 14, 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/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ fn test_apple(target: &str) {
"mach/mach_init.h",
"mach/mach_time.h",
"mach/mach_types.h",
"mach/mach_vm.h",
"mach/thread_act.h",
"mach/thread_policy.h",
"malloc/malloc.h",
Expand Down
14 changes: 14 additions & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ MAXTHREADNAMESIZE
MCL_CURRENT
MCL_FUTURE
MDMBUF
MEMORY_OBJECT_NULL
MH_MAGIC
MH_MAGIC_64
MINCORE_INCORE
Expand Down Expand Up @@ -1414,6 +1415,10 @@ VM_MEMORY_TCMALLOC
VM_MEMORY_UNSHARED_PMAP
VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS
VM_METER
VM_PROT_EXECUTE
VM_PROT_NONE
VM_PROT_READ
VM_PROT_WRITE
VM_SWAPUSAGE
VSTATUS
VT0
Expand Down Expand Up @@ -1700,6 +1705,10 @@ mach_port_t
mach_thread_self
mach_timebase_info
mach_timebase_info_data_t
mach_vm_address_t
mach_vm_map
Copy link
Member

@JohnTitor JohnTitor Jul 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the list seems incomplete for the changes in this PR.

mach_vm_offset_t
mach_vm_size_t
madvise
malloc_default_zone
malloc_printf
Expand All @@ -1718,10 +1727,13 @@ malloc_zone_t
malloc_zone_valloc
max_align_t
mcontext_t
memory_object_t
memory_object_offset_t
memset_pattern4
memset_pattern8
memset_pattern16
memset_s
mem_entry_name_port_t
mincore
mkdirat
mkstemps
Expand Down Expand Up @@ -1902,6 +1914,8 @@ uselocale
utimensat
utmpx
utmpxname
vm_inherit_t
vm_map_t
vm_prot_t
vm_size_t
wait4
Expand Down
29 changes: 28 additions & 1 deletion src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ pub type processor_flavor_t = ::c_int;
pub type thread_flavor_t = natural_t;
pub type thread_inspect_t = mach_port_t;
pub type policy_t = ::c_int;
pub type mach_vm_address_t = u64;
pub type mach_vm_offset_t = u64;
pub type mach_vm_size_t = u64;
pub type vm_map_t = ::mach_port_t;
pub type mem_entry_name_port_t = ::mach_port_t;
pub type memory_object_t = ::mach_port_t;
pub type memory_object_offset_t = ::c_ulonglong;
pub type vm_inherit_t = ::c_uint;
pub type vm_prot_t = ::c_int;

pub type iconv_t = *mut ::c_void;

Expand Down Expand Up @@ -88,7 +97,6 @@ pub type CCCryptorStatus = i32;
pub type CCRNGStatus = ::CCCryptorStatus;

deprecated_mach! {
pub type vm_prot_t = ::c_int;
pub type vm_size_t = ::uintptr_t;
pub type mach_timebase_info_data_t = mach_timebase_info;
}
Expand Down Expand Up @@ -3218,6 +3226,11 @@ pub const VM_LOADAVG: ::c_int = 2;
pub const VM_MACHFACTOR: ::c_int = 4;
pub const VM_SWAPUSAGE: ::c_int = 5;
pub const VM_MAXID: ::c_int = 6;
pub const VM_PROT_NONE: ::vm_prot_t = 0x00;
pub const VM_PROT_READ: ::vm_prot_t = 0x01;
pub const VM_PROT_WRITE: ::vm_prot_t = 0x02;
pub const VM_PROT_EXECUTE: ::vm_prot_t = 0x04;
pub const MEMORY_OBJECT_NULL: ::memory_object_t = 0;
pub const HW_MACHINE: ::c_int = 1;
pub const HW_MODEL: ::c_int = 2;
pub const HW_NCPU: ::c_int = 3;
Expand Down Expand Up @@ -4289,6 +4302,20 @@ extern "C" {
pub fn CCRandomGenerateBytes(bytes: *mut ::c_void, size: ::size_t) -> ::CCRNGStatus;

pub fn _NSGetExecutablePath(buf: *mut ::c_char, bufsize: *mut u32) -> ::c_int;

pub fn mach_vm_map(
target_task: ::vm_map_t,
address: *mut ::mach_vm_address_t,
size: ::mach_vm_size_t,
mask: ::mach_vm_offset_t,
flags: ::c_int,
object: ::mem_entry_name_port_t,
offset: ::memory_object_offset_t,
copy: ::boolean_t,
cur_protection: ::vm_prot_t,
max_protection: ::vm_prot_t,
inheritance: ::vm_inherit_t,
) -> ::kern_return_t;
}

cfg_if! {
Expand Down