File tree 3 files changed +9
-5
lines changed
3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use mem;
13
13
use sync:: atomic:: { AtomicU32 , Ordering } ;
14
14
use sys:: cloudabi:: abi;
15
15
use sys:: mutex:: { self , Mutex } ;
16
- use sys:: time:: dur2intervals ;
16
+ use sys:: time:: checked_dur2intervals ;
17
17
use time:: Duration ;
18
18
19
19
extern "C" {
@@ -114,6 +114,8 @@ impl Condvar {
114
114
115
115
// Call into the kernel to wait on the condition variable.
116
116
let condvar = self . condvar . get ( ) ;
117
+ let timeout = checked_dur2intervals ( & dur)
118
+ . expect ( "overflow converting duration to nanoseconds" ) ;
117
119
let subscriptions = [
118
120
abi:: subscription {
119
121
type_ : abi:: eventtype:: CONDVAR ,
@@ -132,7 +134,7 @@ impl Condvar {
132
134
union : abi:: subscription_union {
133
135
clock : abi:: subscription_clock {
134
136
clock_id : abi:: clockid:: MONOTONIC ,
135
- timeout : dur2intervals ( & dur ) ,
137
+ timeout,
136
138
..mem:: zeroed ( )
137
139
} ,
138
140
} ,
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ use libc;
16
16
use mem;
17
17
use ptr;
18
18
use sys:: cloudabi:: abi;
19
- use sys:: time:: dur2intervals ;
19
+ use sys:: time:: checked_dur2intervals ;
20
20
use sys_common:: thread:: * ;
21
21
use time:: Duration ;
22
22
@@ -70,13 +70,15 @@ impl Thread {
70
70
}
71
71
72
72
pub fn sleep ( dur : Duration ) {
73
+ let timeout = checked_dur2intervals ( & dur)
74
+ . expect ( "overflow converting duration to nanoseconds" ) ;
73
75
unsafe {
74
76
let subscription = abi:: subscription {
75
77
type_ : abi:: eventtype:: CLOCK ,
76
78
union : abi:: subscription_union {
77
79
clock : abi:: subscription_clock {
78
80
clock_id : abi:: clockid:: MONOTONIC ,
79
- timeout : dur2intervals ( & dur ) ,
81
+ timeout,
80
82
..mem:: zeroed ( )
81
83
} ,
82
84
} ,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ pub struct Instant {
19
19
t : abi:: timestamp ,
20
20
}
21
21
22
- fn checked_dur2intervals ( dur : & Duration ) -> Option < abi:: timestamp > {
22
+ pub fn checked_dur2intervals ( dur : & Duration ) -> Option < abi:: timestamp > {
23
23
dur. as_secs ( )
24
24
. checked_mul ( NSEC_PER_SEC ) ?
25
25
. checked_add ( dur. subsec_nanos ( ) as abi:: timestamp )
You can’t perform that action at this time.
0 commit comments