]> Cypherpunks repositories - gostls13.git/commit
runtime: implement usleep in Go instead of assembly on Windows
authorqmuntal <quimmuntal@gmail.com>
Thu, 7 Sep 2023 12:59:58 +0000 (14:59 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Thu, 21 Sep 2023 15:56:43 +0000 (15:56 +0000)
commitb6ae112ff1bb7ace761ed8dfee95626069280f07
tree571d45bce3397c43de95eb4bccb76fcb5191ebbd
parentace1494d9235be94f1325ab6e45105a446b3224c
runtime: implement usleep in Go instead of assembly on Windows

Windows APIs are normally not arch-specific, so it's better to
implement them in Go instead of assembly.

It was previously implemented in assembly because it was the only way
to support calls without a valid g. This CL defines a new function,
stdcall_no_g, that can be used in such cases.

While here, I've also replaced the use of the deprecated syscall
NtWaitForSingleObject with WaitForSingleObject. The former may
give the illusion of being more accurate, as it takes a higher
resolution timeout, but it's not. Windows time resolution is 15.6ms,
and can be as high as 1ms when using a high resolution timer, which
WaitForSingleObject supports.

Change-Id: I903400220ade4d4ccc15685c8da47182430f8686
Reviewed-on: https://go-review.googlesource.com/c/go/+/526477
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
src/runtime/os_windows.go
src/runtime/sys_windows_386.s
src/runtime/sys_windows_amd64.s
src/runtime/sys_windows_arm.s
src/runtime/sys_windows_arm64.s