]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make mmap return 0 instead of -1 on aix/ppc64
authorClément Chigot <clement.chigot@atos.net>
Mon, 29 Apr 2019 14:15:47 +0000 (16:15 +0200)
committerIan Lance Taylor <iant@golang.org>
Mon, 29 Apr 2019 21:26:07 +0000 (21:26 +0000)
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

index 750c8c6115e8b87a421927f9a19ba51119f5202d..162d93ef5226fcc552c04cb976f84f1c8b7865ef 100644 (file)
@@ -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)
 }