Browse Source

windows: fix NewCallback function

It has been suggested to migrate from syscall to golang.org/x/sys
The NewCallback function works in syscall. But the golang.org/x/sys/windows NewCallback function did not work.

Since golang.org/x/sys/windows already imports syscall, the NewCallback function now calls syscall.NewCallback.

Fixes golang/go#21831

Change-Id: I5cabd8540777b398a288308a66ae20896ed4a1db
Reviewed-on: https://go-review.googlesource.com/63250
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Jeet Parekh 8 năm trước cách đây
mục cha
commit
062cd7e4e6
1 tập tin đã thay đổi với 11 bổ sung6 xóa
  1. 11 6
      windows/syscall_windows.go

+ 11 - 6
windows/syscall_windows.go

@@ -71,12 +71,17 @@ func UTF16PtrFromString(s string) (*uint16, error) {
 
 func Getpagesize() int { return 4096 }
 
-// Converts a Go function to a function pointer conforming
-// to the stdcall or cdecl calling convention.  This is useful when
-// interoperating with Windows code requiring callbacks.
-// Implemented in runtime/syscall_windows.goc
-func NewCallback(fn interface{}) uintptr
-func NewCallbackCDecl(fn interface{}) uintptr
+// NewCallback converts a Go function to a function pointer conforming to the stdcall calling convention.
+// This is useful when interoperating with Windows code requiring callbacks.
+func NewCallback(fn interface{}) uintptr {
+	return syscall.NewCallback(fn)
+}
+
+// NewCallbackCDecl converts a Go function to a function pointer conforming to the cdecl calling convention.
+// This is useful when interoperating with Windows code requiring callbacks.
+func NewCallbackCDecl(fn interface{}) uintptr {
+	return syscall.NewCallbackCDecl(fn)
+}
 
 // windows api calls