*** empty log message ***

This commit is contained in:
Marc Alexander Lehmann 2008-11-20 00:35:10 +00:00
parent bfcc49b9ef
commit f3be4c72a3
4 changed files with 71 additions and 11 deletions

View File

@ -1,5 +1,8 @@
Revision history for libev, a high-performance and full-featured event loop.
- new config symbol, EV_USE_CLOCK_SYSCALL, to make libev use
a direct syscall - slower, but no dependency on librt et al.
3.49 Wed Nov 19 11:26:53 CET 2008
- ev_stat watchers will now use inotify as a mere hint on
kernels <2.6.25, or if the filesystem is not in the

29
ev.c
View File

@ -49,6 +49,18 @@ extern "C" {
# include "config.h"
# endif
# if HAVE_CLOCK_SYSCALL
# ifndef EV_USE_CLOCK_SYSCALL
# define EV_USE_CLOCK_SYSCALL 1
# ifndef EV_USE_REALTIME
# define EV_USE_REALTIME 0
# endif
# ifndef EV_USE_MONOTONIC
# define EV_USE_MONOTONIC 1
# endif
# endif
# endif
# if HAVE_CLOCK_GETTIME
# ifndef EV_USE_MONOTONIC
# define EV_USE_MONOTONIC 1
@ -166,6 +178,14 @@ extern "C" {
/* this block tries to deduce configuration from header-defined symbols and defaults */
#ifndef EV_USE_CLOCK_SYSCALL
# if __linux && __GLIBC__ >= 2
# define EV_USE_CLOCK_SYSCALL 1
# else
# define EV_USE_CLOCK_SYSCALL 0
# endif
#endif
#ifndef EV_USE_MONOTONIC
# if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0
# define EV_USE_MONOTONIC 1
@ -302,6 +322,15 @@ extern "C" {
# include <winsock.h>
#endif
/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
/* which makes programs even slower. might work on other unices, too. */
#if EV_USE_CLOCK_SYSCALL
# include <syscall.h>
# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
# undef EV_USE_MONOTONIC
# define EV_USE_MONOTONIC 1
#endif
#if EV_USE_EVENTFD
/* our minimum requirement is glibc 2.7 which has the stub, but not the header */
# include <stdint.h>

36
ev.pod
View File

@ -3001,6 +3001,9 @@ of the libev API and adds file handle abstractions, asynchronous DNS and
more on top of it. It can be found via gem servers. Its homepage is at
L<http://rev.rubyforge.org/>.
Roger Pack reports that using the link order C<-lws2_32 -lmsvcrt-ruby-190>
makes rev work even on mingw.
=item D
Leandro Lucarella has written a D language binding (F<ev.d>) for libev, to
@ -3186,15 +3189,18 @@ implementations for some libevent functions (such as logging, which is not
supported). It will also not define any of the structs usually found in
F<event.h> that are not directly supported by the libev core alone.
In stanbdalone mode, libev will still try to automatically deduce the
configuration, but has to be more conservative.
=item EV_USE_MONOTONIC
If defined to be C<1>, libev will try to detect the availability of the
monotonic clock option at both compile time and runtime. Otherwise no use
of the monotonic clock option will be attempted. If you enable this, you
usually have to link against librt or something similar. Enabling it when
the functionality isn't available is safe, though, although you have
monotonic clock option at both compile time and runtime. Otherwise no
use of the monotonic clock option will be attempted. If you enable this,
you usually have to link against librt or something similar. Enabling it
when the functionality isn't available is safe, though, although you have
to make sure you link against any libraries where the C<clock_gettime>
function is hiding in (often F<-lrt>).
function is hiding in (often F<-lrt>). See also C<EV_USE_CLOCK_SYSCALL>.
=item EV_USE_REALTIME
@ -3205,6 +3211,16 @@ be attempted. This effectively replaces C<gettimeofday> by C<clock_get
(CLOCK_REALTIME, ...)> and will not normally affect correctness. See the
note about libraries in the description of C<EV_USE_MONOTONIC>, though.
=item EV_USE_CLOCK_SYSCALL
If defined to be C<1>, libev will try to use a direct syscall instead
of calling the system-provided C<clock_gettime> function. This option
exists because on GNU/Linux, C<clock_gettime> is in C<librt>, but C<librt>
unconditionally pulls in C<libpthread>, slowing down single-threaded
programs needlessly. Using a direct syscall is slightly slower, because
no optimised vdso implementation can be used, but avoids the pthread
dependency. Defaults to C<1> on GNU/Linux with glibc 2.x or higher.
=item EV_USE_NANOSLEEP
If defined to be C<1>, libev will assume that C<nanosleep ()> is available
@ -3229,11 +3245,11 @@ will not be compiled in.
If defined to C<1>, then the select backend will use the system C<fd_set>
structure. This is useful if libev doesn't compile due to a missing
C<NFDBITS> or C<fd_mask> definition or it mis-guesses the bitset layout on
exotic systems. This usually limits the range of file descriptors to some
low limit such as 1024 or might have other limitations (winsocket only
allows 64 sockets). The C<FD_SETSIZE> macro, set before compilation, might
influence the size of the C<fd_set> used.
C<NFDBITS> or C<fd_mask> definition or it mis-guesses the bitset layout
on exotic systems. This usually limits the range of file descriptors to
some low limit such as 1024 or might have other limitations (winsocket
only allows 64 sockets). The C<FD_SETSIZE> macro, set before compilation,
configures the maximum size of the C<fd_set>.
=item EV_SELECT_IS_WINSOCKET

View File

@ -7,7 +7,19 @@ AC_CHECK_HEADERS(sys/inotify.h sys/epoll.h sys/event.h sys/queue.h port.h poll.h
AC_CHECK_FUNCS(inotify_init epoll_ctl kqueue port_create poll select eventfd)
AC_CHECK_FUNC(clock_gettime, [], [
if test -z "$LIBEV_M4_AVOID_LIBRT"; then
dnl on linux, try syscall wrapper first
if test $(uname) = Linux; then
AC_MSG_CHECKING(for clock_gettime syscall)
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[#include <syscall.h>
#include <time.h>],
[struct timespec ts; int status = syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts)])],
[ac_have_clock_syscall=1
AC_DEFINE(HAVE_CLOCK_SYSCALL, 1, "use syscall interface for clock_gettime")
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
fi
if test -z "$LIBEV_M4_AVOID_LIBRT" && test -z "$ac_have_clock_syscall"; then
AC_CHECK_LIB(rt, clock_gettime)
unset ac_cv_func_clock_gettime
AC_CHECK_FUNCS(clock_gettime)