Skip to content

Commit 8ff97bd

Browse files
committed
runtime: remove unnecessary check for negative sleepTicks duration
This is now fixed for every target in the previous commit. Also see: #4239
1 parent a6c4287 commit 8ff97bd

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/runtime/runtime_mimxrt1062_time.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,17 @@ func ticks() timeUnit {
119119
}
120120

121121
func sleepTicks(duration timeUnit) {
122-
if duration >= 0 {
123-
curr := ticks()
124-
last := curr + duration // 64-bit overflow unlikely
125-
for curr < last {
126-
cycles := timeUnit((last - curr) / pitCyclesPerMicro)
127-
if cycles > 0xFFFFFFFF {
128-
cycles = 0xFFFFFFFF
129-
}
130-
if !timerSleep(uint32(cycles)) {
131-
return // return early due to interrupt
132-
}
133-
curr = ticks()
122+
curr := ticks()
123+
last := curr + duration // 64-bit overflow unlikely
124+
for curr < last {
125+
cycles := timeUnit((last - curr) / pitCyclesPerMicro)
126+
if cycles > 0xFFFFFFFF {
127+
cycles = 0xFFFFFFFF
134128
}
129+
if !timerSleep(uint32(cycles)) {
130+
return // return early due to interrupt
131+
}
132+
curr = ticks()
135133
}
136134
}
137135

src/runtime/runtime_rp2040.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ func nanosecondsToTicks(ns int64) timeUnit {
3131
}
3232

3333
func sleepTicks(d timeUnit) {
34-
if d <= 0 {
35-
return
36-
}
37-
3834
if hasScheduler {
3935
// With scheduler, sleepTicks may return early if an interrupt or
4036
// event fires - so scheduler can schedule any go routines now

0 commit comments

Comments
 (0)