1
/* Generated by Pyrex 0.9.4.1 on Sun Oct 15 15:04:09 2006 */
3
#define PY_SSIZE_T_CLEAN
5
#include "structmember.h"
7
#define PY_LONG_LONG LONG_LONG
9
#if PY_VERSION_HEX < 0x02050000
10
typedef int Py_ssize_t;
11
#define PY_SSIZE_T_MAX INT_MAX
12
#define PY_SSIZE_T_MIN INT_MIN
13
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
14
#define PyInt_AsSsize_t(o) PyInt_AsLong(o)
17
#define __PYX_EXTERN_C extern "C"
19
#define __PYX_EXTERN_C extern
21
__PYX_EXTERN_C double pow(double, double);
26
#include "sys/epoll.h"
29
typedef struct {const char *s; const void **p;} __Pyx_CApiTabEntry; /*proto*/
30
typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
31
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
32
static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t); /*proto*/
33
static int __Pyx_EndUnpack(PyObject *, Py_ssize_t); /*proto*/
34
static int __Pyx_PrintItem(PyObject *); /*proto*/
35
static int __Pyx_PrintNewline(void); /*proto*/
36
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
37
static void __Pyx_ReRaise(void); /*proto*/
38
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
39
static PyObject *__Pyx_GetExcValue(void); /*proto*/
40
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/
41
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
42
static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2); /*proto*/
43
static void __Pyx_WriteUnraisable(char *name); /*proto*/
44
static void __Pyx_AddTraceback(char *funcname); /*proto*/
45
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/
46
static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
47
static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/
48
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/
49
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
50
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
51
static int __Pyx_InitCApi(PyObject *module); /*proto*/
52
static int __Pyx_ImportModuleCApi(__Pyx_CApiTabEntry *t); /*proto*/
53
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
55
static PyObject *__pyx_m;
56
static PyObject *__pyx_b;
57
static int __pyx_lineno;
58
static char *__pyx_filename;
59
static char **__pyx_f;
61
static char __pyx_mdoc[] = "\nInterface to epoll I/O event notification facility.\n";
63
/* Declarations from _epoll */
66
struct __pyx_obj_6_epoll_epoll {
72
static PyTypeObject *__pyx_ptype_6_epoll_epoll = 0;
74
/* Implementation of _epoll */
76
static PyObject *__pyx_n_CTL_ADD;
77
static PyObject *__pyx_n_CTL_DEL;
78
static PyObject *__pyx_n_CTL_MOD;
79
static PyObject *__pyx_n_IN;
80
static PyObject *__pyx_n_OUT;
81
static PyObject *__pyx_n_PRI;
82
static PyObject *__pyx_n_ERR;
83
static PyObject *__pyx_n_HUP;
84
static PyObject *__pyx_n_ET;
85
static PyObject *__pyx_n_RDNORM;
86
static PyObject *__pyx_n_RDBAND;
87
static PyObject *__pyx_n_WRNORM;
88
static PyObject *__pyx_n_WRBAND;
89
static PyObject *__pyx_n_MSG;
91
static PyObject *__pyx_n_IOError;
93
static int __pyx_f_6_epoll_5epoll___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
94
static int __pyx_f_6_epoll_5epoll___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
98
PyObject *__pyx_2 = 0;
99
PyObject *__pyx_3 = 0;
100
PyObject *__pyx_4 = 0;
101
PyObject *__pyx_5 = 0;
102
static char *__pyx_argnames[] = {"size",0};
103
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_size)) return -1;
104
Py_INCREF(__pyx_v_self);
106
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":77 */
107
((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->fd = epoll_create(__pyx_v_size);
109
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":78 */
110
__pyx_1 = (((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->fd == (-1));
113
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":79 */
114
__pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_IOError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
115
__pyx_3 = PyInt_FromLong(errno); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
116
__pyx_4 = PyString_FromString(strerror(errno)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
117
__pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
118
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
119
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
122
__pyx_3 = PyObject_Call(__pyx_2, __pyx_5, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
123
Py_DECREF(__pyx_2); __pyx_2 = 0;
124
Py_DECREF(__pyx_5); __pyx_5 = 0;
125
__Pyx_Raise(__pyx_3, 0, 0);
126
Py_DECREF(__pyx_3); __pyx_3 = 0;
127
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; goto __pyx_L1;}
132
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":80 */
133
((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->initialized = 1;
142
__Pyx_AddTraceback("_epoll.epoll.__init__");
145
Py_DECREF(__pyx_v_self);
149
static void __pyx_f_6_epoll_5epoll___dealloc__(PyObject *__pyx_v_self); /*proto*/
150
static void __pyx_f_6_epoll_5epoll___dealloc__(PyObject *__pyx_v_self) {
152
Py_INCREF(__pyx_v_self);
154
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":83 */
155
__pyx_1 = ((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->initialized;
158
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":84 */
159
close(((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->fd);
161
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":85 */
162
((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->initialized = 0;
169
__Pyx_AddTraceback("_epoll.epoll.__dealloc__");
171
Py_DECREF(__pyx_v_self);
174
static PyObject *__pyx_f_6_epoll_5epoll_close(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
175
static char __pyx_doc_6_epoll_5epoll_close[] = "\n Close the epoll file descriptor.\n ";
176
static PyObject *__pyx_f_6_epoll_5epoll_close(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
179
PyObject *__pyx_2 = 0;
180
PyObject *__pyx_3 = 0;
181
PyObject *__pyx_4 = 0;
182
PyObject *__pyx_5 = 0;
183
static char *__pyx_argnames[] = {0};
184
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
185
Py_INCREF(__pyx_v_self);
187
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":91 */
188
__pyx_1 = ((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->initialized;
191
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":92 */
192
__pyx_1 = (close(((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->fd) == (-1));
195
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":93 */
196
__pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_IOError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
197
__pyx_3 = PyInt_FromLong(errno); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
198
__pyx_4 = PyString_FromString(strerror(errno)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
199
__pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
200
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
201
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
204
__pyx_3 = PyObject_Call(__pyx_2, __pyx_5, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
205
Py_DECREF(__pyx_2); __pyx_2 = 0;
206
Py_DECREF(__pyx_5); __pyx_5 = 0;
207
__Pyx_Raise(__pyx_3, 0, 0);
208
Py_DECREF(__pyx_3); __pyx_3 = 0;
209
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; goto __pyx_L1;}
214
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":94 */
215
((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->initialized = 0;
220
__pyx_r = Py_None; Py_INCREF(Py_None);
227
__Pyx_AddTraceback("_epoll.epoll.close");
230
Py_DECREF(__pyx_v_self);
234
static PyObject *__pyx_f_6_epoll_5epoll_fileno(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
235
static char __pyx_doc_6_epoll_5epoll_fileno[] = "\n Return the epoll file descriptor number.\n ";
236
static PyObject *__pyx_f_6_epoll_5epoll_fileno(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
238
PyObject *__pyx_1 = 0;
239
static char *__pyx_argnames[] = {0};
240
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
241
Py_INCREF(__pyx_v_self);
243
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":100 */
244
__pyx_1 = PyInt_FromLong(((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->fd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;}
249
__pyx_r = Py_None; Py_INCREF(Py_None);
253
__Pyx_AddTraceback("_epoll.epoll.fileno");
256
Py_DECREF(__pyx_v_self);
260
static PyObject *__pyx_f_6_epoll_5epoll__control(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
261
static char __pyx_doc_6_epoll_5epoll__control[] = "\n Modify the monitored state of a particular file descriptor.\n \n Wrap epoll_ctl(2).\n\n @type op: C{int}\n @param op: One of CTL_ADD, CTL_DEL, or CTL_MOD\n\n @type fd: C{int}\n @param fd: File descriptor to modify\n\n @type events: C{int}\n @param events: A bit set of IN, OUT, PRI, ERR, HUP, and ET.\n\n @raise IOError: Raised if the underlying epoll_ctl() call fails.\n ";
262
static PyObject *__pyx_f_6_epoll_5epoll__control(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
267
struct epoll_event __pyx_v_evt;
270
PyObject *__pyx_2 = 0;
271
PyObject *__pyx_3 = 0;
272
PyObject *__pyx_4 = 0;
273
PyObject *__pyx_5 = 0;
274
static char *__pyx_argnames[] = {"op","fd","events",0};
275
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iii", __pyx_argnames, &__pyx_v_op, &__pyx_v_fd, &__pyx_v_events)) return 0;
276
Py_INCREF(__pyx_v_self);
278
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":121 */
279
__pyx_v_evt.events = __pyx_v_events;
281
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":122 */
282
__pyx_v_evt.data.fd = __pyx_v_fd;
284
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":123 */
285
__pyx_v_result = epoll_ctl(((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->fd,__pyx_v_op,__pyx_v_fd,(&__pyx_v_evt));
287
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":124 */
288
__pyx_1 = (__pyx_v_result == (-1));
291
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":125 */
292
__pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_IOError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
293
__pyx_3 = PyInt_FromLong(errno); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
294
__pyx_4 = PyString_FromString(strerror(errno)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
295
__pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
296
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
297
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
300
__pyx_3 = PyObject_Call(__pyx_2, __pyx_5, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
301
Py_DECREF(__pyx_2); __pyx_2 = 0;
302
Py_DECREF(__pyx_5); __pyx_5 = 0;
303
__Pyx_Raise(__pyx_3, 0, 0);
304
Py_DECREF(__pyx_3); __pyx_3 = 0;
305
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
310
__pyx_r = Py_None; Py_INCREF(Py_None);
317
__Pyx_AddTraceback("_epoll.epoll._control");
320
Py_DECREF(__pyx_v_self);
324
static PyObject *__pyx_n_append;
326
static PyObject *__pyx_f_6_epoll_5epoll_wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
327
static char __pyx_doc_6_epoll_5epoll_wait[] = "\n Wait for an I/O event, wrap epoll_wait(2).\n\n @type maxevents: C{int}\n @param maxevents: Maximum number of events returned.\n\n @type timeout: C{int}\n @param timeout: Maximum time waiting for events. 0 makes it return\n immediately whereas -1 makes it wait indefinitely.\n \n @raise IOError: Raised if the underlying epoll_wait() call fails.\n ";
328
static PyObject *__pyx_f_6_epoll_5epoll_wait(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
329
unsigned int __pyx_v_maxevents;
331
struct epoll_event (*__pyx_v_events);
335
PyThreadState (*__pyx_v__save);
336
PyObject *__pyx_v_results;
340
PyObject *__pyx_2 = 0;
341
PyObject *__pyx_3 = 0;
342
PyObject *__pyx_4 = 0;
343
PyObject *__pyx_5 = 0;
346
static char *__pyx_argnames[] = {"maxevents","timeout",0};
347
if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Ii", __pyx_argnames, &__pyx_v_maxevents, &__pyx_v_timeout)) return 0;
348
Py_INCREF(__pyx_v_self);
349
__pyx_v_results = Py_None; Py_INCREF(Py_None);
350
__pyx_v_i = Py_None; Py_INCREF(Py_None);
352
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":146 */
353
__pyx_v_nbytes = ((sizeof(struct epoll_event )) * __pyx_v_maxevents);
355
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":147 */
356
__pyx_v_events = ((struct epoll_event (*))malloc(__pyx_v_nbytes));
358
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":148 */
359
memset(__pyx_v_events,0,__pyx_v_nbytes);
361
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":149 */
364
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":150 */
365
__pyx_v_fd = ((struct __pyx_obj_6_epoll_epoll *)__pyx_v_self)->fd;
367
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":152 */
368
__pyx_v__save = PyEval_SaveThread();
370
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":153 */
371
__pyx_v_result = epoll_wait(__pyx_v_fd,__pyx_v_events,__pyx_v_maxevents,__pyx_v_timeout);
373
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":154 */
374
PyEval_RestoreThread(__pyx_v__save);
376
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":156 */
377
__pyx_1 = (__pyx_v_result == (-1));
380
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":157 */
381
__pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_IOError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L3;}
382
__pyx_3 = PyInt_FromLong(errno); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L3;}
383
__pyx_4 = PyString_FromString(strerror(errno)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L3;}
384
__pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L3;}
385
PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
386
PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
389
__pyx_3 = PyObject_Call(__pyx_2, __pyx_5, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L3;}
390
Py_DECREF(__pyx_2); __pyx_2 = 0;
391
Py_DECREF(__pyx_5); __pyx_5 = 0;
392
__Pyx_Raise(__pyx_3, 0, 0);
393
Py_DECREF(__pyx_3); __pyx_3 = 0;
394
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L3;}
399
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":158 */
400
__pyx_4 = PyList_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; goto __pyx_L3;}
401
Py_DECREF(__pyx_v_results);
402
__pyx_v_results = __pyx_4;
405
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":159 */
406
for (__pyx_6 = 0; __pyx_6 < __pyx_v_result; ++__pyx_6) {
407
__pyx_2 = PyInt_FromLong(__pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L3;}
408
Py_DECREF(__pyx_v_i);
412
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":160 */
413
__pyx_5 = PyObject_GetAttr(__pyx_v_results, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L3;}
414
__pyx_7 = PyInt_AsSsize_t(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L3;}
415
__pyx_3 = PyInt_FromLong((__pyx_v_events[__pyx_7]).data.fd); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L3;}
416
__pyx_7 = PyInt_AsSsize_t(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L3;}
417
__pyx_4 = PyInt_FromLong(((int )(__pyx_v_events[__pyx_7]).events)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L3;}
418
__pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L3;}
419
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
420
PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);
423
__pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L3;}
424
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
426
__pyx_4 = PyObject_Call(__pyx_5, __pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L3;}
427
Py_DECREF(__pyx_5); __pyx_5 = 0;
428
Py_DECREF(__pyx_3); __pyx_3 = 0;
429
Py_DECREF(__pyx_4); __pyx_4 = 0;
434
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":161 */
435
Py_INCREF(__pyx_v_results);
436
__pyx_r = __pyx_v_results;
441
__pyx_why = 0; goto __pyx_L4;
442
__pyx_L2: __pyx_why = 3; goto __pyx_L4;
445
Py_XDECREF(__pyx_2); __pyx_2 = 0;
446
Py_XDECREF(__pyx_5); __pyx_5 = 0;
447
Py_XDECREF(__pyx_3); __pyx_3 = 0;
448
Py_XDECREF(__pyx_4); __pyx_4 = 0;
449
PyErr_Fetch(&__pyx_2, &__pyx_5, &__pyx_3);
450
__pyx_1 = __pyx_lineno;
455
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":163 */
456
free(__pyx_v_events);
458
case 3: goto __pyx_L0;
460
PyErr_Restore(__pyx_2, __pyx_5, __pyx_3);
461
__pyx_lineno = __pyx_1;
470
__pyx_r = Py_None; Py_INCREF(Py_None);
477
__Pyx_AddTraceback("_epoll.epoll.wait");
480
Py_DECREF(__pyx_v_results);
481
Py_DECREF(__pyx_v_i);
482
Py_DECREF(__pyx_v_self);
486
static __Pyx_InternTabEntry __pyx_intern_tab[] = {
487
{&__pyx_n_CTL_ADD, "CTL_ADD"},
488
{&__pyx_n_CTL_DEL, "CTL_DEL"},
489
{&__pyx_n_CTL_MOD, "CTL_MOD"},
490
{&__pyx_n_ERR, "ERR"},
492
{&__pyx_n_HUP, "HUP"},
494
{&__pyx_n_IOError, "IOError"},
495
{&__pyx_n_MSG, "MSG"},
496
{&__pyx_n_OUT, "OUT"},
497
{&__pyx_n_PRI, "PRI"},
498
{&__pyx_n_RDBAND, "RDBAND"},
499
{&__pyx_n_RDNORM, "RDNORM"},
500
{&__pyx_n_WRBAND, "WRBAND"},
501
{&__pyx_n_WRNORM, "WRNORM"},
502
{&__pyx_n_append, "append"},
506
static PyObject *__pyx_tp_new_6_epoll_epoll(PyTypeObject *t, PyObject *a, PyObject *k) {
507
PyObject *o = (*t->tp_alloc)(t, 0);
508
struct __pyx_obj_6_epoll_epoll *p = (struct __pyx_obj_6_epoll_epoll *)o;
512
static void __pyx_tp_dealloc_6_epoll_epoll(PyObject *o) {
513
struct __pyx_obj_6_epoll_epoll *p = (struct __pyx_obj_6_epoll_epoll *)o;
515
PyObject *etype, *eval, *etb;
516
PyErr_Fetch(&etype, &eval, &etb);
518
__pyx_f_6_epoll_5epoll___dealloc__(o);
519
if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
521
PyErr_Restore(etype, eval, etb);
523
(*o->ob_type->tp_free)(o);
526
static int __pyx_tp_traverse_6_epoll_epoll(PyObject *o, visitproc v, void *a) {
528
struct __pyx_obj_6_epoll_epoll *p = (struct __pyx_obj_6_epoll_epoll *)o;
532
static int __pyx_tp_clear_6_epoll_epoll(PyObject *o) {
533
struct __pyx_obj_6_epoll_epoll *p = (struct __pyx_obj_6_epoll_epoll *)o;
537
static struct PyMethodDef __pyx_methods_6_epoll_epoll[] = {
538
{"close", (PyCFunction)__pyx_f_6_epoll_5epoll_close, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_epoll_5epoll_close},
539
{"fileno", (PyCFunction)__pyx_f_6_epoll_5epoll_fileno, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_epoll_5epoll_fileno},
540
{"_control", (PyCFunction)__pyx_f_6_epoll_5epoll__control, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_epoll_5epoll__control},
541
{"wait", (PyCFunction)__pyx_f_6_epoll_5epoll_wait, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6_epoll_5epoll_wait},
545
static PyNumberMethods __pyx_tp_as_number_epoll = {
569
0, /*nb_inplace_add*/
570
0, /*nb_inplace_subtract*/
571
0, /*nb_inplace_multiply*/
572
0, /*nb_inplace_divide*/
573
0, /*nb_inplace_remainder*/
574
0, /*nb_inplace_power*/
575
0, /*nb_inplace_lshift*/
576
0, /*nb_inplace_rshift*/
577
0, /*nb_inplace_and*/
578
0, /*nb_inplace_xor*/
580
0, /*nb_floor_divide*/
581
0, /*nb_true_divide*/
582
0, /*nb_inplace_floor_divide*/
583
0, /*nb_inplace_true_divide*/
586
static PySequenceMethods __pyx_tp_as_sequence_epoll = {
595
0, /*sq_inplace_concat*/
596
0, /*sq_inplace_repeat*/
599
static PyMappingMethods __pyx_tp_as_mapping_epoll = {
602
0, /*mp_ass_subscript*/
605
static PyBufferProcs __pyx_tp_as_buffer_epoll = {
606
0, /*bf_getreadbuffer*/
607
0, /*bf_getwritebuffer*/
608
0, /*bf_getsegcount*/
609
0, /*bf_getcharbuffer*/
612
PyTypeObject __pyx_type_6_epoll_epoll = {
613
PyObject_HEAD_INIT(0)
615
"_epoll.epoll", /*tp_name*/
616
sizeof(struct __pyx_obj_6_epoll_epoll), /*tp_basicsize*/
618
__pyx_tp_dealloc_6_epoll_epoll, /*tp_dealloc*/
624
&__pyx_tp_as_number_epoll, /*tp_as_number*/
625
&__pyx_tp_as_sequence_epoll, /*tp_as_sequence*/
626
&__pyx_tp_as_mapping_epoll, /*tp_as_mapping*/
632
&__pyx_tp_as_buffer_epoll, /*tp_as_buffer*/
633
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
634
"\n Represent a set of file descriptors being monitored for events.\n ", /*tp_doc*/
635
__pyx_tp_traverse_6_epoll_epoll, /*tp_traverse*/
636
__pyx_tp_clear_6_epoll_epoll, /*tp_clear*/
637
0, /*tp_richcompare*/
638
0, /*tp_weaklistoffset*/
641
__pyx_methods_6_epoll_epoll, /*tp_methods*/
649
__pyx_f_6_epoll_5epoll___init__, /*tp_init*/
651
__pyx_tp_new_6_epoll_epoll, /*tp_new*/
661
static struct PyMethodDef __pyx_methods[] = {
665
static void __pyx_init_filenames(void); /*proto*/
667
PyMODINIT_FUNC init_epoll(void); /*proto*/
668
PyMODINIT_FUNC init_epoll(void) {
669
PyObject *__pyx_1 = 0;
670
__pyx_init_filenames();
671
__pyx_m = Py_InitModule4("_epoll", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
672
if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
673
__pyx_b = PyImport_AddModule("__builtin__");
674
if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
675
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
676
if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;};
677
if (PyType_Ready(&__pyx_type_6_epoll_epoll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;}
678
if (PyObject_SetAttrString(__pyx_m, "epoll", (PyObject *)&__pyx_type_6_epoll_epoll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;}
679
__pyx_ptype_6_epoll_epoll = &__pyx_type_6_epoll_epoll;
681
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":165 */
682
__pyx_1 = PyInt_FromLong(EPOLL_CTL_ADD); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}
683
if (PyObject_SetAttr(__pyx_m, __pyx_n_CTL_ADD, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; goto __pyx_L1;}
684
Py_DECREF(__pyx_1); __pyx_1 = 0;
686
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":166 */
687
__pyx_1 = PyInt_FromLong(EPOLL_CTL_DEL); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
688
if (PyObject_SetAttr(__pyx_m, __pyx_n_CTL_DEL, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; goto __pyx_L1;}
689
Py_DECREF(__pyx_1); __pyx_1 = 0;
691
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":167 */
692
__pyx_1 = PyInt_FromLong(EPOLL_CTL_MOD); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L1;}
693
if (PyObject_SetAttr(__pyx_m, __pyx_n_CTL_MOD, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L1;}
694
Py_DECREF(__pyx_1); __pyx_1 = 0;
696
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":169 */
697
__pyx_1 = PyInt_FromLong(EPOLLIN); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
698
if (PyObject_SetAttr(__pyx_m, __pyx_n_IN, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
699
Py_DECREF(__pyx_1); __pyx_1 = 0;
701
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":170 */
702
__pyx_1 = PyInt_FromLong(EPOLLOUT); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;}
703
if (PyObject_SetAttr(__pyx_m, __pyx_n_OUT, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; goto __pyx_L1;}
704
Py_DECREF(__pyx_1); __pyx_1 = 0;
706
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":171 */
707
__pyx_1 = PyInt_FromLong(EPOLLPRI); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
708
if (PyObject_SetAttr(__pyx_m, __pyx_n_PRI, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; goto __pyx_L1;}
709
Py_DECREF(__pyx_1); __pyx_1 = 0;
711
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":172 */
712
__pyx_1 = PyInt_FromLong(EPOLLERR); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; goto __pyx_L1;}
713
if (PyObject_SetAttr(__pyx_m, __pyx_n_ERR, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; goto __pyx_L1;}
714
Py_DECREF(__pyx_1); __pyx_1 = 0;
716
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":173 */
717
__pyx_1 = PyInt_FromLong(EPOLLHUP); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
718
if (PyObject_SetAttr(__pyx_m, __pyx_n_HUP, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
719
Py_DECREF(__pyx_1); __pyx_1 = 0;
721
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":174 */
722
__pyx_1 = PyInt_FromLong(EPOLLET); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
723
if (PyObject_SetAttr(__pyx_m, __pyx_n_ET, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
724
Py_DECREF(__pyx_1); __pyx_1 = 0;
726
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":176 */
727
__pyx_1 = PyInt_FromLong(EPOLLRDNORM); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
728
if (PyObject_SetAttr(__pyx_m, __pyx_n_RDNORM, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;}
729
Py_DECREF(__pyx_1); __pyx_1 = 0;
731
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":177 */
732
__pyx_1 = PyInt_FromLong(EPOLLRDBAND); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
733
if (PyObject_SetAttr(__pyx_m, __pyx_n_RDBAND, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; goto __pyx_L1;}
734
Py_DECREF(__pyx_1); __pyx_1 = 0;
736
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":178 */
737
__pyx_1 = PyInt_FromLong(EPOLLWRNORM); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L1;}
738
if (PyObject_SetAttr(__pyx_m, __pyx_n_WRNORM, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; goto __pyx_L1;}
739
Py_DECREF(__pyx_1); __pyx_1 = 0;
741
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":179 */
742
__pyx_1 = PyInt_FromLong(EPOLLWRBAND); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
743
if (PyObject_SetAttr(__pyx_m, __pyx_n_WRBAND, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
744
Py_DECREF(__pyx_1); __pyx_1 = 0;
746
/* "/home/exarkun/Projects/Twisted/branches/epollreactor-1953-2/twisted/python/_epoll.pyx":180 */
747
__pyx_1 = PyInt_FromLong(EPOLLMSG); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
748
if (PyObject_SetAttr(__pyx_m, __pyx_n_MSG, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; goto __pyx_L1;}
749
Py_DECREF(__pyx_1); __pyx_1 = 0;
753
__Pyx_AddTraceback("_epoll");
756
static char *__pyx_filenames[] = {
760
/* Runtime support code */
762
static void __pyx_init_filenames(void) {
763
__pyx_f = __pyx_filenames;
766
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
768
result = PyObject_GetAttr(dict, name);
770
PyErr_SetObject(PyExc_NameError, name);
774
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
778
/* First, check the traceback argument, replacing None with NULL. */
783
else if (tb != NULL && !PyTraceBack_Check(tb)) {
784
PyErr_SetString(PyExc_TypeError,
785
"raise: arg 3 must be a traceback or None");
788
/* Next, replace a missing value with None */
793
/* Next, repeatedly, replace a tuple exception with its first item */
794
while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {
795
PyObject *tmp = type;
796
type = PyTuple_GET_ITEM(type, 0);
800
if (PyString_CheckExact(type)) {
801
/* Raising builtin string is deprecated but still allowed --
802
* do nothing. Raising an instance of a new-style str
803
* subclass is right out. */
804
if (PyErr_Warn(PyExc_DeprecationWarning,
805
"raising a string exception is deprecated"))
808
else if (PyType_Check(type) || PyClass_Check(type))
809
; /* PyErr_NormalizeException(&type, &value, &tb); */
810
else if (PyInstance_Check(type)) {
811
/* Raising an instance. The value should be a dummy. */
812
if (value != Py_None) {
813
PyErr_SetString(PyExc_TypeError,
814
"instance exception may not have a separate value");
818
/* Normalize to raise <class>, <instance> */
821
type = (PyObject*) ((PyInstanceObject*)type)->in_class;
825
else if (PyType_IsSubtype(type->ob_type, (PyTypeObject*)PyExc_Exception)) {
826
/* Raising a new-style object (in Py2.5).
827
The value should be a dummy. */
828
if (value != Py_None) {
829
PyErr_SetString(PyExc_TypeError,
830
"instance exception may not have a separate value");
834
/* Normalize to raise <class>, <instance> */
837
type = (PyObject*) type->ob_type;
842
/* Not something you can raise. You get an exception
843
anyway, just not what you specified :-) */
844
PyErr_Format(PyExc_TypeError,
845
"exceptions must be classes, instances, or "
846
"strings (deprecated), not %s",
847
type->ob_type->tp_name);
850
PyErr_Restore(type, value, tb);
859
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
861
*t->p = PyString_InternFromString(t->s);
870
#include "frameobject.h"
871
#include "traceback.h"
873
static void __Pyx_AddTraceback(char *funcname) {
874
PyObject *py_srcfile = 0;
875
PyObject *py_funcname = 0;
876
PyObject *py_globals = 0;
877
PyObject *empty_tuple = 0;
878
PyObject *empty_string = 0;
879
PyCodeObject *py_code = 0;
880
PyFrameObject *py_frame = 0;
882
py_srcfile = PyString_FromString(__pyx_filename);
883
if (!py_srcfile) goto bad;
884
py_funcname = PyString_FromString(funcname);
885
if (!py_funcname) goto bad;
886
py_globals = PyModule_GetDict(__pyx_m);
887
if (!py_globals) goto bad;
888
empty_tuple = PyTuple_New(0);
889
if (!empty_tuple) goto bad;
890
empty_string = PyString_FromString("");
891
if (!empty_string) goto bad;
892
py_code = PyCode_New(
895
0, /*int stacksize,*/
897
empty_string, /*PyObject *code,*/
898
empty_tuple, /*PyObject *consts,*/
899
empty_tuple, /*PyObject *names,*/
900
empty_tuple, /*PyObject *varnames,*/
901
empty_tuple, /*PyObject *freevars,*/
902
empty_tuple, /*PyObject *cellvars,*/
903
py_srcfile, /*PyObject *filename,*/
904
py_funcname, /*PyObject *name,*/
905
__pyx_lineno, /*int firstlineno,*/
906
empty_string /*PyObject *lnotab*/
908
if (!py_code) goto bad;
909
py_frame = PyFrame_New(
910
PyThreadState_Get(), /*PyThreadState *tstate,*/
911
py_code, /*PyCodeObject *code,*/
912
py_globals, /*PyObject *globals,*/
913
0 /*PyObject *locals*/
915
if (!py_frame) goto bad;
916
py_frame->f_lineno = __pyx_lineno;
917
PyTraceBack_Here(py_frame);
919
Py_XDECREF(py_srcfile);
920
Py_XDECREF(py_funcname);
921
Py_XDECREF(empty_tuple);
922
Py_XDECREF(empty_string);
924
Py_XDECREF(py_frame);