1
0
mirror of https://github.com/golang/go synced 2024-11-21 17:44:40 -07:00

cgo: fixes callback for windows amd64

R=rsc
CC=golang-dev
https://golang.org/cl/4826041
This commit is contained in:
Wei Guangjing 2011-08-26 16:43:37 -04:00 committed by Russ Cox
parent 26d9c804f8
commit e753512e2d
3 changed files with 38 additions and 5 deletions

View File

@ -11,6 +11,20 @@ CGOFILES=\
CGO_OFILES=\
c-life.o\
ifeq ($(GOOS),windows)
ifeq ($(GOARCH),amd64)
CGO_OFILES+=\
lib64_libmingwex_a-wassert.o\
lib64_libmingw32_a-mingw_helpers.o\
lib64_libmingwex_a-wassert.o:
ar -x /mingw/x86_64-w64-mingw32/lib/libmingwex.a lib64_libmingwex_a-wassert.o
lib64_libmingw32_a-mingw_helpers.o:
ar -x /mingw/x86_64-w64-mingw32/lib/libmingw32.a lib64_libmingw32_a-mingw_helpers.o
endif
endif
CLEANFILES+=life

View File

@ -448,19 +448,19 @@ TEXT runtime·asmcgocall(SB),7,$0
MOVQ (g_sched+gobuf_sp)(SI), SP
// Now on a scheduling stack (a pthread-created stack).
SUBQ $32, SP
SUBQ $48, SP
ANDQ $~15, SP // alignment for gcc ABI
MOVQ DI, 16(SP) // save g
MOVQ DX, 8(SP) // save SP
MOVQ DI, 32(SP) // save g
MOVQ DX, 24(SP) // save SP
MOVQ BX, DI // DI = first argument in AMD64 ABI
MOVQ BX, CX // CX = first argument in Win64
CALL AX
// Restore registers, g, stack pointer.
get_tls(CX)
MOVQ 16(SP), DI
MOVQ 32(SP), DI
MOVQ DI, g(CX)
MOVQ 8(SP), SP
MOVQ 24(SP), SP
RET
// cgocallback(void (*fn)(void*), void *frame, uintptr framesize)

View File

@ -32,7 +32,11 @@ EXT(crosscall_amd64):
pushq %r14
pushq %r15
#if defined(_WIN64)
call *%rcx /* fn */
#else
call *%rdi /* fn */
#endif
popq %r15
popq %r14
@ -58,10 +62,21 @@ EXT(crosscall2):
movq %r14, 0x30(%rsp)
movq %r15, 0x38(%rsp)
#if defined(_WIN64)
// Win64 save RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15
movq %rdi, 0x40(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0(%rsp) /* arg */
movq %r8, 8(%rsp) /* argsize (includes padding) */
call %rcx /* fn */
#else
movq %rsi, 0(%rsp) /* arg */
movq %rdx, 8(%rsp) /* argsize (includes padding) */
call *%rdi /* fn */
#endif
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %rbp
@ -69,5 +84,9 @@ EXT(crosscall2):
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %r15
#if defined(__WIN64)
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
#endif
addq $0x58, %rsp
ret