Kaynağa Gözat

go.sys/windows: keep windows syscall pointers live

apply latest changes made to syscall/mksyscall_windows.go

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/152200043
Alex Brainman 11 yıl önce
ebeveyn
işleme
c17938b803
2 değiştirilmiş dosya ile 31 ekleme ve 7 silme
  1. 1 1
      windows/Makefile
  2. 30 6
      windows/zsyscall_windows.go

+ 1 - 1
windows/Makefile

@@ -7,6 +7,6 @@ all: zsyscall_windows.go
 TMP=/tmp/mksyscall_windows
 
 zsyscall_windows.go: syscall_windows.go security_windows.go
-	go build -o $(TMP) $(GOROOT)/src/pkg/syscall/mksyscall_windows.go
+	go build -o $(TMP) $(GOROOT)/src/syscall/mksyscall_windows.go
 	GOOS=windows $(TMP) $^ | gofmt > $@
 	rm $(TMP)

+ 30 - 6
windows/zsyscall_windows.go

@@ -177,7 +177,11 @@ func LoadLibrary(libname string) (handle Handle, err error) {
 	if err != nil {
 		return
 	}
-	r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0)
+	return _LoadLibrary(_p0)
+}
+
+func _LoadLibrary(libname *uint16) (handle Handle, err error) {
+	r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
 	handle = Handle(r0)
 	if handle == 0 {
 		if e1 != 0 {
@@ -207,7 +211,11 @@ func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
 	if err != nil {
 		return
 	}
-	r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(_p0)), 0)
+	return _GetProcAddress(module, _p0)
+}
+
+func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
+	r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
 	proc = uintptr(r0)
 	if proc == 0 {
 		if e1 != 0 {
@@ -1559,7 +1567,11 @@ func GetHostByName(name string) (h *Hostent, err error) {
 	if err != nil {
 		return
 	}
-	r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0)
+	return _GetHostByName(_p0)
+}
+
+func _GetHostByName(name *byte) (h *Hostent, err error) {
+	r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
 	h = (*Hostent)(unsafe.Pointer(r0))
 	if h == nil {
 		if e1 != 0 {
@@ -1582,7 +1594,11 @@ func GetServByName(name string, proto string) (s *Servent, err error) {
 	if err != nil {
 		return
 	}
-	r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+	return _GetServByName(_p0, _p1)
+}
+
+func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
+	r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
 	s = (*Servent)(unsafe.Pointer(r0))
 	if s == nil {
 		if e1 != 0 {
@@ -1606,7 +1622,11 @@ func GetProtoByName(name string) (p *Protoent, err error) {
 	if err != nil {
 		return
 	}
-	r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0)
+	return _GetProtoByName(_p0)
+}
+
+func _GetProtoByName(name *byte) (p *Protoent, err error) {
+	r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
 	p = (*Protoent)(unsafe.Pointer(r0))
 	if p == nil {
 		if e1 != 0 {
@@ -1624,7 +1644,11 @@ func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSR
 	if status != nil {
 		return
 	}
-	r0, _, _ := syscall.Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(_p0)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr)))
+	return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
+}
+
+func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
+	r0, _, _ := syscall.Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(name)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr)))
 	if r0 != 0 {
 		status = syscall.Errno(r0)
 	}