2
2
//@compile-flags: -Zmiri-disable-isolation
3
3
4
4
use std:: mem:: MaybeUninit ;
5
- use std:: ptr;
5
+ use std:: ptr:: { self , addr_of } ;
6
6
use std:: sync:: atomic:: AtomicI32 ;
7
7
use std:: sync:: atomic:: Ordering ;
8
8
use std:: thread;
@@ -13,15 +13,15 @@ fn wake_nobody() {
13
13
14
14
// Wake 1 waiter. Expect zero waiters woken up, as nobody is waiting.
15
15
unsafe {
16
- assert_eq ! ( libc:: syscall( libc:: SYS_futex , & futex as * const i32 , libc:: FUTEX_WAKE , 1 ) , 0 ) ;
16
+ assert_eq ! ( libc:: syscall( libc:: SYS_futex , addr_of! ( futex) , libc:: FUTEX_WAKE , 1 ) , 0 ) ;
17
17
}
18
18
19
19
// Same, but without omitting the unused arguments.
20
20
unsafe {
21
21
assert_eq ! (
22
22
libc:: syscall(
23
23
libc:: SYS_futex ,
24
- & futex as * const i32 ,
24
+ addr_of! ( futex) ,
25
25
libc:: FUTEX_WAKE ,
26
26
1 ,
27
27
ptr:: null:: <libc:: timespec>( ) ,
@@ -52,7 +52,7 @@ fn wait_wrong_val() {
52
52
assert_eq ! (
53
53
libc:: syscall(
54
54
libc:: SYS_futex ,
55
- & futex as * const i32 ,
55
+ addr_of! ( futex) ,
56
56
libc:: FUTEX_WAIT ,
57
57
456 ,
58
58
ptr:: null:: <libc:: timespec>( ) ,
@@ -73,7 +73,7 @@ fn wait_timeout() {
73
73
assert_eq ! (
74
74
libc:: syscall(
75
75
libc:: SYS_futex ,
76
- & futex as * const i32 ,
76
+ addr_of! ( futex) ,
77
77
libc:: FUTEX_WAIT ,
78
78
123 ,
79
79
& libc:: timespec { tv_sec: 0 , tv_nsec: 200_000_000 } ,
@@ -110,7 +110,7 @@ fn wait_absolute_timeout() {
110
110
assert_eq ! (
111
111
libc:: syscall(
112
112
libc:: SYS_futex ,
113
- & futex as * const i32 ,
113
+ addr_of! ( futex) ,
114
114
libc:: FUTEX_WAIT_BITSET ,
115
115
123 ,
116
116
& timeout,
@@ -136,7 +136,7 @@ fn wait_wake() {
136
136
assert_eq ! (
137
137
libc:: syscall(
138
138
libc:: SYS_futex ,
139
- & FUTEX as * const i32 ,
139
+ addr_of! ( FUTEX ) ,
140
140
libc:: FUTEX_WAKE ,
141
141
10 , // Wake up at most 10 threads.
142
142
) ,
@@ -149,7 +149,7 @@ fn wait_wake() {
149
149
assert_eq ! (
150
150
libc:: syscall(
151
151
libc:: SYS_futex ,
152
- & FUTEX as * const i32 ,
152
+ addr_of! ( FUTEX ) ,
153
153
libc:: FUTEX_WAIT ,
154
154
0 ,
155
155
ptr:: null:: <libc:: timespec>( ) ,
@@ -173,7 +173,7 @@ fn wait_wake_bitset() {
173
173
assert_eq ! (
174
174
libc:: syscall(
175
175
libc:: SYS_futex ,
176
- & FUTEX as * const i32 ,
176
+ addr_of! ( FUTEX ) ,
177
177
libc:: FUTEX_WAKE_BITSET ,
178
178
10 , // Wake up at most 10 threads.
179
179
ptr:: null:: <libc:: timespec>( ) ,
@@ -188,7 +188,7 @@ fn wait_wake_bitset() {
188
188
assert_eq ! (
189
189
libc:: syscall(
190
190
libc:: SYS_futex ,
191
- & FUTEX as * const i32 ,
191
+ addr_of! ( FUTEX ) ,
192
192
libc:: FUTEX_WAKE_BITSET ,
193
193
10 , // Wake up at most 10 threads.
194
194
ptr:: null:: <libc:: timespec>( ) ,
@@ -204,7 +204,7 @@ fn wait_wake_bitset() {
204
204
assert_eq ! (
205
205
libc:: syscall(
206
206
libc:: SYS_futex ,
207
- & FUTEX as * const i32 ,
207
+ addr_of! ( FUTEX ) ,
208
208
libc:: FUTEX_WAIT_BITSET ,
209
209
0 ,
210
210
ptr:: null:: <libc:: timespec>( ) ,
@@ -244,7 +244,7 @@ fn concurrent_wait_wake() {
244
244
unsafe {
245
245
let ret = libc:: syscall (
246
246
libc:: SYS_futex ,
247
- & FUTEX as * const AtomicI32 ,
247
+ addr_of ! ( FUTEX ) ,
248
248
libc:: FUTEX_WAIT ,
249
249
HELD ,
250
250
ptr:: null :: < libc:: timespec > ( ) ,
@@ -267,7 +267,7 @@ fn concurrent_wait_wake() {
267
267
FUTEX . store ( FREE , Ordering :: Relaxed ) ;
268
268
unsafe {
269
269
DATA = 1 ;
270
- libc:: syscall ( libc:: SYS_futex , & FUTEX as * const AtomicI32 , libc:: FUTEX_WAKE , 1 ) ;
270
+ libc:: syscall ( libc:: SYS_futex , addr_of ! ( FUTEX ) , libc:: FUTEX_WAKE , 1 ) ;
271
271
}
272
272
273
273
t. join ( ) . unwrap ( ) ;
0 commit comments