Commit 8556c76f authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

runtime: minor Windows cleanup

Change-Id: I9a8081ef1109469e9577c642156aa635188d8954
Reviewed-on: https://go-review.googlesource.com/21538
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
parent cb284313
...@@ -110,28 +110,24 @@ func asmstdcall(fn unsafe.Pointer) ...@@ -110,28 +110,24 @@ func asmstdcall(fn unsafe.Pointer)
var asmstdcallAddr unsafe.Pointer var asmstdcallAddr unsafe.Pointer
func windowsFindfunc(name []byte, lib uintptr) stdFunction { func windowsFindfunc(lib uintptr, name []byte) stdFunction {
if name[len(name)-1] != 0 {
throw("usage")
}
f := stdcall2(_GetProcAddress, lib, uintptr(unsafe.Pointer(&name[0]))) f := stdcall2(_GetProcAddress, lib, uintptr(unsafe.Pointer(&name[0])))
return stdFunction(unsafe.Pointer(f)) return stdFunction(unsafe.Pointer(f))
} }
func loadOptionalSyscalls() { func loadOptionalSyscalls() {
var ( var kernel32dll = []byte("kernel32.dll\000")
kernel32dll = []byte("kernel32.dll\000")
addVectoredContinueHandler = []byte("AddVectoredContinueHandler\000")
getQueuedCompletionStatusEx = []byte("GetQueuedCompletionStatusEx\000")
addDllDirectory = []byte("AddDllDirectory\000")
loadLibraryExW = []byte("LoadLibraryExW\000")
)
k32 := stdcall1(_LoadLibraryA, uintptr(unsafe.Pointer(&kernel32dll[0]))) k32 := stdcall1(_LoadLibraryA, uintptr(unsafe.Pointer(&kernel32dll[0])))
if k32 == 0 { if k32 == 0 {
throw("kernel32.dll not found") throw("kernel32.dll not found")
} }
_AddDllDirectory = windowsFindfunc(addDllDirectory, k32) _AddDllDirectory = windowsFindfunc(k32, []byte("AddDllDirectory\000"))
_AddVectoredContinueHandler = windowsFindfunc(addVectoredContinueHandler, k32) _AddVectoredContinueHandler = windowsFindfunc(k32, []byte("AddVectoredContinueHandler\000"))
_GetQueuedCompletionStatusEx = windowsFindfunc(getQueuedCompletionStatusEx, k32) _GetQueuedCompletionStatusEx = windowsFindfunc(k32, []byte("GetQueuedCompletionStatusEx\000"))
_LoadLibraryExW = windowsFindfunc(loadLibraryExW, k32) _LoadLibraryExW = windowsFindfunc(k32, []byte("LoadLibraryExW\000"))
} }
//go:nosplit //go:nosplit
......
...@@ -10,7 +10,7 @@ type mOS struct { ...@@ -10,7 +10,7 @@ type mOS struct {
waitsema uintptr // semaphore for parking on locks waitsema uintptr // semaphore for parking on locks
} }
type stdFunction *byte type stdFunction unsafe.Pointer
//go:linkname os_sigpipe os.sigpipe //go:linkname os_sigpipe os.sigpipe
func os_sigpipe() { func os_sigpipe() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment