Skip to content

Commit

Permalink
runtime: remove unnecessary check for negative sleepTicks duration
Browse files Browse the repository at this point in the history
This is now fixed for every target in the previous commit.

Also see: #4239
  • Loading branch information
aykevl committed Oct 30, 2024
1 parent c93697f commit 5df3fa3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
22 changes: 10 additions & 12 deletions src/runtime/runtime_mimxrt1062_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,17 @@ func ticks() timeUnit {
}

func sleepTicks(duration timeUnit) {
if duration >= 0 {
curr := ticks()
last := curr + duration // 64-bit overflow unlikely
for curr < last {
cycles := timeUnit((last - curr) / pitCyclesPerMicro)
if cycles > 0xFFFFFFFF {
cycles = 0xFFFFFFFF
}
if !timerSleep(uint32(cycles)) {
return // return early due to interrupt
}
curr = ticks()
curr := ticks()
last := curr + duration // 64-bit overflow unlikely
for curr < last {
cycles := timeUnit((last - curr) / pitCyclesPerMicro)
if cycles > 0xFFFFFFFF {
cycles = 0xFFFFFFFF
}
if !timerSleep(uint32(cycles)) {
return // return early due to interrupt
}
curr = ticks()
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/runtime/runtime_rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ func nanosecondsToTicks(ns int64) timeUnit {
}

func sleepTicks(d timeUnit) {
if d <= 0 {
return
}

if hasScheduler {
// With scheduler, sleepTicks may return early if an interrupt or
// event fires - so scheduler can schedule any go routines now
Expand Down

0 comments on commit 5df3fa3

Please sign in to comment.