github.com/wencode/hack@v0.2.9/proc/proc_unix.go (about) 1 // +build linux darwin 2 3 package proc 4 5 import ( 6 "unsafe" 7 ) 8 9 func Call(fn uintptr, args ...uintptr) uintptr { 10 ta := new(tramargs) 11 ta.fn = fn 12 copy(ta.arg[:], args) 13 runtime_cgocall(unsafe.Pointer(trampoline_fn), uintptr(unsafe.Pointer(ta))) 14 return ta.ret 15 } 16 17 func SmallCall(smallfn uintptr, args ...uintptr) uintptr { 18 ta := new(tramargs) 19 ta.fn = smallfn 20 copy(ta.arg[:], args) 21 realcall(ta) 22 return ta.ret 23 } 24 25 type tramargs struct { 26 fn uintptr 27 arg [6]uintptr 28 ret uintptr 29 pad [4]byte 30 } 31 32 33 var ( 34 trampoline_fn uintptr 35 ) 36 37 func init() { 38 trampoline_fn = trampoline_addr() 39 } 40 41 func trampoline(*tramargs) 42 func trampoline_addr() uintptr 43 func realcall(*tramargs) 44 45 //go:linkname runtime_cgocall runtime.cgocall 46 func runtime_cgocall(unsafe.Pointer, uintptr) int32