Browse Source

Upgrade libev to 4.4

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
470ebe249f
  1. 9
      deps/libev/Changes
  2. 2
      deps/libev/configure.ac
  3. 41
      deps/libev/ev.3
  4. 47
      deps/libev/ev.c
  5. 4
      deps/libev/ev.h
  6. 39
      deps/libev/ev.pod
  7. 2
      deps/libev/ev_epoll.c
  8. 4
      deps/libev/ev_poll.c
  9. 2
      deps/libev/ev_port.c
  10. 5
      deps/libev/ev_select.c
  11. 4
      deps/libev/libev.m4

9
deps/libev/Changes

@ -1,5 +1,14 @@
Revision history for libev, a high-performance and full-featured event loop.
4.04 Wed Feb 16 09:01:51 CET 2011
- fix two problems in the native win32 backend, where reuse of fd's
with different underlying handles caused handles not to be removed
or added to the select set (analyzed and tested by Bert Belder).
- do no rely on ceil() in ev_e?poll.c.
- backport libev to HP-UX versions before 11 v3.
- configure did not detect nanosleep and clock_gettime properly when
they are available in the libc (as opposed to -lrt).
4.03 Tue Jan 11 14:37:25 CET 2011
- officially support polling files with all backends.
- support files, /dev/zero etc. the same way as select in the epoll

2
deps/libev/configure.ac

@ -1,7 +1,7 @@
AC_INIT
AC_CONFIG_SRCDIR([ev_epoll.c])
AM_INIT_AUTOMAKE(libev,4.03) dnl also update ev.h!
AM_INIT_AUTOMAKE(libev,4.04) dnl also update ev.h!
AC_CONFIG_HEADERS([config.h])
AM_MAINTAINER_MODE

41
deps/libev/ev.3

