summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/cgo
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/cgo')
-rw-r--r--src/pkg/runtime/cgo/amd64.S19
-rw-r--r--src/pkg/runtime/cgo/util.c2
2 files changed, 20 insertions, 1 deletions
diff --git a/src/pkg/runtime/cgo/amd64.S b/src/pkg/runtime/cgo/amd64.S
index 083c2bc94..6c1a4c8e9 100644
--- a/src/pkg/runtime/cgo/amd64.S
+++ b/src/pkg/runtime/cgo/amd64.S
@@ -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
diff --git a/src/pkg/runtime/cgo/util.c b/src/pkg/runtime/cgo/util.c
index 9d96521f5..e06b6f64d 100644
--- a/src/pkg/runtime/cgo/util.c
+++ b/src/pkg/runtime/cgo/util.c
@@ -18,7 +18,7 @@ x_cgo_malloc(void *p)
void (*_cgo_malloc)(void*) = x_cgo_malloc;
-/* Stub for calling from Go */
+/* Stub for calling free from Go */
static void
x_cgo_free(void *p)
{