-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from byeongkeunahn/run-macos
Support macOS (AArch64)
- Loading branch information
Showing
27 changed files
with
382 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,8 @@ basm.bin | |
Cargo.lock | ||
/[Tt]mp | ||
*.obj | ||
*.pyc | ||
*.pyc | ||
.DS_Store | ||
._.DS_Store | ||
**/.DS_Store | ||
**/._.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#![allow(clippy::not_unsafe_ptr_arg_deref)] | ||
|
||
use super::dlmalloc_interface::DlmallocAllocator; | ||
use super::super::os::macos::syscall; | ||
|
||
|
||
pub struct System { | ||
_priv: (), | ||
} | ||
|
||
impl System { | ||
pub const fn new() -> System { | ||
System { _priv: () } | ||
} | ||
} | ||
|
||
unsafe impl DlmallocAllocator for System { | ||
fn alloc(&self, size: usize) -> (*mut u8, usize, u32) { | ||
let addr = unsafe { | ||
syscall::mmap( | ||
core::ptr::null_mut(), | ||
size, | ||
syscall::PROT_WRITE | syscall::PROT_READ, | ||
syscall::MAP_ANON | syscall::MAP_PRIVATE, | ||
-1, | ||
0, | ||
) | ||
}; | ||
if core::ptr::eq(addr, syscall::MAP_FAILED) { | ||
(core::ptr::null_mut(), 0, 0) | ||
} else { | ||
(addr, size, 0) | ||
} | ||
} | ||
|
||
#[allow(unused)] | ||
fn remap(&self, ptr: *mut u8, oldsize: usize, newsize: usize, can_move: bool) -> *mut u8 { | ||
core::ptr::null_mut() | ||
} | ||
|
||
#[allow(unused)] | ||
fn free_part(&self, ptr: *mut u8, oldsize: usize, newsize: usize) -> bool { | ||
false | ||
} | ||
|
||
fn free(&self, ptr: *mut u8, size: usize) -> bool { | ||
unsafe { syscall::munmap(ptr as *mut _, size).is_null() } | ||
} | ||
|
||
fn can_release_part(&self, _flags: u32) -> bool { | ||
false | ||
} | ||
|
||
fn allocates_zeros(&self) -> bool { | ||
true | ||
} | ||
|
||
fn page_size(&self) -> usize { | ||
4096 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
pub mod dlmalloc_interface; | ||
pub mod dlmalloc; | ||
#[cfg(not(target_arch = "wasm32"))] | ||
#[cfg(not(any(target_arch = "wasm32", target_arch = "aarch64")))] | ||
pub mod dlmalloc_windows; | ||
#[cfg(not(target_arch = "wasm32"))] | ||
#[cfg(not(any(target_arch = "wasm32", target_arch = "aarch64")))] | ||
pub mod dlmalloc_linux; | ||
#[cfg(target_arch = "aarch64")] | ||
pub mod dlmalloc_macos; | ||
#[cfg(target_arch = "wasm32")] | ||
pub mod dlmalloc_wasm32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.