@ -124,7 +124,7 @@
.\" ========================================================================
.\"
.IX Title "LIBEV 3"
.TH LIBEV 3 "2011-01-11" "libev-4.03" "libev - high performance full featured event loop"
.TH LIBEV 3 "2011-02-16" "libev-4.04" "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
@ -191,7 +191,7 @@ libev \- a high performance full\-featured event loop written in C
\& // now wait for events to arrive
\& ev_run (loop, 0);
\&
\& // unloop was called, so exit
\& // break was called, so exit
\& return 0;
\& }
.Ve
@ -562,6 +562,9 @@ This behaviour is useful when you want to do your own signal handling, or
want to handle signals only in specific threads and want to avoid libev
unblocking the signals.
.Sp
It's also required by \s-1POSIX\s0 in a threaded program, as libev calls
\&\f(CW\*(C`sigprocmask\*(C'\fR, whose behaviour is officially unspecified.
.Sp
This flag's behaviour will become the default in future versions of libev.
.ie n .IP """EVBACKEND_SELECT"" (value 1, portable select backend)" 4
.el .IP "\f(CWEVBACKEND_SELECT\fR (value 1, portable select backend)" 4
@ -987,7 +990,7 @@ anymore.
\& ... queue jobs here, make sure they register event watchers as long
\& ... as they still have work to do (even an idle watcher will do..)
\& ev_run (my_loop, 0);
\& ... jobs done or somebody called unloop. yeah!
\& ... jobs done or somebody called break. yeah!
.Ve
.IP "ev_break (loop, how)" 4
.IX Item "ev_break (loop, how)"
@ -1492,8 +1495,10 @@ Before a watcher can be registered with the event looop it has to be
initialised. This can be done with a call to \f(CW\*(C`ev_TYPE_init\*(C'\fR, or calls to
\&\f(CW\*(C`ev_init\*(C'\fR followed by the watcher-specific \f(CW\*(C`ev_TYPE_set\*(C'\fR function.
.Sp
In this state it is simply some block of memory that is suitable for use
in an event loop. It can be moved around, freed, reused etc. at will.
In this state it is simply some block of memory that is suitable for
use in an event loop. It can be moved around, freed, reused etc. at
will \- as long as you either keep the memory contents intact, or call
\&\f(CW\*(C`ev_TYPE_init\*(C'\fR again.
.IP "started/running/active" 4
.IX Item "started/running/active"
Once a watcher has been started with a call to \f(CW\*(C`ev_TYPE_start\*(C'\fR it becomes
@ -1528,8 +1533,9 @@ of whether it was active or not, so stopping a watcher explicitly before
freeing it is often a good idea.
.Sp
While stopped (and not pending) the watcher is essentially in the
initialised state, that is it can be reused, moved, modified in any way
you wish.
initialised state, that is, it can be reused, moved, modified in any way
you wish (but when you trash the memory block, you need to \f(CW\*(C`ev_TYPE_init\*(C'\fR
it again).
.SS "\s-1WATCHER\s0 \s-1PRIORITY\s0 \s-1MODELS\s0"
.IX Subsection "WATCHER PRIORITY MODELS"
Many event loops support \fIwatcher priorities\fR, which are usually small
@ -2431,7 +2437,8 @@ and unblock them in an \f(CW\*(C`ev_prepare\*(C'\fR watcher.
Both the signal mask (\f(CW\*(C`sigprocmask\*(C'\fR) and the signal disposition
(\f(CW\*(C`sigaction\*(C'\fR) are unspecified after starting a signal watcher (and after
stopping it again), that is, libev might or might not block the signal,
and might or might not set or restore the installed signal handler.
and might or might not set or restore the installed signal handler (but
see \f(CW\*(C`EVFLAG_NOSIGMASK\*(C'\fR).
.PP
While this does not matter for the signal disposition (libev never
sets signals to \f(CW\*(C`SIG_IGN\*(C'\fR, so handlers will be reset to \f(CW\*(C`SIG_DFL\*(C'\fR on
@ -3309,7 +3316,7 @@ cleanup functions are called.
.ie n .SS """ev_async"" \- how to wake up an event loop"
.el .SS "\f(CWev_async\fP \- how to wake up an event loop"
.IX Subsection "ev_async - how to wake up an event loop"
In general, you cannot use an \f(CW\*(C`ev_run\*(C'\fR from multiple threads or other
In general, you cannot use an \f(CW\*(C`ev_loop\*(C'\fR from multiple threads or other
asynchronous sources such as signal handlers (as opposed to multiple event
loops \- those are of course safe to use in different threads).
.PP
@ -3424,10 +3431,12 @@ trust me.
.IP "ev_async_send (loop, ev_async *)" 4
.IX Item "ev_async_send (loop, ev_async *)"
Sends/signals/activates the given \f(CW\*(C`ev_async\*(C'\fR watcher, that is, feeds
an \f(CW\*(C`EV_ASYNC\*(C'\fR event on the watcher into the event loop. Unlike
\&\f(CW\*(C`ev_feed_event\*(C'\fR, this call is safe to do from other threads, signal or
similar contexts (see the discussion of \f(CW\*(C`EV_ATOMIC_T\*(C'\fR in the embedding
section below on what exactly this means).
an \f(CW\*(C`EV_ASYNC\*(C'\fR event on the watcher into the event loop, and instantly
returns.
.Sp
Unlike \f(CW\*(C`ev_feed_event\*(C'\fR, this call is safe to do from other threads,
signal or similar contexts (see the discussion of \f(CW\*(C`EV_ATOMIC_T\*(C'\fR in the
embedding section below on what exactly this means).
.Sp
Note that, as with other watchers in libev, multiple events might get
compressed into a single callback invocation (another way to look at this
@ -3660,7 +3669,7 @@ First, you need to associate some data with the event loop:
\& ev_set_invoke_pending_cb (EV_A_ l_invoke);
\& ev_set_loop_release_cb (EV_A_ l_release, l_acquire);
\&
\& // then create the thread running ev_loop
\& // then create the thread running ev_run
\& pthread_create (&u\->tid, 0, l_run, EV_A);
\& }
.Ve
@ -5290,7 +5299,7 @@ The physical time that is observed. It is apparently strictly monotonic :)
.IP "wall-clock time" 4
.IX Item "wall-clock time"
The time and date as shown on clocks. Unlike real time, it can actually
be wrong and jump forwards and backwards, e.g. when the you adjust your
be wrong and jump forwards and backwards, e.g. when you adjust your
clock.
.IP "watcher" 4
.IX Item "watcher"
@ -5299,4 +5308,4 @@ to be started (attached to an event loop) before they can receive events.
.SH "AUTHOR"
.IX Header "AUTHOR"
Marc Lehmann <libev@schmorp.de>, with repeated corrections by Mikael
Magnusson and Emanuele Giaquinta.
Magnusson and Emanuele Giaquinta, and minor corrections by many others.

47
deps/libev/ev.c

@ -378,7 +378,8 @@ EV_CPP(extern "C" {)
#endif
#if !EV_USE_NANOSLEEP
# ifndef _WIN32
/* hp-ux has it in sys/time.h, which we unconditionally include above */
# if !defined(_WIN32) && !defined(__hpux)
# include <sys/select.h>
# endif
#endif
@ -817,6 +818,14 @@ ev_sleep (ev_tstamp delay)
}
}
inline_speed int
ev_timeout_to_ms (ev_tstamp timeout)
{
int ms = timeout * 1000. + .999999;
return expect_true (ms) ? ms : timeout < 1e-6 ? 0 : 1;
}
/*****************************************************************************/
#define MALLOC_ROUND 4096 /* prefer to allocate in chunks of this size, must be 2**n and >> 4 longs */
@ -1328,12 +1337,12 @@ evpipe_write (EV_P_ EV_ATOMIC_T *flag)
}
else
#endif
#ifdef __MINGW32__
send(EV_FD_TO_WIN32_HANDLE(evpipe [1]), &dummy, 1, 0);
#else
write (evpipe [1], &dummy, 1);
#endif
/* win32 people keep sending patches that change this write() to send() */
/* and then run away. but send() is wrong, it wants a socket handle on win32 */
/* so when you think this write should be a send instead, please find out */
/* where your send() is from - it's definitely not the microsoft send, and */
/* tell me. thank you. */
write (evpipe [1], &dummy, 1);
errno = old_errno;
}
@ -1356,13 +1365,11 @@ pipecb (EV_P_ ev_io *iow, int revents)
#endif
{
char dummy;
#ifdef __MINGW32__
recv(EV_FD_TO_WIN32_HANDLE(evpipe [0]), &dummy, 1, 0);
#else
/* see discussion in evpipe_write when you think this read should be recv in win32 */
read (evpipe [0], &dummy, 1);
#endif
}
#if EV_SIGNAL_ENABLE
if (sig_pending)
{
sig_pending = 0;
@ -1371,6 +1378,7 @@ pipecb (EV_P_ ev_io *iow, int revents)
if (expect_false (signals [i].pending))
ev_feed_signal_event (EV_A_ i + 1);
}
#endif
#if EV_ASYNC_ENABLE
if (async_pending)
@ -2201,6 +2209,15 @@ timers_reify (EV_P)
}
#if EV_PERIODIC_ENABLE
inline_speed void
periodic_recalc (EV_P_ ev_periodic *w)
{
/* TODO: use slow but potentially more correct incremental algo, */
/* also do not rely on ceil */
ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
}
/* make periodics pending */
inline_size void
periodics_reify (EV_P)
@ -2229,7 +2246,8 @@ periodics_reify (EV_P)
}
else if (w->interval)
{
ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
periodic_recalc (EV_A_ w);
/* if next trigger time is not sufficiently in the future, put it there */
/* this might happen because of floating point inexactness */
if (ev_at (w) - ev_rt_now < TIME_EPSILON)
@ -2273,7 +2291,7 @@ periodics_reschedule (EV_P)
if (w->reschedule_cb)
ev_at (w) = w->reschedule_cb (w, ev_rt_now);
else if (w->interval)
ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
periodic_recalc (EV_A_ w);
ANHE_at_cache (periodics [i]);
}
@ -2775,8 +2793,7 @@ ev_periodic_start (EV_P_ ev_periodic *w)
else if (w->interval)
{
assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
/* this formula differs from the one in periodic_reify because we do not always round up */
ev_at (w) = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
periodic_recalc (EV_A_ w);
}
else
ev_at (w) = w->offset;

4
deps/libev/ev.h

@ -185,7 +185,7 @@ struct ev_loop;
# define EV_INLINE static
#endif
/* EV_PROTOTYPES can be sued to switch of prototype declarations */
/* EV_PROTOTYPES can be used to switch of prototype declarations */
#ifndef EV_PROTOTYPES
# define EV_PROTOTYPES 1
#endif
@ -193,7 +193,7 @@ struct ev_loop;
/*****************************************************************************/
#define EV_VERSION_MAJOR 4
#define EV_VERSION_MINOR 3
#define EV_VERSION_MINOR 4
/* eventmask, revents, events... */
enum {

39
deps/libev/ev.pod

@ -60,7 +60,7 @@ libev - a high performance full-featured event loop written in C
// now wait for events to arrive
ev_run (loop, 0);
// unloop was called, so exit
// break was called, so exit
return 0;
}
@ -444,6 +444,9 @@ This behaviour is useful when you want to do your own signal handling, or
want to handle signals only in specific threads and want to avoid libev
unblocking the signals.
It's also required by POSIX in a threaded program, as libev calls
C<sigprocmask>, whose behaviour is officially unspecified.
This flag's behaviour will become the default in future versions of libev.
=item C<EVBACKEND_SELECT> (value 1, portable select backend)
@ -867,7 +870,7 @@ anymore.
... queue jobs here, make sure they register event watchers as long
... as they still have work to do (even an idle watcher will do..)
ev_run (my_loop, 0);
... jobs done or somebody called unloop. yeah!
... jobs done or somebody called break. yeah!
=item ev_break (loop, how)
@ -1377,8 +1380,10 @@ Before a watcher can be registered with the event looop it has to be
initialised. This can be done with a call to C<ev_TYPE_init>, or calls to
C<ev_init> followed by the watcher-specific C<ev_TYPE_set> function.
In this state it is simply some block of memory that is suitable for use
in an event loop. It can be moved around, freed, reused etc. at will.
In this state it is simply some block of memory that is suitable for
use in an event loop. It can be moved around, freed, reused etc. at
will - as long as you either keep the memory contents intact, or call
C<ev_TYPE_init> again.
=item started/running/active
@ -1416,8 +1421,9 @@ of whether it was active or not, so stopping a watcher explicitly before
freeing it is often a good idea.
While stopped (and not pending) the watcher is essentially in the
initialised state, that is it can be reused, moved, modified in any way
you wish.
initialised state, that is, it can be reused, moved, modified in any way
you wish (but when you trash the memory block, you need to C<ev_TYPE_init>
it again).
=back
@ -2302,7 +2308,8 @@ and unblock them in an C<ev_prepare> watcher.
Both the signal mask (C<sigprocmask>) and the signal disposition
(C<sigaction>) are unspecified after starting a signal watcher (and after
stopping it again), that is, libev might or might not block the signal,
and might or might not set or restore the installed signal handler.
and might or might not set or restore the installed signal handler (but
see C<EVFLAG_NOSIGMASK>).
While this does not matter for the signal disposition (libev never
sets signals to C<SIG_IGN>, so handlers will be reset to C<SIG_DFL> on
@ -3183,7 +3190,7 @@ cleanup functions are called.
=head2 C<ev_async> - how to wake up an event loop
In general, you cannot use an C<ev_run> from multiple threads or other
In general, you cannot use an C<ev_loop> from multiple threads or other
asynchronous sources such as signal handlers (as opposed to multiple event
loops - those are of course safe to use in different threads).
@ -3303,10 +3310,12 @@ trust me.
=item ev_async_send (loop, ev_async *)
Sends/signals/activates the given C<ev_async> watcher, that is, feeds
an C<EV_ASYNC> event on the watcher into the event loop. Unlike
C<ev_feed_event>, this call is safe to do from other threads, signal or
similar contexts (see the discussion of C<EV_ATOMIC_T> in the embedding
section below on what exactly this means).
an C<EV_ASYNC> event on the watcher into the event loop, and instantly
returns.
Unlike C<ev_feed_event>, this call is safe to do from other threads,
signal or similar contexts (see the discussion of C<EV_ATOMIC_T> in the
embedding section below on what exactly this means).
Note that, as with other watchers in libev, multiple events might get
compressed into a single callback invocation (another way to look at this
@ -3542,7 +3551,7 @@ First, you need to associate some data with the event loop:
ev_set_invoke_pending_cb (EV_A_ l_invoke);
ev_set_loop_release_cb (EV_A_ l_release, l_acquire);
// then create the thread running ev_loop
// then create the thread running ev_run
pthread_create (&u->tid, 0, l_run, EV_A);
}
@ -5217,7 +5226,7 @@ The physical time that is observed. It is apparently strictly monotonic :)
=item wall-clock time
The time and date as shown on clocks. Unlike real time, it can actually
be wrong and jump forwards and backwards, e.g. when the you adjust your
be wrong and jump forwards and backwards, e.g. when you adjust your
clock.
=item watcher
@ -5230,5 +5239,5 @@ to be started (attached to an event loop) before they can receive events.
=head1 AUTHOR
Marc Lehmann <libev@schmorp.de>, with repeated corrections by Mikael
Magnusson and Emanuele Giaquinta.
Magnusson and Emanuele Giaquinta, and minor corrections by many others.

2
deps/libev/ev_epoll.c

@ -148,7 +148,7 @@ epoll_poll (EV_P_ ev_tstamp timeout)
/* the default libev max wait time, however. */
EV_RELEASE_CB;
eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax,
epoll_epermcnt ? 0 : (int)ceil (timeout * 1000.));
epoll_epermcnt ? 0 : ev_timeout_to_ms (timeout));
EV_ACQUIRE_CB;
if (expect_false (eventcnt < 0))

4
deps/libev/ev_poll.c

@ -1,7 +1,7 @@
/*
* libev poll fd activity backend
*
* Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
@ -92,7 +92,7 @@ poll_poll (EV_P_ ev_tstamp timeout)
int res;
EV_RELEASE_CB;
res = poll (polls, pollcnt, (int)ceil (timeout * 1000.));
res = poll (polls, pollcnt, ev_timeout_to_ms (timeout));
EV_ACQUIRE_CB;
if (expect_false (res < 0))

2
deps/libev/ev_port.c

@ -1,7 +1,7 @@
/*
* libev solaris event port backend
*
* Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-

5
deps/libev/ev_select.c

@ -39,8 +39,11 @@
#ifndef _WIN32
/* for unix systems */
# include <sys/select.h>
# include <inttypes.h>
# ifndef __hpux
/* for REAL unix systems */
# include <sys/select.h>
# endif
#endif
#ifndef EV_SELECT_USE_FD_SET

4
deps/libev/libev.m4

@ -6,7 +6,7 @@ AC_CHECK_HEADERS(sys/inotify.h sys/epoll.h sys/event.h port.h poll.h sys/select.
AC_CHECK_FUNCS(inotify_init epoll_ctl kqueue port_create poll select eventfd signalfd)
AC_CHECK_FUNC(clock_gettime, [], [
AC_CHECK_FUNCS(clock_gettime, [], [
dnl on linux, try syscall wrapper first
if test $(uname) = Linux; then
AC_MSG_CHECKING(for clock_gettime syscall)
@ -27,7 +27,7 @@ AC_CHECK_FUNC(clock_gettime, [], [
fi
])
AC_CHECK_FUNC(nanosleep, [], [
AC_CHECK_FUNCS(nanosleep, [], [
if test -z "$LIBEV_M4_AVOID_LIBRT"; then
AC_CHECK_LIB(rt, nanosleep)
unset ac_cv_func_nanosleep

Loading…
Cancel
Save