OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 // Linux system calls. | 5 // Linux system calls. |
6 // This file is compiled as ordinary Go code, | 6 // This file is compiled as ordinary Go code, |
7 // but it is also input to mksyscall, | 7 // but it is also input to mksyscall, |
8 // which parses the //sys lines and generates system call stubs. | 8 // which parses the //sys lines and generates system call stubs. |
9 // Note that sometimes we use a lowercase //sys name and | 9 // Note that sometimes we use a lowercase //sys name and |
10 // wrap it in our own nicer implementation. | 10 // wrap it in our own nicer implementation. |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 fd, errno = socket(domain, typ, proto) | 409 fd, errno = socket(domain, typ, proto) |
410 return | 410 return |
411 } | 411 } |
412 | 412 |
413 func Socketpair(domain, typ, proto int) (fd [2]int, errno int) { | 413 func Socketpair(domain, typ, proto int) (fd [2]int, errno int) { |
414 errno = socketpair(domain, typ, proto, &fd) | 414 errno = socketpair(domain, typ, proto, &fd) |
415 return | 415 return |
416 } | 416 } |
417 | 417 |
| 418 func GetsockoptInt(fd, level, opt int) (value, errno int) { |
| 419 var n int32 |
| 420 vallen := _Socklen(4) |
| 421 errno = getsockopt(fd, level, opt, uintptr(unsafe.Pointer(&n)), &vallen) |
| 422 return int(n), errno |
| 423 } |
| 424 |
418 func SetsockoptInt(fd, level, opt int, value int) (errno int) { | 425 func SetsockoptInt(fd, level, opt int, value int) (errno int) { |
419 var n = int32(value) | 426 var n = int32(value) |
420 return setsockopt(fd, level, opt, uintptr(unsafe.Pointer(&n)), 4) | 427 return setsockopt(fd, level, opt, uintptr(unsafe.Pointer(&n)), 4) |
421 } | 428 } |
422 | 429 |
423 func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (errno int) { | 430 func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (errno int) { |
424 return setsockopt(fd, level, opt, uintptr(unsafe.Pointer(tv)), unsafe.Si
zeof(*tv)) | 431 return setsockopt(fd, level, opt, uintptr(unsafe.Pointer(tv)), unsafe.Si
zeof(*tv)) |
425 } | 432 } |
426 | 433 |
427 func SetsockoptLinger(fd, level, opt int, l *Linger) (errno int) { | 434 func SetsockoptLinger(fd, level, opt int, l *Linger) (errno int) { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0)
} | 675 func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0)
} |
669 | 676 |
670 //sys reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int) | 677 //sys reboot(magic1 uint, magic2 uint, cmd int, arg string) (errno int) |
671 func Reboot(cmd int) (errno int) { | 678 func Reboot(cmd int) (errno int) { |
672 return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, "") | 679 return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, "") |
673 } | 680 } |
674 | 681 |
675 // Sendto | 682 // Sendto |
676 // Recvfrom | 683 // Recvfrom |
677 // Socketpair | 684 // Socketpair |
678 // Getsockopt | |
679 | 685 |
680 /* | 686 /* |
681 * Direct access | 687 * Direct access |
682 */ | 688 */ |
683 //sys Access(path string, mode uint32) (errno int) | 689 //sys Access(path string, mode uint32) (errno int) |
684 //sys Acct(path string) (errno int) | 690 //sys Acct(path string) (errno int) |
685 //sys Adjtimex(buf *Timex) (state int, errno int) | 691 //sys Adjtimex(buf *Timex) (state int, errno int) |
686 //sys Chdir(path string) (errno int) | 692 //sys Chdir(path string) (errno int) |
687 //sys Chmod(path string, mode uint32) (errno int) | 693 //sys Chmod(path string, mode uint32) (errno int) |
688 //sys Chroot(path string) (errno int) | 694 //sys Chroot(path string) (errno int) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 // Umount2 | 907 // Umount2 |
902 // Uselib | 908 // Uselib |
903 // Utimensat | 909 // Utimensat |
904 // Vfork | 910 // Vfork |
905 // Vhangup | 911 // Vhangup |
906 // Vmsplice | 912 // Vmsplice |
907 // Vserver | 913 // Vserver |
908 // Waitid | 914 // Waitid |
909 // Writev | 915 // Writev |
910 // _Sysctl | 916 // _Sysctl |
OLD | NEW |