Skip to content

Commit

Permalink
runtime: fix Plan 9 build for new C calling convention
Browse files Browse the repository at this point in the history
LGTM=0intro, rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/132320043
  • Loading branch information
ality committed Aug 28, 2014
1 parent 13c69f0 commit b3de7f2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
27 changes: 14 additions & 13 deletions src/pkg/runtime/sys_plan9_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -217,28 +217,29 @@ TEXT runtime·setfpmasks(SB),NOSPLIT,$0

#define ERRMAX 128 /* from os_plan9.h */

// func errstr() String
// void errstr(int8 *buf, int32 len)
TEXT errstr<>(SB),NOSPLIT,$0
MOVL $41, AX
INT $64
RET

// func errstr() string
// Only used by package syscall.
// Grab error string due to a syscall made
// in entersyscall mode, without going
// through the allocator (issue 4994).
// See ../syscall/asm_plan9_386.s:/·Syscall/
TEXT runtime·errstr(SB),NOSPLIT,$0
TEXT runtime·errstr(SB),NOSPLIT,$8-8
get_tls(AX)
MOVL g(AX), BX
MOVL g_m(BX), BX
MOVL m_errstr(BX), CX
MOVL CX, ret_base+0(FP)
MOVL $ERRMAX, ret_len+4(FP)
MOVL $41, AX
INT $64

// syscall requires caller-save
MOVL ret_base+0(FP), CX

// push the argument
PUSHL CX
MOVL CX, 0(SP)
MOVL $ERRMAX, 4(SP)
CALL errstr<>(SB)
CALL runtime·findnull(SB)
POPL CX
MOVL 4(SP), AX
MOVL AX, ret_len+4(FP)
MOVL 0(SP), AX
MOVL AX, ret_base+0(FP)
RET
29 changes: 15 additions & 14 deletions src/pkg/runtime/sys_plan9_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -212,28 +212,29 @@ TEXT runtime·setfpmasks(SB),NOSPLIT,$8

#define ERRMAX 128 /* from os_plan9.h */

// func errstr() String
// void errstr(int8 *buf, int32 len)
TEXT errstr<>(SB),NOSPLIT,$0
MOVQ $41, BP
SYSCALL
RET

// func errstr() string
// Only used by package syscall.
// Grab error string due to a syscall made
// in entersyscall mode, without going
// through the allocator (issue 4994).
// See ../syscall/asm_plan9_386.s:/·Syscall/
TEXT runtime·errstr(SB),NOSPLIT,$0
// See ../syscall/asm_plan9_amd64.s:/·Syscall/
TEXT runtime·errstr(SB),NOSPLIT,$16-16
get_tls(AX)
MOVQ g(AX), BX
MOVQ g_m(BX), BX
MOVQ m_errstr(BX), CX
MOVQ CX, ret_base+0(FP)
MOVQ $ERRMAX, ret_len+8(FP)
MOVQ $41, BP
SYSCALL

// syscall requires caller-save
MOVQ ret_base+0(FP), CX

// push the argument
PUSHQ CX
MOVQ CX, 0(SP)
MOVQ $ERRMAX, 8(SP)
CALL errstr<>(SB)
CALL runtime·findnull(SB)
POPQ CX
MOVQ 8(SP), AX
MOVQ AX, ret_len+8(FP)
MOVQ 0(SP), AX
MOVQ AX, ret_base+0(FP)
RET

0 comments on commit b3de7f2

Please sign in to comment.