...
1
2
3
4
5
6
7
8
9 package unix
10
11 import (
12 "unsafe"
13 )
14
15 func bytes2iovec(bs [][]byte) []Iovec {
16 iovecs := make([]Iovec, len(bs))
17 for i, b := range bs {
18 iovecs[i].SetLen(len(b))
19 if len(b) > 0 {
20 iovecs[i].Base = &b[0]
21 } else {
22 iovecs[i].Base = (*byte)(unsafe.Pointer(&_zero))
23 }
24 }
25 return iovecs
26 }
27
28
29
30 func Readv(fd int, iovs [][]byte) (n int, err error) {
31 iovecs := bytes2iovec(iovs)
32 n, err = readv(fd, iovecs)
33 return n, err
34 }
35
36
37
38 func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) {
39 iovecs := bytes2iovec(iovs)
40 n, err = preadv(fd, iovecs, off)
41 return n, err
42 }
43
44
45
46 func Writev(fd int, iovs [][]byte) (n int, err error) {
47 iovecs := bytes2iovec(iovs)
48 n, err = writev(fd, iovecs)
49 return n, err
50 }
51
52
53
54 func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) {
55 iovecs := bytes2iovec(iovs)
56 n, err = pwritev(fd, iovecs, off)
57 return n, err
58 }
59
60
61
62 func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
63 var rsa RawSockaddrAny
64 var len _Socklen = SizeofSockaddrAny
65 nfd, err = accept4(fd, &rsa, &len, flags)
66 if err != nil {
67 return
68 }
69 if len > SizeofSockaddrAny {
70 panic("RawSockaddrAny too small")
71 }
72 sa, err = anyToSockaddr(fd, &rsa)
73 if err != nil {
74 Close(nfd)
75 nfd = 0
76 }
77 return
78 }
79
View as plain text