Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Matt Layher
I ended up doing my own struct definition without the union (I only care about the pointer variant) so I could go along with what Ian suggested above: > It would be OK to pass a pointer to a struct to ioctl if the struct contains a pointer to other Go memory, but the struct field must have poi

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Jan Mercl
On Fri, May 17, 2019, 19:09 Matt Layher wrote: > Thanks for the insight, this is very useful information. Perhaps I'll look > into the mmap route. > Possibly useful: https://godoc.org/modernc.org/memory -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Matt Layher
Thanks for the insight, this is very useful information. Perhaps I'll look into the mmap route. - Matt On Friday, May 17, 2019 at 12:54:28 PM UTC-4, Ian Lance Taylor wrote: > > On Fri, May 17, 2019 at 7:44 AM Matt Layher > wrote: > > > >> Pointers passed to unix.Syscall or syscall.Syscall are

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Ian Lance Taylor
On Fri, May 17, 2019 at 7:44 AM Matt Layher wrote: > >> Pointers passed to unix.Syscall or syscall.Syscall are always safe. >> They will be treated as live for the duration of the call to Syscall, >> and they will not be moved. This is a special exception for functions >> written in assembly, doc

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Matt Layher
olang-nuts Subject: Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory If Go ever adding a compacting collector I don't think these techniques would work - I would start with cgo as you will be protected then. -Original Message---

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Robert Engels
-nuts Subject: Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory If Go ever adding a compacting collector I don't think these techniques would work - I would start with cgo as you will be protected then.-Original Message- From: Matt Layher Sent: May

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Robert Engels
If Go ever adding a compacting collector I don't think these techniques would work - I would start with cgo as you will be protected then.-Original Message- From: Matt Layher Sent: May 17, 2019 9:44 AM To: golang-nuts Subject: Re: [go-nuts] Passing structures containing other pointe

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Matt Layher
Hi Ian, Pointers passed to unix.Syscall or syscall.Syscall are always safe. > They will be treated as live for the duration of the call to Syscall, > and they will not be moved. This is a special exception for functions > written in assembly, documented at > https://golang.org/pkg/unsafe/#Poi

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Ian Lance Taylor
On Thu, May 16, 2019 at 5:24 AM Matt Layher wrote: > > I'm working on a project that involves an ioctl API on OpenBSD. The idea is > that you store a memory address in a union within another structure, and then > invoke the ioctl. When it returns, both the structure itself and the memory > poin

[go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-16 Thread Matt Layher
Hey folks, I'm working on a project that involves an ioctl API on OpenBSD. The idea is that you store a memory address in a union within another structure, and then invoke the ioctl. When it returns, both the structure itself and the memory pointed at by the address in the union are filled with