From: Akshat Kumar Date: Mon, 25 Feb 2013 21:40:14 +0000 (+0100) Subject: syscall: Plan9, amd64: fix syscall error handling in assembly X-Git-Tag: go1.1rc2~854 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b6e322dcf50675ad9ae3f9e587ca9b738004d035;p=gostls13.git 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 --- diff --git a/src/pkg/syscall/asm_plan9_amd64.s b/src/pkg/syscall/asm_plan9_amd64.s index 673d53f008..e363b743c1 100644 --- a/src/pkg/syscall/asm_plan9_amd64.s +++ b/src/pkg/syscall/asm_plan9_amd64.s @@ -28,7 +28,7 @@ TEXT ·Syscall(SB),7,$0 SYSCALL MOVQ AX, r1+40(SP) MOVQ $0, r2+48(SP) - CMPQ AX, $-1 + CMPL AX, $-1 JNE ok3 SUBQ $16, SP @@ -67,7 +67,7 @@ TEXT ·Syscall6(SB),7,$0 SYSCALL MOVQ AX, r1+64(SP) MOVQ $0, r2+72(SP) - CMPQ AX, $-1 + CMPL AX, $-1 JNE ok4 SUBQ $16, SP @@ -83,8 +83,8 @@ copyresult4: LEAQ err+80(SP), DI CLD - MOVSL - MOVSL + MOVSQ + MOVSQ CALL runtime·exitsyscall(SB) RET @@ -135,9 +135,9 @@ TEXT ·seek(SB),7,$0 MOVQ $SYS_SEEK, BP // syscall entry SYSCALL - CMPQ AX, $-1 + CMPL AX, $-1 JNE ok6 - MOVQ AX, 40(SP) // newoffset + MOVQ $-1, newoffset+40(SP) SUBQ $16, SP CALL syscall·errstr(SB)