akavel / winq

Package winq provides functions for quick & dirty WinAPI calls, with easy errors capturing.
godoc.org/github.com/akavel/winq
16 stars 1 forks source link

go1.7: use runtime.KeepAlive() #2

Open akavel opened 8 years ago

akavel commented 8 years ago

See:

https://github.com/golang/go/commit/6ab45c09f6fc1bde56e3a72e50505b9a5021aaaf

https://groups.google.com/forum/#!topic/golang-dev/AlMCfgQLkdo

akavel commented 8 years ago

Also, Syscall handling of unsafe.Pointer and uintptrs must be changed, per newly fleshed out rules regarding unsafe.Pointer->uintptr->syscall.Syscall handling.

Currently proposed solution would be to build a bitmask of the arguments list (with 1 on positions corresponding to unsafe.Pointer in args, 0 to other values), then switch into a machine-generated list of corresponding syscall.Syscall call combinations. That is, for example:

winq.F(int(1), byte(2), unsafe.Pointer(&x), unsafe.Pointer(&y))  // call site
// assuming: package winq; func F(args ...interface{}) (...)
tmpargs := []interface{}{}
// ...copy unsafe.Pointer args to tmpargs, others converted to uintptr...
bitmap = 0x03  // big endian binary: 0000 0011 -- or could use little endian instead
switch (nargs, bitmap) {
case (4, 0x03):
    syscall.Syscall(tmpargs[0].(uintptr), tmpargs[1].(uintptr), uintptr(tmpargs[2].(unsafe.Pointer)), uintptr(tmpargs[3].(unsafe.Pointer)))
...
}