Skip to content

Commit

Permalink
Call exit syscall properly in linux aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
byeongkeunahn committed Sep 4, 2024
1 parent 359843e commit a0334cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 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 @@ -52,16 +52,21 @@ 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
if (pd.env_flags & services::ENV_FLAGS_NO_EXIT) != 0 {
return;
}
#[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);
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

0 comments on commit a0334cd

Please sign in to comment.