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
-
11
1
#[ cfg( test) ]
12
2
use stdarch_test:: assert_instr;
13
3
14
4
extern "C" {
15
- #[ link_name = "llvm.wasm.memory.atomic.wait.i32 " ]
5
+ #[ link_name = "llvm.wasm.memory.atomic.wait32 " ]
16
6
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 " ]
18
8
fn llvm_atomic_wait_i64 ( ptr : * mut i64 , exp : i64 , timeout : i64 ) -> i32 ;
19
9
#[ link_name = "llvm.wasm.memory.atomic.notify" ]
20
10
fn llvm_atomic_notify ( ptr : * mut i32 , cnt : i32 ) -> i32 ;
@@ -41,16 +31,10 @@ extern "C" {
41
31
/// didn't block
42
32
/// * 2 - the thread blocked, but the timeout expired.
43
33
///
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
- ///
51
34
/// [instr]: https://webassembly.github.io/threads/syntax/instructions.html#syntax-instr-atomic-memory
52
35
#[ inline]
53
- #[ cfg_attr( test, assert_instr( "i32.atomic.wait" ) ) ]
36
+ #[ cfg_attr( test, assert_instr( memory. atomic. wait32) ) ]
37
+ #[ target_feature( enable = "atomics" ) ]
54
38
pub unsafe fn memory_atomic_wait32 ( ptr : * mut i32 , expression : i32 , timeout_ns : i64 ) -> i32 {
55
39
llvm_atomic_wait_i32 ( ptr, expression, timeout_ns)
56
40
}
@@ -76,16 +60,10 @@ pub unsafe fn memory_atomic_wait32(ptr: *mut i32, expression: i32, timeout_ns: i
76
60
/// didn't block
77
61
/// * 2 - the thread blocked, but the timeout expired.
78
62
///
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
- ///
86
63
/// [instr]: https://webassembly.github.io/threads/syntax/instructions.html#syntax-instr-atomic-memory
87
64
#[ inline]
88
- #[ cfg_attr( test, assert_instr( "i64.atomic.wait" ) ) ]
65
+ #[ cfg_attr( test, assert_instr( memory. atomic. wait64) ) ]
66
+ #[ target_feature( enable = "atomics" ) ]
89
67
pub unsafe fn memory_atomic_wait64 ( ptr : * mut i64 , expression : i64 , timeout_ns : i64 ) -> i32 {
90
68
llvm_atomic_wait_i64 ( ptr, expression, timeout_ns)
91
69
}
@@ -103,16 +81,10 @@ pub unsafe fn memory_atomic_wait64(ptr: *mut i64, expression: i64, timeout_ns: i
103
81
///
104
82
/// Returns the number of waiters which were actually notified.
105
83
///
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
- ///
113
84
/// [instr]: https://webassembly.github.io/threads/syntax/instructions.html#syntax-instr-atomic-memory
114
85
#[ inline]
115
- #[ cfg_attr( test, assert_instr( "atomic.wake" ) ) ]
86
+ #[ cfg_attr( test, assert_instr( memory. atomic. notify) ) ]
87
+ #[ target_feature( enable = "atomics" ) ]
116
88
pub unsafe fn memory_atomic_notify ( ptr : * mut i32 , waiters : u32 ) -> u32 {
117
89
llvm_atomic_notify ( ptr, waiters as i32 ) as u32
118
90
}
0 commit comments