diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-04-05 11:42:37 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-10-21 14:07:34 +0000 |
commit | b653c878b1ad8d1b4f8d7b04201d0cb0a4156ead (patch) | |
tree | 3f4189ae0a4f5c61ae8fc0badf402d2016533289 /src/runtime/sys_darwin_arm64.s | |
parent | 6917b3c839af615e22ef479b23983d186e578bd6 (diff) | |
download | go-b653c878b1ad8d1b4f8d7b04201d0cb0a4156ead.tar.gz go-b653c878b1ad8d1b4f8d7b04201d0cb0a4156ead.zip |
runtime: change read and write to return negative errno value
The internal read and write functions used to return -1 on error;
change them to return a negative errno value instead.
This will be used by later CLs in this series.
For most targets this is a simplification, although for ones that call
into libc it is a complication.
Updates #27707
Change-Id: Id02bf9487f03e7e88e4f2b85e899e986738697ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/171823
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/sys_darwin_arm64.s')
-rw-r--r-- | src/runtime/sys_darwin_arm64.s | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime/sys_darwin_arm64.s b/src/runtime/sys_darwin_arm64.s index ac3ca74f63..8d39a0727f 100644 --- a/src/runtime/sys_darwin_arm64.s +++ b/src/runtime/sys_darwin_arm64.s @@ -35,6 +35,13 @@ TEXT runtime·write_trampoline(SB),NOSPLIT,$0 MOVW 16(R0), R2 // arg 3 count MOVW 0(R0), R0 // arg 1 fd BL libc_write(SB) + MOVD $-1, R1 + CMP R0, R1 + BNE noerr + BL libc_error(SB) + MOVW (R0), R0 + NEG R0, R0 // caller expects negative errno value +noerr: RET TEXT runtime·read_trampoline(SB),NOSPLIT,$0 @@ -42,6 +49,13 @@ TEXT runtime·read_trampoline(SB),NOSPLIT,$0 MOVW 16(R0), R2 // arg 3 count MOVW 0(R0), R0 // arg 1 fd BL libc_read(SB) + MOVD $-1, R1 + CMP R0, R1 + BNE noerr + BL libc_error(SB) + MOVW (R0), R0 + NEG R0, R0 // caller expects negative errno value +noerr: RET TEXT runtime·pipe_trampoline(SB),NOSPLIT,$0 |