diff options
author | Ayke van Laethem <[email protected]> | 2024-10-30 19:29:12 +0100 |
---|---|---|
committer | Ayke <[email protected]> | 2024-11-07 15:37:18 +0100 |
commit | 8ff97bdedd5dc420462943dffe662bae57b6d567 (patch) | |
tree | 65a49e34ab761d6dac8c1224d927a7b8c4b967bf /src/runtime | |
parent | a6c4287b4d2dc8c951227820a1dbc69d7e26b689 (diff) | |
download | tinygo-8ff97bdedd5dc420462943dffe662bae57b6d567.tar.gz tinygo-8ff97bdedd5dc420462943dffe662bae57b6d567.zip |
runtime: remove unnecessary check for negative sleepTicks duration
This is now fixed for every target in the previous commit.
Also see: https://github.com/tinygo-org/tinygo/pull/4239
Diffstat (limited to 'src/runtime')
-rw-r--r-- | src/runtime/runtime_mimxrt1062_time.go | 22 | ||||
-rw-r--r-- | src/runtime/runtime_rp2040.go | 4 |
2 files changed, 10 insertions, 16 deletions
diff --git a/src/runtime/runtime_mimxrt1062_time.go b/src/runtime/runtime_mimxrt1062_time.go index e3779052f..feaf68dbd 100644 --- a/src/runtime/runtime_mimxrt1062_time.go +++ b/src/runtime/runtime_mimxrt1062_time.go @@ -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() } } diff --git a/src/runtime/runtime_rp2040.go b/src/runtime/runtime_rp2040.go index fa048117b..1d36a771e 100644 --- a/src/runtime/runtime_rp2040.go +++ b/src/runtime/runtime_rp2040.go @@ -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 |