summaryrefslogtreecommitdiff
path: root/Modules/selectmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r--Modules/selectmodule.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 00324a51bf..47da49399f 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -4,6 +4,10 @@
have any value except INVALID_SOCKET.
*/
+#if defined(HAVE_POLL_H) && !defined(_GNU_SOURCE)
+#define _GNU_SOURCE
+#endif
+
#include "Python.h"
#include <structmember.h>
@@ -1793,7 +1797,7 @@ static PyTypeObject kqueue_queue_Type;
*/
#if !defined(__OpenBSD__)
# define IDENT_TYPE T_UINTPTRT
-# define IDENT_CAST Py_intptr_t
+# define IDENT_CAST intptr_t
# define DATA_TYPE T_INTPTRT
# define DATA_FMT_UNIT INTPTRT_FMT_UNIT
# define IDENT_AsType PyLong_AsUintptr_t
@@ -1842,7 +1846,7 @@ kqueue_event_init(kqueue_event_Object *self, PyObject *args, PyObject *kwds)
PyObject *pfd;
static char *kwlist[] = {"ident", "filter", "flags", "fflags",
"data", "udata", NULL};
- static char *fmt = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
+ static const char fmt[] = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */
@@ -1872,7 +1876,7 @@ static PyObject *
kqueue_event_richcompare(kqueue_event_Object *s, kqueue_event_Object *o,
int op)
{
- Py_intptr_t result = 0;
+ intptr_t result = 0;
if (!kqueue_event_Check(o)) {
if (op == Py_EQ || op == Py_NE) {
@@ -2127,7 +2131,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
if (_PyTime_FromSecondsObject(&timeout,
otimeout, _PyTime_ROUND_CEILING) < 0) {
PyErr_Format(PyExc_TypeError,
- "timeout argument must be an number "
+ "timeout argument must be a number "
"or None, got %.200s",
Py_TYPE(otimeout)->tp_name);
return NULL;
@@ -2452,6 +2456,10 @@ PyInit_select(void)
#ifdef POLLMSG
PyModule_AddIntMacro(m, POLLMSG);
#endif
+#ifdef POLLRDHUP
+ /* Kernel 2.6.17+ */
+ PyModule_AddIntMacro(m, POLLRDHUP);
+#endif
}
#endif /* HAVE_POLL */
@@ -2473,12 +2481,18 @@ PyInit_select(void)
PyModule_AddIntMacro(m, EPOLLPRI);
PyModule_AddIntMacro(m, EPOLLERR);
PyModule_AddIntMacro(m, EPOLLHUP);
+#ifdef EPOLLRDHUP
+ /* Kernel 2.6.17 */
+ PyModule_AddIntMacro(m, EPOLLRDHUP);
+#endif
PyModule_AddIntMacro(m, EPOLLET);
#ifdef EPOLLONESHOT
/* Kernel 2.6.2+ */
PyModule_AddIntMacro(m, EPOLLONESHOT);
#endif
- /* PyModule_AddIntConstant(m, "EPOLL_RDHUP", EPOLLRDHUP); */
+#ifdef EPOLLEXCLUSIVE
+ PyModule_AddIntMacro(m, EPOLLEXCLUSIVE);
+#endif
#ifdef EPOLLRDNORM
PyModule_AddIntMacro(m, EPOLLRDNORM);
@@ -2519,13 +2533,21 @@ PyInit_select(void)
/* event filters */
PyModule_AddIntConstant(m, "KQ_FILTER_READ", EVFILT_READ);
PyModule_AddIntConstant(m, "KQ_FILTER_WRITE", EVFILT_WRITE);
+#ifdef EVFILT_AIO
PyModule_AddIntConstant(m, "KQ_FILTER_AIO", EVFILT_AIO);
+#endif
+#ifdef EVFILT_VNODE
PyModule_AddIntConstant(m, "KQ_FILTER_VNODE", EVFILT_VNODE);
+#endif
+#ifdef EVFILT_PROC
PyModule_AddIntConstant(m, "KQ_FILTER_PROC", EVFILT_PROC);
+#endif
#ifdef EVFILT_NETDEV
PyModule_AddIntConstant(m, "KQ_FILTER_NETDEV", EVFILT_NETDEV);
#endif
+#ifdef EVFILT_SIGNAL
PyModule_AddIntConstant(m, "KQ_FILTER_SIGNAL", EVFILT_SIGNAL);
+#endif
PyModule_AddIntConstant(m, "KQ_FILTER_TIMER", EVFILT_TIMER);
/* event flags */
@@ -2536,16 +2558,23 @@ PyInit_select(void)
PyModule_AddIntConstant(m, "KQ_EV_ONESHOT", EV_ONESHOT);
PyModule_AddIntConstant(m, "KQ_EV_CLEAR", EV_CLEAR);
+#ifdef EV_SYSFLAGS
PyModule_AddIntConstant(m, "KQ_EV_SYSFLAGS", EV_SYSFLAGS);
+#endif
+#ifdef EV_FLAG1
PyModule_AddIntConstant(m, "KQ_EV_FLAG1", EV_FLAG1);
+#endif
PyModule_AddIntConstant(m, "KQ_EV_EOF", EV_EOF);
PyModule_AddIntConstant(m, "KQ_EV_ERROR", EV_ERROR);
/* READ WRITE filter flag */
+#ifdef NOTE_LOWAT
PyModule_AddIntConstant(m, "KQ_NOTE_LOWAT", NOTE_LOWAT);
+#endif
/* VNODE filter flags */
+#ifdef EVFILT_VNODE
PyModule_AddIntConstant(m, "KQ_NOTE_DELETE", NOTE_DELETE);
PyModule_AddIntConstant(m, "KQ_NOTE_WRITE", NOTE_WRITE);
PyModule_AddIntConstant(m, "KQ_NOTE_EXTEND", NOTE_EXTEND);
@@ -2553,8 +2582,10 @@ PyInit_select(void)
PyModule_AddIntConstant(m, "KQ_NOTE_LINK", NOTE_LINK);
PyModule_AddIntConstant(m, "KQ_NOTE_RENAME", NOTE_RENAME);
PyModule_AddIntConstant(m, "KQ_NOTE_REVOKE", NOTE_REVOKE);
+#endif
/* PROC filter flags */
+#ifdef EVFILT_PROC
PyModule_AddIntConstant(m, "KQ_NOTE_EXIT", NOTE_EXIT);
PyModule_AddIntConstant(m, "KQ_NOTE_FORK", NOTE_FORK);
PyModule_AddIntConstant(m, "KQ_NOTE_EXEC", NOTE_EXEC);
@@ -2564,6 +2595,7 @@ PyInit_select(void)
PyModule_AddIntConstant(m, "KQ_NOTE_TRACK", NOTE_TRACK);
PyModule_AddIntConstant(m, "KQ_NOTE_CHILD", NOTE_CHILD);
PyModule_AddIntConstant(m, "KQ_NOTE_TRACKERR", NOTE_TRACKERR);
+#endif
/* NETDEV filter flags */
#ifdef EVFILT_NETDEV