/*
+ * libev select fd activity backend
+ *
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
#include <unistd.h>
/* for unix systems */
-#include <sys/select.h>
+#ifndef WIN32
+# include <sys/select.h>
+#endif
#include <string.h>
#include <inttypes.h>
if (vec_max < (fd >> 5) + 1)
{
- vec_max = (fd >> 5) + 1;
+ int new_max = (fd >> 5) + 1;
+
+ vec_ri = (unsigned char *)realloc (vec_ri, new_max * 4);
+ vec_ro = (unsigned char *)realloc (vec_ro, new_max * 4); /* could free/malloc */
+ vec_wi = (unsigned char *)realloc (vec_wi, new_max * 4);
+ vec_wo = (unsigned char *)realloc (vec_wo, new_max * 4); /* could free/malloc */
- vec_ri = (unsigned char *)realloc (vec_ri, vec_max * 4);
- vec_ro = (unsigned char *)realloc (vec_ro, vec_max * 4); /* could free/malloc */
- vec_wi = (unsigned char *)realloc (vec_wi, vec_max * 4);
- vec_wo = (unsigned char *)realloc (vec_wo, vec_max * 4); /* could free/malloc */
+ for (; vec_max < new_max; ++vec_max)
+ ((uint32_t *)vec_ri)[vec_max] =
+ ((uint32_t *)vec_wi)[vec_max] = 0;
}
vec_ri [offs] |= mask;
vec_wi [offs] &= ~mask;
}
-static void select_poll (ev_tstamp timeout)
+static void
+select_poll (ev_tstamp timeout)
{
struct timeval tv;
int res;
}
}
}
+ else if (res < 0)
+ {
+ if (errno == EBADF)
+ fd_ebadf ();
+ else if (errno == ENOMEM)
+ fd_enomem ();
+ }
}
-void select_init (int flags)
+static void
+select_init (int flags)
{
ev_method = EVMETHOD_SELECT;
method_fudge = 1e-2; /* needed to compensate for select returning early, very conservative */
method_poll = select_poll;
}
-