Source file src/pkg/cmd/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
1
2
3
4
5
6
7 package unix
8
9 import "unsafe"
10
11 func EpollCreate(size int) (fd int, err error) {
12 if size <= 0 {
13 return -1, EINVAL
14 }
15 return EpollCreate1(0)
16 }
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
36 var ts *Timespec
37 if timeout != nil {
38 ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
39 }
40 return Pselect(nfd, r, w, e, ts, nil)
41 }
42
43
44
45
46
47
48
49
50
51
52
53
54 func Stat(path string, stat *Stat_t) (err error) {
55 return Fstatat(AT_FDCWD, path, stat, 0)
56 }
57
58 func Lchown(path string, uid int, gid int) (err error) {
59 return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW)
60 }
61
62 func Lstat(path string, stat *Stat_t) (err error) {
63 return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
64 }
65
66
67
68
69
70 func Ustat(dev int, ubuf *Ustat_t) (err error) {
71 return ENOSYS
72 }
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94 func setTimespec(sec, nsec int64) Timespec {
95 return Timespec{Sec: sec, Nsec: nsec}
96 }
97
98 func setTimeval(sec, usec int64) Timeval {
99 return Timeval{Sec: sec, Usec: usec}
100 }
101
102 func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
103 if tv == nil {
104 return utimensat(dirfd, path, nil, 0)
105 }
106
107 ts := []Timespec{
108 NsecToTimespec(TimevalToNsec(tv[0])),
109 NsecToTimespec(TimevalToNsec(tv[1])),
110 }
111 return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
112 }
113
114 func Time(t *Time_t) (Time_t, error) {
115 var tv Timeval
116 err := Gettimeofday(&tv)
117 if err != nil {
118 return 0, err
119 }
120 if t != nil {
121 *t = Time_t(tv.Sec)
122 }
123 return Time_t(tv.Sec), nil
124 }
125
126 func Utime(path string, buf *Utimbuf) error {
127 tv := []Timeval{
128 {Sec: buf.Actime},
129 {Sec: buf.Modtime},
130 }
131 return Utimes(path, tv)
132 }
133
134 func utimes(path string, tv *[2]Timeval) (err error) {
135 if tv == nil {
136 return utimensat(AT_FDCWD, path, nil, 0)
137 }
138
139 ts := []Timespec{
140 NsecToTimespec(TimevalToNsec(tv[0])),
141 NsecToTimespec(TimevalToNsec(tv[1])),
142 }
143 return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
144 }
145
146 func Pipe(p []int) (err error) {
147 if len(p) != 2 {
148 return EINVAL
149 }
150 var pp [2]_C_int
151 err = pipe2(&pp, 0)
152 p[0] = int(pp[0])
153 p[1] = int(pp[1])
154 return
155 }
156
157
158
159 func Pipe2(p []int, flags int) (err error) {
160 if len(p) != 2 {
161 return EINVAL
162 }
163 var pp [2]_C_int
164 err = pipe2(&pp, flags)
165 p[0] = int(pp[0])
166 p[1] = int(pp[1])
167 return
168 }
169
170 func (r *PtraceRegs) PC() uint64 { return r.Pc }
171
172 func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
173
174 func (iov *Iovec) SetLen(length int) {
175 iov.Len = uint64(length)
176 }
177
178 func (msghdr *Msghdr) SetControllen(length int) {
179 msghdr.Controllen = uint64(length)
180 }
181
182 func (cmsg *Cmsghdr) SetLen(length int) {
183 cmsg.Len = uint64(length)
184 }
185
186 func InotifyInit() (fd int, err error) {
187 return InotifyInit1(0)
188 }
189
190 func Dup2(oldfd int, newfd int) (err error) {
191 return Dup3(oldfd, newfd, 0)
192 }
193
194 func Pause() error {
195 _, err := ppoll(nil, 0, nil, nil)
196 return err
197 }
198
199 func Poll(fds []PollFd, timeout int) (n int, err error) {
200 var ts *Timespec
201 if timeout >= 0 {
202 ts = new(Timespec)
203 *ts = NsecToTimespec(int64(timeout) * 1e6)
204 }
205 if len(fds) == 0 {
206 return ppoll(nil, 0, ts, nil)
207 }
208 return ppoll(&fds[0], len(fds), ts, nil)
209 }
210
211 func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
212 return Renameat2(olddirfd, oldpath, newdirfd, newpath, 0)
213 }
214
215
216
217 func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error {
218 cmdlineLen := len(cmdline)
219 if cmdlineLen > 0 {
220
221
222
223 cmdlineLen++
224 }
225 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
226 }
227
View as plain text