github.com/jwijenbergh/purego@v0.0.0-20240126093400-70ff3a61df13/internal/fakecgo/asm_amd64.s (about)

     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  #include "abi_amd64.h"
     7  
     8  // Called by C code generated by cmd/cgo.
     9  // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
    10  // Saves C callee-saved registers and calls cgocallback with three arguments.
    11  // fn is the PC of a func(a unsafe.Pointer) function.
    12  // This signature is known to SWIG, so we can't change it.
    13  TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0-0
    14  	PUSH_REGS_HOST_TO_ABI0()
    15  
    16  	// Make room for arguments to cgocallback.
    17  	ADJSP $0x18
    18  
    19  #ifndef GOOS_windows
    20  	MOVQ DI, 0x0(SP) // fn
    21  	MOVQ SI, 0x8(SP) // arg
    22  
    23  	// Skip n in DX.
    24  	MOVQ CX, 0x10(SP) // ctxt
    25  
    26  #else
    27  	MOVQ CX, 0x0(SP) // fn
    28  	MOVQ DX, 0x8(SP) // arg
    29  
    30  	// Skip n in R8.
    31  	MOVQ R9, 0x10(SP) // ctxt
    32  
    33  #endif
    34  
    35  	CALL runtime·cgocallback(SB)
    36  
    37  	ADJSP $-0x18
    38  	POP_REGS_HOST_TO_ABI0()
    39  	RET