summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-11-07 13:27:56 +0000
committerroot <root>2007-11-07 13:27:56 +0000
commit69799d7a176d30624a5499b13ceff8687143f1b1 (patch)
tree2b6c87980868d39f5d313aa737496b9f8f96d63e
parent93fba227a29eca5571bc73e4e13525dd35710bd1 (diff)
*** empty log message ***
-rw-r--r--ev_select.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/ev_select.c b/ev_select.c
index d9fdf92..fc32b20 100644
--- a/ev_select.c
+++ b/ev_select.c
@@ -30,14 +30,22 @@
*/
/* for unix systems */
-#ifdef WIN32
+#if WIN32
typedef unsigned int uint32_t;
-# define EV_SELECT_USE_FD_SET 1
+# ifndef EV_SELECT_USE_FD_SET
+# define EV_SELECT_USE_FD_SET 1
+# endif
#else
# include <sys/select.h>
# include <inttypes.h>
#endif
+#if EV_SELECT_USE_WIN32_HANDLES
+# undef EV_SELECT_USE_FD_SET
+# define EV_SELECT_USE_FD_SET 1
+#else
+#endif
+
#include <string.h>
static void
@@ -47,6 +55,12 @@ select_modify (EV_P_ int fd, int oev, int nev)
return;
#if EV_SELECT_USE_FD_SET
+# if EV_SELECT_USE_WIN32_HANDLES
+ fd = _get_osfhandle (fd);
+ if (fd < 0)
+ return;
+# endif
+
if (nev & EV_READ)
FD_SET (fd, (struct fd_set *)vec_ri);
else
@@ -124,6 +138,26 @@ select_poll (EV_P_ ev_tstamp timeout)
}
#if EV_SELECT_USE_FD_SET
+# if EV_SELECT_USE_WIN32_HANDLES
+ for (word = 0; word < anfdmax; ++word)
+ {
+ if (!anfd [word].events)
+ {
+ int fd = _get_osfhandle (word);
+
+ if (fd >= 0)
+ {
+ int events = 0;
+
+ if (FD_ISSET (fd, (struct fd_set *)vec_ro)) events |= EV_READ;
+ if (FD_ISSET (fd, (struct fd_set *)vec_wo)) events |= EV_WRITE;
+
+ if (events)
+ fd_event (EV_A_ word, events);
+ }
+ }
+ }
+# else
for (word = 0; word < FD_SETSIZE; ++word)
{
int events = 0;
@@ -133,6 +167,7 @@ select_poll (EV_P_ ev_tstamp timeout)
if (events)
fd_event (EV_A_ word, events);
}
+# endif
#else
for (word = vec_max; word--; )
{