aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_darwin_amd64.s
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2017-10-16 20:28:29 -0400
committerAustin Clements <austin@google.com>2017-10-18 19:22:08 +0000
commit193088b246f4bbe9a7d3a84ec7f4cc6786dac043 (patch)
tree5798ac6c11085c6364b3af1120233b64a5c902da /src/runtime/sys_darwin_amd64.s
parent3ba818c894a1aa1e616a8531a1262d4f9d54f02a (diff)
downloadgo-193088b246f4bbe9a7d3a84ec7f4cc6786dac043.tar.gz
go-193088b246f4bbe9a7d3a84ec7f4cc6786dac043.zip
runtime: separate error result for mmap
Currently mmap returns an unsafe.Pointer that encodes OS errors as values less than 4096. In practice this is okay, but it borders on being really unsafe: for example, the value has to be checked immediately after return and if stack copying were ever to observe such a value, it would panic. It's also not remotely idiomatic. Fix this by making mmap return a separate pointer value and error, like a normal Go function. Updates #22218. Change-Id: Iefd965095ffc82cc91118872753a5d39d785c3a6 Reviewed-on: https://go-review.googlesource.com/71270 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/sys_darwin_amd64.s')
-rw-r--r--src/runtime/sys_darwin_amd64.s8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s
index 88f509352e..f549efdbf6 100644
--- a/src/runtime/sys_darwin_amd64.s
+++ b/src/runtime/sys_darwin_amd64.s
@@ -374,7 +374,13 @@ TEXT runtime·mmap(SB),NOSPLIT,$0
MOVL off+28(FP), R9 // arg 6 offset
MOVL $(0x2000000+197), AX // syscall entry
SYSCALL
- MOVQ AX, ret+32(FP)
+ JCC ok
+ MOVQ $0, p+32(FP)
+ MOVQ AX, err+40(FP)
+ RET
+ok:
+ MOVQ AX, p+32(FP)
+ MOVQ $0, err+40(FP)
RET
TEXT runtime·munmap(SB),NOSPLIT,$0