浏览代码

windows: run "go generate"

Change-Id: Ide01e409af85a5e2615ba647b44eda67bc14c07f
Reviewed-on: https://go-review.googlesource.com/33812
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Alex Brainman 9 年之前
父节点
当前提交
ca83bd2cb9
共有 2 个文件被更改,包括 161 次插入110 次删除
  1. 28 2
      windows/registry/zsyscall_windows.go
  2. 133 108
      windows/zsyscall_windows.go

+ 28 - 2
windows/registry/zsyscall_windows.go

@@ -3,13 +3,39 @@
 package registry
 
 import (
-	"golang.org/x/sys/windows"
 	"syscall"
 	"unsafe"
+
+	"golang.org/x/sys/windows"
 )
 
 var _ unsafe.Pointer
 
+// Do the interface allocations only once for common
+// Errno values.
+const (
+	errnoERROR_IO_PENDING = 997
+)
+
+var (
+	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
+)
+
+// errnoErr returns common boxed Errno values, to prevent
+// allocations at runtime.
+func errnoErr(e syscall.Errno) error {
+	switch e {
+	case 0:
+		return nil
+	case errnoERROR_IO_PENDING:
+		return errERROR_IO_PENDING
+	}
+	// TODO: add more here, after collecting data on the common
+	// error values see on Windows. (perhaps when running
+	// all.bat?)
+	return e
+}
+
 var (
 	modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
 	modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
@@ -76,7 +102,7 @@ func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32,
 	n = uint32(r0)
 	if n == 0 {
 		if e1 != 0 {
-			err = error(e1)
+			err = errnoErr(e1)
 		} else {
 			err = syscall.EINVAL
 		}

文件差异内容过多而无法显示
+ 133 - 108
windows/zsyscall_windows.go


部分文件因为文件数量过多而无法显示