Also, take a look at this post:
https://utcc.utoronto.ca/~cks/space/blog/programming/GoCGoCompatibleStructs

I do quite a bit of ioctl stuff and generate all my Go structs using the 
cgo tool just because the C side is not stable yet and still changes a lot, 
I could not keep up with the changes and maintain Go structs by hand.

There are also some things to be aware when making syscalls, check out page 
357 in the GoPL book and the godoc below regarding the rules around uintptr 
conversions (the quick rule is that you don't want to store uintptr or pass 
them around, you want to wait and convert to uintptr at the last minute, in 
the syscall function call):
https://golang.org/pkg/unsafe/#Pointer

E.g.

_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), uintptr(op), 
uintptr(data))

where f is *os.File, op is uint64 (though it doesn't matter in this case) 
and data is an unsafe.Pointer


On Wednesday, December 7, 2016 at 5:28:25 PM UTC-8, Steven Logan wrote:
>
> I was concerned that there might be a fundamental issue that would make 
> this a massive pain, wasn't expecting it to be quite this straight forward.
> I'll have a go at these suggestions tomorrow, Cheers!
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to