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