File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
src/libstd/sys/unix/freertos Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -113,8 +113,30 @@ impl Thread {
113
113
pub fn sleep ( dur : Duration ) {
114
114
let tick_rate = unsafe { xPortGetTickRateHz ( ) } ;
115
115
116
+ let millis;
117
+
118
+ #[ cfg( target_arch = "xtensa" ) ]
119
+ {
120
+ extern "C" {
121
+ fn ets_delay_us ( us : u32 ) ;
122
+ }
123
+
124
+ let mut micros = dur. subsec_micros ( ) ;
125
+ millis = micros / 1000 ;
126
+ micros = micros % 1000 ;
127
+
128
+ if micros > 0 {
129
+ unsafe { ets_delay_us ( micros) } ;
130
+ }
131
+ }
132
+
133
+ #[ cfg( not( target_arch = "xtensa" ) ) ]
134
+ {
135
+ millis = dur. subsec_millis ( ) ;
136
+ }
137
+
116
138
let mut ticks_to_delay = u128:: from ( dur. as_secs ( ) ) * u128:: from ( tick_rate)
117
- + u128:: from ( ( ( dur . subsec_millis ( ) + 1 ) * tick_rate - 1 ) ) / u128:: from ( tick_rate) ;
139
+ + u128:: from ( ( ( millis + 1 ) * tick_rate - 1 ) ) / u128:: from ( tick_rate) ;
118
140
119
141
while ticks_to_delay > u128:: from ( crate :: u32:: MAX ) {
120
142
ticks_to_delay -= u128:: from ( crate :: u32:: MAX ) ;
You can’t perform that action at this time.
0 commit comments