1- //! Intrinsics associated with WebAssembly's upcoming threads proposal.
2- //!
3- //! These intrinsics are all unstable because they're not actually stable in
4- //! WebAssembly itself yet. The signatures may change as [the
5- //! specification][spec] is updated.
6- //!
7- //! [spec]: https://github.com/WebAssembly/threads
8-
9- #![ cfg( any( target_feature = "atomics" , doc) ) ]
10-
111#[ cfg( test) ]
122use stdarch_test:: assert_instr;
133
144extern "C" {
15- #[ link_name = "llvm.wasm.memory.atomic.wait.i32 " ]
5+ #[ link_name = "llvm.wasm.memory.atomic.wait32 " ]
166 fn llvm_atomic_wait_i32 ( ptr : * mut i32 , exp : i32 , timeout : i64 ) -> i32 ;
17- #[ link_name = "llvm.wasm.memory.atomic.wait.i64 " ]
7+ #[ link_name = "llvm.wasm.memory.atomic.wait64 " ]
188 fn llvm_atomic_wait_i64 ( ptr : * mut i64 , exp : i64 , timeout : i64 ) -> i32 ;
199 #[ link_name = "llvm.wasm.memory.atomic.notify" ]
2010 fn llvm_atomic_notify ( ptr : * mut i32 , cnt : i32 ) -> i32 ;
@@ -41,16 +31,10 @@ extern "C" {
4131/// didn't block
4232/// * 2 - the thread blocked, but the timeout expired.
4333///
44- /// # Availability
45- ///
46- /// This intrinsic is only available **when the standard library itself is
47- /// compiled with the `atomics` target feature**. This version of the standard
48- /// library is not obtainable via `rustup`, but rather will require the
49- /// standard library to be compiled from source.
50- ///
5134/// [instr]: https://webassembly.github.io/threads/syntax/instructions.html#syntax-instr-atomic-memory
5235#[ inline]
53- #[ cfg_attr( test, assert_instr( "i32.atomic.wait" ) ) ]
36+ #[ cfg_attr( test, assert_instr( memory. atomic. wait32) ) ]
37+ #[ target_feature( enable = "atomics" ) ]
5438pub unsafe fn memory_atomic_wait32 ( ptr : * mut i32 , expression : i32 , timeout_ns : i64 ) -> i32 {
5539 llvm_atomic_wait_i32 ( ptr, expression, timeout_ns)
5640}
@@ -76,16 +60,10 @@ pub unsafe fn memory_atomic_wait32(ptr: *mut i32, expression: i32, timeout_ns: i
7660/// didn't block
7761/// * 2 - the thread blocked, but the timeout expired.
7862///
79- /// # Availability
80- ///
81- /// This intrinsic is only available **when the standard library itself is
82- /// compiled with the `atomics` target feature**. This version of the standard
83- /// library is not obtainable via `rustup`, but rather will require the
84- /// standard library to be compiled from source.
85- ///
8663/// [instr]: https://webassembly.github.io/threads/syntax/instructions.html#syntax-instr-atomic-memory
8764#[ inline]
88- #[ cfg_attr( test, assert_instr( "i64.atomic.wait" ) ) ]
65+ #[ cfg_attr( test, assert_instr( memory. atomic. wait64) ) ]
66+ #[ target_feature( enable = "atomics" ) ]
8967pub unsafe fn memory_atomic_wait64 ( ptr : * mut i64 , expression : i64 , timeout_ns : i64 ) -> i32 {
9068 llvm_atomic_wait_i64 ( ptr, expression, timeout_ns)
9169}
@@ -103,16 +81,10 @@ pub unsafe fn memory_atomic_wait64(ptr: *mut i64, expression: i64, timeout_ns: i
10381///
10482/// Returns the number of waiters which were actually notified.
10583///
106- /// # Availability
107- ///
108- /// This intrinsic is only available **when the standard library itself is
109- /// compiled with the `atomics` target feature**. This version of the standard
110- /// library is not obtainable via `rustup`, but rather will require the
111- /// standard library to be compiled from source.
112- ///
11384/// [instr]: https://webassembly.github.io/threads/syntax/instructions.html#syntax-instr-atomic-memory
11485#[ inline]
115- #[ cfg_attr( test, assert_instr( "atomic.wake" ) ) ]
86+ #[ cfg_attr( test, assert_instr( memory. atomic. notify) ) ]
87+ #[ target_feature( enable = "atomics" ) ]
11688pub unsafe fn memory_atomic_notify ( ptr : * mut i32 , waiters : u32 ) -> u32 {
11789 llvm_atomic_notify ( ptr, waiters as i32 ) as u32
11890}
0 commit comments