golang/go

x/sys/unix: standardize Kevent_t Udata as integer, not pointer

Open

#32,153 opened on May 20, 2019

View on GitHub
 (19 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
NeedsFixhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

unix.SetKevent only takes mode(eg. Filter field) and flags parameter.

Other fields also have different types depending on the ach/platform, say Udata which is either a *byte or a int32.

Since Go1 compat promise prevent us from changing the SetKevent function, perhaps it could be feasible to add new methods to the Kevent_t type to set the others fields, similar to *Iovec.SetLen for example.

Fflags and Data methods looks straightforward to implement, on the model of SetKevent, since types are integers on all platforms/archs.

However, so far, I am unsure about the type of the Udata parameter for the eponym method. I typically would do kev.Udata = (*byte)(unsafe.Pointer(&foobar)) on my own currently for darwin/amd64, but I guess that exposing unsafe.Pointer as a parameter type is not a good solution.

Contributor guide