I am getting it to compile and run with this but I am struggling how you 
send a string pointer across a syscall that c can send back. Also not sure 
about the //go:nosplit I sprinkel around which one is actually right?

package main

import (
 "syscall"
 "unsafe"

 "golang.org/x/sys/unix"
)

//go:linkname hello_t hello_c
//go:cgo_import_dynamic hello_c hello "./c/hello.dylib"
//go:nosplit
func hello_t(s unsafe.Pointer) (uintptr, uintptr, syscall.Errno) {
 return unix.Syscall6(funcPC(hello_trampoline), uintptr(s), uintptr(0),
 0, 0, uintptr(s), 0)
}

func hello_trampoline()

//go:nosplit
func funcPC(f func()) uintptr {
 return **(**uintptr)(unsafe.Pointer(&f))
}

func main() {
 s := "test    "
 hello_t(unsafe.Pointer(&s))
 print(s)
}

> go build    
> ./trampoline
> test        %
>                                                                         









-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e53e7a50-cdf1-43ee-8f88-c68d63677bda%40googlegroups.com.

Reply via email to