aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_darwin_amd64.s
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2019-06-05 14:51:57 -0400
committerRuss Cox <rsc@golang.org>2019-06-06 19:56:53 +0000
commit7d65e3a8533c90e5a3ec3d73734891a18b057fed (patch)
tree461b62764aa6344486ed30ee928d53cc31979ac2 /src/runtime/sys_darwin_amd64.s
parent47df542fefc355d65659278761d06cb9d5eba235 (diff)
downloadgo-7d65e3a8533c90e5a3ec3d73734891a18b057fed.tar.gz
go-7d65e3a8533c90e5a3ec3d73734891a18b057fed.zip
runtime: document, fix libc error checks on macOS
It matters whether we are calling a function that would return a 32-bit or 64-bit -1 on error. A few sites were wrong and this key detail was omitted from syscall/syscallX docs. Change-Id: I48a421b6cc4d2d2b5e58f790cc947e3cb2f98940 Reviewed-on: https://go-review.googlesource.com/c/go/+/180841 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/sys_darwin_amd64.s')
-rw-r--r--src/runtime/sys_darwin_amd64.s14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s
index 016b056eb3..bbe6bc14bf 100644
--- a/src/runtime/sys_darwin_amd64.s
+++ b/src/runtime/sys_darwin_amd64.s
@@ -369,7 +369,7 @@ TEXT runtime·kevent_trampoline(SB),NOSPLIT,$0
MOVQ 40(DI), R9 // arg 6 ts
MOVL 0(DI), DI // arg 1 kq
CALL libc_kevent(SB)
- CMPQ AX, $-1
+ CMPL AX, $-1
JNE ok
CALL libc_error(SB)
MOVLQSX (AX), AX // errno
@@ -556,6 +556,9 @@ TEXT runtime·pthread_cond_signal_trampoline(SB),NOSPLIT,$0
// }
// syscall must be called on the g0 stack with the
// C calling convention (use libcCall).
+//
+// syscall expects a 32-bit result and tests for 32-bit -1
+// to decide there was an error.
TEXT runtime·syscall(SB),NOSPLIT,$0
PUSHQ BP
MOVQ SP, BP
@@ -603,6 +606,9 @@ ok:
// }
// syscallX must be called on the g0 stack with the
// C calling convention (use libcCall).
+//
+// syscallX is like syscall but expects a 64-bit result
+// and tests for 64-bit -1 to decide there was an error.
TEXT runtime·syscallX(SB),NOSPLIT,$0
PUSHQ BP
MOVQ SP, BP
@@ -689,6 +695,9 @@ ok:
// }
// syscall6 must be called on the g0 stack with the
// C calling convention (use libcCall).
+//
+// syscall6 expects a 32-bit result and tests for 32-bit -1
+// to decide there was an error.
TEXT runtime·syscall6(SB),NOSPLIT,$0
PUSHQ BP
MOVQ SP, BP
@@ -739,6 +748,9 @@ ok:
// }
// syscall6X must be called on the g0 stack with the
// C calling convention (use libcCall).
+//
+// syscall6X is like syscall6 but expects a 64-bit result
+// and tests for 64-bit -1 to decide there was an error.
TEXT runtime·syscall6X(SB),NOSPLIT,$0
PUSHQ BP
MOVQ SP, BP