mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-27 20:36:31 -04:00
unix: remove redundant xnu version check for {p}readv/{p}writev
As discussed later in golang/go#64710, these checks are unnecessary. For golang/go#64710 Change-Id: I8693af81cc543b886732922eb5cd64e07ed4b7a8 Reviewed-on: https://go-review.googlesource.com/c/sys/+/688858 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Mark Freeman <mark@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
committed by
Gopher Robot
parent
9920300fc8
commit
3a827038f2
@@ -605,10 +605,6 @@ func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocI
|
|||||||
const minIovec = 8
|
const minIovec = 8
|
||||||
|
|
||||||
func Readv(fd int, iovs [][]byte) (n int, err error) {
|
func Readv(fd int, iovs [][]byte) (n int, err error) {
|
||||||
if !darwinKernelVersionMin(11, 0, 0) {
|
|
||||||
return 0, ENOSYS
|
|
||||||
}
|
|
||||||
|
|
||||||
iovecs := make([]Iovec, 0, minIovec)
|
iovecs := make([]Iovec, 0, minIovec)
|
||||||
iovecs = appendBytes(iovecs, iovs)
|
iovecs = appendBytes(iovecs, iovs)
|
||||||
n, err = readv(fd, iovecs)
|
n, err = readv(fd, iovecs)
|
||||||
@@ -617,9 +613,6 @@ func Readv(fd int, iovs [][]byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
||||||
if !darwinKernelVersionMin(11, 0, 0) {
|
|
||||||
return 0, ENOSYS
|
|
||||||
}
|
|
||||||
iovecs := make([]Iovec, 0, minIovec)
|
iovecs := make([]Iovec, 0, minIovec)
|
||||||
iovecs = appendBytes(iovecs, iovs)
|
iovecs = appendBytes(iovecs, iovs)
|
||||||
n, err = preadv(fd, iovecs, offset)
|
n, err = preadv(fd, iovecs, offset)
|
||||||
@@ -628,10 +621,6 @@ func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Writev(fd int, iovs [][]byte) (n int, err error) {
|
func Writev(fd int, iovs [][]byte) (n int, err error) {
|
||||||
if !darwinKernelVersionMin(11, 0, 0) {
|
|
||||||
return 0, ENOSYS
|
|
||||||
}
|
|
||||||
|
|
||||||
iovecs := make([]Iovec, 0, minIovec)
|
iovecs := make([]Iovec, 0, minIovec)
|
||||||
iovecs = appendBytes(iovecs, iovs)
|
iovecs = appendBytes(iovecs, iovs)
|
||||||
if raceenabled {
|
if raceenabled {
|
||||||
@@ -643,10 +632,6 @@ func Writev(fd int, iovs [][]byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
||||||
if !darwinKernelVersionMin(11, 0, 0) {
|
|
||||||
return 0, ENOSYS
|
|
||||||
}
|
|
||||||
|
|
||||||
iovecs := make([]Iovec, 0, minIovec)
|
iovecs := make([]Iovec, 0, minIovec)
|
||||||
iovecs = appendBytes(iovecs, iovs)
|
iovecs = appendBytes(iovecs, iovs)
|
||||||
if raceenabled {
|
if raceenabled {
|
||||||
@@ -706,45 +691,6 @@ func readvRacedetect(iovecs []Iovec, n int, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func darwinMajorMinPatch() (maj, min, patch int, err error) {
|
|
||||||
var un Utsname
|
|
||||||
err = Uname(&un)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var mmp [3]int
|
|
||||||
c := 0
|
|
||||||
Loop:
|
|
||||||
for _, b := range un.Release[:] {
|
|
||||||
switch {
|
|
||||||
case b >= '0' && b <= '9':
|
|
||||||
mmp[c] = 10*mmp[c] + int(b-'0')
|
|
||||||
case b == '.':
|
|
||||||
c++
|
|
||||||
if c > 2 {
|
|
||||||
return 0, 0, 0, ENOTSUP
|
|
||||||
}
|
|
||||||
case b == 0:
|
|
||||||
break Loop
|
|
||||||
default:
|
|
||||||
return 0, 0, 0, ENOTSUP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if c != 2 {
|
|
||||||
return 0, 0, 0, ENOTSUP
|
|
||||||
}
|
|
||||||
return mmp[0], mmp[1], mmp[2], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func darwinKernelVersionMin(maj, min, patch int) bool {
|
|
||||||
actualMaj, actualMin, actualPatch, err := darwinMajorMinPatch()
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return actualMaj > maj || actualMaj == maj && (actualMin > min || actualMin == min && actualPatch >= patch)
|
|
||||||
}
|
|
||||||
|
|
||||||
//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
|
//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
|
||||||
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
|
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user