File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
1
//@ignore-target-windows: No eventfd on Windows
2
2
//@ignore-target-apple: No eventfd in macos
3
3
fn main ( ) {
4
- // eventfd write will block when we try to add until it exceed u64::MAX - 1.
4
+ // eventfd write will block when EFD_NONBLOCK flag is clear
5
+ // and the addition caused counter to exceed u64::MAX - 1.
5
6
// This will pass when blocking is implemented.
6
7
let flags = libc:: EFD_CLOEXEC ;
7
8
let fd = unsafe { libc:: eventfd ( 0 , flags) } ;
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ fn test_race() {
103
103
let res: i32 = unsafe {
104
104
libc:: read ( fd, buf. as_mut_ptr ( ) . cast ( ) , buf. len ( ) as libc:: size_t ) . try_into ( ) . unwrap ( )
105
105
} ;
106
- // read returns number of bytes has been read, which is always 8
106
+ // read returns number of bytes has been read, which is always 8.
107
107
assert_eq ! ( res, 8 ) ;
108
108
let counter: u64 ;
109
109
if cfg ! ( target_endian = "big" ) {
@@ -113,10 +113,8 @@ fn test_race() {
113
113
counter = u64:: from_le_bytes ( buf) ;
114
114
}
115
115
assert_eq ! ( counter, 1 ) ;
116
- // Read from the static mutable variable
117
116
unsafe { assert_eq ! ( VAL , 1 ) } ;
118
117
} ) ;
119
- // Write to the static mutable variable
120
118
unsafe { VAL = 1 } ;
121
119
let data: [ u8 ; 8 ] ;
122
120
if cfg ! ( target_endian = "big" ) {
@@ -127,7 +125,7 @@ fn test_race() {
127
125
}
128
126
let res: i64 =
129
127
unsafe { libc:: write ( fd, data. as_ptr ( ) as * const libc:: c_void , 8 ) . try_into ( ) . unwrap ( ) } ;
130
- // write return number of bytes written, which is always 8
128
+ // write returns number of bytes written, which is always 8.
131
129
assert_eq ! ( res, 8 ) ;
132
130
thread:: yield_now ( ) ;
133
131
thread1. join ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments