File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -136,15 +136,13 @@ pub fn futex_wake_all(futex: &AtomicU32) {
136136
137137#[ cfg( target_os = "openbsd" ) ]
138138pub fn futex_wait ( futex : & AtomicU32 , expected : u32 , timeout : Option < Duration > ) -> bool {
139+ use super :: time:: Timespec ;
139140 use crate :: ptr:: { null, null_mut} ;
140- let timespec = timeout. and_then ( |d| {
141- Some ( libc:: timespec {
142- // Sleep forever if the timeout is longer than fits in a timespec.
143- tv_sec : d. as_secs ( ) . try_into ( ) . ok ( ) ?,
144- // This conversion never truncates, as subsec_nanos is always <1e9.
145- tv_nsec : d. subsec_nanos ( ) as _ ,
146- } )
147- } ) ;
141+
142+ // Overflows are rounded up to an infinite timeout (None).
143+ let timespec = timeout
144+ . and_then ( |d| Timespec :: zero ( ) . checked_add_duration ( & d) )
145+ . and_then ( |t| t. to_timespec ( ) ) ;
148146
149147 let r = unsafe {
150148 libc:: futex (
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ impl fmt::Debug for SystemTime {
5151}
5252
5353impl Timespec {
54- const fn zero ( ) -> Timespec {
54+ pub const fn zero ( ) -> Timespec {
5555 Timespec { tv_sec : 0 , tv_nsec : 0 }
5656 }
5757
You can’t perform that action at this time.
0 commit comments