Skip to content

Commit b219b65

Browse files
committed
treat hermit like wasm32
1 parent 61411cf commit b219b65

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ psm_stack_manipulation! {
142142
}
143143

144144
impl StackRestoreGuard {
145-
#[cfg(target_arch = "wasm32")]
145+
#[cfg(any(target_arch = "wasm32",target_os = "hermit"))]
146146
unsafe fn new(stack_bytes: usize, _page_size: usize) -> StackRestoreGuard {
147147
let layout = std::alloc::Layout::from_size_align(stack_bytes, 16).unwrap();
148148
let ptr = std::alloc::alloc(layout);
@@ -154,7 +154,7 @@ psm_stack_manipulation! {
154154
}
155155
}
156156

157-
#[cfg(not(target_arch = "wasm32"))]
157+
#[cfg(not(any(target_arch = "wasm32",target_os = "hermit")))]
158158
unsafe fn new(stack_bytes: usize, page_size: usize) -> StackRestoreGuard {
159159
let new_stack = libc::mmap(
160160
std::ptr::null_mut(),
@@ -207,14 +207,14 @@ psm_stack_manipulation! {
207207

208208
impl Drop for StackRestoreGuard {
209209
fn drop(&mut self) {
210-
#[cfg(target_arch = "wasm32")]
210+
#[cfg(any(target_arch = "wasm32",target_os = "hermit"))]
211211
unsafe {
212212
std::alloc::dealloc(
213213
self.new_stack as *mut u8,
214214
std::alloc::Layout::from_size_align_unchecked(self.stack_bytes, 16),
215215
);
216216
}
217-
#[cfg(not(target_arch = "wasm32"))]
217+
#[cfg(not(any(target_arch = "wasm32",target_os = "hermit")))]
218218
unsafe {
219219
// FIXME: check the error code and decide what to do with it.
220220
// Perhaps a debug_assertion?
@@ -263,9 +263,9 @@ psm_stack_manipulation! {
263263

264264
fn page_size() -> usize {
265265
// FIXME: consider caching the page size.
266-
#[cfg(not(target_arch = "wasm32"))]
266+
#[cfg(not(any(target_arch = "wasm32",target_os = "hermit")))]
267267
unsafe { libc::sysconf(libc::_SC_PAGE_SIZE) as usize }
268-
#[cfg(target_arch = "wasm32")]
268+
#[cfg(any(target_arch = "wasm32",target_os = "hermit"))]
269269
{ 65536 }
270270
}
271271
}

0 commit comments

Comments
 (0)