Skip to content

Commit 9cff7c6

Browse files
committed
treat hermit like wasm32
1 parent cf52a70 commit 9cff7c6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ psm_stack_manipulation! {
140140
}
141141

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

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

203203
impl Drop for StackRestoreGuard {
204204
fn drop(&mut self) {
205-
#[cfg(target_arch = "wasm32")]
205+
#[cfg(any(target_arch = "wasm32",target_os = "hermit"))]
206206
unsafe {
207207
std::alloc::dealloc(
208208
self.new_stack as *mut u8,
209209
std::alloc::Layout::from_size_align_unchecked(self.stack_bytes, 16),
210210
);
211211
}
212-
#[cfg(not(target_arch = "wasm32"))]
212+
#[cfg(not(any(target_arch = "wasm32",target_os = "hermit")))]
213213
unsafe {
214214
// FIXME: check the error code and decide what to do with it.
215215
// Perhaps a debug_assertion?
@@ -258,9 +258,9 @@ psm_stack_manipulation! {
258258

259259
fn page_size() -> usize {
260260
// FIXME: consider caching the page size.
261-
#[cfg(not(target_arch = "wasm32"))]
261+
#[cfg(not(any(target_arch = "wasm32",target_os = "hermit")))]
262262
unsafe { libc::sysconf(libc::_SC_PAGE_SIZE) as usize }
263-
#[cfg(target_arch = "wasm32")]
263+
#[cfg(any(target_arch = "wasm32",target_os = "hermit"))]
264264
{ 65536 }
265265
}
266266
}

0 commit comments

Comments
 (0)