.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / sys@v0.0.0-20210124154548-22da62e12c0c / unix / syscall_illumos.go
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // illumos system calls not present on Solaris.
6
7 // +build amd64,illumos
8
9 package unix
10
11 import "unsafe"
12
13 func bytes2iovec(bs [][]byte) []Iovec {
14         iovecs := make([]Iovec, len(bs))
15         for i, b := range bs {
16                 iovecs[i].SetLen(len(b))
17                 if len(b) > 0 {
18                         // somehow Iovec.Base on illumos is (*int8), not (*byte)
19                         iovecs[i].Base = (*int8)(unsafe.Pointer(&b[0]))
20                 } else {
21                         iovecs[i].Base = (*int8)(unsafe.Pointer(&_zero))
22                 }
23         }
24         return iovecs
25 }
26
27 //sys   readv(fd int, iovs []Iovec) (n int, err error)
28
29 func Readv(fd int, iovs [][]byte) (n int, err error) {
30         iovecs := bytes2iovec(iovs)
31         n, err = readv(fd, iovecs)
32         return n, err
33 }
34
35 //sys   preadv(fd int, iovs []Iovec, off int64) (n int, err error)
36
37 func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) {
38         iovecs := bytes2iovec(iovs)
39         n, err = preadv(fd, iovecs, off)
40         return n, err
41 }
42
43 //sys   writev(fd int, iovs []Iovec) (n int, err error)
44
45 func Writev(fd int, iovs [][]byte) (n int, err error) {
46         iovecs := bytes2iovec(iovs)
47         n, err = writev(fd, iovecs)
48         return n, err
49 }
50
51 //sys   pwritev(fd int, iovs []Iovec, off int64) (n int, err error)
52
53 func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) {
54         iovecs := bytes2iovec(iovs)
55         n, err = pwritev(fd, iovecs, off)
56         return n, err
57 }
58
59 //sys   accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4
60
61 func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
62         var rsa RawSockaddrAny
63         var len _Socklen = SizeofSockaddrAny
64         nfd, err = accept4(fd, &rsa, &len, flags)
65         if err != nil {
66                 return
67         }
68         if len > SizeofSockaddrAny {
69                 panic("RawSockaddrAny too small")
70         }
71         sa, err = anyToSockaddr(fd, &rsa)
72         if err != nil {
73                 Close(nfd)
74                 nfd = 0
75         }
76         return
77 }