1
2
3
4
5
6 package syscall
7
8 import (
9 "unsafe"
10 )
11
12
13
14
15
16 func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr)
17
18 func EpollCreate1(flags int32) (fd int32, errno uintptr) {
19 r1, _, e := Syscall6(SYS_EPOLL_CREATE1, uintptr(flags), 0, 0, 0, 0, 0)
20 return int32(r1), e
21 }
22
23 var _zero uintptr
24
25 func EpollWait(epfd int32, events []EpollEvent, maxev, waitms int32) (n int32, errno uintptr) {
26 var ev unsafe.Pointer
27 if len(events) > 0 {
28 ev = unsafe.Pointer(&events[0])
29 } else {
30 ev = unsafe.Pointer(&_zero)
31 }
32 r1, _, e := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(ev), uintptr(maxev), uintptr(waitms), 0, 0)
33 return int32(r1), e
34 }
35
36 func EpollCtl(epfd, op, fd int32, event *EpollEvent) (errno uintptr) {
37 _, _, e := Syscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
38 return e
39 }
40
41 func Eventfd(initval, flags int32) (fd int32, errno uintptr) {
42 r1, _, e := Syscall6(SYS_EVENTFD2, uintptr(initval), uintptr(flags), 0, 0, 0, 0)
43 return int32(r1), e
44 }
45
View as plain text