From: Brad Fitzpatrick Date: Tue, 5 Apr 2016 18:22:23 +0000 (+0000) Subject: runtime: minor Windows cleanup X-Git-Tag: go1.7beta1~882 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8556c76f88a6e80aafb535802be71cc79bd22c75;p=gostls13.git runtime: minor Windows cleanup Change-Id: I9a8081ef1109469e9577c642156aa635188d8954 Reviewed-on: https://go-review.googlesource.com/21538 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Alex Brainman --- diff --git a/src/runtime/os1_windows.go b/src/runtime/os1_windows.go index 315dd9816a..a36def0ffe 100644 --- a/src/runtime/os1_windows.go +++ b/src/runtime/os1_windows.go @@ -110,28 +110,24 @@ func asmstdcall(fn 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]))) return stdFunction(unsafe.Pointer(f)) } func loadOptionalSyscalls() { - var ( - kernel32dll = []byte("kernel32.dll\000") - addVectoredContinueHandler = []byte("AddVectoredContinueHandler\000") - getQueuedCompletionStatusEx = []byte("GetQueuedCompletionStatusEx\000") - addDllDirectory = []byte("AddDllDirectory\000") - loadLibraryExW = []byte("LoadLibraryExW\000") - ) - + var kernel32dll = []byte("kernel32.dll\000") k32 := stdcall1(_LoadLibraryA, uintptr(unsafe.Pointer(&kernel32dll[0]))) if k32 == 0 { throw("kernel32.dll not found") } - _AddDllDirectory = windowsFindfunc(addDllDirectory, k32) - _AddVectoredContinueHandler = windowsFindfunc(addVectoredContinueHandler, k32) - _GetQueuedCompletionStatusEx = windowsFindfunc(getQueuedCompletionStatusEx, k32) - _LoadLibraryExW = windowsFindfunc(loadLibraryExW, k32) + _AddDllDirectory = windowsFindfunc(k32, []byte("AddDllDirectory\000")) + _AddVectoredContinueHandler = windowsFindfunc(k32, []byte("AddVectoredContinueHandler\000")) + _GetQueuedCompletionStatusEx = windowsFindfunc(k32, []byte("GetQueuedCompletionStatusEx\000")) + _LoadLibraryExW = windowsFindfunc(k32, []byte("LoadLibraryExW\000")) } //go:nosplit diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go index 8bdf5a271f..24b3b8cf29 100644 --- a/src/runtime/os_windows.go +++ b/src/runtime/os_windows.go @@ -10,7 +10,7 @@ type mOS struct { waitsema uintptr // semaphore for parking on locks } -type stdFunction *byte +type stdFunction unsafe.Pointer //go:linkname os_sigpipe os.sigpipe func os_sigpipe() {