Преглед на файлове

go.sys/windows: delete errors_windows.go (except APPLICATION_ERROR) and Errno

All consts in errors_windows.go (except APPLICATION_ERROR) were
"invented" at the start of windows port to have minimal impact on
existing Go packages. No point keeping them around.
Also remove Errno, since we will be using syscall.Errno everywhere anyway.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/128290044
Alex Brainman преди 11 години
родител
ревизия
70c4b52aa0

+ 2 - 2
windows/dll_windows.go

@@ -21,8 +21,8 @@ type DLLError struct {
 func (e *DLLError) Error() string { return e.Msg }
 
 // Implemented in runtime/syscall_windows.goc; we provide jumps to them in our assembly file.
-func loadlibrary(filename *uint16) (handle uintptr, err Errno)
-func getprocaddress(handle uintptr, procname *uint8) (proc uintptr, err Errno)
+func loadlibrary(filename *uint16) (handle uintptr, err syscall.Errno)
+func getprocaddress(handle uintptr, procname *uint8) (proc uintptr, err syscall.Errno)
 
 // A DLL implements access to a single DLL.
 type DLL struct {

+ 0 - 286
windows/errors_windows.go

@@ -1,286 +0,0 @@
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package windows
-
-import "syscall"
-
-// Go names for Windows errors.
-const (
-	ENOENT  syscall.Errno = ERROR_FILE_NOT_FOUND
-	ENOTDIR syscall.Errno = ERROR_PATH_NOT_FOUND
-)
-
-// Windows reserves errors >= 1<<29 for application use.
-const APPLICATION_ERROR = 1 << 29
-
-// Invented values to support what package os and others expects.
-const (
-	E2BIG syscall.Errno = APPLICATION_ERROR + iota
-	EACCES
-	EADDRINUSE
-	EADDRNOTAVAIL
-	EADV
-	EAFNOSUPPORT
-	EAGAIN
-	EALREADY
-	EBADE
-	EBADF
-	EBADFD
-	EBADMSG
-	EBADR
-	EBADRQC
-	EBADSLT
-	EBFONT
-	EBUSY
-	ECANCELED
-	ECHILD
-	ECHRNG
-	ECOMM
-	ECONNABORTED
-	ECONNREFUSED
-	ECONNRESET
-	EDEADLK
-	EDEADLOCK
-	EDESTADDRREQ
-	EDOM
-	EDOTDOT
-	EDQUOT
-	EEXIST
-	EFAULT
-	EFBIG
-	EHOSTDOWN
-	EHOSTUNREACH
-	EIDRM
-	EILSEQ
-	EINPROGRESS
-	EINTR
-	EINVAL
-	EIO
-	EISCONN
-	EISDIR
-	EISNAM
-	EKEYEXPIRED
-	EKEYREJECTED
-	EKEYREVOKED
-	EL2HLT
-	EL2NSYNC
-	EL3HLT
-	EL3RST
-	ELIBACC
-	ELIBBAD
-	ELIBEXEC
-	ELIBMAX
-	ELIBSCN
-	ELNRNG
-	ELOOP
-	EMEDIUMTYPE
-	EMFILE
-	EMLINK
-	EMSGSIZE
-	EMULTIHOP
-	ENAMETOOLONG
-	ENAVAIL
-	ENETDOWN
-	ENETRESET
-	ENETUNREACH
-	ENFILE
-	ENOANO
-	ENOBUFS
-	ENOCSI
-	ENODATA
-	ENODEV
-	ENOEXEC
-	ENOKEY
-	ENOLCK
-	ENOLINK
-	ENOMEDIUM
-	ENOMEM
-	ENOMSG
-	ENONET
-	ENOPKG
-	ENOPROTOOPT
-	ENOSPC
-	ENOSR
-	ENOSTR
-	ENOSYS
-	ENOTBLK
-	ENOTCONN
-	ENOTEMPTY
-	ENOTNAM
-	ENOTRECOVERABLE
-	ENOTSOCK
-	ENOTSUP
-	ENOTTY
-	ENOTUNIQ
-	ENXIO
-	EOPNOTSUPP
-	EOVERFLOW
-	EOWNERDEAD
-	EPERM
-	EPFNOSUPPORT
-	EPIPE
-	EPROTO
-	EPROTONOSUPPORT
-	EPROTOTYPE
-	ERANGE
-	EREMCHG
-	EREMOTE
-	EREMOTEIO
-	ERESTART
-	EROFS
-	ESHUTDOWN
-	ESOCKTNOSUPPORT
-	ESPIPE
-	ESRCH
-	ESRMNT
-	ESTALE
-	ESTRPIPE
-	ETIME
-	ETIMEDOUT
-	ETOOMANYREFS
-	ETXTBSY
-	EUCLEAN
-	EUNATCH
-	EUSERS
-	EWOULDBLOCK
-	EXDEV
-	EXFULL
-	EWINDOWS
-)
-
-// Error strings for invented errors
-var errors = [...]string{
-	E2BIG - APPLICATION_ERROR:           "argument list too long",
-	EACCES - APPLICATION_ERROR:          "permission denied",
-	EADDRINUSE - APPLICATION_ERROR:      "address already in use",
-	EADDRNOTAVAIL - APPLICATION_ERROR:   "cannot assign requested address",
-	EADV - APPLICATION_ERROR:            "advertise error",
-	EAFNOSUPPORT - APPLICATION_ERROR:    "address family not supported by protocol",
-	EAGAIN - APPLICATION_ERROR:          "resource temporarily unavailable",
-	EALREADY - APPLICATION_ERROR:        "operation already in progress",
-	EBADE - APPLICATION_ERROR:           "invalid exchange",
-	EBADF - APPLICATION_ERROR:           "bad file descriptor",
-	EBADFD - APPLICATION_ERROR:          "file descriptor in bad state",
-	EBADMSG - APPLICATION_ERROR:         "bad message",
-	EBADR - APPLICATION_ERROR:           "invalid request descriptor",
-	EBADRQC - APPLICATION_ERROR:         "invalid request code",
-	EBADSLT - APPLICATION_ERROR:         "invalid slot",
-	EBFONT - APPLICATION_ERROR:          "bad font file format",
-	EBUSY - APPLICATION_ERROR:           "device or resource busy",
-	ECANCELED - APPLICATION_ERROR:       "operation canceled",
-	ECHILD - APPLICATION_ERROR:          "no child processes",
-	ECHRNG - APPLICATION_ERROR:          "channel number out of range",
-	ECOMM - APPLICATION_ERROR:           "communication error on send",
-	ECONNABORTED - APPLICATION_ERROR:    "software caused connection abort",
-	ECONNREFUSED - APPLICATION_ERROR:    "connection refused",
-	ECONNRESET - APPLICATION_ERROR:      "connection reset by peer",
-	EDEADLK - APPLICATION_ERROR:         "resource deadlock avoided",
-	EDEADLOCK - APPLICATION_ERROR:       "resource deadlock avoided",
-	EDESTADDRREQ - APPLICATION_ERROR:    "destination address required",
-	EDOM - APPLICATION_ERROR:            "numerical argument out of domain",
-	EDOTDOT - APPLICATION_ERROR:         "RFS specific error",
-	EDQUOT - APPLICATION_ERROR:          "disk quota exceeded",
-	EEXIST - APPLICATION_ERROR:          "file exists",
-	EFAULT - APPLICATION_ERROR:          "bad address",
-	EFBIG - APPLICATION_ERROR:           "file too large",
-	EHOSTDOWN - APPLICATION_ERROR:       "host is down",
-	EHOSTUNREACH - APPLICATION_ERROR:    "no route to host",
-	EIDRM - APPLICATION_ERROR:           "identifier removed",
-	EILSEQ - APPLICATION_ERROR:          "invalid or incomplete multibyte or wide character",
-	EINPROGRESS - APPLICATION_ERROR:     "operation now in progress",
-	EINTR - APPLICATION_ERROR:           "interrupted system call",
-	EINVAL - APPLICATION_ERROR:          "invalid argument",
-	EIO - APPLICATION_ERROR:             "input/output error",
-	EISCONN - APPLICATION_ERROR:         "transport endpoint is already connected",
-	EISDIR - APPLICATION_ERROR:          "is a directory",
-	EISNAM - APPLICATION_ERROR:          "is a named type file",
-	EKEYEXPIRED - APPLICATION_ERROR:     "key has expired",
-	EKEYREJECTED - APPLICATION_ERROR:    "key was rejected by service",
-	EKEYREVOKED - APPLICATION_ERROR:     "key has been revoked",
-	EL2HLT - APPLICATION_ERROR:          "level 2 halted",
-	EL2NSYNC - APPLICATION_ERROR:        "level 2 not synchronized",
-	EL3HLT - APPLICATION_ERROR:          "level 3 halted",
-	EL3RST - APPLICATION_ERROR:          "level 3 reset",
-	ELIBACC - APPLICATION_ERROR:         "can not access a needed shared library",
-	ELIBBAD - APPLICATION_ERROR:         "accessing a corrupted shared library",
-	ELIBEXEC - APPLICATION_ERROR:        "cannot exec a shared library directly",
-	ELIBMAX - APPLICATION_ERROR:         "attempting to link in too many shared libraries",
-	ELIBSCN - APPLICATION_ERROR:         ".lib section in a.out corrupted",
-	ELNRNG - APPLICATION_ERROR:          "link number out of range",
-	ELOOP - APPLICATION_ERROR:           "too many levels of symbolic links",
-	EMEDIUMTYPE - APPLICATION_ERROR:     "wrong medium type",
-	EMFILE - APPLICATION_ERROR:          "too many open files",
-	EMLINK - APPLICATION_ERROR:          "too many links",
-	EMSGSIZE - APPLICATION_ERROR:        "message too long",
-	EMULTIHOP - APPLICATION_ERROR:       "multihop attempted",
-	ENAMETOOLONG - APPLICATION_ERROR:    "file name too long",
-	ENAVAIL - APPLICATION_ERROR:         "no XENIX semaphores available",
-	ENETDOWN - APPLICATION_ERROR:        "network is down",
-	ENETRESET - APPLICATION_ERROR:       "network dropped connection on reset",
-	ENETUNREACH - APPLICATION_ERROR:     "network is unreachable",
-	ENFILE - APPLICATION_ERROR:          "too many open files in system",
-	ENOANO - APPLICATION_ERROR:          "no anode",
-	ENOBUFS - APPLICATION_ERROR:         "no buffer space available",
-	ENOCSI - APPLICATION_ERROR:          "no CSI structure available",
-	ENODATA - APPLICATION_ERROR:         "no data available",
-	ENODEV - APPLICATION_ERROR:          "no such device",
-	ENOEXEC - APPLICATION_ERROR:         "exec format error",
-	ENOKEY - APPLICATION_ERROR:          "required key not available",
-	ENOLCK - APPLICATION_ERROR:          "no locks available",
-	ENOLINK - APPLICATION_ERROR:         "link has been severed",
-	ENOMEDIUM - APPLICATION_ERROR:       "no medium found",
-	ENOMEM - APPLICATION_ERROR:          "cannot allocate memory",
-	ENOMSG - APPLICATION_ERROR:          "no message of desired type",
-	ENONET - APPLICATION_ERROR:          "machine is not on the network",
-	ENOPKG - APPLICATION_ERROR:          "package not installed",
-	ENOPROTOOPT - APPLICATION_ERROR:     "protocol not available",
-	ENOSPC - APPLICATION_ERROR:          "no space left on device",
-	ENOSR - APPLICATION_ERROR:           "out of streams resources",
-	ENOSTR - APPLICATION_ERROR:          "device not a stream",
-	ENOSYS - APPLICATION_ERROR:          "function not implemented",
-	ENOTBLK - APPLICATION_ERROR:         "block device required",
-	ENOTCONN - APPLICATION_ERROR:        "transport endpoint is not connected",
-	ENOTEMPTY - APPLICATION_ERROR:       "directory not empty",
-	ENOTNAM - APPLICATION_ERROR:         "not a XENIX named type file",
-	ENOTRECOVERABLE - APPLICATION_ERROR: "state not recoverable",
-	ENOTSOCK - APPLICATION_ERROR:        "socket operation on non-socket",
-	ENOTSUP - APPLICATION_ERROR:         "operation not supported",
-	ENOTTY - APPLICATION_ERROR:          "inappropriate ioctl for device",
-	ENOTUNIQ - APPLICATION_ERROR:        "name not unique on network",
-	ENXIO - APPLICATION_ERROR:           "no such device or address",
-	EOPNOTSUPP - APPLICATION_ERROR:      "operation not supported",
-	EOVERFLOW - APPLICATION_ERROR:       "value too large for defined data type",
-	EOWNERDEAD - APPLICATION_ERROR:      "owner died",
-	EPERM - APPLICATION_ERROR:           "operation not permitted",
-	EPFNOSUPPORT - APPLICATION_ERROR:    "protocol family not supported",
-	EPIPE - APPLICATION_ERROR:           "broken pipe",
-	EPROTO - APPLICATION_ERROR:          "protocol error",
-	EPROTONOSUPPORT - APPLICATION_ERROR: "protocol not supported",
-	EPROTOTYPE - APPLICATION_ERROR:      "protocol wrong type for socket",
-	ERANGE - APPLICATION_ERROR:          "numerical result out of range",
-	EREMCHG - APPLICATION_ERROR:         "remote address changed",
-	EREMOTE - APPLICATION_ERROR:         "object is remote",
-	EREMOTEIO - APPLICATION_ERROR:       "remote I/O error",
-	ERESTART - APPLICATION_ERROR:        "interrupted system call should be restarted",
-	EROFS - APPLICATION_ERROR:           "read-only file system",
-	ESHUTDOWN - APPLICATION_ERROR:       "cannot send after transport endpoint shutdown",
-	ESOCKTNOSUPPORT - APPLICATION_ERROR: "socket type not supported",
-	ESPIPE - APPLICATION_ERROR:          "illegal seek",
-	ESRCH - APPLICATION_ERROR:           "no such process",
-	ESRMNT - APPLICATION_ERROR:          "srmount error",
-	ESTALE - APPLICATION_ERROR:          "stale NFS file handle",
-	ESTRPIPE - APPLICATION_ERROR:        "streams pipe error",
-	ETIME - APPLICATION_ERROR:           "timer expired",
-	ETIMEDOUT - APPLICATION_ERROR:       "connection timed out",
-	ETOOMANYREFS - APPLICATION_ERROR:    "too many references: cannot splice",
-	ETXTBSY - APPLICATION_ERROR:         "text file busy",
-	EUCLEAN - APPLICATION_ERROR:         "structure needs cleaning",
-	EUNATCH - APPLICATION_ERROR:         "protocol driver not attached",
-	EUSERS - APPLICATION_ERROR:          "too many users",
-	EWOULDBLOCK - APPLICATION_ERROR:     "resource temporarily unavailable",
-	EXDEV - APPLICATION_ERROR:           "invalid cross-device link",
-	EXFULL - APPLICATION_ERROR:          "exchange full",
-	EWINDOWS - APPLICATION_ERROR:        "not supported by windows",
-}

+ 9 - 8
windows/exec_windows.go

@@ -8,6 +8,7 @@ package windows
 
 import (
 	"sync"
+	"syscall"
 	"unicode/utf16"
 	"unsafe"
 )
@@ -149,7 +150,7 @@ func getFullPath(name string) (path string, err error) {
 			return "", err
 		}
 		if n > uint32(len(buf)) {
-			return "", EINVAL
+			return "", syscall.EINVAL
 		}
 	}
 	return UTF16ToString(buf[:n]), nil
@@ -166,7 +167,7 @@ func normalizeDir(dir string) (name string, err error) {
 	}
 	if len(ndir) > 2 && isSlash(ndir[0]) && isSlash(ndir[1]) {
 		// dir cannot have \\server\share\path form
-		return "", EINVAL
+		return "", syscall.EINVAL
 	}
 	return ndir, nil
 }
