Commit b6e322dc authored by Akshat Kumar's avatar Akshat Kumar Committed by Ron Minnich

syscall: Plan9, amd64: fix syscall error handling in assembly

Syscalls return `-1' on error and the representation is always
32-bits. The `$-1' literal in 64-bit assembly is always the
64-bit representation. So this change makes sure that we
always do a 32-bit comparison when checking for error.
Also makes sure that in the error case, we return a 64-bit
`-1' from runtime.seek.

Fixes the arithmetic for handling the error-string in
runtime.Syscall6.

R=golang-dev, rminnich, rsc, ality, minux.ma
CC=golang-dev
https://golang.org/cl/7399052
parent 4eb7ba74
...@@ -28,7 +28,7 @@ TEXT ·Syscall(SB),7,$0 ...@@ -28,7 +28,7 @@ TEXT ·Syscall(SB),7,$0
SYSCALL SYSCALL
MOVQ AX, r1+40(SP) MOVQ AX, r1+40(SP)
MOVQ $0, r2+48(SP) MOVQ $0, r2+48(SP)
CMPQ AX, $-1 CMPL AX, $-1
JNE ok3 JNE ok3
SUBQ $16, SP SUBQ $16, SP
...@@ -67,7 +67,7 @@ TEXT ·Syscall6(SB),7,$0 ...@@ -67,7 +67,7 @@ TEXT ·Syscall6(SB),7,$0
SYSCALL SYSCALL
MOVQ AX, r1+64(SP) MOVQ AX, r1+64(SP)
MOVQ $0, r2+72(SP) MOVQ $0, r2+72(SP)
CMPQ AX, $-1 CMPL AX, $-1
JNE ok4 JNE ok4
SUBQ $16, SP SUBQ $16, SP
...@@ -83,8 +83,8 @@ copyresult4: ...@@ -83,8 +83,8 @@ copyresult4:
LEAQ err+80(SP), DI LEAQ err+80(SP), DI
CLD CLD
MOVSL MOVSQ
MOVSL MOVSQ
CALL runtime·exitsyscall(SB) CALL runtime·exitsyscall(SB)
RET RET
...@@ -135,9 +135,9 @@ TEXT ·seek(SB),7,$0 ...@@ -135,9 +135,9 @@ TEXT ·seek(SB),7,$0
MOVQ $SYS_SEEK, BP // syscall entry MOVQ $SYS_SEEK, BP // syscall entry
SYSCALL SYSCALL
CMPQ AX, $-1 CMPL AX, $-1
JNE ok6 JNE ok6
MOVQ AX, 40(SP) // newoffset MOVQ $-1, newoffset+40(SP)
SUBQ $16, SP SUBQ $16, SP
CALL syscall·errstr(SB) CALL syscall·errstr(SB)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment