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

Call exit syscall properly in linux aarch64 #108

Merged
merged 1 commit into from
Sep 4, 2024
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
2 changes: 1 addition & 1 deletion basm-std/src/platform/malloc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod dlmalloc;
pub mod dlmalloc_interface;
#[cfg(not(any(target_arch = "wasm32", target_arch = "aarch64")))]
#[cfg(not(target_arch = "wasm32"))]
pub mod dlmalloc_linux;
#[cfg(target_arch = "aarch64")]
pub mod dlmalloc_macos;
Expand Down
25 changes: 15 additions & 10 deletions basm-std/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ pub fn init(platform_data_by_loader: usize) {
/* use OS APIs directly */
os::windows::init();
}
#[cfg(not(any(target_arch = "wasm32", target_arch = "aarch64")))]
#[cfg(not(any(target_arch = "wasm32")))]
services::ENV_ID_LINUX => {
/* use syscalls directly */
os::linux::init();
}
#[cfg(target_arch = "aarch64")]
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
services::ENV_ID_MACOS => {
os::macos::init();
}
Expand All @@ -51,17 +51,22 @@ pub fn init(platform_data_by_loader: usize) {
}
#[cfg(not(test))]
pub fn try_exit() {
let pd = services::platform_data();
if (pd.env_id == services::ENV_ID_LINUX || pd.env_id == services::ENV_ID_MACOS)
&& (pd.env_flags & services::ENV_FLAGS_NO_EXIT) == 0
#[cfg(not(target_arch = "wasm32"))]
{
#[cfg(not(any(target_arch = "wasm32", target_arch = "aarch64")))]
unsafe {
os::linux::syscall::exit_group(services::get_exit_status() as usize);
let pd = services::platform_data();
if (pd.env_flags & services::ENV_FLAGS_NO_EXIT) != 0 {
return;
}
if pd.env_id == services::ENV_ID_LINUX {
unsafe {
os::linux::syscall::exit_group(services::get_exit_status() as usize);
}
}
#[cfg(target_arch = "aarch64")]
unsafe {
os::macos::syscall::exit_group(services::get_exit_status() as usize);
if pd.env_id == services::ENV_ID_MACOS {
unsafe {
os::macos::syscall::exit_group(services::get_exit_status() as usize);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion basm-std/src/platform/os/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(not(any(target_arch = "wasm32", target_arch = "aarch64")))]
#[cfg(not(any(target_arch = "wasm32")))]
pub mod linux;
#[cfg(target_arch = "aarch64")]
pub mod macos;
Expand Down
Loading