Proposal Details
The following syscalls could be supported on modern OSX versions (Darwin 11 and newer)
unix.Readv(fd int, iovs [][]byte) (n int, err error)
unix.Preadv(fd int, iovs [][]byte, offset int64) (n int, err error)
unix.Writev(fd int, iovs [][]byte) (n int, err error)
unix.Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error)
I think https://go-review.googlesource.com/c/sys/+/548795 contains everything needed to implement this on Darwin.
In cases where the version is too old, the public functions in unix
would simply return ENOSYS
instead of running into a dyld
error due to trying to jump to a function that doesn't exist.
Comment From: mauri870
cc @golang/darwin
Comment From: gopherbot
Change https://go.dev/cl/548795 mentions this issue: unix: support Readv, Preadv, Writev and Pwritev for darwin
Comment From: adonovan
Why just Darwin? p{read,write}v have been supported on Linux and various BSDs for a while. Ideally the sys interface would have implementations for all platforms that support it, even if the macOS implementation needs an additional compatibility check.
[Update: I now see that we have a Linux implementation already. But my point is that the proposal should cover the API change, and implementations for all platforms can follow at their own pace if they conform to the approved proposal.]
Comment From: mschoenlaub
Hm, yeah, @adonovan I think you are right. The goal should be to implement it on all platforms supported, but I agree on these implementations better coming in at their own pace. However, I think I wasn't fully aware of actually proposing an API change of any sort, because due to the Linux implementation already being there, I just assumed that the API now basically has to be whatever the Linux implementation conforms to.
Comment From: ianlancetaylor
Yes, there is no need for a proposal to add new system calls for a GOOS that are the same as existing system calls for a different GOOS.
Comment From: mschoenlaub
@gopherbot remove NeedsFix
Comment From: mschoenlaub
@ianlancetaylor, Hoping I'm using these labels right.
@gopherbot add PendingFix.
Comment From: mschoenlaub
@gopherbot add FixPending
Comment From: gopherbot
Change https://go.dev/cl/689115 mentions this issue: unix: fix //sys decl after CL 548795
Comment From: wwqgtxx
By consulting the official header file of APPLE:
https://github.com/apple-oss-distributions/xnu/blob/a1e26a70f38d1d7daa7b49b258e2f8538ad81650/bsd/sys/uio.h#L269-L280
readv/writev does not have a clear version requirement (according to the commit history, the system call has existed at least in xnu-123.5, which should correspond to macos10.0)
And the version requirement of preadv/pwritev should also be 10.16 instead of 11.0, so the system version check here is wrong and unnecessary.
In addition, the current darwinKernelVersionMin
implementation does not have any result caching mechanism, which will lead to high operating overhead in high-frequency calls (each call needs to bear 5 sysctl calls brought by Uname
, and result string parsing).
Comment From: gopherbot
Change https://go.dev/cl/688858 mentions this issue: unix: remove redundant xnu version check for {p}readv/{p}writev
Comment From: gopherbot
Change https://go.dev/cl/688857 mentions this issue: unix: fix //sys decl after CL 548795