Skip to content

Commit 04dee1e

Browse files
committed
Build with stable intrinsics on wasm
1 parent de99f4b commit 04dee1e

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//! testing this crate.
1313
1414
#![cfg_attr(feature = "allocator-api", feature(allocator_api))]
15-
#![cfg_attr(target_arch = "wasm32", feature(link_llvm_intrinsics))]
1615
#![cfg_attr(target_env = "sgx", feature(asm))]
1716
#![cfg_attr(not(feature = "allocator-api"), allow(dead_code))]
1817
#![no_std]

src/wasm.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
use core::ptr;
2-
3-
extern {
4-
#[link_name = "llvm.wasm.grow.memory.i32"]
5-
fn grow_memory(pages: u32) -> i32;
6-
}
2+
use core::arch::wasm32;
73

84
pub unsafe fn alloc(size: usize) -> (*mut u8, usize, u32) {
95
let pages = size / page_size();
10-
let prev = grow_memory(pages as u32);
11-
if prev == -1 {
6+
let prev = wasm32::memory_grow(0, pages);
7+
if prev == usize::max_value() {
128
return (ptr::null_mut(), 0, 0);
139
}
14-
let prev = prev as usize;
1510
((prev * page_size()) as *mut u8, pages * page_size(), 0)
1611
}
1712

0 commit comments

Comments
 (0)