File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
src/libstd/sys/unix/freertos Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -102,14 +102,11 @@ impl Thread {
102
102
pub fn sleep ( dur : Duration ) {
103
103
let tick_rate = unsafe { xPortGetTickRateHz ( ) } ;
104
104
105
- let mut ticks_to_delay: u64 = dur
106
- . as_secs ( )
107
- . checked_mul ( u64:: from ( tick_rate) )
108
- . and_then ( |ms| ms. checked_add ( u64:: from ( dur. subsec_nanos ( ) / tick_rate) ) )
109
- . expect ( "overflow converting duration to ticks" ) ;
110
-
111
- while ticks_to_delay > u64:: from ( crate :: u32:: MAX ) {
112
- ticks_to_delay -= u64:: from ( crate :: u32:: MAX ) ;
105
+ let mut ticks_to_delay = u128:: from ( dur. as_secs ( ) ) * u128:: from ( tick_rate)
106
+ + u128:: from ( ( ( dur. subsec_millis ( ) + 1 ) * tick_rate - 1 ) ) / u128:: from ( tick_rate) ;
107
+
108
+ while ticks_to_delay > u128:: from ( crate :: u32:: MAX ) {
109
+ ticks_to_delay -= u128:: from ( crate :: u32:: MAX ) ;
113
110
unsafe { vTaskDelay ( crate :: u32:: MAX ) } ;
114
111
}
115
112
You can’t perform that action at this time.
0 commit comments