From: Christopher Wedgwood Date: Sun, 13 Dec 2009 21:05:49 +0000 (-0800) Subject: syscall: fix error return bug for 64-bit return on 32-bit platform X-Git-Tag: weekly.2009-12-22~72 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=58578905bad8c1c4c2bfec974964567d1da0044f;p=gostls13.git syscall: fix error return bug for 64-bit return on 32-bit platform R=dho, rsc CC=r https://golang.org/cl/176058 --- diff --git a/src/pkg/syscall/mksyscall.sh b/src/pkg/syscall/mksyscall.sh index 07a8783ff5..2158825520 100755 --- a/src/pkg/syscall/mksyscall.sh +++ b/src/pkg/syscall/mksyscall.sh @@ -158,7 +158,6 @@ while(<>) { } $ret[$i] = sprintf("r%d", $i); $ret[$i+1] = sprintf("r%d", $i+1); - $i++; # loop will do another $i++ } $body .= "\t$name = $type($reg);\n"; } diff --git a/src/pkg/syscall/zsyscall_darwin_386.go b/src/pkg/syscall/zsyscall_darwin_386.go index 21322f62ba..f4c33edc96 100644 --- a/src/pkg/syscall/zsyscall_darwin_386.go +++ b/src/pkg/syscall/zsyscall_darwin_386.go @@ -502,8 +502,9 @@ func Rmdir(path string) (errno int) { } func Seek(fd int, offset int64, whence int) (newoffset int64, errno int) { - r0, r1, _ := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0); + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0); newoffset = int64(int64(r1)<<32 | int64(r0)); + errno = int(e1); return; } diff --git a/src/pkg/syscall/zsyscall_freebsd_386.go b/src/pkg/syscall/zsyscall_freebsd_386.go index 5ce8c81300..055d12775e 100644 --- a/src/pkg/syscall/zsyscall_freebsd_386.go +++ b/src/pkg/syscall/zsyscall_freebsd_386.go @@ -502,8 +502,9 @@ func Rmdir(path string) (errno int) { } func Seek(fd int, offset int64, whence int) (newoffset int64, errno int) { - r0, r1, _ := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0); + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0); newoffset = int64(int64(r1)<<32 | int64(r0)); + errno = int(e1); return; } diff --git a/src/pkg/syscall/zsyscall_linux_386.go b/src/pkg/syscall/zsyscall_linux_386.go index 26b07618bc..e7019b63e7 100644 --- a/src/pkg/syscall/zsyscall_linux_386.go +++ b/src/pkg/syscall/zsyscall_linux_386.go @@ -453,8 +453,9 @@ func Setuid(uid int) (errno int) { } func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, errno int) { - r0, r1, _ := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)); + r0, r1, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)); n = int64(int64(r1)<<32 | int64(r0)); + errno = int(e1); return; } @@ -476,8 +477,9 @@ func Sysinfo(info *Sysinfo_t) (errno int) { } func Tee(rfd int, wfd int, len int, flags int) (n int64, errno int) { - r0, r1, _ := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0); + r0, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0); n = int64(int64(r1)<<32 | int64(r0)); + errno = int(e1); return; } diff --git a/src/pkg/syscall/zsyscall_linux_arm.go b/src/pkg/syscall/zsyscall_linux_arm.go index f8cd8a70a3..c221d3c48d 100644 --- a/src/pkg/syscall/zsyscall_linux_arm.go +++ b/src/pkg/syscall/zsyscall_linux_arm.go @@ -453,8 +453,9 @@ func Setuid(uid int) (errno int) { } func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, errno int) { - r0, r1, _ := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)); + r0, r1, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)); n = int64(int64(r1)<<32 | int64(r0)); + errno = int(e1); return; } @@ -476,8 +477,9 @@ func Sysinfo(info *Sysinfo_t) (errno int) { } func Tee(rfd int, wfd int, len int, flags int) (n int64, errno int) { - r0, r1, _ := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0); + r0, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0); n = int64(int64(r1)<<32 | int64(r0)); + errno = int(e1); return; } @@ -637,6 +639,27 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (errno int) { return; } +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, errno int) { + var _p0 *byte; + if len(p) > 0 { + _p0 = &p[0] + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))); + n = int(r0); + errno = int(e1); + return; +} + +func sendto(s int, buf []byte, flags int, to uintptr, addrlen _Socklen) (errno int) { + var _p0 *byte; + if len(buf) > 0 { + _p0 = &buf[0] + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)); + errno = int(e1); + return; +} + func Chown(path string, uid int, gid int) (errno int) { _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(uid), uintptr(gid)); errno = int(e1); @@ -704,8 +727,9 @@ func Lstat(path string, stat *Stat_t) (errno int) { } func Seek(fd int, offset int64, whence int) (off int64, errno int) { - r0, r1, _ := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0); + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0); off = int64(int64(r1)<<32 | int64(r0)); + errno = int(e1); return; } @@ -775,24 +799,3 @@ func Statfs(path string, buf *Statfs_t) (errno int) { errno = int(e1); return; } - -func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, errno int) { - var _p0 *byte; - if len(p) > 0 { - _p0 = &p[0] - } - r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))); - n = int(r0); - errno = int(e1); - return; -} - -func sendto(s int, buf []byte, flags int, to uintptr, addrlen _Socklen) (errno int) { - var _p0 *byte; - if len(buf) > 0 { - _p0 = &buf[0] - } - _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)); - errno = int(e1); - return; -}