You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
x/sys/unix and syscall have a Msghdr structure that looks like the following on 64-bit GOOS=linux, e.g., GOARCH=amd64:
type Msghdr struct {
Name *byte
Namelen uint32
Pad_cgo_0 [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
Controllen uint64
Flags int32
Pad_cgo_1 [4]byte
}
On 32-bit GOOS=linux like GOARCH=386 it looks like:
type Msghdr struct {
Name *byte
Namelen uint32
Iov *Iovec
Iovlen uint32
Control *byte
Controllen uint32
Flags int32
}
The Iovlen and Controllen are of type uint64 on 64-bit GOOS=linux and of type uint32 on 32-bit GOOS=linux.
There is a method for setting the Controllen member given an int. Here is the GOARCH=386 version that converts the int length to uint32. There are corresponding versions for 64-bit Linuxes that convert to uint64.
This is an inconvenience, as it is difficult to write generic code that fills this structure on any Linux, 32-bit and 64-bit. For the sake of consistency and convenience, I'd expect there to be a setter for the Iovlen member as well.
The missing setter forces to use build tags like the following: internal/socket/msghdr_linux_64bit.go#L5 and maintain lists of which GOARCH are 32-bit and which are 64-bit.
The text was updated successfully, but these errors were encountered:
I've just noticed that the net msghdr struct seems to be not the one from sys (see golang/net#52). In fact, sys has only recently been added as a dependency to net at all. So- the PR is there- but I'm really unsure what good it does.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
At the time of writing, yes, it reproduces with 1.13, which is the latest release.
What operating system and processor architecture are you using (
go env
)?go env
OutputIssue
x/sys/unix and syscall have a Msghdr structure that looks like the following on 64-bit GOOS=linux, e.g., GOARCH=amd64:
On 32-bit GOOS=linux like GOARCH=386 it looks like:
The Iovlen and Controllen are of type uint64 on 64-bit GOOS=linux and of type uint32 on 32-bit GOOS=linux.
There is a method for setting the Controllen member given an int. Here is the GOARCH=386 version that converts the int length to uint32. There are corresponding versions for 64-bit Linuxes that convert to uint64.
However, there is no corresponding method for setting the Iovlen member. In particular, there is no SetIovlen (GOARCH=386):
This is an inconvenience, as it is difficult to write generic code that fills this structure on any Linux, 32-bit and 64-bit. For the sake of consistency and convenience, I'd expect there to be a setter for the Iovlen member as well.
The missing setter forces to use build tags like the following: internal/socket/msghdr_linux_64bit.go#L5 and maintain lists of which GOARCH are 32-bit and which are 64-bit.
The text was updated successfully, but these errors were encountered: