Skip to content

Commit

Permalink
Add doc aliases for all wasm intrinsics
Browse files Browse the repository at this point in the history
Recommended in rust-lang#74372
  • Loading branch information
alexcrichton authored and Amanieu committed May 11, 2021
1 parent c2f21d2 commit e091c22
Show file tree
Hide file tree
Showing 3 changed files with 263 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/core_arch/src/wasm32/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern "C" {
#[inline]
#[cfg_attr(test, assert_instr(memory.atomic.wait32))]
#[target_feature(enable = "atomics")]
#[doc(alias("memory.atomic.wait32"))]
pub unsafe fn memory_atomic_wait32(ptr: *mut i32, expression: i32, timeout_ns: i64) -> i32 {
llvm_atomic_wait_i32(ptr, expression, timeout_ns)
}
Expand Down Expand Up @@ -64,6 +65,7 @@ pub unsafe fn memory_atomic_wait32(ptr: *mut i32, expression: i32, timeout_ns: i
#[inline]
#[cfg_attr(test, assert_instr(memory.atomic.wait64))]
#[target_feature(enable = "atomics")]
#[doc(alias("memory.atomic.wait64"))]
pub unsafe fn memory_atomic_wait64(ptr: *mut i64, expression: i64, timeout_ns: i64) -> i32 {
llvm_atomic_wait_i64(ptr, expression, timeout_ns)
}
Expand All @@ -85,6 +87,7 @@ pub unsafe fn memory_atomic_wait64(ptr: *mut i64, expression: i64, timeout_ns: i
#[inline]
#[cfg_attr(test, assert_instr(memory.atomic.notify))]
#[target_feature(enable = "atomics")]
#[doc(alias("memory.atomic.notify"))]
pub unsafe fn memory_atomic_notify(ptr: *mut i32, waiters: u32) -> u32 {
llvm_atomic_notify(ptr, waiters as i32) as u32
}
2 changes: 2 additions & 0 deletions crates/core_arch/src/wasm32/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern "C" {
#[cfg_attr(test, assert_instr("memory.size", MEM = 0))]
#[rustc_legacy_const_generics(0)]
#[stable(feature = "simd_wasm32", since = "1.33.0")]
#[doc(alias("memory.size"))]
pub fn memory_size<const MEM: u32>() -> usize {
static_assert!(MEM: u32 where MEM == 0);
unsafe { llvm_memory_size(MEM) as usize }
Expand All @@ -48,6 +49,7 @@ pub fn memory_size<const MEM: u32>() -> usize {
#[cfg_attr(test, assert_instr("memory.grow", MEM = 0))]
#[rustc_legacy_const_generics(0)]
#[stable(feature = "simd_wasm32", since = "1.33.0")]
#[doc(alias("memory.grow"))]
pub fn memory_grow<const MEM: u32>(delta: usize) -> usize {
unsafe {
static_assert!(MEM: u32 where MEM == 0);
Expand Down
Loading

0 comments on commit e091c22

Please sign in to comment.