diff options
| author | qmuntal <quimmuntal@gmail.com> | 2023-01-30 14:42:17 +0100 |
|---|---|---|
| committer | Damien Neil <dneil@google.com> | 2023-01-31 22:06:41 +0000 |
| commit | a17d959debdb04cd550016a3501dd09d50cd62e7 (patch) | |
| tree | 3fd64a6cfada925520bf0a915f1389a47f1c5552 /src/runtime/syscall_windows.go | |
| parent | 34d026862df50e36bdb74f010f746f91b7d6a052 (diff) | |
| download | go-a17d959debdb04cd550016a3501dd09d50cd62e7.tar.xz | |
runtime: always use LoadLibraryEx to load system libraries
This CL removes a fallback that used LoadLibraryA when the runtime
was loading system DLLs on Windows 7, Windows Server 2008 R2,
or earlier.
We can safely remove that fallback now, as go1.21 will require at least
Windows 8 or Server 2012.
This CL also saves some syscall initialization time and bytes:
new:
init syscall @2.3 ms, 0 ms clock, 1000 bytes, 18 allocs
old:
init syscall @3.6 ms, 0.52 ms clock, 1744 bytes, 24 allocs
Updates #57003
Change-Id: I7dcc1173537785b6b580e9f78632c0c74da658d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/463842
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/runtime/syscall_windows.go')
| -rw-r--r-- | src/runtime/syscall_windows.go | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/runtime/syscall_windows.go b/src/runtime/syscall_windows.go index 76036ad098..947f68510c 100644 --- a/src/runtime/syscall_windows.go +++ b/src/runtime/syscall_windows.go @@ -413,36 +413,23 @@ func callbackWrap(a *callbackArgs) { const _LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800 -// When available, this function will use LoadLibraryEx with the filename -// parameter and the important SEARCH_SYSTEM32 argument. But on systems that -// do not have that option, absoluteFilepath should contain a fallback -// to the full path inside of system32 for use with vanilla LoadLibrary. -// //go:linkname syscall_loadsystemlibrary syscall.loadsystemlibrary //go:nosplit //go:cgo_unsafe_args -func syscall_loadsystemlibrary(filename *uint16, absoluteFilepath *uint16) (handle, err uintptr) { +func syscall_loadsystemlibrary(filename *uint16) (handle, err uintptr) { lockOSThread() c := &getg().m.syscall - - if useLoadLibraryEx { - c.fn = getLoadLibraryEx() - c.n = 3 - args := struct { - lpFileName *uint16 - hFile uintptr // always 0 - flags uint32 - }{filename, 0, _LOAD_LIBRARY_SEARCH_SYSTEM32} - c.args = uintptr(noescape(unsafe.Pointer(&args))) - } else { - c.fn = getLoadLibrary() - c.n = 1 - c.args = uintptr(noescape(unsafe.Pointer(&absoluteFilepath))) - } + c.fn = getLoadLibraryEx() + c.n = 3 + args := struct { + lpFileName *uint16 + hFile uintptr // always 0 + flags uint32 + }{filename, 0, _LOAD_LIBRARY_SEARCH_SYSTEM32} + c.args = uintptr(noescape(unsafe.Pointer(&args))) cgocall(asmstdcallAddr, unsafe.Pointer(c)) KeepAlive(filename) - KeepAlive(absoluteFilepath) handle = c.r1 if handle == 0 { err = c.err |
