1
0
mirror of https://github.com/golang/go synced 2024-09-29 13:14:28 -06:00

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>
This commit is contained in:
Russ Cox 2019-06-05 14:51:57 -04:00
parent 47df542fef
commit 7d65e3a853
2 changed files with 15 additions and 3 deletions

View File

@ -10,7 +10,7 @@ TEXT runtime·res_init_trampoline(SB),NOSPLIT,$0
PUSHQ BP
MOVQ SP, BP
CALL libc_res_init(SB)
CMPQ AX, $-1
CMPL AX, $-1
JNE ok
CALL libc_error(SB)
ok:
@ -28,7 +28,7 @@ TEXT runtime·res_search_trampoline(SB),NOSPLIT,$0
MOVQ 0(BX), DI // arg 1 name
CALL libc_res_search(SB)
XORL DX, DX
CMPQ AX, $-1
CMPL AX, $-1
JNE ok
CALL libc_error(SB)
MOVLQSX (AX), DX // move return from libc_error into DX

View File

@ -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