File tree Expand file tree Collapse file tree 9 files changed +20
-14
lines changed
crossbeam-utils/src/atomic Expand file tree Collapse file tree 9 files changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -1580,9 +1580,7 @@ mod race_chan_test {
15801580}
15811581
15821582// https://github.com/golang/go/blob/master/test/ken/chan.go
1583- #[ cfg( not( miri) ) ] // Miri is too slow
15841583mod chan {
1585-
15861584 use super :: * ;
15871585
15881586 const MESSAGES_PER_CHANEL : u32 = 76 ;
@@ -2052,6 +2050,7 @@ mod chan {
20522050 }
20532051
20542052 #[ test]
2053+ #[ cfg_attr( miri, ignore) ] // Miri is too slow
20552054 fn main ( ) {
20562055 let mut ctx = Context {
20572056 nproc : Arc :: new ( Mutex :: new ( 0 ) ) ,
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ fn len_empty_full() {
6767}
6868
6969#[ test]
70+ #[ cfg_attr( miri, ignore) ] // this test makes timing assumptions, but Miri is so slow it violates them
7071fn try_recv ( ) {
7172 let ( s, r) = unbounded ( ) ;
7273
Original file line number Diff line number Diff line change @@ -408,7 +408,6 @@ fn both_ready() {
408408 . unwrap ( ) ;
409409}
410410
411- #[ cfg_attr( miri, ignore) ] // Miri is too slow
412411#[ test]
413412fn loop_try ( ) {
414413 const RUNS : usize = 20 ;
Original file line number Diff line number Diff line change @@ -284,7 +284,6 @@ fn both_ready() {
284284 . unwrap ( ) ;
285285}
286286
287- #[ cfg_attr( miri, ignore) ] // Miri is too slow
288287#[ test]
289288fn loop_try ( ) {
290289 const RUNS : usize = 20 ;
Original file line number Diff line number Diff line change @@ -328,9 +328,11 @@ fn stress_oneshot() {
328328 }
329329}
330330
331- #[ cfg_attr( miri, ignore) ] // Miri is too slow
332331#[ test]
333332fn stress_iter ( ) {
333+ #[ cfg( miri) ]
334+ const COUNT : usize = 50 ;
335+ #[ cfg( not( miri) ) ]
334336 const COUNT : usize = 1000 ;
335337
336338 let ( request_s, request_r) = bounded ( 0 ) ;
@@ -483,10 +485,9 @@ fn fairness() {
483485}
484486
485487#[ test]
486- #[ cfg_attr( miri, ignore) ] // Miri is too slow
487488fn fairness_duplicates ( ) {
488489 #[ cfg( miri) ]
489- const COUNT : usize = 50 ;
490+ const COUNT : usize = 100 ;
490491 #[ cfg( not( miri) ) ]
491492 const COUNT : usize = 10_000 ;
492493
Original file line number Diff line number Diff line change @@ -402,10 +402,10 @@ mod tests {
402402 v. push ( i as i32 ) ;
403403 }
404404
405- let ptr = v. as_mut_ptr ( ) as usize ;
405+ let ptr = v. as_mut_ptr ( ) ;
406406 let len = v. len ( ) ;
407407 guard. defer_unchecked ( move || {
408- drop ( Vec :: from_raw_parts ( ptr as * const i32 as * mut i32 , len, len) ) ;
408+ drop ( Vec :: from_raw_parts ( ptr, len, len) ) ;
409409 DESTROYS . fetch_add ( len, Ordering :: Relaxed ) ;
410410 } ) ;
411411 guard. flush ( ) ;
Original file line number Diff line number Diff line change @@ -193,9 +193,11 @@ fn spsc_ring_buffer() {
193193 }
194194}
195195
196- #[ cfg_attr( miri, ignore) ] // Miri is too slow
197196#[ test]
198197fn mpmc ( ) {
198+ #[ cfg( miri) ]
199+ const COUNT : usize = 50 ;
200+ #[ cfg( not( miri) ) ]
199201 const COUNT : usize = 25_000 ;
200202 const THREADS : usize = 4 ;
201203
@@ -230,9 +232,11 @@ fn mpmc() {
230232 }
231233}
232234
233- #[ cfg_attr( miri, ignore) ] // Miri is too slow
234235#[ test]
235236fn mpmc_ring_buffer ( ) {
237+ #[ cfg( miri) ]
238+ const COUNT : usize = 50 ;
239+ #[ cfg( not( miri) ) ]
236240 const COUNT : usize = 25_000 ;
237241 const THREADS : usize = 4 ;
238242
Original file line number Diff line number Diff line change @@ -82,9 +82,11 @@ fn spsc() {
8282 . unwrap ( ) ;
8383}
8484
85- #[ cfg_attr( miri, ignore) ] // Miri is too slow
8685#[ test]
8786fn mpmc ( ) {
87+ #[ cfg( miri) ]
88+ const COUNT : usize = 50 ;
89+ #[ cfg( not( miri) ) ]
8890 const COUNT : usize = 25_000 ;
8991 const THREADS : usize = 4 ;
9092
Original file line number Diff line number Diff line change @@ -1009,10 +1009,11 @@ where
10091009 // discard the data when a data race is detected. The proper solution would be to
10101010 // do atomic reads and atomic writes, but we can't atomically read and write all
10111011 // kinds of data since `AtomicU8` is not available on stable Rust yet.
1012- let val = ptr:: read_volatile( src) ;
1012+ // Load as `MaybeUninit` because we may load a value that is not valid as `T`.
1013+ let val = ptr:: read_volatile( src as * mut MaybeUninit <T >) ;
10131014
10141015 if lock. validate_read( stamp) {
1015- return val;
1016+ return val. assume_init ( ) ;
10161017 }
10171018 }
10181019
You can’t perform that action at this time.
0 commit comments