]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: minor Windows cleanup
authorBrad Fitzpatrick <bradfitz@golang.org>
Tue, 5 Apr 2016 18:22:23 +0000 (18:22 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 6 Apr 2016 02:23:29 +0000 (02:23 +0000)
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: Alex Brainman <alex.brainman@gmail.com>
src/runtime/os1_windows.go
src/runtime/os_windows.go

index 315dd9816a1ceb43d5f5fa66a4081509f65ed28e..a36def0ffe716e372acb973390e6f71a1dc00736 100644 (file)
@@ -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
index 8bdf5a271f1e83995b7b7b2087e800ac9c93aabc..24b3b8cf29e422719ad07e14cdc6559452fb0801 100644 (file)
@@ -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() {