LEFT | RIGHT |
1 // Copyright 2013 The Go Authors. All rights reserved. | 1 // Copyright 2013 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package syscall | 5 package syscall |
6 #include "runtime.h" | 6 #include "runtime.h" |
7 #include "defs_GOOS_GOARCH.h" | 7 #include "defs_GOOS_GOARCH.h" |
8 #include "os_GOOS.h" | 8 #include "os_GOOS.h" |
9 #include "cgocall.h" | 9 #include "cgocall.h" |
10 #include "../../cmd/ld/textflag.h" | 10 #include "../../cmd/ld/textflag.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 runtime·cgocall(runtime·asmsysvicall6, &c); | 156 runtime·cgocall(runtime·asmsysvicall6, &c); |
157 proc = c.r1; | 157 proc = c.r1; |
158 if(proc == 0) | 158 if(proc == 0) |
159 err = c.err; | 159 err = c.err; |
160 else | 160 else |
161 err = 0; | 161 err = 0; |
162 } | 162 } |
163 | 163 |
164 #pragma textflag NOSPLIT | 164 #pragma textflag NOSPLIT |
165 func execve(path uintptr, argv uintptr, envp uintptr) (err uintptr) { | 165 func execve(path uintptr, argv uintptr, envp uintptr) (err uintptr) { |
| 166 LibCall c; |
| 167 |
166 USED(argv); | 168 USED(argv); |
167 USED(envp); | 169 USED(envp); |
168 LibCall c; | |
169 c.fn = (void*)libc·execve; | 170 c.fn = (void*)libc·execve; |
170 c.n = 3; | 171 c.n = 3; |
171 c.args = (void*)&path; | 172 c.args = (void*)&path; |
172 runtime·cgocall(runtime·asmsysvicall6, &c); | 173 runtime·cgocall(runtime·asmsysvicall6, &c); |
173 err = c.err; | 174 err = c.err; |
174 } | 175 } |
175 | 176 |
176 #pragma textflag NOSPLIT | 177 #pragma textflag NOSPLIT |
177 func exit(code uintptr) { | 178 func exit(code uintptr) { |
178 LibCall c; | 179 LibCall c; |
179 | 180 |
180 c.fn = (void*)libc·exit; | 181 c.fn = (void*)libc·exit; |
181 c.n = 1; | 182 c.n = 1; |
182 c.args = (void*)&code; | 183 c.args = (void*)&code; |
183 runtime·asmcgocall(runtime·asmsysvicall6, &c); | 184 runtime·asmcgocall(runtime·asmsysvicall6, &c); |
184 } | 185 } |
185 | 186 |
186 #pragma textflag NOSPLIT | 187 #pragma textflag NOSPLIT |
187 func fcntl1(fd uintptr, cmd uintptr, arg uintptr) (val uintptr, err uintptr) { | 188 func fcntl1(fd uintptr, cmd uintptr, arg uintptr) (val uintptr, err uintptr) { |
| 189 LibCall c; |
| 190 |
188 USED(cmd); | 191 USED(cmd); |
189 USED(arg); | 192 USED(arg); |
190 LibCall c; | |
191 c.fn = (void*)libc·fcntl; | 193 c.fn = (void*)libc·fcntl; |
192 c.n = 3; | 194 c.n = 3; |
193 c.args = (void*)&fd; | 195 c.args = (void*)&fd; |
194 runtime·cgocall(runtime·asmsysvicall6, &c); | 196 runtime·cgocall(runtime·asmsysvicall6, &c); |
195 err = c.err; | 197 err = c.err; |
196 val = c.r1; | 198 val = c.r1; |
197 } | 199 } |
198 | 200 |
199 func gethostname() (name String, err uintptr) { | 201 func gethostname() (name String, err uintptr) { |
200 struct { uintptr v[2]; } args; | 202 struct { uintptr v[2]; } args; |
(...skipping 10 matching lines...) Expand all Loading... |
211 if(c.r1) { | 213 if(c.r1) { |
212 name = runtime·emptystring; | 214 name = runtime·emptystring; |
213 return; | 215 return; |
214 } | 216 } |
215 cname[MAXHOSTNAMELEN - 1] = 0; | 217 cname[MAXHOSTNAMELEN - 1] = 0; |
216 name = runtime·gostring(cname); | 218 name = runtime·gostring(cname); |
217 } | 219 } |
218 | 220 |
219 #pragma textflag NOSPLIT | 221 #pragma textflag NOSPLIT |
220 func ioctl(fd uintptr, req uintptr, arg uintptr) (err uintptr) { | 222 func ioctl(fd uintptr, req uintptr, arg uintptr) (err uintptr) { |
| 223 LibCall c; |
| 224 |
221 USED(req); | 225 USED(req); |
222 USED(arg); | 226 USED(arg); |
223 LibCall c; | |
224 c.fn = (void*)libc·ioctl; | 227 c.fn = (void*)libc·ioctl; |
225 c.n = 3; | 228 c.n = 3; |
226 c.args = (void*)&fd; | 229 c.args = (void*)&fd; |
227 runtime·cgocall(runtime·asmsysvicall6, &c); | 230 runtime·cgocall(runtime·asmsysvicall6, &c); |
228 err = c.err; | 231 err = c.err; |
229 } | 232 } |
230 | 233 |
231 func wait4(pid uintptr, wstatus *uint32, options uintptr, rusage *void) (wpid in
t, err uintptr) { | 234 func wait4(pid uintptr, wstatus *uint32, options uintptr, rusage *void) (wpid in
t, err uintptr) { |
| 235 LibCall c; |
| 236 |
232 USED(wstatus); | 237 USED(wstatus); |
233 USED(options); | 238 USED(options); |
234 USED(rusage); | 239 USED(rusage); |
235 LibCall c; | |
236 c.fn = (void*)libc·wait4; | 240 c.fn = (void*)libc·wait4; |
237 c.n = 4; | 241 c.n = 4; |
238 c.args = (void*)&pid; | 242 c.args = (void*)&pid; |
239 runtime·cgocall(runtime·asmsysvicall6, &c); | 243 runtime·cgocall(runtime·asmsysvicall6, &c); |
240 err = c.err; | 244 err = c.err; |
241 wpid = c.r1; | 245 wpid = c.r1; |
242 } | 246 } |
243 | 247 |
244 #pragma textflag NOSPLIT | 248 #pragma textflag NOSPLIT |
245 func setgid(gid uintptr) (err uintptr) { | 249 func setgid(gid uintptr) (err uintptr) { |
246 LibCall c; | 250 LibCall c; |
| 251 |
247 c.fn = (void*)libc·setgid; | 252 c.fn = (void*)libc·setgid; |
248 c.n = 1; | 253 c.n = 1; |
249 c.args = (void*)&gid; | 254 c.args = (void*)&gid; |
250 runtime·asmcgocall(runtime·asmsysvicall6, &c); | 255 runtime·asmcgocall(runtime·asmsysvicall6, &c); |
251 err = c.err; | 256 err = c.err; |
252 } | 257 } |
253 | 258 |
254 #pragma textflag NOSPLIT | 259 #pragma textflag NOSPLIT |
255 func setgroups1(ngid uintptr, gid uintptr) (err uintptr) { | 260 func setgroups1(ngid uintptr, gid uintptr) (err uintptr) { |
256 LibCall c; | 261 LibCall c; |
257 | 262 |
258 USED(gid); | 263 USED(gid); |
259 c.fn = (void*)libc·setgroups; | 264 c.fn = (void*)libc·setgroups; |
260 c.n = 2; | 265 c.n = 2; |
261 c.args = (void*)&ngid; | 266 c.args = (void*)&ngid; |
262 runtime·asmcgocall(runtime·asmsysvicall6, &c); | 267 runtime·asmcgocall(runtime·asmsysvicall6, &c); |
263 err = c.err; | 268 err = c.err; |
264 } | 269 } |
265 | 270 |
266 #pragma textflag NOSPLIT | 271 #pragma textflag NOSPLIT |
267 func setsid() (pid uintptr, err uintptr) { | 272 func setsid() (pid uintptr, err uintptr) { |
268 LibCall c; | 273 LibCall c; |
| 274 |
269 c.fn = (void*)libc·setsid; | 275 c.fn = (void*)libc·setsid; |
270 c.n = 0; | 276 c.n = 0; |
271 c.args = (void*)0; | 277 c.args = (void*)0; |
272 runtime·asmcgocall(runtime·asmsysvicall6, &c); | 278 runtime·asmcgocall(runtime·asmsysvicall6, &c); |
273 err = c.err; | 279 err = c.err; |
274 pid = c.r1; | 280 pid = c.r1; |
275 } | 281 } |
276 | 282 |
277 #pragma textflag NOSPLIT | 283 #pragma textflag NOSPLIT |
278 func setuid(uid uintptr) (err uintptr) { | 284 func setuid(uid uintptr) (err uintptr) { |
279 LibCall c; | 285 LibCall c; |
| 286 |
280 c.fn = (void*)libc·setuid; | 287 c.fn = (void*)libc·setuid; |
281 c.n = 1; | 288 c.n = 1; |
282 c.args = (void*)&uid; | 289 c.args = (void*)&uid; |
283 runtime·asmcgocall(runtime·asmsysvicall6, &c); | 290 runtime·asmcgocall(runtime·asmsysvicall6, &c); |
284 err = c.err; | 291 err = c.err; |
285 } | 292 } |
286 | 293 |
287 #pragma textflag NOSPLIT | 294 #pragma textflag NOSPLIT |
288 func setpgid(pid uintptr, pgid uintptr) (err uintptr) { | 295 func setpgid(pid uintptr, pgid uintptr) (err uintptr) { |
289 LibCall c; | 296 LibCall c; |
290 | 297 |
291 USED(pgid); | 298 USED(pgid); |
292 c.fn = (void*)libc·setpgid; | 299 c.fn = (void*)libc·setpgid; |
293 c.n = 2; | 300 c.n = 2; |
294 c.args = (void*)&pid; | 301 c.args = (void*)&pid; |
295 runtime·asmcgocall(runtime·asmsysvicall6, &c); | 302 runtime·asmcgocall(runtime·asmsysvicall6, &c); |
296 err = c.err; | 303 err = c.err; |
297 } | 304 } |
298 | 305 |
299 #pragma textflag NOSPLIT | 306 #pragma textflag NOSPLIT |
300 func forkx(flags uintptr) (pid uintptr, err uintptr) { | 307 func forkx(flags uintptr) (pid uintptr, err uintptr) { |
301 LibCall c; | 308 LibCall c; |
| 309 |
302 c.fn = (void*)libc·forkx; | 310 c.fn = (void*)libc·forkx; |
303 c.n = 1; | 311 c.n = 1; |
304 c.args = (void*)&flags; | 312 c.args = (void*)&flags; |
305 runtime·asmcgocall(runtime·asmsysvicall6, &c); | 313 runtime·asmcgocall(runtime·asmsysvicall6, &c); |
306 err = c.err; | 314 err = c.err; |
307 pid = c.r1; | 315 pid = c.r1; |
308 } | 316 } |
309 | 317 |
310 void runtime·pipe1(void); | 318 void runtime·pipe1(void); |
311 | 319 |
312 func pipe() (r uintptr, w uintptr, err uintptr) { | 320 func pipe() (r uintptr, w uintptr, err uintptr) { |
313 LibCall c; | 321 LibCall c; |
314 | 322 |
315 c.fn = (void*)runtime·pipe1; | 323 c.fn = (void*)runtime·pipe1; |
316 c.n = 0; | 324 c.n = 0; |
317 c.args = (void*)0; | 325 c.args = (void*)0; |
318 runtime·cgocall(runtime·asmsysvicall6, &c); | 326 runtime·cgocall(runtime·asmsysvicall6, &c); |
319 err = c.err; | 327 err = c.err; |
320 r = c.r1; | 328 r = c.r1; |
321 w = c.r2; | 329 w = c.r2; |
322 } | 330 } |
323 | 331 |
324 #pragma textflag NOSPLIT | 332 #pragma textflag NOSPLIT |
325 func write1(fd uintptr, buf uintptr, nbyte uintptr) (n uintptr, err uintptr) { | 333 func write1(fd uintptr, buf uintptr, nbyte uintptr) (n uintptr, err uintptr) { |
| 334 LibCall c; |
| 335 |
326 USED(buf); | 336 USED(buf); |
327 USED(nbyte); | 337 USED(nbyte); |
328 LibCall c; | |
329 c.fn = (void*)libc·write; | 338 c.fn = (void*)libc·write; |
330 c.n = 3; | 339 c.n = 3; |
331 c.args = (void*)fd; | 340 c.args = (void*)fd; |
332 runtime·cgocall(runtime·asmsysvicall6, &c); | 341 runtime·cgocall(runtime·asmsysvicall6, &c); |
333 err = c.err; | 342 err = c.err; |
334 n = c.r1; | 343 n = c.r1; |
335 } | 344 } |
336 | 345 |
337 func Syscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr) (r1 uintptr, r2 u
intptr, err uintptr) { | 346 func Syscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr) (r1 uintptr, r2 u
intptr, err uintptr) { |
338 LibCall c; | 347 LibCall c; |
(...skipping 17 matching lines...) Expand all Loading... |
356 USED(a2); | 365 USED(a2); |
357 USED(a3); | 366 USED(a3); |
358 c.fn = (void*)libc·syscall; | 367 c.fn = (void*)libc·syscall; |
359 c.n = 4; | 368 c.n = 4; |
360 c.args = &trap; | 369 c.args = &trap; |
361 runtime·asmcgocall(runtime·asmsysvicall6, &c); | 370 runtime·asmcgocall(runtime·asmsysvicall6, &c); |
362 err = c.err; | 371 err = c.err; |
363 r1 = c.r1; | 372 r1 = c.r1; |
364 r2 = c.r2; | 373 r2 = c.r2; |
365 } | 374 } |
LEFT | RIGHT |