mirror of
https://github.com/golang/go
synced 2024-11-25 11:17:56 -07:00
cgo: fixes callback for windows amd64
R=rsc CC=golang-dev https://golang.org/cl/4826041
This commit is contained in:
parent
26d9c804f8
commit
e753512e2d
@ -12,6 +12,20 @@ CGOFILES=\
|
|||||||
CGO_OFILES=\
|
CGO_OFILES=\
|
||||||
c-life.o\
|
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
|
CLEANFILES+=life
|
||||||
|
|
||||||
include ../../../src/Make.pkg
|
include ../../../src/Make.pkg
|
||||||
|
@ -448,19 +448,19 @@ TEXT runtime·asmcgocall(SB),7,$0
|
|||||||
MOVQ (g_sched+gobuf_sp)(SI), SP
|
MOVQ (g_sched+gobuf_sp)(SI), SP
|
||||||
|
|
||||||
// Now on a scheduling stack (a pthread-created stack).
|
// Now on a scheduling stack (a pthread-created stack).
|
||||||
SUBQ $32, SP
|
SUBQ $48, SP
|
||||||
ANDQ $~15, SP // alignment for gcc ABI
|
ANDQ $~15, SP // alignment for gcc ABI
|
||||||
MOVQ DI, 16(SP) // save g
|
MOVQ DI, 32(SP) // save g
|
||||||
MOVQ DX, 8(SP) // save SP
|
MOVQ DX, 24(SP) // save SP
|
||||||
MOVQ BX, DI // DI = first argument in AMD64 ABI
|
MOVQ BX, DI // DI = first argument in AMD64 ABI
|
||||||
MOVQ BX, CX // CX = first argument in Win64
|
MOVQ BX, CX // CX = first argument in Win64
|
||||||
CALL AX
|
CALL AX
|
||||||
|
|
||||||
// Restore registers, g, stack pointer.
|
// Restore registers, g, stack pointer.
|
||||||
get_tls(CX)
|
get_tls(CX)
|
||||||
MOVQ 16(SP), DI
|
MOVQ 32(SP), DI
|
||||||
MOVQ DI, g(CX)
|
MOVQ DI, g(CX)
|
||||||
MOVQ 8(SP), SP
|
MOVQ 24(SP), SP
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// cgocallback(void (*fn)(void*), void *frame, uintptr framesize)
|
// cgocallback(void (*fn)(void*), void *frame, uintptr framesize)
|
||||||
|
@ -32,7 +32,11 @@ EXT(crosscall_amd64):
|
|||||||
pushq %r14
|
pushq %r14
|
||||||
pushq %r15
|
pushq %r15
|
||||||
|
|
||||||
|
#if defined(_WIN64)
|
||||||
|
call *%rcx /* fn */
|
||||||
|
#else
|
||||||
call *%rdi /* fn */
|
call *%rdi /* fn */
|
||||||
|
#endif
|
||||||
|
|
||||||
popq %r15
|
popq %r15
|
||||||
popq %r14
|
popq %r14
|
||||||
@ -58,10 +62,21 @@ EXT(crosscall2):
|
|||||||
movq %r14, 0x30(%rsp)
|
movq %r14, 0x30(%rsp)
|
||||||
movq %r15, 0x38(%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 %rsi, 0(%rsp) /* arg */
|
||||||
movq %rdx, 8(%rsp) /* argsize (includes padding) */
|
movq %rdx, 8(%rsp) /* argsize (includes padding) */
|
||||||
|
|
||||||
call *%rdi /* fn */
|
call *%rdi /* fn */
|
||||||
|
#endif
|
||||||
|
|
||||||
movq 0x10(%rsp), %rbx
|
movq 0x10(%rsp), %rbx
|
||||||
movq 0x18(%rsp), %rbp
|
movq 0x18(%rsp), %rbp
|
||||||
@ -69,5 +84,9 @@ EXT(crosscall2):
|
|||||||
movq 0x28(%rsp), %r13
|
movq 0x28(%rsp), %r13
|
||||||
movq 0x30(%rsp), %r14
|
movq 0x30(%rsp), %r14
|
||||||
movq 0x38(%rsp), %r15
|
movq 0x38(%rsp), %r15
|
||||||
|
#if defined(__WIN64)
|
||||||
|
movq 0x40(%rsp), %rdi
|
||||||
|
movq 0x48(%rsp), %rsi
|
||||||
|
#endif
|
||||||
addq $0x58, %rsp
|
addq $0x58, %rsp
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user