From d5014ec05b3cfe2589974b240863b5439e204417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net> Date: Mon, 29 Apr 2019 16:15:47 +0200 Subject: [PATCH] runtime: make mmap return 0 instead of -1 on aix/ppc64 Most of the platforms are returning 0 instead of -1 when mmap syscalls is failing. This patch corrects it for AIX in order to fix TestMmapErrorSign and to improve AIX compatibility. Change-Id: I1dad88d0e69163ad55c504b2b4a997892fd876cd Reviewed-on: https://go-review.googlesource.com/c/go/+/174297 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> --- src/runtime/os2_aix.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/runtime/os2_aix.go b/src/runtime/os2_aix.go index 750c8c6115..162d93ef52 100644 --- a/src/runtime/os2_aix.go +++ b/src/runtime/os2_aix.go @@ -436,8 +436,11 @@ func pipe(fd *int32) int32 { // by the assembly routine as 0. // The err result is an OS error code such as ENOMEM. //go:nosplit -func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (p unsafe.Pointer, err int) { +func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (unsafe.Pointer, int) { r, err0 := syscall6(&libc_mmap, uintptr(addr), uintptr(n), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(off)) + if r == ^uintptr(0) { + return nil, int(err0) + } return unsafe.Pointer(r), int(err0) } -- 2.30.9