1 # Copyright (C) 2008-2009, Eduardo Silva <edsiper@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # Linux sys/epoll.h values
31 EPOLLONESHOT = (1 << 30)
38 # epoll data structures
39 class epoll_data(Structure):
40 _fields_ = [("ptr", c_void_p),
45 class epoll_event(Structure):
46 _fields_ = [("events", c_uint32),
55 self._lib = cdll.LoadLibrary(self._LIBC)
57 print "Cannot open %s" % self._LIBC
60 def epoll_create(self, size):
62 n = self._lib.epoll_create(size)
65 print "Error calling epoll_create()"
68 def epoll_wait(self, efd, events, max_events, timeout):
69 return self._lib.epoll_wait(efd, events, max_events, timeout)
72 def epoll_ctl(self, epfd, op, fd, event):
73 return self._lib.epoll_ctl(epfd, op, fd, byref(event))
75 def epoll_event(self, events, edata):
76 return byref(epoll_event(events, edata))