I want to call a function written in go assembly from cgo . Example
runtime·memclrNoHeapPointers is written in memclr_amd64.s.
I am able to call it from go code but not from cgo code.
What if you export a “stub.” There’s probably a way to put this all into one function, but I haven’t looked into it yet.
//go:linkname MemclrNoHeapPointers runtime.memclrNoHeapPointers
func MemclrNoHeapPointers(p unsafe.Pointer, n uintptr) int
//export RuntimeMemclrNoHeapPointers
func RuntimeMemclrNoHeapPointers(p unsafe.Pointer, n uintptr) {
MemclrNoHeapPointers(p, n)
}
I think you could call RuntimeMemclrNoHeapPointers
from C, but I’m not certain.
What’s your use case?
By exporting a stub, cgo will call a function of go. What if i do not call any go method from cgo.
I want to call following function from cgo.
TEXT ·getg(SB), NOSPLIT, $0-8
get_tls(CX)
MOVQ g(CX), AX
MOVQ AX, ret+0(FP)
RET
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.