From 062cd7e4e68206d8bab9b18396626e855c992658 Mon Sep 17 00:00:00 2001 From: Jeet Parekh Date: Tue, 12 Sep 2017 21:49:26 +0530 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Alex Brainman --- windows/syscall_windows.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index c7ff24b5..9b5ed549 100644 --- a/windows/syscall_windows.go +++ b/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