1 // socket_epoll.go -- GNU/Linux epoll handling.
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Support for GNU/Linux epoll.
8 // Only for implementing net package.
9 // DO NOT USE DIRECTLY.
13 // We don't take this type directly from the header file because it
14 // uses a union. FIXME.
16 type EpollEvent
struct {
22 func libc_epoll_create(size
int) int __asm__ ("epoll_create");
23 func libc_epoll_ctl(epfd
, op
, fd
int, event
*EpollEvent
) int __asm__ ("epoll_ctl");
24 func libc_epoll_wait(epfd
int, events
*EpollEvent
, maxevents
int,
25 timeout
int) int __asm__ ("epoll_wait");
28 func EpollCreate(size
int) (fd
int, errno
int) {
29 fd
= libc_epoll_create(int(size
));
30 if fd
< 0 { errno
= GetErrno() }
34 func EpollCtl(epfd
, op
, fd
int, ev
*EpollEvent
) (errno
int) {
35 r
:= libc_epoll_ctl(epfd
, op
, fd
, ev
);
36 if r
< 0 { errno
= GetErrno() }
40 func EpollWait(epfd
int, ev
[]EpollEvent
, msec
int) (n
int, errno
int) {
41 var events
*EpollEvent
;
47 n
= libc_epoll_wait(epfd
, events
, maxevents
, msec
);
48 if n
< 0 { errno
= GetErrno() }