Skip to content

Commit

Permalink
Merge pull request #25 from alexcrichton/wasm64
Browse files Browse the repository at this point in the history
Add support for wasm64
  • Loading branch information
alexcrichton authored Nov 1, 2021
2 parents fb9bb77 + b510fa9 commit 91861fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ pub unsafe trait Allocator: Send {
/// lingering memory back to the OS. That may happen eventually though!
pub struct Dlmalloc<A = System>(dlmalloc::Dlmalloc<A>);

#[cfg(target_arch = "wasm32")]
#[cfg(target_family = "wasm")]
#[path = "wasm.rs"]
mod sys;

#[cfg(any(target_os = "linux", target_os = "macos"))]
#[path = "unix.rs"]
mod sys;

#[cfg(not(any(target_os = "linux", target_os = "macos", target_arch = "wasm32")))]
#[cfg(not(any(target_os = "linux", target_os = "macos", target_family = "wasm")))]
#[path = "dummy.rs"]
mod sys;

Expand Down
7 changes: 5 additions & 2 deletions src/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use core::arch::wasm32;
#[cfg(target_arch = "wasm32")]
use core::arch::wasm32 as wasm;
#[cfg(target_arch = "wasm64")]
use core::arch::wasm64 as wasm;
use core::ptr;
use Allocator;

Expand All @@ -16,7 +19,7 @@ impl System {
unsafe impl Allocator for System {
fn alloc(&self, size: usize) -> (*mut u8, usize, u32) {
let pages = size / self.page_size();
let prev = wasm32::memory_grow(0, pages);
let prev = wasm::memory_grow(0, pages);
if prev == usize::max_value() {
return (ptr::null_mut(), 0, 0);
}
Expand Down

0 comments on commit 91861fb

Please sign in to comment.