Codebase list golang-golang-x-sys / 5d61b82
Imported Upstream version 0.0~git20160704.0.a408501 Martín Ferrari 7 years ago
35 changed file(s) with 284 addition(s) and 38 deletion(s). Raw diff Collapse all Expand all
0 # Treat all files in this repo as binary, with no git magic updating
1 # line endings. Windows users contributing to Go will need to use a
2 # modern version of git and editors capable of LF line endings.
3 #
4 # We'll prevent accidental CRLF line endings from entering the repo
5 # via the git-review gofmt checks.
6 #
7 # See golang.org/issue/9281
8
9 * -text
0 # Add no patterns to .hgignore except for files generated by the build.
1 last-change
143143 uintptr(options),
144144 0,
145145 )
146 use(unsafe.Pointer(_p0))
146147 if e1 != 0 {
147148 return nil, e1
148149 }
195196 bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
196197 }
197198 r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags))
199 use(unsafe.Pointer(_p0))
198200 n = int(r0)
199201 if e1 != 0 {
200202 err = e1
108108 bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
109109 }
110110 r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
111 use(unsafe.Pointer(_p0))
111112 n = int(r0)
112113 if e1 != 0 {
113114 err = e1
128128 bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
129129 }
130130 r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
131 use(unsafe.Pointer(_p0))
131132 n = int(r0)
132133 if e1 != 0 {
133134 err = e1
5959 return openat(dirfd, path, flags|O_LARGEFILE, mode)
6060 }
6161
62 //sys poll(fds *PollFd, nfd int, timeout int) (n int, err error)
63
64 func Poll(fds []PollFd, timeout int) (n int, err error) {
62 //sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
63
64 func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
6565 if len(fds) == 0 {
66 return poll(nil, 0, timeout)
67 }
68 return poll(&fds[0], len(fds), timeout)
66 return ppoll(nil, 0, timeout, sigmask)
67 }
68 return ppoll(&fds[0], len(fds), timeout, sigmask)
6969 }
7070
7171 //sys readlinkat(dirfd int, path string, buf []byte) (n int, err error)
10511051 // Newfstatat
10521052 // Nfsservctl
10531053 // Personality
1054 // Ppoll
10551054 // Pselect6
10561055 // Ptrace
10571056 // Putpmsg
387387 func (cmsg *Cmsghdr) SetLen(length int) {
388388 cmsg.Len = uint32(length)
389389 }
390
391 //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
392
393 func Poll(fds []PollFd, timeout int) (n int, err error) {
394 if len(fds) == 0 {
395 return poll(nil, 0, timeout)
396 }
397 return poll(&fds[0], len(fds), timeout)
398 }
145145 func (cmsg *Cmsghdr) SetLen(length int) {
146146 cmsg.Len = uint64(length)
147147 }
148
149 //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
150
151 func Poll(fds []PollFd, timeout int) (n int, err error) {
152 if len(fds) == 0 {
153 return poll(nil, 0, timeout)
154 }
155 return poll(&fds[0], len(fds), timeout)
156 }
251251 func (cmsg *Cmsghdr) SetLen(length int) {
252252 cmsg.Len = uint32(length)
253253 }
254
255 //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
256
257 func Poll(fds []PollFd, timeout int) (n int, err error) {
258 if len(fds) == 0 {
259 return poll(nil, 0, timeout)
260 }
261 return poll(&fds[0], len(fds), timeout)
262 }
177177 SYS_EPOLL_CREATE = 1042
178178 SYS_EPOLL_WAIT = 1069
179179 )
180
181 func Poll(fds []PollFd, timeout int) (n int, err error) {
182 var ts *Timespec
183 if timeout >= 0 {
184 ts = new(Timespec)
185 *ts = NsecToTimespec(int64(timeout) * 1e6)
186 }
187 if len(fds) == 0 {
188 return ppoll(nil, 0, ts, nil)
189 }
190 return ppoll(&fds[0], len(fds), ts, nil)
191 }
203203 func (cmsg *Cmsghdr) SetLen(length int) {
204204 cmsg.Len = uint64(length)
205205 }
206
207 //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
208
209 func Poll(fds []PollFd, timeout int) (n int, err error) {
210 if len(fds) == 0 {
211 return poll(nil, 0, timeout)
212 }
213 return poll(&fds[0], len(fds), timeout)
214 }
123123 p[1] = int(pp[1])
124124 return
125125 }
126
127 //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
128
129 func Poll(fds []PollFd, timeout int) (n int, err error) {
130 if len(fds) == 0 {
131 return poll(nil, 0, timeout)
132 }
133 return poll(&fds[0], len(fds), timeout)
134 }
317317 }
318318 return nil
319319 }
320
321 //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
322
323 func Poll(fds []PollFd, timeout int) (n int, err error) {
324 if len(fds) == 0 {
325 return poll(nil, 0, timeout)
326 }
327 return poll(&fds[0], len(fds), timeout)
328 }
1515 )
1616
1717 func TestPoll(t *testing.T) {
18 err := unix.Mkfifo("fifo", 0666)
19 if err != nil {
20 t.Errorf("Poll: failed to create FIFO: %v", err)
21 return
22 }
23 defer os.Remove("fifo")
24
25 f, err := os.OpenFile("fifo", os.O_RDWR, 0666)
26 if err != nil {
27 t.Errorf("Poll: failed to open FIFO: %v", err)
28 return
29 }
30 defer f.Close()
18 f, cleanup := mktmpfifo(t)
19 defer cleanup()
3120
3221 const timeout = 100
3322
5039 if n != 0 {
5140 t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0)
5241 return
42 }
43 }
44
45 func TestPpoll(t *testing.T) {
46 f, cleanup := mktmpfifo(t)
47 defer cleanup()
48
49 const timeout = 100 * time.Millisecond
50
51 ok := make(chan bool, 1)
52 go func() {
53 select {
54 case <-time.After(10 * timeout):
55 t.Errorf("Ppoll: failed to timeout after %d", 10*timeout)
56 case <-ok:
57 }
58 }()
59
60 fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}}
61 timeoutTs := unix.NsecToTimespec(int64(timeout))
62 n, err := unix.Ppoll(fds, &timeoutTs, nil)
63 ok <- true
64 if err != nil {
65 t.Errorf("Ppoll: unexpected error: %v", err)
66 return
67 }
68 if n != 0 {
69 t.Errorf("Ppoll: wrong number of events: got %v, expected %v", n, 0)
70 return
71 }
72 }
73
74 // mktmpfifo creates a temporary FIFO and provides a cleanup function.
75 func mktmpfifo(t *testing.T) (*os.File, func()) {
76 err := unix.Mkfifo("fifo", 0666)
77 if err != nil {
78 t.Fatalf("mktmpfifo: failed to create FIFO: %v", err)
79 }
80
81 f, err := os.OpenFile("fifo", os.O_RDWR, 0666)
82 if err != nil {
83 os.Remove("fifo")
84 t.Fatalf("mktmpfifo: failed to open FIFO: %v", err)
85 }
86
87 return f, func() {
88 f.Close()
89 os.Remove("fifo")
5390 }
5491 }
5592
110110 bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
111111 }
112112 r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
113 use(unsafe.Pointer(_p0))
113114 n = int(r0)
114115 if e1 != 0 {
115116 err = e1
442442 POLLNVAL = C.POLLNVAL
443443 )
444444
445 type Sigset_t C.sigset_t
446
445447 // Terminal handling
446448
447449 type Termios C.termios_t
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
16461646 }
16471647 return
16481648 }
1649
1650 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1651
1652 func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
1653 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
1654 n = int(r0)
1655 if e1 != 0 {
1656 err = errnoErr(e1)
1657 }
1658 return
1659 }
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
18401840 }
18411841 return
18421842 }
1843
1844 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1845
1846 func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
1847 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
1848 n = int(r0)
1849 if e1 != 0 {
1850 err = errnoErr(e1)
1851 }
1852 return
1853 }
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
17471747 }
17481748 return
17491749 }
1750
1751 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1752
1753 func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
1754 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
1755 n = int(r0)
1756 if e1 != 0 {
1757 err = errnoErr(e1)
1758 }
1759 return
1760 }
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
17891789 }
17901790 return
17911791 }
1792
1793 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1794
1795 func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
1796 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
1797 n = int(r0)
1798 if e1 != 0 {
1799 err = errnoErr(e1)
1800 }
1801 return
1802 }
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
17891789 }
17901790 return
17911791 }
1792
1793 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1794
1795 func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
1796 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
1797 n = int(r0)
1798 if e1 != 0 {
1799 err = errnoErr(e1)
1800 }
1801 return
1802 }
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
18511851 }
18521852 return
18531853 }
1854
1855 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1856
1857 func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
1858 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
1859 n = int(r0)
1860 if e1 != 0 {
1861 err = errnoErr(e1)
1862 }
1863 return
1864 }
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
18511851 }
18521852 return
18531853 }
1854
1855 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1856
1857 func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
1858 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
1859 n = int(r0)
1860 if e1 != 0 {
1861 err = errnoErr(e1)
1862 }
1863 return
1864 }
5252
5353 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
5454
55 func poll(fds *PollFd, nfd int, timeout int) (n int, err error) {
56 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfd), uintptr(timeout))
55 func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
56 r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
5757 n = int(r0)
5858 if e1 != 0 {
5959 err = errnoErr(e1)
16311631 }
16321632 return
16331633 }
1634
1635 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
1636
1637 func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
1638 r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
1639 n = int(r0)
1640 if e1 != 0 {
1641 err = errnoErr(e1)
1642 }
1643 return
1644 }
610610 POLLNVAL = 0x20
611611 )
612612
613 type Sigset_t struct {
614 X__val [16]uint64
615 }
616
613617 type Termios struct {
614618 Iflag uint32
615619 Oflag uint32
628628 POLLNVAL = 0x20
629629 )
630630
631 type Sigset_t struct {
632 X__val [16]uint64
633 }
634
631635 type Termios struct {
632636 Iflag uint32
633637 Oflag uint32
590590 POLLNVAL = 0x20
591591 )
592592
593 type Sigset_t struct {
594 X__val [16]uint64
595 }
596
593597 type Termios struct {
594598 Iflag uint32
595599 Oflag uint32
607607 POLLNVAL = 0x20
608608 )
609609
610 type Sigset_t struct {
611 X__val [16]uint64
612 }
613
610614 type Termios struct {
611615 Iflag uint32
612616 Oflag uint32
611611 POLLNVAL = 0x20
612612 )
613613
614 type Sigset_t struct {
615 X__val [16]uint64
616 }
617
614618 type Termios struct {
615619 Iflag uint32
616620 Oflag uint32
611611 POLLNVAL = 0x20
612612 )
613613
614 type Sigset_t struct {
615 X__val [16]uint64
616 }
617
614618 type Termios struct {
615619 Iflag uint32
616620 Oflag uint32
617617 POLLNVAL = 0x20
618618 )
619619
620 type Sigset_t struct {
621 X__val [16]uint64
622 }
623
620624 type Termios struct {
621625 Iflag uint32
622626 Oflag uint32
617617 POLLNVAL = 0x20
618618 )
619619
620 type Sigset_t struct {
621 X__val [16]uint64
622 }
623
620624 type Termios struct {
621625 Iflag uint32
622626 Oflag uint32
632632 POLLNVAL = 0x20
633633 )
634634
635 type Sigset_t struct {
636 X__val [16]uint64
637 }
638
635639 type Termios struct {
636640 Iflag uint32
637641 Oflag uint32