File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use mem;
1313use sync:: atomic:: { AtomicU32 , Ordering } ;
1414use sys:: cloudabi:: abi;
1515use sys:: mutex:: { self , Mutex } ;
16- use sys:: time:: dur2intervals ;
16+ use sys:: time:: checked_dur2intervals ;
1717use time:: Duration ;
1818
1919extern "C" {
@@ -114,6 +114,8 @@ impl Condvar {
114114
115115 // Call into the kernel to wait on the condition variable.
116116 let condvar = self . condvar . get ( ) ;
117+ let timeout = checked_dur2intervals ( & dur)
118+ . expect ( "overflow converting duration to nanoseconds" ) ;
117119 let subscriptions = [
118120 abi:: subscription {
119121 type_ : abi:: eventtype:: CONDVAR ,
@@ -132,7 +134,7 @@ impl Condvar {
132134 union : abi:: subscription_union {
133135 clock : abi:: subscription_clock {
134136 clock_id : abi:: clockid:: MONOTONIC ,
135- timeout : dur2intervals ( & dur ) ,
137+ timeout,
136138 ..mem:: zeroed ( )
137139 } ,
138140 } ,
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ use libc;
1616use mem;
1717use ptr;
1818use sys:: cloudabi:: abi;
19- use sys:: time:: dur2intervals ;
19+ use sys:: time:: checked_dur2intervals ;
2020use sys_common:: thread:: * ;
2121use time:: Duration ;
2222
@@ -70,13 +70,15 @@ impl Thread {
7070 }
7171
7272 pub fn sleep ( dur : Duration ) {
73+ let timeout = checked_dur2intervals ( & dur)
74+ . expect ( "overflow converting duration to nanoseconds" ) ;
7375 unsafe {
7476 let subscription = abi:: subscription {
7577 type_ : abi:: eventtype:: CLOCK ,
7678 union : abi:: subscription_union {
7779 clock : abi:: subscription_clock {
7880 clock_id : abi:: clockid:: MONOTONIC ,
79- timeout : dur2intervals ( & dur ) ,
81+ timeout,
8082 ..mem:: zeroed ( )
8183 } ,
8284 } ,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ pub struct Instant {
1919 t : abi:: timestamp ,
2020}
2121
22- fn checked_dur2intervals ( dur : & Duration ) -> Option < abi:: timestamp > {
22+ pub fn checked_dur2intervals ( dur : & Duration ) -> Option < abi:: timestamp > {
2323 dur. as_secs ( )
2424 . checked_mul ( NSEC_PER_SEC ) ?
2525 . checked_add ( dur. subsec_nanos ( ) as abi:: timestamp )
You can’t perform that action at this time.
0 commit comments