]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: document, fix libc error checks on macOS
authorRuss Cox <rsc@golang.org>
Wed, 5 Jun 2019 18:51:57 +0000 (14:51 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 6 Jun 2019 19:56:53 +0000 (19:56 +0000)
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>
src/runtime/lookup_darwin_amd64.s
src/runtime/sys_darwin_amd64.s

index 2e3068649ad99a1cf17708fc9d6aaef47ff1678c..587e43612ea107a528aec0f3b86945535337f1dc 100644 (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
index 016b056eb34dd99e9308e5697643e8501a54e462..bbe6bc14bff8c00397bac5cf78bb98c277a80d3a 100644 (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