1// Copyright 2009 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5#include "textflag.h" 6 7// Set the x_crosscall2_ptr C function pointer variable point to crosscall2. 8// It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2 9// Use a local trampoline, to avoid taking the address of a dynamically exported 10// function. 11TEXT ·set_crosscall2(SB),NOSPLIT,$0-0 12 MOVL _crosscall2_ptr(SB), AX 13 MOVL $crosscall2_trampoline<>(SB), BX 14 MOVL BX, (AX) 15 RET 16 17TEXT crosscall2_trampoline<>(SB),NOSPLIT,$0-0 18 JMP crosscall2(SB) 19 20// Called by C code generated by cmd/cgo. 21// func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) 22// Saves C callee-saved registers and calls cgocallback with three arguments. 23// fn is the PC of a func(a unsafe.Pointer) function. 24TEXT crosscall2(SB),NOSPLIT,$28-16 25 MOVL BP, 24(SP) 26 MOVL BX, 20(SP) 27 MOVL SI, 16(SP) 28 MOVL DI, 12(SP) 29 30 MOVL ctxt+12(FP), AX 31 MOVL AX, 8(SP) 32 MOVL a+4(FP), AX 33 MOVL AX, 4(SP) 34 MOVL fn+0(FP), AX 35 MOVL AX, 0(SP) 36 CALL runtime·cgocallback(SB) 37 38 MOVL 12(SP), DI 39 MOVL 16(SP), SI 40 MOVL 20(SP), BX 41 MOVL 24(SP), BP 42 RET 43