diff options
author | Clément Chigot <clement.chigot@atos.net> | 2019-04-29 16:15:47 +0200 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-04-29 21:26:07 +0000 |
commit | d5014ec05b3cfe2589974b240863b5439e204417 (patch) | |
tree | 41eb0cb26d541ddbdd6cc08a8ed2e1553d4674e6 /src/runtime/os2_aix.go | |
parent | fbc6a972226f889d2ab1150468755615098ee80f (diff) | |
download | go-d5014ec05b3cfe2589974b240863b5439e204417.tar.gz go-d5014ec05b3cfe2589974b240863b5439e204417.zip |
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>
Diffstat (limited to 'src/runtime/os2_aix.go')
-rw-r--r-- | src/runtime/os2_aix.go | 5 |
1 files changed, 4 insertions, 1 deletions
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) } |