From 03934a56326d43c1c8bb185979a90830fd25f880 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor <ian@gcc.gnu.org> Date: Fri, 23 Mar 2012 18:41:07 +0000 Subject: [PATCH] syscall: Fix errno handling in syscall.Syscall and friends. From-SVN: r185746 --- libgo/go/syscall/syscall_unix.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libgo/go/syscall/syscall_unix.go b/libgo/go/syscall/syscall_unix.go index e3c6629ed077..d4bff9efc9c1 100644 --- a/libgo/go/syscall/syscall_unix.go +++ b/libgo/go/syscall/syscall_unix.go @@ -31,6 +31,7 @@ const darwinAMD64 = runtime.GOOS == "darwin" && runtime.GOARCH == "amd64" // expects a 32-bit one. func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { Entersyscall() + SetErrno(0) var r uintptr if unsafe.Sizeof(r) == 4 { r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), 0, 0, 0) @@ -46,6 +47,7 @@ func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { Entersyscall() + SetErrno(0) var r uintptr if unsafe.Sizeof(r) == 4 { r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), @@ -63,6 +65,7 @@ func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r uintptr + SetErrno(0) if unsafe.Sizeof(r) == 4 { r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), 0, 0, 0) r = uintptr(r1) @@ -76,6 +79,7 @@ func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r uintptr + SetErrno(0) if unsafe.Sizeof(r) == 4 { r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), int32(a4), int32(a5), int32(a6)) -- GitLab