fixes #23732, os.sleep(-1) now returns immediately (#23734)

fixes #23732

(cherry picked from commit 2a658c64d8)
This commit is contained in:
lit
2024-06-18 23:39:34 +08:00
committed by narimiran
parent b79e603702
commit ae117bd7bc

View File

@@ -692,7 +692,10 @@ proc getAppDir*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect], noWeirdT
proc sleep*(milsecs: int) {.rtl, extern: "nos$1", tags: [TimeEffect], noWeirdTarget.} =
## Sleeps `milsecs` milliseconds.
## A negative `milsecs` causes sleep to return immediately.
when defined(windows):
if milsecs < 0:
return # fixes #23732
winlean.sleep(int32(milsecs))
else:
var a, b: Timespec