@@ -180,7 +181,7 @@ func volToUpper(ch int) int {
 
 func joinExeDirAndFName(dir, p string) (name string, err error) {
 	if len(p) == 0 {
-		return "", EINVAL
+		return "", syscall.EINVAL
 	}
 	if len(p) > 2 && isSlash(p[0]) && isSlash(p[1]) {
 		// \\server\share\path form
@@ -189,7 +190,7 @@ func joinExeDirAndFName(dir, p string) (name string, err error) {
 	if len(p) > 1 && p[1] == ':' {
 		// has drive letter
 		if len(p) == 2 {
-			return "", EINVAL
+			return "", syscall.EINVAL
 		}
 		if isSlash(p[2]) {
 			return p, nil
@@ -217,7 +218,7 @@ func joinExeDirAndFName(dir, p string) (name string, err error) {
 		}
 	}
 	// we shouldn't be here
-	return "", EINVAL
+	return "", syscall.EINVAL
 }
 
 type ProcAttr struct {
@@ -238,7 +239,7 @@ var zeroSysProcAttr SysProcAttr
 
 func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) {
 	if len(argv0) == 0 {
-		return 0, 0, EWINDOWS
+		return 0, 0, syscall.EWINDOWS
 	}
 	if attr == nil {
 		attr = &zeroProcAttr
@@ -249,7 +250,7 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
 	}
 
 	if len(attr.Files) > 3 {
-		return 0, 0, EWINDOWS
+		return 0, 0, syscall.EWINDOWS
 	}
 
 	if len(attr.Dir) != 0 {
@@ -337,5 +338,5 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle
 }
 
 func Exec(argv0 string, argv []string, envv []string) (err error) {
-	return EWINDOWS
+	return syscall.EWINDOWS
 }

+ 2 - 1
windows/security_windows.go

@@ -5,6 +5,7 @@
 package windows
 
 import (
+	"syscall"
 	"unsafe"
 )
 
@@ -123,7 +124,7 @@ func StringToSid(s string) (*SID, error) {
 // System specify target computer to search.
 func LookupSID(system, account string) (sid *SID, domain string, accType uint32, err error) {
 	if len(account) == 0 {
-		return nil, "", 0, EINVAL
+		return nil, "", 0, syscall.EINVAL
 	}
 	acc, e := UTF16PtrFromString(account)
 	if e != nil {

+ 5 - 3
windows/syscall.go

@@ -21,13 +21,15 @@
 // holds a value of type syscall.Errno.
 package windows
 
+import "syscall"
+
 // ByteSliceFromString returns a NUL-terminated slice of bytes
 // containing the text of s. If s contains a NUL byte at any
-// location, it returns (nil, EINVAL).
+// location, it returns (nil, syscall.EINVAL).
 func ByteSliceFromString(s string) ([]byte, error) {
 	for i := 0; i < len(s); i++ {
 		if s[i] == 0 {
-			return nil, EINVAL
+			return nil, syscall.EINVAL
 		}
 	}
 	a := make([]byte, len(s)+1)
@@ -37,7 +39,7 @@ func ByteSliceFromString(s string) ([]byte, error) {
 
 // BytePtrFromString returns a pointer to a NUL-terminated array of
 // bytes containing the text of s. If s contains a NUL byte at any
-// location, it returns (nil, EINVAL).
+// location, it returns (nil, syscall.EINVAL).
 func BytePtrFromString(s string) (*byte, error) {
 	a, err := ByteSliceFromString(s)
 	if err != nil {

+ 32 - 65
windows/syscall_windows.go

@@ -31,11 +31,11 @@ func StringToUTF16(s string) []uint16 {
 
 // UTF16FromString returns the UTF-16 encoding of the UTF-8 string
 // s, with a terminating NUL added. If s contains a NUL byte at any
-// location, it returns (nil, EINVAL).
+// location, it returns (nil, syscall.EINVAL).
 func UTF16FromString(s string) ([]uint16, error) {
 	for i := 0; i < len(s); i++ {
 		if s[i] == 0 {
-			return nil, EINVAL
+			return nil, syscall.EINVAL
 		}
 	}
 	return utf16.Encode([]rune(s + "\x00")), nil
@@ -60,7 +60,7 @@ func StringToUTF16Ptr(s string) *uint16 { return &StringToUTF16(s)[0] }
 
 // UTF16PtrFromString returns pointer to the UTF-16 encoding of
 // the UTF-8 string s, with a terminating NUL added. If s
-// contains a NUL byte at any location, it returns (nil, EINVAL).
+// contains a NUL byte at any location, it returns (nil, syscall.EINVAL).
 func UTF16PtrFromString(s string) (*uint16, error) {
 	a, err := UTF16FromString(s)
 	if err != nil {
@@ -71,41 +71,6 @@ func UTF16PtrFromString(s string) (*uint16, error) {
 
 func Getpagesize() int { return 4096 }
 
-// Errno is the Windows error number.
-type Errno uintptr
-
-func langid(pri, sub uint16) uint32 { return uint32(sub)<<10 | uint32(pri) }
-
-func (e Errno) Error() string {
-	// deal with special go errors
-	idx := int(e - APPLICATION_ERROR)
-	if 0 <= idx && idx < len(errors) {
-		return errors[idx]
-	}
-	// ask windows for the remaining errors
-	var flags uint32 = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_IGNORE_INSERTS
-	b := make([]uint16, 300)
-	n, err := FormatMessage(flags, 0, uint32(e), langid(LANG_ENGLISH, SUBLANG_ENGLISH_US), b, nil)
-	if err != nil {
-		n, err = FormatMessage(flags, 0, uint32(e), 0, b, nil)
-		if err != nil {
-			return "winapi error #" + itoa(int(e))
-		}
-	}
-	// trim terminating \r and \n
-	for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- {
-	}
-	return string(utf16.Decode(b[:n]))
-}
-
-func (e Errno) Temporary() bool {
-	return e == EINTR || e == EMFILE || e.Timeout()
-}
-
-func (e Errno) Timeout() bool {
-	return e == EAGAIN || e == EWOULDBLOCK || e == ETIMEDOUT
-}
-
 // 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.
@@ -321,7 +286,7 @@ func Seek(fd Handle, offset int64, whence int) (newoffset int64, err error) {
 	// use GetFileType to check pipe, pipe can't do seek
 	ft, _ := GetFileType(fd)
 	if ft == FILE_TYPE_PIPE {
-		return 0, EPIPE
+		return 0, syscall.EPIPE
 	}
 	rlo, e := SetFilePointer(fd, lo, &hi, w)
 	if e != nil {
@@ -437,7 +402,7 @@ func Gettimeofday(tv *Timeval) (err error) {
 
 func Pipe(p []Handle) (err error) {
 	if len(p) != 2 {
-		return EINVAL
+		return syscall.EINVAL
 	}
 	var r, w Handle
 	e := CreatePipe(&r, &w, makeInheritSa(), 0)
@@ -451,7 +416,7 @@ func Pipe(p []Handle) (err error) {
 
 func Utimes(path string, tv []Timeval) (err error) {
 	if len(tv) != 2 {
-		return EINVAL
+		return syscall.EINVAL
 	}
 	pathp, e := UTF16PtrFromString(path)
 	if e != nil {
@@ -471,7 +436,7 @@ func Utimes(path string, tv []Timeval) (err error) {
 
 func UtimesNano(path string, ts []Timespec) (err error) {
 	if len(ts) != 2 {
-		return EINVAL
+		return syscall.EINVAL
 	}
 	pathp, e := UTF16PtrFromString(path)
 	if e != nil {
@@ -495,7 +460,7 @@ func Fsync(fd Handle) (err error) {
 
 func Chmod(path string, mode uint32) (err error) {
 	if mode == 0 {
-		return EINVAL
+		return syscall.EINVAL
 	}
 	p, e := UTF16PtrFromString(path)
 	if e != nil {
@@ -598,7 +563,7 @@ type SockaddrInet4 struct {
 
 func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, int32, error) {
 	if sa.Port < 0 || sa.Port > 0xFFFF {
-		return nil, 0, EINVAL
+		return nil, 0, syscall.EINVAL
 	}
 	sa.raw.Family = AF_INET
 	p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
@@ -619,7 +584,7 @@ type SockaddrInet6 struct {
 
 func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, int32, error) {
 	if sa.Port < 0 || sa.Port > 0xFFFF {
-		return nil, 0, EINVAL
+		return nil, 0, syscall.EINVAL
 	}
 	sa.raw.Family = AF_INET6
 	p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
@@ -638,13 +603,13 @@ type SockaddrUnix struct {
 
 func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, int32, error) {
 	// TODO(brainman): implement SockaddrUnix.sockaddr()
-	return nil, 0, EWINDOWS
+	return nil, 0, syscall.EWINDOWS
 }
 
 func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) {
 	switch rsa.Addr.Family {
 	case AF_UNIX:
-		return nil, EWINDOWS
+		return nil, syscall.EWINDOWS
 
 	case AF_INET:
 		pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
@@ -667,12 +632,12 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) {
 		}
 		return sa, nil
 	}
-	return nil, EAFNOSUPPORT
+	return nil, syscall.EAFNOSUPPORT
 }
 
 func Socket(domain, typ, proto int) (fd Handle, err error) {
 	if domain == AF_INET6 && SocketDisableIPv6 {
-		return InvalidHandle, EAFNOSUPPORT
+		return InvalidHandle, syscall.EAFNOSUPPORT
 	}
 	return socket(int32(domain), int32(typ), int32(proto))
 }
@@ -768,7 +733,7 @@ func connectEx(s Handle, name unsafe.Pointer, namelen int32, sendBuf *byte, send
 		if e1 != 0 {
 			err = error(e1)
 		} else {
-			err = EINVAL
+			err = syscall.EINVAL
 		}
 	}
 	return
@@ -833,12 +798,12 @@ func NsecToTimespec(nsec int64) (ts Timespec) {
 
 // TODO(brainman): fix all needed for net
 
-func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) { return 0, nil, EWINDOWS }
+func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) { return 0, nil, syscall.EWINDOWS }
 func Recvfrom(fd Handle, p []byte, flags int) (n int, from Sockaddr, err error) {
-	return 0, nil, EWINDOWS
+	return 0, nil, syscall.EWINDOWS
 }
-func Sendto(fd Handle, p []byte, flags int, to Sockaddr) (err error)       { return EWINDOWS }
-func SetsockoptTimeval(fd Handle, level, opt int, tv *Timeval) (err error) { return EWINDOWS }
+func Sendto(fd Handle, p []byte, flags int, to Sockaddr) (err error)       { return syscall.EWINDOWS }
+func SetsockoptTimeval(fd Handle, level, opt int, tv *Timeval) (err error) { return syscall.EWINDOWS }
 
 // The Linger struct is wrong but we only noticed after Go 1.
 // sysLinger is the real system call structure.
@@ -867,7 +832,7 @@ type IPv6Mreq struct {
 	Interface uint32
 }
 
-func GetsockoptInt(fd Handle, level, opt int) (int, error) { return -1, EWINDOWS }
+func GetsockoptInt(fd Handle, level, opt int) (int, error) { return -1, syscall.EWINDOWS }
 
 func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) {
 	sys := sysLinger{Onoff: uint16(l.Onoff), Linger: uint16(l.Linger)}
@@ -880,7 +845,9 @@ func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) {
 func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) {
 	return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq)))
 }
-func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return EWINDOWS }
+func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) {
+	return syscall.EWINDOWS
+}
 
 func Getpid() (pid int) { return int(getCurrentProcessId()) }
 
@@ -941,20 +908,20 @@ func Getppid() (ppid int) {
 }
 
 // TODO(brainman): fix all needed for os
-func Fchdir(fd Handle) (err error)             { return EWINDOWS }
-func Link(oldpath, newpath string) (err error) { return EWINDOWS }
-func Symlink(path, link string) (err error)    { return EWINDOWS }
+func Fchdir(fd Handle) (err error)             { return syscall.EWINDOWS }
+func Link(oldpath, newpath string) (err error) { return syscall.EWINDOWS }
+func Symlink(path, link string) (err error)    { return syscall.EWINDOWS }
 
-func Fchmod(fd Handle, mode uint32) (err error)        { return EWINDOWS }
-func Chown(path string, uid int, gid int) (err error)  { return EWINDOWS }
-func Lchown(path string, uid int, gid int) (err error) { return EWINDOWS }
-func Fchown(fd Handle, uid int, gid int) (err error)   { return EWINDOWS }
+func Fchmod(fd Handle, mode uint32) (err error)        { return syscall.EWINDOWS }
+func Chown(path string, uid int, gid int) (err error)  { return syscall.EWINDOWS }
+func Lchown(path string, uid int, gid int) (err error) { return syscall.EWINDOWS }
+func Fchown(fd Handle, uid int, gid int) (err error)   { return syscall.EWINDOWS }
 
 func Getuid() (uid int)                  { return -1 }
 func Geteuid() (euid int)                { return -1 }
 func Getgid() (gid int)                  { return -1 }
 func Getegid() (egid int)                { return -1 }
-func Getgroups() (gids []int, err error) { return nil, EWINDOWS }
+func Getgroups() (gids []int, err error) { return nil, syscall.EWINDOWS }
 
 type Signal int
 
@@ -994,7 +961,7 @@ func Readlink(path string, buf []byte) (n int, err error) {
 	if uintptr(bytesReturned) < unsafe.Sizeof(*rdb) ||
 		rdb.ReparseTag != IO_REPARSE_TAG_SYMLINK {
 		// the path is not a symlink but another type of reparse point
-		return -1, ENOENT
+		return -1, syscall.ENOENT
 	}
 
 	s := UTF16ToString((*[0xffff]uint16)(unsafe.Pointer(&rdb.PathBuffer[0]))[:rdb.PrintNameLength/2])

Файловите разлики са ограничени, защото са твърде много
+ 112 - 112
windows/zsyscall_windows_386.go


Файловите разлики са ограничени, защото са твърде много
+ 112 - 112
windows/zsyscall_windows_amd64.go


+ 5 - 0
windows/ztypes_windows.go

@@ -4,6 +4,8 @@
 
 package windows
 
+import "syscall"
+
 const (
 	// Windows errors.
 	ERROR_FILE_NOT_FOUND      syscall.Errno = 2
@@ -176,6 +178,9 @@ const (
 
 	CTRL_C_EVENT     = 0
 	CTRL_BREAK_EVENT = 1
+
+	// Windows reserves errors >= 1<<29 for application use.
+	APPLICATION_ERROR = 1 << 29
 )
 
 const (

Някои файлове не бяха показани, защото твърде много файлове са промени