Source file
src/syscall/syscall_linux_s390x.go
1
2
3
4
5 package syscall
6
7 import "unsafe"
8
9 const _SYS_setgroups = SYS_SETGROUPS
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 func Time(t *Time_t) (tt Time_t, err error) {
49 var tv Timeval
50 err = Gettimeofday(&tv)
51 if err != nil {
52 return 0, err
53 }
54 if t != nil {
55 *t = Time_t(tv.Sec)
56 }
57 return Time_t(tv.Sec), nil
58 }
59
60
61
62
63 func setTimespec(sec, nsec int64) Timespec {
64 return Timespec{Sec: sec, Nsec: nsec}
65 }
66
67 func setTimeval(sec, usec int64) Timeval {
68 return Timeval{Sec: sec, Usec: usec}
69 }
70
71
72
73 func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
74 mmap_args := [6]uintptr{addr, length, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)}
75 r0, _, e1 := Syscall(SYS_MMAP, uintptr(unsafe.Pointer(&mmap_args[0])), 0, 0)
76 xaddr = uintptr(r0)
77 if e1 != 0 {
78 err = errnoErr(e1)
79 }
80 return
81 }
82
83
84
85
86
87
88 const (
89
90 _SOCKET = 1
91 _BIND = 2
92 _CONNECT = 3
93 _LISTEN = 4
94 _ACCEPT = 5
95 _GETSOCKNAME = 6
96 _GETPEERNAME = 7
97 _SOCKETPAIR = 8
98 _SEND = 9
99 _RECV = 10
100 _SENDTO = 11
101 _RECVFROM = 12
102 _SHUTDOWN = 13
103 _SETSOCKOPT = 14
104 _GETSOCKOPT = 15
105 _SENDMSG = 16
106 _RECVMSG = 17
107 _ACCEPT4 = 18
108 _RECVMMSG = 19
109 _SENDMMSG = 20
110 )
111
112 func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err Errno)
113 func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err Errno)
114
115 func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
116 fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
117 if e != 0 {
118 err = e
119 }
120 return
121 }
122
123 func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
124 fd, e := socketcall(_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
125 if e != 0 {
126 err = e
127 }
128 return
129 }
130
131 func getsockname(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
132 _, e := rawsocketcall(_GETSOCKNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
133 if e != 0 {
134 err = e
135 }
136 return
137 }
138
139 func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
140 _, e := rawsocketcall(_GETPEERNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
141 if e != 0 {
142 err = e
143 }
144 return
145 }
146
147 func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) {
148 _, e := rawsocketcall(_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
149 if e != 0 {
150 err = e
151 }
152 return
153 }
154
155 func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
156 _, e := socketcall(_BIND, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
157 if e != 0 {
158 err = e
159 }
160 return
161 }
162
163 func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
164 _, e := socketcall(_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
165 if e != 0 {
166 err = e
167 }
168 return
169 }
170
171 func socket(domain int, typ int, proto int) (fd int, err error) {
172 fd, e := rawsocketcall(_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0)
173 if e != 0 {
174 err = e
175 }
176 return
177 }
178
179 func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
180 _, e := socketcall(_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
181 if e != 0 {
182 err = e
183 }
184 return
185 }
186
187 func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
188 _, e := socketcall(_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), vallen, 0)
189 if e != 0 {
190 err = e
191 }
192 return
193 }
194
195 func recvfrom(s int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
196 var base uintptr
197 if len(p) > 0 {
198 base = uintptr(unsafe.Pointer(&p[0]))
199 }
200 n, e := socketcall(_RECVFROM, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
201 if e != 0 {
202 err = e
203 }
204 return
205 }
206
207 func sendto(s int, p []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
208 var base uintptr
209 if len(p) > 0 {
210 base = uintptr(unsafe.Pointer(&p[0]))
211 }
212 _, e := socketcall(_SENDTO, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(to), uintptr(addrlen))
213 if e != 0 {
214 err = e
215 }
216 return
217 }
218
219 func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
220 n, e := socketcall(_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
221 if e != 0 {
222 err = e
223 }
224 return
225 }
226
227 func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
228 n, e := socketcall(_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0)
229 if e != 0 {
230 err = e
231 }
232 return
233 }
234
235 func Listen(s int, n int) (err error) {
236 _, e := socketcall(_LISTEN, uintptr(s), uintptr(n), 0, 0, 0, 0)
237 if e != 0 {
238 err = e
239 }
240 return
241 }
242
243 func Shutdown(s, how int) (err error) {
244 _, e := socketcall(_SHUTDOWN, uintptr(s), uintptr(how), 0, 0, 0, 0)
245 if e != 0 {
246 err = e
247 }
248 return
249 }
250
251 func (r *PtraceRegs) PC() uint64 { return r.Psw.Addr }
252
253 func (r *PtraceRegs) SetPC(pc uint64) { r.Psw.Addr = pc }
254
255 func (iov *Iovec) SetLen(length int) {
256 iov.Len = uint64(length)
257 }
258
259 func (msghdr *Msghdr) SetControllen(length int) {
260 msghdr.Controllen = uint64(length)
261 }
262
263 func (cmsg *Cmsghdr) SetLen(length int) {
264 cmsg.Len = uint64(length)
265 }
266
267 func rawVforkSyscall(trap, a1 uintptr) (r1 uintptr, err Errno)
268
View as plain text