summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes4
-rw-r--r--ev.392
-rw-r--r--ev.c10
-rw-r--r--ev_vars.h21
-rw-r--r--ev_wrap.h322
-rwxr-xr-xupdate_ev_wrap4
6 files changed, 251 insertions, 202 deletions
diff --git a/Changes b/Changes
index 3346822..3698cde 100644
--- a/Changes
+++ b/Changes
@@ -7,8 +7,8 @@ TODO: document WSA_EV_USE_SOCKET in win32 part
TODO: ^ OR use WSASend/WSARecv on the handle, which always works
TODO: assert on fd watcher linked list pointing to itself
TODO: faq, process a thing in each iteration
-TODO: abuse idle watchers for their side effect
-TODO: abuse check watchers for their side effect
+ - queueing pending watchers of higher priority from a watcher now invokes
+ them in a timely fashion (reported by Denis Bilenko).
- add throw() to all libev functions that cannot throw exceptions, for
further code size decrease when compiling for C++.
- add throw () to callbacks that must not throw exceptions (allocator,
diff --git a/ev.3 b/ev.3
index d2c36f3..f9fcaf2 100644
--- a/ev.3
+++ b/ev.3
@@ -124,7 +124,7 @@
.\" ========================================================================
.\"
.IX Title "LIBEV 3"
-.TH LIBEV 3 "2012-04-19" "libev-4.11" "libev - high performance full featured event loop"
+.TH LIBEV 3 "2012-05-06" "libev-4.11" "libev - high performance full featured event loop"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -1301,13 +1301,18 @@ The \f(CW\*(C`ev_idle\*(C'\fR watcher has determined that you have nothing bette
.el .IP "\f(CWEV_CHECK\fR" 4
.IX Item "EV_CHECK"
.PD
-All \f(CW\*(C`ev_prepare\*(C'\fR watchers are invoked just \fIbefore\fR \f(CW\*(C`ev_run\*(C'\fR starts
-to gather new events, and all \f(CW\*(C`ev_check\*(C'\fR watchers are invoked just after
-\&\f(CW\*(C`ev_run\*(C'\fR has gathered them, but before it invokes any callbacks for any
-received events. Callbacks of both watcher types can start and stop as
-many watchers as they want, and all of them will be taken into account
-(for example, a \f(CW\*(C`ev_prepare\*(C'\fR watcher might start an idle watcher to keep
-\&\f(CW\*(C`ev_run\*(C'\fR from blocking).
+All \f(CW\*(C`ev_prepare\*(C'\fR watchers are invoked just \fIbefore\fR \f(CW\*(C`ev_run\*(C'\fR starts to
+gather new events, and all \f(CW\*(C`ev_check\*(C'\fR watchers are queued (not invoked)
+just after \f(CW\*(C`ev_run\*(C'\fR has gathered them, but before it queues any callbacks
+for any received events. That means \f(CW\*(C`ev_prepare\*(C'\fR watchers are the last
+watchers invoked before the event loop sleeps or polls for new events, and
+\&\f(CW\*(C`ev_check\*(C'\fR watchers will be invoked before any other watchers of the same
+or lower priority within an event loop iteration.
+.Sp
+Callbacks of both watcher types can start and stop as many watchers as
+they want, and all of them will be taken into account (for example, a
+\&\f(CW\*(C`ev_prepare\*(C'\fR watcher might start an idle watcher to keep \f(CW\*(C`ev_run\*(C'\fR from
+blocking).
.ie n .IP """EV_EMBED""" 4
.el .IP "\f(CWEV_EMBED\fR" 4
.IX Item "EV_EMBED"
@@ -1438,8 +1443,8 @@ it).
.IP "callback ev_cb (ev_TYPE *watcher)" 4
.IX Item "callback ev_cb (ev_TYPE *watcher)"
Returns the callback currently set on the watcher.
-.IP "ev_cb_set (ev_TYPE *watcher, callback)" 4
-.IX Item "ev_cb_set (ev_TYPE *watcher, callback)"
+.IP "ev_set_cb (ev_TYPE *watcher, callback)" 4
+.IX Item "ev_set_cb (ev_TYPE *watcher, callback)"
Change the callback. You can change the callback at virtually any time
(modulo threads).
.IP "ev_set_priority (ev_TYPE *watcher, int priority)" 4
@@ -1996,7 +2001,7 @@ within the callback:
\& // calculate when the timeout would happen
\& ev_tstamp after = last_activity \- ev_now (EV_A) + timeout;
\&
-\& // if negative, it means we the timeout already occured
+\& // if negative, it means we the timeout already occurred
\& if (after < 0.)
\& {
\& // timeout occurred, take action
@@ -2025,7 +2030,7 @@ Otherwise, we now the earliest time at which the timeout would trigger,
and simply start the timer with this timeout value.
.Sp
In other words, each time the callback is invoked it will check whether
-the timeout cocured. If not, it will simply reschedule itself to check
+the timeout occurred. If not, it will simply reschedule itself to check
again at the earliest time it could time out. Rinse. Repeat.
.Sp
This scheme causes more callback invocations (about one every 60 seconds
@@ -2053,7 +2058,7 @@ When there is some activity, simply store the current time in
.Sp
When your timeout value changes, then the timeout can be changed by simply
providing a new value, stopping the timer and calling the callback, which
-will agaion do the right thing (for example, time out immediately :).
+will again do the right thing (for example, time out immediately :).
.Sp
.Vb 3
\& timeout = new_value;
@@ -2979,6 +2984,21 @@ effect on its own sometimes), idle watchers are a good place to do
\&\*(L"pseudo-background processing\*(R", or delay processing stuff to after the
event loop has handled all outstanding events.
.PP
+\fIAbusing an \f(CI\*(C`ev_idle\*(C'\fI watcher for its side-effect\fR
+.IX Subsection "Abusing an ev_idle watcher for its side-effect"
+.PP
+As long as there is at least one active idle watcher, libev will never
+sleep unnecessarily. Or in other words, it will loop as fast as possible.
+For this to work, the idle watcher doesn't need to be invoked at all \- the
+lowest priority will do.
+.PP
+This mode of operation can be useful together with an \f(CW\*(C`ev_check\*(C'\fR watcher,
+to do something on each event loop iteration \- for example to balance load
+between different connections.
+.PP
+See \*(L"Abusing an ev_check watcher for its side-effect\*(R" for a longer
+example.
+.PP
\fIWatcher-Specific Functions and Data Members\fR
.IX Subsection "Watcher-Specific Functions and Data Members"
.IP "ev_idle_init (ev_idle *, callback)" 4
@@ -2993,11 +3013,16 @@ believe me.
Example: Dynamically allocate an \f(CW\*(C`ev_idle\*(C'\fR watcher, start it, and in the
callback, free it. Also, use no error checking, as usual.
.PP
-.Vb 7
+.Vb 5
\& static void
\& idle_cb (struct ev_loop *loop, ev_idle *w, int revents)
\& {
+\& // stop the watcher
+\& ev_idle_stop (loop, w);
+\&
+\& // now we can free it
\& free (w);
+\&
\& // now do something you wanted to do when the program has
\& // no longer anything immediate to do.
\& }
@@ -3009,7 +3034,7 @@ callback, free it. Also, use no error checking, as usual.
.ie n .SS """ev_prepare"" and ""ev_check"" \- customise your event loop!"
.el .SS "\f(CWev_prepare\fP and \f(CWev_check\fP \- customise your event loop!"
.IX Subsection "ev_prepare and ev_check - customise your event loop!"
-Prepare and check watchers are usually (but not always) used in pairs:
+Prepare and check watchers are often (but not always) used in pairs:
prepare watchers get invoked before the process blocks and check watchers
afterwards.
.PP
@@ -3047,9 +3072,10 @@ of lower priority, but only once, using idle watchers to keep the event
loop from blocking if lower-priority coroutines are active, thus mapping
low-priority coroutines to idle/background tasks).
.PP
-It is recommended to give \f(CW\*(C`ev_check\*(C'\fR watchers highest (\f(CW\*(C`EV_MAXPRI\*(C'\fR)
-priority, to ensure that they are being run before any other watchers
-after the poll (this doesn't matter for \f(CW\*(C`ev_prepare\*(C'\fR watchers).
+When used for this purpose, it is recommended to give \f(CW\*(C`ev_check\*(C'\fR watchers
+highest (\f(CW\*(C`EV_MAXPRI\*(C'\fR) priority, to ensure that they are being run before
+any other watchers after the poll (this doesn't matter for \f(CW\*(C`ev_prepare\*(C'\fR
+watchers).
.PP
Also, \f(CW\*(C`ev_check\*(C'\fR watchers (and \f(CW\*(C`ev_prepare\*(C'\fR watchers, too) should not
activate (\*(L"feed\*(R") events into libev. While libev fully supports this, they
@@ -3059,6 +3085,26 @@ loops those other event loops might be in an unusable state until their
\&\f(CW\*(C`ev_check\*(C'\fR watcher ran (always remind yourself to coexist peacefully with
others).
.PP
+\fIAbusing an \f(CI\*(C`ev_check\*(C'\fI watcher for its side-effect\fR
+.IX Subsection "Abusing an ev_check watcher for its side-effect"
+.PP
+\&\f(CW\*(C`ev_check\*(C'\fR (and less often also \f(CW\*(C`ev_prepare\*(C'\fR) watchers can also be
+useful because they are called once per event loop iteration. For
+example, if you want to handle a large number of connections fairly, you
+normally only do a bit of work for each active connection, and if there
+is more work to do, you wait for the next event loop iteration, so other
+connections have a chance of making progress.
+.PP
+Using an \f(CW\*(C`ev_check\*(C'\fR watcher is almost enough: it will be called on the
+next event loop iteration. However, that isn't as soon as possible \-
+without external events, your \f(CW\*(C`ev_check\*(C'\fR watcher will not be invoked.
+.PP
+This is where \f(CW\*(C`ev_idle\*(C'\fR watchers come in handy \- all you need is a
+single global idle watcher that is active as long as you have one active
+\&\f(CW\*(C`ev_check\*(C'\fR watcher. The \f(CW\*(C`ev_idle\*(C'\fR watcher makes sure the event loop
+will not sleep, and the \f(CW\*(C`ev_check\*(C'\fR watcher makes sure a callback gets
+invoked. Neither watcher alone can do that.
+.PP
\fIWatcher-Specific Functions and Data Members\fR
.IX Subsection "Watcher-Specific Functions and Data Members"
.IP "ev_prepare_init (ev_prepare *, callback)" 4
@@ -3446,7 +3492,7 @@ it by calling \f(CW\*(C`ev_async_send\*(C'\fR, which is thread\- and signal safe
This functionality is very similar to \f(CW\*(C`ev_signal\*(C'\fR watchers, as signals,
too, are asynchronous in nature, and signals, too, will be compressed
(i.e. the number of callback invocations may be less than the number of
-\&\f(CW\*(C`ev_async_sent\*(C'\fR calls). In fact, you could use signal watchers as a kind
+\&\f(CW\*(C`ev_async_send\*(C'\fR calls). In fact, you could use signal watchers as a kind
of \*(L"global async watchers\*(R" by using a watcher on an otherwise unused
signal, and \f(CW\*(C`ev_feed_signal\*(C'\fR to signal this watcher from another thread,
even without knowing which loop owns the signal.
@@ -3973,7 +4019,7 @@ called):
\& void
\& wait_for_event (ev_watcher *w)
\& {
-\& ev_cb_set (w) = current_coro;
+\& ev_set_cb (w, current_coro);
\& switch_to (libev_coro);
\& }
.Ve
@@ -3987,7 +4033,7 @@ instead of storing a coroutine, you store the queue object and instead of
switching to a coroutine, you push the watcher onto the queue and notify
any waiters.
.PP
-To embed libev, see \s-1EMBEDDING\s0, but in short, it's easiest to create two
+To embed libev, see \*(L"\s-1EMBEDDING\s0\*(R", but in short, it's easiest to create two
files, \fImy_ev.h\fR and \fImy_ev.c\fR that include the respective libev files:
.PP
.Vb 4
@@ -4062,7 +4108,7 @@ and \*(C+ you can use the \f(CW\*(C`EV_THROW\*(C'\fR macro for this:
.Ve
.PP
The only \s-1API\s0 functions that can currently throw exceptions are \f(CW\*(C`ev_run\*(C'\fR,
-\&\f(CW\*(C`ev_inoke\*(C'\fR, \f(CW\*(C`ev_invoke_pending\*(C'\fR and \f(CW\*(C`ev_loop_destroy\*(C'\fR (the latter
+\&\f(CW\*(C`ev_invoke\*(C'\fR, \f(CW\*(C`ev_invoke_pending\*(C'\fR and \f(CW\*(C`ev_loop_destroy\*(C'\fR (the latter
because it runs cleanup watchers).
.PP
Throwing exceptions in watcher callbacks is only supported if libev itself
@@ -5458,7 +5504,7 @@ new \s-1API\s0 early than late.
.el .IP "\f(CWEV_COMPAT3\fR backwards compatibility mechanism" 4
.IX Item "EV_COMPAT3 backwards compatibility mechanism"
The backward compatibility mechanism can be controlled by
-\&\f(CW\*(C`EV_COMPAT3\*(C'\fR. See \*(L"\s-1MACROS\s0\*(R" in \s-1PREPROCESSOR\s0 \s-1SYMBOLS\s0 in the \s-1EMBEDDING\s0
+\&\f(CW\*(C`EV_COMPAT3\*(C'\fR. See \*(L"\s-1PREPROCESSOR\s0 \s-1SYMBOLS/MACROS\s0\*(R" in the \*(L"\s-1EMBEDDING\s0\*(R"
section.
.ie n .IP """ev_default_destroy"" and ""ev_default_fork"" have been removed" 4
.el .IP "\f(CWev_default_destroy\fR and \f(CWev_default_fork\fR have been removed" 4
diff --git a/ev.c b/ev.c
index e24ed6f..c1bd4a7 100644
--- a/ev.c
+++ b/ev.c
@@ -1432,6 +1432,8 @@ ev_feed_event (EV_P_ void *w, int revents) EV_THROW
pendings [pri][w_->pending - 1].w = w_;
pendings [pri][w_->pending - 1].events = revents;
}
+
+ pendingpri = NUMPRI - 1;
}
inline_speed void
@@ -2687,12 +2689,10 @@ ev_pending_count (EV_P) EV_THROW
void noinline
ev_invoke_pending (EV_P)
{
- int pri;
-
- for (pri = NUMPRI; pri--; )
- while (pendingcnt [pri])
+ for (pendingpri = NUMPRI; pendingpri--; ) /* pendingpri is modified during the loop */
+ while (pendingcnt [pendingpri])
{
- ANPENDING *p = pendings [pri] + --pendingcnt [pri];
+ ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri];
p->w->pending = 0;
EV_CB_INVOKE (p->w, p->events);
diff --git a/ev_vars.h b/ev_vars.h
index 5cd26d0..53bcfee 100644
--- a/ev_vars.h
+++ b/ev_vars.h
@@ -43,6 +43,17 @@ VARx(ev_tstamp, now_floor) /* last time we refreshed rt_time */
VARx(ev_tstamp, mn_now) /* monotonic clock "now" */
VARx(ev_tstamp, rtmn_diff) /* difference realtime - monotonic time */
+/* for reverse feeding of events */
+VARx(W *, rfeeds)
+VARx(int, rfeedmax)
+VARx(int, rfeedcnt)
+
+VAR (pendings, ANPENDING *pendings [NUMPRI])
+VAR (pendingmax, int pendingmax [NUMPRI])
+VAR (pendingcnt, int pendingcnt [NUMPRI])
+VARx(int, pendingpri) /* highest priority currently pending */
+VARx(ev_prepare, pending_w) /* dummy pending watcher */
+
VARx(ev_tstamp, io_blocktime)
VARx(ev_tstamp, timeout_blocktime)
@@ -58,16 +69,6 @@ VAR (backend_poll , void (*backend_poll)(EV_P_ ev_tstamp timeout))
VARx(ANFD *, anfds)
VARx(int, anfdmax)
-VAR (pendings, ANPENDING *pendings [NUMPRI])
-VAR (pendingmax, int pendingmax [NUMPRI])
-VAR (pendingcnt, int pendingcnt [NUMPRI])
-VARx(ev_prepare, pending_w) /* dummy pending watcher */
-
-/* for reverse feeding of events */
-VARx(W *, rfeeds)
-VARx(int, rfeedmax)
-VARx(int, rfeedcnt)
-
#if EV_USE_EVENTFD || EV_GENWRAP
VARx(int, evfd)
#endif
diff --git a/ev_wrap.h b/ev_wrap.h
index 3c47c6e..4dd3d15 100644
--- a/ev_wrap.h
+++ b/ev_wrap.h
@@ -1,200 +1,202 @@
/* DO NOT EDIT, automatically generated by update_ev_wrap */
#ifndef EV_WRAP_H
#define EV_WRAP_H
-#define now_floor ((loop)->now_floor)
-#define mn_now ((loop)->mn_now)
-#define rtmn_diff ((loop)->rtmn_diff)
-#define io_blocktime ((loop)->io_blocktime)
-#define timeout_blocktime ((loop)->timeout_blocktime)
-#define backend ((loop)->backend)
+#define acquire_cb ((loop)->acquire_cb)
#define activecnt ((loop)->activecnt)
-#define loop_done ((loop)->loop_done)
+#define anfdmax ((loop)->anfdmax)
+#define anfds ((loop)->anfds)
+#define async_pending ((loop)->async_pending)
+#define asynccnt ((loop)->asynccnt)
+#define asyncmax ((loop)->asyncmax)
+#define asyncs ((loop)->asyncs)
+#define backend ((loop)->backend)
#define backend_fd ((loop)->backend_fd)
#define backend_mintime ((loop)->backend_mintime)
#define backend_modify ((loop)->backend_modify)
#define backend_poll ((loop)->backend_poll)
-#define anfds ((loop)->anfds)
-#define anfdmax ((loop)->anfdmax)
-#define pendings ((loop)->pendings)
-#define pendingmax ((loop)->pendingmax)
-#define pendingcnt ((loop)->pendingcnt)
-#define pending_w ((loop)->pending_w)
-#define rfeeds ((loop)->rfeeds)
-#define rfeedmax ((loop)->rfeedmax)
-#define rfeedcnt ((loop)->rfeedcnt)
+#define checkcnt ((loop)->checkcnt)
+#define checkmax ((loop)->checkmax)
+#define checks ((loop)->checks)
+#define cleanupcnt ((loop)->cleanupcnt)
+#define cleanupmax ((loop)->cleanupmax)
+#define cleanups ((loop)->cleanups)
+#define curpid ((loop)->curpid)
+#define epoll_epermcnt ((loop)->epoll_epermcnt)
+#define epoll_epermmax ((loop)->epoll_epermmax)
+#define epoll_eperms ((loop)->epoll_eperms)
+#define epoll_eventmax ((loop)->epoll_eventmax)
+#define epoll_events ((loop)->epoll_events)
#define evfd ((loop)->evfd)
#define evpipe ((loop)->evpipe)
+#define fdchangecnt ((loop)->fdchangecnt)
+#define fdchangemax ((loop)->fdchangemax)
+#define fdchanges ((loop)->fdchanges)
+#define forkcnt ((loop)->forkcnt)
+#define forkmax ((loop)->forkmax)
+#define forks ((loop)->forks)
+#define fs_2625 ((loop)->fs_2625)
+#define fs_fd ((loop)->fs_fd)
+#define fs_hash ((loop)->fs_hash)
+#define fs_w ((loop)->fs_w)
+#define idleall ((loop)->idleall)
+#define idlecnt ((loop)->idlecnt)
+#define idlemax ((loop)->idlemax)
+#define idles ((loop)->idles)
+#define invoke_cb ((loop)->invoke_cb)
+#define io_blocktime ((loop)->io_blocktime)
+#define iocp ((loop)->iocp)
+#define kqueue_changecnt ((loop)->kqueue_changecnt)
+#define kqueue_changemax ((loop)->kqueue_changemax)
+#define kqueue_changes ((loop)->kqueue_changes)
+#define kqueue_eventmax ((loop)->kqueue_eventmax)
+#define kqueue_events ((loop)->kqueue_events)
+#define kqueue_fd_pid ((loop)->kqueue_fd_pid)
+#define loop_count ((loop)->loop_count)
+#define loop_depth ((loop)->loop_depth)
+#define loop_done ((loop)->loop_done)
+#define mn_now ((loop)->mn_now)
+#define now_floor ((loop)->now_floor)
+#define origflags ((loop)->origflags)
+#define pending_w ((loop)->pending_w)
+#define pendingcnt ((loop)->pendingcnt)
+#define pendingmax ((loop)->pendingmax)
+#define pendingpri ((loop)->pendingpri)
+#define pendings ((loop)->pendings)
+#define periodiccnt ((loop)->periodiccnt)
+#define periodicmax ((loop)->periodicmax)
+#define periodics ((loop)->periodics)
#define pipe_w ((loop)->pipe_w)
-#define pipe_write_wanted ((loop)->pipe_write_wanted)
#define pipe_write_skipped ((loop)->pipe_write_skipped)
-#define curpid ((loop)->curpid)
-#define postfork ((loop)->postfork)
-#define vec_ri ((loop)->vec_ri)
-#define vec_ro ((loop)->vec_ro)
-#define vec_wi ((loop)->vec_wi)
-#define vec_wo ((loop)->vec_wo)
-#define vec_eo ((loop)->vec_eo)
-#define vec_max ((loop)->vec_max)
-#define polls ((loop)->polls)
-#define pollmax ((loop)->pollmax)
+#define pipe_write_wanted ((loop)->pipe_write_wanted)
#define pollcnt ((loop)->pollcnt)
-#define pollidxs ((loop)->pollidxs)
#define pollidxmax ((loop)->pollidxmax)
-#define epoll_events ((loop)->epoll_events)
-#define epoll_eventmax ((loop)->epoll_eventmax)
-#define epoll_eperms ((loop)->epoll_eperms)
-#define epoll_epermcnt ((loop)->epoll_epermcnt)
-#define epoll_epermmax ((loop)->epoll_epermmax)
-#define kqueue_fd_pid ((loop)->kqueue_fd_pid)
-#define kqueue_changes ((loop)->kqueue_changes)
-#define kqueue_changemax ((loop)->kqueue_changemax)
-#define kqueue_changecnt ((loop)->kqueue_changecnt)
-#define kqueue_events ((loop)->kqueue_events)
-#define kqueue_eventmax ((loop)->kqueue_eventmax)
-#define port_events ((loop)->port_events)
+#define pollidxs ((loop)->pollidxs)
+#define pollmax ((loop)->pollmax)
+#define polls ((loop)->polls)
#define port_eventmax ((loop)->port_eventmax)
-#define iocp ((loop)->iocp)
-#define fdchanges ((loop)->fdchanges)
-#define fdchangemax ((loop)->fdchangemax)
-#define fdchangecnt ((loop)->fdchangecnt)
-#define timers ((loop)->timers)
-#define timermax ((loop)->timermax)
-#define timercnt ((loop)->timercnt)
-#define periodics ((loop)->periodics)
-#define periodicmax ((loop)->periodicmax)
-#define periodiccnt ((loop)->periodiccnt)
-#define idles ((loop)->idles)
-#define idlemax ((loop)->idlemax)
-#define idlecnt ((loop)->idlecnt)
-#define idleall ((loop)->idleall)
-#define prepares ((loop)->prepares)
-#define preparemax ((loop)->preparemax)
+#define port_events ((loop)->port_events)
+#define postfork ((loop)->postfork)
#define preparecnt ((loop)->preparecnt)
-#define checks ((loop)->checks)
-#define checkmax ((loop)->checkmax)
-#define checkcnt ((loop)->checkcnt)
-#define forks ((loop)->forks)
-#define forkmax ((loop)->forkmax)
-#define forkcnt ((loop)->forkcnt)
-#define cleanups ((loop)->cleanups)
-#define cleanupmax ((loop)->cleanupmax)
-#define cleanupcnt ((loop)->cleanupcnt)
-#define async_pending ((loop)->async_pending)
-#define asyncs ((loop)->asyncs)
-#define asyncmax ((loop)->asyncmax)
-#define asynccnt ((loop)->asynccnt)
-#define fs_fd ((loop)->fs_fd)
-#define fs_w ((loop)->fs_w)
-#define fs_2625 ((loop)->fs_2625)
-#define fs_hash ((loop)->fs_hash)
+#define preparemax ((loop)->preparemax)
+#define prepares ((loop)->prepares)
+#define release_cb ((loop)->release_cb)
+#define rfeedcnt ((loop)->rfeedcnt)
+#define rfeedmax ((loop)->rfeedmax)
+#define rfeeds ((loop)->rfeeds)
+#define rtmn_diff ((loop)->rtmn_diff)
#define sig_pending ((loop)->sig_pending)
#define sigfd ((loop)->sigfd)
-#define sigfd_w ((loop)->sigfd_w)
#define sigfd_set ((loop)->sigfd_set)
-#define origflags ((loop)->origflags)
-#define loop_count ((loop)->loop_count)
-#define loop_depth ((loop)->loop_depth)
+#define sigfd_w ((loop)->sigfd_w)
+#define timeout_blocktime ((loop)->timeout_blocktime)
+#define timercnt ((loop)->timercnt)
+#define timermax ((loop)->timermax)
+#define timers ((loop)->timers)
#define userdata ((loop)->userdata)
-#define release_cb ((loop)->release_cb)
-#define acquire_cb ((loop)->acquire_cb)
-#define invoke_cb ((loop)->invoke_cb)
+#define vec_eo ((loop)->vec_eo)
+#define vec_max ((loop)->vec_max)
+#define vec_ri ((loop)->vec_ri)
+#define vec_ro ((loop)->vec_ro)
+#define vec_wi ((loop)->vec_wi)
+#define vec_wo ((loop)->vec_wo)
#else
#undef EV_WRAP_H
-#undef now_floor
-#undef mn_now
-#undef rtmn_diff
-#undef io_blocktime
-#undef timeout_blocktime
-#undef backend
+#undef acquire_cb
#undef activecnt
-#undef loop_done
+#undef anfdmax
+#undef anfds
+#undef async_pending
+#undef asynccnt
+#undef asyncmax
+#undef asyncs
+#undef backend
#undef backend_fd
#undef backend_mintime
#undef backend_modify
#undef backend_poll
-#undef anfds
-#undef anfdmax
-#undef pendings
-#undef pendingmax
-#undef pendingcnt
-#undef pending_w
-#undef rfeeds
-#undef rfeedmax
-#undef rfeedcnt
+#undef checkcnt
+#undef checkmax
+#undef checks
+#undef cleanupcnt
+#undef cleanupmax
+#undef cleanups
+#undef curpid
+#undef epoll_epermcnt
+#undef epoll_epermmax
+#undef epoll_eperms
+#undef epoll_eventmax
+#undef epoll_events
#undef evfd
#undef evpipe
+#undef fdchangecnt
+#undef fdchangemax
+#undef fdchanges
+#undef forkcnt
+#undef forkmax
+#undef forks
+#undef fs_2625
+#undef fs_fd
+#undef fs_hash
+#undef fs_w
+#undef idleall
+#undef idlecnt
+#undef idlemax
+#undef idles
+#undef invoke_cb
+#undef io_blocktime
+#undef iocp
+#undef kqueue_changecnt
+#undef kqueue_changemax
+#undef kqueue_changes
+#undef kqueue_eventmax
+#undef kqueue_events
+#undef kqueue_fd_pid
+#undef loop_count
+#undef loop_depth
+#undef loop_done
+#undef mn_now
+#undef now_floor
+#undef origflags
+#undef pending_w
+#undef pendingcnt
+#undef pendingmax
+#undef pendingpri
+#undef pendings
+#undef periodiccnt
+#undef periodicmax
+#undef periodics
#undef pipe_w
-#undef pipe_write_wanted
#undef pipe_write_skipped
-#undef curpid
-#undef postfork
-#undef vec_ri
-#undef vec_ro
-#undef vec_wi
-#undef vec_wo
-#undef vec_eo
-#undef vec_max
-#undef polls
-#undef pollmax
+#undef pipe_write_wanted
#undef pollcnt
-#undef pollidxs
#undef pollidxmax
-#undef epoll_events
-#undef epoll_eventmax
-#undef epoll_eperms
-#undef epoll_epermcnt
-#undef epoll_epermmax
-#undef kqueue_fd_pid
-#undef kqueue_changes
-#undef kqueue_changemax
-#undef kqueue_changecnt
-#undef kqueue_events
-#undef kqueue_eventmax
-#undef port_events
+#undef pollidxs
+#undef pollmax
+#undef polls
#undef port_eventmax
-#undef iocp
-#undef fdchanges
-#undef fdchangemax
-#undef fdchangecnt
-#undef timers
-#undef timermax
-#undef timercnt
-#undef periodics
-#undef periodicmax
-#undef periodiccnt
-#undef idles
-#undef idlemax
-#undef idlecnt
-#undef idleall
-#undef prepares
-#undef preparemax
+#undef port_events
+#undef postfork
#undef preparecnt
-#undef checks
-#undef checkmax
-#undef checkcnt
-#undef forks
-#undef forkmax
-#undef forkcnt
-#undef cleanups
-#undef cleanupmax
-#undef cleanupcnt
-#undef async_pending
-#undef asyncs
-#undef asyncmax
-#undef asynccnt
-#undef fs_fd
-#undef fs_w
-#undef fs_2625
-#undef fs_hash
+#undef preparemax
+#undef prepares
+#undef release_cb
+#undef rfeedcnt
+#undef rfeedmax
+#undef rfeeds
+#undef rtmn_diff
#undef sig_pending
#undef sigfd
-#undef sigfd_w
#undef sigfd_set
-#undef origflags
-#undef loop_count
-#undef loop_depth
+#undef sigfd_w
+#undef timeout_blocktime
+#undef timercnt
+#undef timermax
+#undef timers
#undef userdata
-#undef release_cb
-#undef acquire_cb
-#undef invoke_cb
+#undef vec_eo
+#undef vec_max
+#undef vec_ri
+#undef vec_ro
+#undef vec_wi
+#undef vec_wo
#endif
diff --git a/update_ev_wrap b/update_ev_wrap
index adb083a..995ea0c 100755
--- a/update_ev_wrap
+++ b/update_ev_wrap
@@ -11,9 +11,9 @@
print "/* DO NOT EDIT, automatically generated by update_ev_wrap */\n",
"#ifndef EV_WRAP_H\n",
"#define EV_WRAP_H\n",
- (map "#define $_ ((loop)->$_)\n", @syms),
+ (map "#define $_ ((loop)->$_)\n", sort @syms),
"#else\n",
"#undef EV_WRAP_H\n",
- (map "#undef $_\n", @syms),
+ (map "#undef $_\n", sort @syms),
"#endif\n";
' >ev_wrap.h