}
#endif
-#define array_roundsize(type,n) ((n) | 4 & ~3)
+#define array_roundsize(type,n) (((n) | 4) & ~3)
#define array_needsize(type,base,cur,cnt,init) \
if (expect_false ((cnt) > cur)) \
}
static void
-loop_init (EV_P_ int methods)
+loop_init (EV_P_ unsigned int flags)
{
if (!method)
{
now_floor = mn_now;
rtmn_diff = ev_rt_now - mn_now;
- if (methods == EVMETHOD_AUTO)
- if (!enable_secure () && getenv ("LIBEV_METHODS"))
- methods = atoi (getenv ("LIBEV_METHODS"));
- else
- methods = EVMETHOD_ANY;
+ if (!(flags & EVMETHOD_NOENV) && !enable_secure () && getenv ("LIBEV_FLAGS"))
+ flags = atoi (getenv ("LIBEV_FLAGS"));
+
+ if (!(flags & 0x0000ffff))
+ flags |= 0x0000ffff;
method = 0;
#if EV_USE_KQUEUE
- if (!method && (methods & EVMETHOD_KQUEUE)) method = kqueue_init (EV_A_ methods);
+ if (!method && (flags & EVMETHOD_KQUEUE)) method = kqueue_init (EV_A_ flags);
#endif
#if EV_USE_EPOLL
- if (!method && (methods & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ methods);
+ if (!method && (flags & EVMETHOD_EPOLL )) method = epoll_init (EV_A_ flags);
#endif
#if EV_USE_POLL
- if (!method && (methods & EVMETHOD_POLL )) method = poll_init (EV_A_ methods);
+ if (!method && (flags & EVMETHOD_POLL )) method = poll_init (EV_A_ flags);
#endif
#if EV_USE_SELECT
- if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods);
+ if (!method && (flags & EVMETHOD_SELECT)) method = select_init (EV_A_ flags);
#endif
ev_init (&sigev, sigcb);
#if EV_MULTIPLICITY
struct ev_loop *
-ev_loop_new (int methods)
+ev_loop_new (unsigned int flags)
{
struct ev_loop *loop = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop));
memset (loop, 0, sizeof (struct ev_loop));
- loop_init (EV_A_ methods);
+ loop_init (EV_A_ flags);
if (ev_method (EV_A))
return loop;
#else
int
#endif
-ev_default_loop (int methods)
+ev_default_loop (unsigned int methods)
{
if (sigpipe [0] == sigpipe [1])
if (pipe (sigpipe))
/* first reschedule or stop timer */
if (w->reschedule_cb)
{
- ev_tstamp at = ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001);
-
+ ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001);
assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > ev_rt_now));
downheap ((WT *)periodics, periodiccnt, 0);
}
struct ev_child child;
};
-#define EVMETHOD_AUTO 0 /* consults environment */
-#define EVMETHOD_SELECT 1
-#define EVMETHOD_POLL 2
-#define EVMETHOD_EPOLL 4
-#define EVMETHOD_KQUEUE 8
-#define EVMETHOD_DEVPOLL 16 /* NYI */
-#define EVMETHOD_PORT 32 /* NYI */
-#define EVMETHOD_WIN32 64 /* NYI */
-#define EVMETHOD_ANY ~0 /* any method, do not consult env */
+/* bits for ev_default_loop and ev_loop_new */
+/* the default */
+#define EVMETHOD_AUTO 0x00000000 /* not quite a mask */
+
+/* method bits to be ored together */
+#define EVMETHOD_SELECT 0x00000001 /* about anywhere */
+#define EVMETHOD_POLL 0x00000002 /* !win */
+#define EVMETHOD_EPOLL 0x00000004 /* linux */
+#define EVMETHOD_KQUEUE 0x00000008 /* bsd */
+#define EVMETHOD_DEVPOLL 0x00000010 /* solaris 8 */ /* NYI */
+#define EVMETHOD_PORT 0x00000020 /* solaris 10 */ /* NYI */
+
+/* flag bits */
+#define EVMETHOD_NOENV 0x01000000 /* do NOT consult environment */
#if EV_PROTOTYPES
int ev_version_major (void);
# if EV_MULTIPLICITY
/* the default loop is the only one that handles signals and child watchers */
/* you can call this as often as you like */
-struct ev_loop *ev_default_loop (int methods); /* returns default loop */
+struct ev_loop *ev_default_loop (unsigned int flags); /* returns default loop */
/* create and destroy alternative loops that don't handle signals */
-struct ev_loop *ev_loop_new (int methods);
+struct ev_loop *ev_loop_new (unsigned int flags);
void ev_loop_destroy (EV_P);
void ev_loop_fork (EV_P);