]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: return errno value from Solaris mmap as expected
authorIan Lance Taylor <iant@golang.org>
Fri, 12 Feb 2016 02:09:34 +0000 (18:09 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 12 Feb 2016 19:20:19 +0000 (19:20 +0000)
The code in mem_bsd.go expects that when mmap fails it will return a
positive errno value.  This fixes the Solaris implementation of mmap to
work as expected.

Change-Id: Id1c34a9b916e8dc955ced90ea2f4af8321d92265
Reviewed-on: https://go-review.googlesource.com/19477
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/os3_solaris.go

index 7bda07bd4a5b793f9473adf3a4c5be46a12deb71..7ebb35c8e9c462e741dd7c0f93904f5c5c9dc26e 100644 (file)
@@ -442,7 +442,21 @@ func madvise(addr unsafe.Pointer, n uintptr, flags int32) {
 
 //go:nosplit
 func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) unsafe.Pointer {
-       return unsafe.Pointer(sysvicall6(&libc_mmap, uintptr(addr), uintptr(n), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(off)))
+       p, err := doMmap(uintptr(addr), n, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(off))
+       if p == ^uintptr(0) {
+               return unsafe.Pointer(err)
+       }
+       return unsafe.Pointer(p)
+}
+
+//go:nosplit
+func doMmap(addr, n, prot, flags, fd, off uintptr) (uintptr, uintptr) {
+       var libcall libcall
+       libcall.fn = uintptr(unsafe.Pointer(&libc_mmap))
+       libcall.n = 6
+       libcall.args = uintptr(noescape(unsafe.Pointer(&addr)))
+       asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&libcall))
+       return libcall.r1, libcall.err
 }
 
 //go:nosplit