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

treat hermit like wasm32 #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ psm_stack_manipulation! {
}

impl StackRestoreGuard {
#[cfg(target_arch = "wasm32")]
#[cfg(any(target_arch = "wasm32",target_os = "hermit"))]
unsafe fn new(stack_bytes: usize, _page_size: usize) -> StackRestoreGuard {
let layout = std::alloc::Layout::from_size_align(stack_bytes, 16).unwrap();
let ptr = std::alloc::alloc(layout);
Expand All @@ -152,7 +152,7 @@ psm_stack_manipulation! {
}
}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32",target_os = "hermit")))]
unsafe fn new(stack_bytes: usize, page_size: usize) -> StackRestoreGuard {
let new_stack = libc::mmap(
std::ptr::null_mut(),
Expand Down Expand Up @@ -202,14 +202,14 @@ psm_stack_manipulation! {

impl Drop for StackRestoreGuard {
fn drop(&mut self) {
#[cfg(target_arch = "wasm32")]
#[cfg(any(target_arch = "wasm32",target_os = "hermit"))]
unsafe {
std::alloc::dealloc(
self.new_stack as *mut u8,
std::alloc::Layout::from_size_align_unchecked(self.stack_bytes, 16),
);
}
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32",target_os = "hermit")))]
unsafe {
// FIXME: check the error code and decide what to do with it.
// Perhaps a debug_assertion?
Expand Down Expand Up @@ -258,9 +258,9 @@ psm_stack_manipulation! {

fn page_size() -> usize {
// FIXME: consider caching the page size.
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(any(target_arch = "wasm32",target_os = "hermit")))]
unsafe { libc::sysconf(libc::_SC_PAGE_SIZE) as usize }
#[cfg(target_arch = "wasm32")]
#[cfg(any(target_arch = "wasm32",target_os = "hermit"))]
Copy link
Member

Choose a reason for hiding this comment

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

If there is absolutely no way to obtain the page size on hermit then lets hardcode it to something more appropriate for platforms hermit runs on (probably 4kB.)

{ 65536 }
}
}
Expand Down
Loading