3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 05:19:25 +01:00
ergo/vendor/golang.org/x/sys/unix/syscall_illumos.go

79 lines
1.8 KiB
Go
Raw Normal View History

2021-11-17 00:18:03 +01:00
// Copyright 2021 The Go Authors. All rights reserved.
2020-06-01 18:02:25 +02:00
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// illumos system calls not present on Solaris.
2021-11-17 00:18:03 +01:00
//go:build amd64 && illumos
2020-06-01 18:02:25 +02:00
package unix
2021-11-17 00:18:03 +01:00
import (
"unsafe"
)
2020-06-01 18:02:25 +02:00
func bytes2iovec(bs [][]byte) []Iovec {
iovecs := make([]Iovec, len(bs))
for i, b := range bs {
iovecs[i].SetLen(len(b))
if len(b) > 0 {
2023-01-15 14:27:18 +01:00
iovecs[i].Base = &b[0]
2020-06-01 18:02:25 +02:00
} else {
2023-01-15 14:27:18 +01:00
iovecs[i].Base = (*byte)(unsafe.Pointer(&_zero))
2020-06-01 18:02:25 +02:00
}
}
return iovecs
}
2020-11-08 23:57:58 +01:00
//sys readv(fd int, iovs []Iovec) (n int, err error)
2020-06-01 18:02:25 +02:00
func Readv(fd int, iovs [][]byte) (n int, err error) {
iovecs := bytes2iovec(iovs)
n, err = readv(fd, iovecs)
return n, err
}
2020-11-08 23:57:58 +01:00
//sys preadv(fd int, iovs []Iovec, off int64) (n int, err error)
2020-06-01 18:02:25 +02:00
func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) {
iovecs := bytes2iovec(iovs)
n, err = preadv(fd, iovecs, off)
return n, err
}
2020-11-08 23:57:58 +01:00
//sys writev(fd int, iovs []Iovec) (n int, err error)
2020-06-01 18:02:25 +02:00
func Writev(fd int, iovs [][]byte) (n int, err error) {
iovecs := bytes2iovec(iovs)
n, err = writev(fd, iovecs)
return n, err
}
2020-11-08 23:57:58 +01:00
//sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error)
2020-06-01 18:02:25 +02:00
func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) {
iovecs := bytes2iovec(iovs)
n, err = pwritev(fd, iovecs, off)
return n, err
}
2020-11-08 23:57:58 +01:00
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4
func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
var rsa RawSockaddrAny
var len _Socklen = SizeofSockaddrAny
nfd, err = accept4(fd, &rsa, &len, flags)
if err != nil {
return
}
if len > SizeofSockaddrAny {
panic("RawSockaddrAny too small")
}
sa, err = anyToSockaddr(fd, &rsa)
if err != nil {
Close(nfd)
nfd = 0
}
return
}