]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: Plan9, amd64: fix syscall error handling in assembly
authorAkshat Kumar <seed@mail.nanosouffle.net>
Mon, 25 Feb 2013 21:40:14 +0000 (22:40 +0100)
committerRon Minnich <rminnich@gmail.com>
Mon, 25 Feb 2013 21:40:14 +0000 (22:40 +0100)
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

src/pkg/syscall/asm_plan9_amd64.s

index 673d53f008c4ff0b9eed04e1c62b4d6c0d22f3b8..e363b743c1e6568e1b300f6731d4e7d4c5830ea8 100644 (file)
@@ -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)