mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-11-30 02:47:35 +08:00
Merge branch 'libev' of https://github.com/Lede-Inc/cetus
This commit is contained in:
commit
b40a5700b3
@ -72,7 +72,6 @@ SET(PACKAGE_NAME cetus)
|
||||
## SET(CPACK_*) before the INCLUDE(CPack)
|
||||
INCLUDE(CPack)
|
||||
|
||||
MESSAGE(STATUS "libevent at libs:${EVENT_LIBRARY_DIRS} incl:${EVENT_INCLUDE_DIRS}")
|
||||
MESSAGE(STATUS "gthread at libs:${GTHREAD_LIBRARY_DIRS} incl:${GTHREAD_INCLUDE_DIRS}")
|
||||
MESSAGE(STATUS "gmodule at libs:${GMODULE_LIBRARY_DIRS} incl:${GMODULE_INCLUDE_DIRS}")
|
||||
|
||||
@ -86,12 +85,6 @@ ENDIF(NOT GLIB_DEV_BASE_DIR)
|
||||
SET(MYSQL_INCLUDE_DIRS CACHE PATH "MySQL include dir")
|
||||
SET(MYSQL_LIBRARY_DIRS CACHE PATH "MySQL library dir")
|
||||
|
||||
IF (NOT EVENT_BASE_DIR)
|
||||
SET(EVENT_INCLUDE_DIRS CACHE PATH "libevent include dir")
|
||||
SET(EVENT_LIBRARY_DIRS CACHE PATH "libevent library dir")
|
||||
ENDIF(NOT EVENT_BASE_DIR)
|
||||
|
||||
MESSAGE(STATUS "libevent at libs:${EVENT_LIBRARY_DIRS} incl:${EVENT_INCLUDE_DIRS}")
|
||||
MESSAGE(STATUS "glib2.0 at libs:${GLIB_LIBRARY_DIRS} incl:${GLIB_INCLUDE_DIRS}")
|
||||
MESSAGE(STATUS "gthread at libs:${GTHREAD_LIBRARY_DIRS} incl:${GTHREAD_INCLUDE_DIRS}")
|
||||
MESSAGE(STATUS "gmodule at libs:${GMODULE_LIBRARY_DIRS} incl:${GMODULE_INCLUDE_DIRS}")
|
||||
@ -139,7 +132,6 @@ ELSE(NOT MYSQL_INCLUDE_DIRS)
|
||||
ENDIF(NOT MYSQL_INCLUDE_DIRS)
|
||||
|
||||
SET(CMAKE_REQUIRED_INCLUDES
|
||||
${EVENT_INCLUDE_DIRS}
|
||||
${MYSQL_INCLUDE_DIRS}
|
||||
${GLIB_INCLUDE_DIRS}
|
||||
${GTHREAD_INCLUDE_DIRS}
|
||||
@ -147,7 +139,6 @@ SET(CMAKE_REQUIRED_INCLUDES
|
||||
|
||||
MESSAGE(STATUS "checking in dirs: ${CMAKE_REQUIRED_INCLUDES}")
|
||||
|
||||
CHECK_INCLUDE_FILES("sys/types.h;event.h" HAVE_EVENT_H)
|
||||
CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILES(netinet/in.h HAVE_NETINET_IN_H)
|
||||
CHECK_INCLUDE_FILES(net/if.h HAVE_NET_IF_H)
|
||||
@ -228,21 +219,8 @@ IF(${HAVE_SYS_RESOURCE_H})
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES )
|
||||
ENDIF(${HAVE_SYS_RESOURCE_H})
|
||||
|
||||
IF(EVENT_LIBRARY_DIRS)
|
||||
FIND_LIBRARY(EVENT_LIBRARIES
|
||||
NAMES event
|
||||
PATHS ${EVENT_LIBRARY_DIRS}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
ELSE(EVENT_LIBRARY_DIRS)
|
||||
FIND_LIBRARY(EVENT_LIBRARIES event)
|
||||
ENDIF(EVENT_LIBRARY_DIRS)
|
||||
|
||||
SET(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${EVENT_LIBRARIES})
|
||||
MESSAGE(STATUS "CMAKE_REQUIRED_LIBRARIES is ${CMAKE_REQUIRED_LIBRARIES}")
|
||||
CHECK_FUNCTION_EXISTS(event_base_new HAVE_EVENT_BASE_NEW)
|
||||
CHECK_FUNCTION_EXISTS(event_base_free HAVE_EVENT_BASE_FREE)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
|
||||
|
||||
IF(GIT_REVISION)
|
||||
@ -263,6 +241,7 @@ ADD_DEFINITIONS(
|
||||
-DPACKAGE="${CMAKE_PROJECT_NAME}"
|
||||
)
|
||||
|
||||
add_subdirectory(libev)
|
||||
ADD_SUBDIRECTORY(src)
|
||||
ADD_SUBDIRECTORY(plugins)
|
||||
IF(EXISTS examples)
|
||||
|
12
libev/CMakeLists.txt
Normal file
12
libev/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
add_definitions(-DEV_STANDALONE=1)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(EV_SRC
|
||||
ev.c
|
||||
event.c
|
||||
)
|
||||
|
||||
add_library(ev-cetus SHARED ${EV_SRC})
|
||||
|
||||
CHASSIS_INSTALL_TARGET(ev-cetus)
|
513
libev/Changes
Normal file
513
libev/Changes
Normal file
@ -0,0 +1,513 @@
|
||||
Revision history for libev, a high-performance and full-featured event loop.
|
||||
|
||||
4.24 Wed Dec 28 05:19:55 CET 2016
|
||||
- bump version to 4.24, as the release tarball inexplicably
|
||||
didn't have the right version in ev.h, even though the cvs-tagged
|
||||
version did have the right one (reported by Ales Teska).
|
||||
|
||||
4.23 Wed Nov 16 18:23:41 CET 2016
|
||||
- move some declarations at the beginning to help certain retarded
|
||||
microsoft compilers, even though their documentation claims
|
||||
otherwise (reported by Ruslan Osmanov).
|
||||
|
||||
4.22 Sun Dec 20 22:11:50 CET 2015
|
||||
- when epoll detects unremovable fds in the fd set, rebuild
|
||||
only the epoll descriptor, not the signal pipe, to avoid
|
||||
SIGPIPE in ev_async_send. This doesn't solve it on fork,
|
||||
so document what needs to be done in ev_loop_fork
|
||||
(analyzed by Benjamin Mahler).
|
||||
- remove superfluous sys/timeb.h include on win32
|
||||
(analyzed by Jason Madden).
|
||||
- updated libecb.
|
||||
|
||||
4.20 Sat Jun 20 13:01:43 CEST 2015
|
||||
- prefer noexcept over throw () with C++ 11.
|
||||
- update ecb.h due to incompatibilities with c11.
|
||||
- fix a potential aliasing issue when reading and writing
|
||||
watcher callbacks.
|
||||
|
||||
4.19 Thu Sep 25 08:18:25 CEST 2014
|
||||
- ev.h wasn't valid C++ anymore, which tripped compilers other than
|
||||
clang, msvc or gcc (analyzed by Raphael 'kena' Poss). Unfortunately,
|
||||
C++ doesn't support typedefs for function pointers fully, so the affected
|
||||
declarations have to spell out the types each time.
|
||||
- when not using autoconf, tighten the check for clock_gettime and related
|
||||
functionality.
|
||||
|
||||
4.18 Fri Sep 5 17:55:26 CEST 2014
|
||||
- events on files were not always generated properly with the
|
||||
epoll backend (testcase by Assaf Inbal).
|
||||
- mark event pipe fd as cloexec after a fork (analyzed by Sami Farin).
|
||||
- (ecb) support m68k, m88k and sh (patch by Miod Vallat).
|
||||
- use a reasonable fallback for EV_NSIG instead of erroring out
|
||||
when we can't detect the signal set size.
|
||||
- in the absence of autoconf, do not use the clock syscall
|
||||
on glibc >= 2.17 (avoids the syscall AND -lrt on systems
|
||||
doing clock_gettime in userspace).
|
||||
- ensure extern "C" function pointers are used for externally-visible
|
||||
loop callbacks (not watcher callbacks yet).
|
||||
- (ecb) work around memory barriers and volatile apparently both being
|
||||
broken in visual studio 2008 and later (analysed and patch by Nicolas Noble).
|
||||
|
||||
4.15 Fri Mar 1 12:04:50 CET 2013
|
||||
- destroying a non-default loop would stop the global waitpid
|
||||
watcher (Denis Bilenko).
|
||||
- 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,
|
||||
syserr, loop acquire/release, periodic reschedule cbs).
|
||||
- fix event_base_loop return code, add event_get_callback, event_base_new,
|
||||
event_base_get_method calls to improve libevent 1.x emulation and add
|
||||
some libevent 2.x functionality (based on a patch by Jeff Davey).
|
||||
- add more memory fences to fix a bug reported by Jeff Davey. Better
|
||||
be overfenced than underprotected.
|
||||
- ev_run now returns a boolean status (true meaning watchers are
|
||||
still active).
|
||||
- ev_once: undef EV_ERROR in ev_kqueue.c, to avoid clashing with
|
||||
libev's EV_ERROR (reported by 191919).
|
||||
- (ecb) add memory fence support for xlC (Darin McBride).
|
||||
- (ecb) add memory fence support for gcc-mips (Anton Kirilov).
|
||||
- (ecb) add memory fence support for gcc-alpha (Christian Weisgerber).
|
||||
- work around some kernels losing file descriptors by leaking
|
||||
the kqueue descriptor in the child.
|
||||
- work around linux inotify not reporting IN_ATTRIB changes for directories
|
||||
in many cases.
|
||||
- include sys/syscall.h instead of plain syscall.h.
|
||||
- check for io watcher loops in ev_verify, check for the most
|
||||
common reported usage bug in ev_io_start.
|
||||
- choose socket vs. WSASocket at compiletime using EV_USE_WSASOCKET.
|
||||
- always use WSASend/WSARecv directly on windows, hoping that this
|
||||
works in all cases (unlike read/write/send/recv...).
|
||||
- try to detect signals around a fork faster (test program by
|
||||
Denis Bilenko).
|
||||
- work around recent glibc versions that leak memory in realloc.
|
||||
- rename ev::embed::set to ev::embed::set_embed to avoid clashing
|
||||
the watcher base set (loop) method.
|
||||
- rewrite the async/signal pipe logic to always keep a valid fd, which
|
||||
simplifies (and hopefully correctifies :) the race checking
|
||||
on fork, at the cost of one extra fd.
|
||||
- add fat, msdos, jffs2, ramfs, ntfs and btrfs to the list of
|
||||
inotify-supporting filesystems.
|
||||
- move orig_CFLAGS assignment to after AC_INIT, as newer autoconf
|
||||
versions ignore it before
|
||||
(https://bugzilla.redhat.com/show_bug.cgi?id=908096).
|
||||
- add some untested android support.
|
||||
- enum expressions must be of type int (reported by Juan Pablo L).
|
||||
|
||||
4.11 Sat Feb 4 19:52:39 CET 2012
|
||||
- INCOMPATIBLE CHANGE: ev_timer_again now clears the pending status, as
|
||||
was documented already, but not implemented in the repeating case.
|
||||
- new compiletime symbols: EV_NO_SMP and EV_NO_THREADS.
|
||||
- fix a race where the workaround against the epoll fork bugs
|
||||
caused signals to not be handled anymore.
|
||||
- correct backend_fudge for most backends, and implement a windows
|
||||
specific workaround to avoid looping because we call both
|
||||
select and Sleep, both with different time resolutions.
|
||||
- document range and guarantees of ev_sleep.
|
||||
- document reasonable ranges for periodics interval and offset.
|
||||
- rename backend_fudge to backend_mintime to avoid future confusion :)
|
||||
- change the default periodic reschedule function to hopefully be more
|
||||
exact and correct even in corner cases or in the far future.
|
||||
- do not rely on -lm anymore: use it when available but use our
|
||||
own floor () if it is missing. This should make it easier to embed,
|
||||
as no external libraries are required.
|
||||
- strategically import macros from libecb and mark rarely-used functions
|
||||
as cache-cold (saving almost 2k code size on typical amd64 setups).
|
||||
- add Symbols.ev and Symbols.event files, that were missing.
|
||||
- fix backend_mintime value for epoll (was 1/1024, is 1/1000 now).
|
||||
- fix #3 "be smart about timeouts" to not "deadlock" when
|
||||
timeout == now, also improve the section overall.
|
||||
- avoid "AVOIDING FINISHING BEFORE RETURNING" idiom.
|
||||
- support new EV_API_STATIC mode to make all libev symbols
|
||||
static.
|
||||
- supply default CFLAGS of -g -O3 with gcc when original CFLAGS
|
||||
were empty.
|
||||
|
||||
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
|
||||
backend, by generating events on our own.
|
||||
- ports backend: work around solaris bug 6874410 and many related ones
|
||||
(EINTR, maybe more), with no performance loss (note that the solaris
|
||||
bug report is actually wrong, reality is far more bizarre and broken
|
||||
than that).
|
||||
- define EV_READ/EV_WRITE as macros in event.h, as some programs use
|
||||
#ifdef to test for them.
|
||||
- new (experimental) function: ev_feed_signal.
|
||||
- new (to become default) EVFLAG_NOSIGMASK flag.
|
||||
- new EVBACKEND_MASK symbol.
|
||||
- updated COMMON IDIOMS SECTION.
|
||||
|
||||
4.01 Fri Nov 5 21:51:29 CET 2010
|
||||
- automake fucked it up, apparently, --add-missing -f is not quite enough
|
||||
to make it update its files, so 4.00 didn't install ev++.h and
|
||||
event.h on make install. grrr.
|
||||
- ev_loop(count|depth) didn't return anything (Robin Haberkorn).
|
||||
- change EV_UNDEF to 0xffffffff to silence some overzealous compilers.
|
||||
- use "(libev) " prefix for all libev error messages now.
|
||||
|
||||
4.00 Mon Oct 25 12:32:12 CEST 2010
|
||||
- "PORTING FROM LIBEV 3.X TO 4.X" (in ev.pod) is recommended reading.
|
||||
- ev_embed_stop did not correctly stop the watcher (very good
|
||||
testcase by Vladimir Timofeev).
|
||||
- ev_run will now always update the current loop time - it erroneously
|
||||
didn't when idle watchers were active, causing timers not to fire.
|
||||
- fix a bug where a timeout of zero caused the timer not to fire
|
||||
in the libevent emulation (testcase by Péter Szabó).
|
||||
- applied win32 fixes by Michael Lenaghan (also James Mansion).
|
||||
- replace EV_MINIMAL by EV_FEATURES.
|
||||
- prefer EPOLL_CTL_ADD over EPOLL_CTL_MOD in some more cases, as it
|
||||
seems the former is *much* faster than the latter.
|
||||
- linux kernel version detection (for inotify bug workarounds)
|
||||
did not work properly.
|
||||
- reduce the number of spurious wake-ups with the ports backend.
|
||||
- remove dependency on sys/queue.h on freebsd (patch by Vanilla Hsu).
|
||||
- do async init within ev_async_start, not ev_async_set, which avoids
|
||||
an API quirk where the set function must be called in the C++ API
|
||||
even when there is nothing to set.
|
||||
- add (undocumented) EV_ENABLE when adding events with kqueue,
|
||||
this might help with OS X, which seems to need it despite documenting
|
||||
not to need it (helpfully pointed out by Tilghman Lesher).
|
||||
- do not use poll by default on freebsd, it's broken (what isn't
|
||||
on freebsd...).
|
||||
- allow to embed epoll on kernels >= 2.6.32.
|
||||
- configure now prepends -O3, not appends it, so one can still
|
||||
override it.
|
||||
- ev.pod: greatly expanded the portability section, added a porting
|
||||
section, a description of watcher states and made lots of minor fixes.
|
||||
- disable poll backend on AIX, the poll header spams the namespace
|
||||
and it's not worth working around dead platforms (reported
|
||||
and analyzed by Aivars Kalvans).
|
||||
- improve header file compatibility of the standalone eventfd code
|
||||
in an obscure case.
|
||||
- implement EV_AVOID_STDIO option.
|
||||
- do not use sscanf to parse linux version number (smaller, faster,
|
||||
no sscanf dependency).
|
||||
- new EV_CHILD_ENABLE and EV_SIGNAL_ENABLE configurable settings.
|
||||
- update libev.m4 HAVE_CLOCK_SYSCALL test for newer glibcs.
|
||||
- add section on accept() problems to the manpage.
|
||||
- rename EV_TIMEOUT to EV_TIMER.
|
||||
- rename ev_loop_count/depth/verify/loop/unloop.
|
||||
- remove ev_default_destroy and ev_default_fork.
|
||||
- switch to two-digit minor version.
|
||||
- work around an apparent gentoo compiler bug.
|
||||
- define _DARWIN_UNLIMITED_SELECT. just so.
|
||||
- use enum instead of #define for most constants.
|
||||
- improve compatibility to older C++ compilers.
|
||||
- (experimental) ev_run/ev_default_loop/ev_break/ev_loop_new have now
|
||||
default arguments when compiled as C++.
|
||||
- enable automake dependency tracking.
|
||||
- ev_loop_new no longer leaks memory when loop creation failed.
|
||||
- new ev_cleanup watcher type.
|
||||
|
||||
3.9 Thu Dec 31 07:59:59 CET 2009
|
||||
- signalfd is no longer used by default and has to be requested
|
||||
explicitly - this means that easy to catch bugs become hard to
|
||||
catch race conditions, but the users have spoken.
|
||||
- point out the unspecified signal mask in the documentation, and
|
||||
that this is a race condition regardless of EV_SIGNALFD.
|
||||
- backport inotify code to C89.
|
||||
- inotify file descriptors could leak into child processes.
|
||||
- ev_stat watchers could keep an erroneous extra ref on the loop,
|
||||
preventing exit when unregistering all watchers (testcases
|
||||
provided by ry@tinyclouds.org).
|
||||
- implement EV_WIN32_HANDLE_TO_FD and EV_WIN32_CLOSE_FD configuration
|
||||
symbols to make it easier for apps to do their own fd management.
|
||||
- support EV_IDLE_ENABLE being disabled in ev++.h
|
||||
(patch by Didier Spezia).
|
||||
- take advantage of inotify_init1, if available, to set cloexec/nonblock
|
||||
on fd creation, to avoid races.
|
||||
- the signal handling pipe wasn't always initialised under windows
|
||||
(analysed by lekma).
|
||||
- changed minimum glibc requirement from glibc 2.9 to 2.7, for
|
||||
signalfd.
|
||||
- add missing string.h include (Denis F. Latypoff).
|
||||
- only replace ev_stat.prev when we detect an actual difference,
|
||||
so prev is (almost) always different to attr. this might
|
||||
have caused the problems with 04_stat.t.
|
||||
- add ev::timer->remaining () method to C++ API.
|
||||
|
||||
3.8 Sun Aug 9 14:30:45 CEST 2009
|
||||
- incompatible change: do not necessarily reset signal handler
|
||||
to SIG_DFL when a sighandler is stopped.
|
||||
- ev_default_destroy did not properly free or zero some members,
|
||||
potentially causing crashes and memory corruption on repeated
|
||||
ev_default_destroy/ev_default_loop calls.
|
||||
- take advantage of signalfd on GNU/Linux systems.
|
||||
- document that the signal mask might be in an unspecified
|
||||
state when using libev's signal handling.
|
||||
- take advantage of some GNU/Linux calls to set cloexec/nonblock
|
||||
on fd creation, to avoid race conditions.
|
||||
|
||||
3.7 Fri Jul 17 16:36:32 CEST 2009
|
||||
- ev_unloop and ev_loop wrongly used a global variable to exit loops,
|
||||
instead of using a per-loop variable (bug caught by accident...).
|
||||
- the ev_set_io_collect_interval interpretation has changed.
|
||||
- add new functionality: ev_set_userdata, ev_userdata,
|
||||
ev_set_invoke_pending_cb, ev_set_loop_release_cb,
|
||||
ev_invoke_pending, ev_pending_count, together with a long example
|
||||
about thread locking.
|
||||
- add ev_timer_remaining (as requested by Denis F. Latypoff).
|
||||
- add ev_loop_depth.
|
||||
- calling ev_unloop in fork/prepare watchers will no longer poll
|
||||
for new events.
|
||||
- Denis F. Latypoff corrected many typos in example code snippets.
|
||||
- honor autoconf detection of EV_USE_CLOCK_SYSCALL, also double-
|
||||
check that the syscall number is available before trying to
|
||||
use it (reported by ry@tinyclouds).
|
||||
- use GetSystemTimeAsFileTime instead of _timeb on windows, for
|
||||
slightly higher accuracy.
|
||||
- properly declare ev_loop_verify and ev_now_update even when
|
||||
!EV_MULTIPLICITY.
|
||||
- do not compile in any priority code when EV_MAXPRI == EV_MINPRI.
|
||||
- support EV_MINIMAL==2 for a reduced API.
|
||||
- actually 0-initialise struct sigaction when installing signals.
|
||||
- add section on hibernate and stopped processes to ev_timer docs.
|
||||
|
||||
3.6 Tue Apr 28 02:49:30 CEST 2009
|
||||
- multiple timers becoming ready within an event loop iteration
|
||||
will be invoked in the "correct" order now.
|
||||
- do not leave the event loop early just because we have no active
|
||||
watchers, fixing a problem when embedding a kqueue loop
|
||||
that has active kernel events but no registered watchers
|
||||
(reported by blacksand blacksand).
|
||||
- correctly zero the idx values for arrays, so destroying and
|
||||
reinitialising the default loop actually works (patch by
|
||||
Malek Hadj-Ali).
|
||||
- implement ev_suspend and ev_resume.
|
||||
- new EV_CUSTOM revents flag for use by applications.
|
||||
- add documentation section about priorities.
|
||||
- add a glossary to the documentation.
|
||||
- extend the ev_fork description slightly.
|
||||
- optimize a jump out of call_pending.
|
||||
|
||||
3.53 Sun Feb 15 02:38:20 CET 2009
|
||||
- fix a bug in event pipe creation on win32 that would cause a
|
||||
failed assertion on event loop creation (patch by Malek Hadj-Ali).
|
||||
- probe for CLOCK_REALTIME support at runtime as well and fall
|
||||
back to gettimeofday if there is an error, to support older
|
||||
operating systems with newer header files/libraries.
|
||||
- prefer gettimeofday over clock_gettime with USE_CLOCK_SYSCALL
|
||||
(default most everywhere), otherwise not.
|
||||
|
||||
3.52 Wed Jan 7 21:43:02 CET 2009
|
||||
- fix compilation of select backend in fd_set mode when NFDBITS is
|
||||
missing (to get it to compile on QNX, reported by Rodrigo Campos).
|
||||
- better select-nfds handling when select backend is in fd_set mode.
|
||||
- diagnose fd_set overruns when select backend is in fd_set mode.
|
||||
- due to a thinko, instead of disabling everything but
|
||||
select on the borked OS X platform, everything but select was
|
||||
allowed (reported by Emanuele Giaquinta).
|
||||
- actually verify that local and remote port are matching in
|
||||
libev's socketpair emulation, which makes denial-of-service
|
||||
attacks harder (but not impossible - it's windows). Make sure
|
||||
it even works under vista, which thinks that getpeer/sockname
|
||||
should return fantasy port numbers.
|
||||
- include "libev" in all assertion messages for potentially
|
||||
clearer diagnostics.
|
||||
- event_get_version (libevent compatibility) returned
|
||||
a useless string instead of the expected version string
|
||||
(patch by W.C.A. Wijngaards).
|
||||
|
||||
3.51 Wed Dec 24 23:00:11 CET 2008
|
||||
- fix a bug where an inotify watcher was added twice, causing
|
||||
freezes on hash collisions (reported and analysed by Graham Leggett).
|
||||
- new config symbol, EV_USE_CLOCK_SYSCALL, to make libev use
|
||||
a direct syscall - slower, but no dependency on librt et al.
|
||||
- assume negative return values != -1 signals success of port_getn
|
||||
(http://cvs.epicsol.org/cgi/viewcvs.cgi/epic5/source/newio.c?rev=1.52)
|
||||
(no known failure reports, but it doesn't hurt).
|
||||
- fork detection in ev_embed now stops and restarts the watcher
|
||||
automatically.
|
||||
- EXPERIMENTAL: default the method to operator () in ev++.h,
|
||||
to make it nicer to use functors (requested by Benedek László).
|
||||
- fixed const object callbacks in ev++.h.
|
||||
- replaced loop_ref argument of watcher.set (loop) by a direct
|
||||
ev_loop * in ev++.h, to avoid clashes with functor patch.
|
||||
- do not try to watch the empty string via inotify.
|
||||
- inotify watchers could be leaked under certain circumstances.
|
||||
- OS X 10.5 is actually even more broken than earlier versions,
|
||||
so fall back to select on that piece of garbage.
|
||||
- fixed some weirdness in the ev_embed documentation.
|
||||
|
||||
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
|
||||
"known to be good" list.
|
||||
- better mingw32 compatibility (it's not as borked as native win32)
|
||||
(analysed by Roger Pack).
|
||||
- include stdio.h in the example program, as too many people are
|
||||
confused by the weird C language otherwise. I guess the next thing
|
||||
I get told is that the "..." ellipses in the examples don't compile
|
||||
with their C compiler.
|
||||
|
||||
3.48 Thu Oct 30 09:02:37 CET 2008
|
||||
- further optimise away the EPOLL_CTL_ADD/MOD combo in the epoll
|
||||
backend by assuming the kernel event mask hasn't changed if
|
||||
ADD fails with EEXIST.
|
||||
- work around spurious event notification bugs in epoll by using
|
||||
a 32-bit generation counter. recreate kernel state if we receive
|
||||
spurious notifications or unwanted events. this is very costly,
|
||||
but I didn't come up with this horrible design.
|
||||
- use memset to initialise most arrays now and do away with the
|
||||
init functions.
|
||||
- expand time-out strategies into a "Be smart about timeouts" section.
|
||||
- drop the "struct" from all ev_watcher declarations in the
|
||||
documentation and did other clarifications (yeah, it was a mistake
|
||||
to have a struct AND a function called ev_loop).
|
||||
- fix a bug where ev_default would not initialise the default
|
||||
loop again after it was destroyed with ev_default_destroy.
|
||||
- rename syserr to ev_syserr to avoid name clashes when embedding,
|
||||
do similar changes for event.c.
|
||||
|
||||
3.45 Tue Oct 21 21:59:26 CEST 2008
|
||||
- disable inotify usage on linux <2.6.25, as it is broken
|
||||
(reported by Yoann Vandoorselaere).
|
||||
- ev_stat erroneously would try to add inotify watchers
|
||||
even when inotify wasn't available (this should only
|
||||
have a performance impact).
|
||||
- ev_once now passes both timeout and io to the callback if both
|
||||
occur concurrently, instead of giving timeouts precedence.
|
||||
- disable EV_USE_INOTIFY when sys/inotify.h is too old.
|
||||
|
||||
3.44 Mon Sep 29 05:18:39 CEST 2008
|
||||
- embed watchers now automatically invoke ev_loop_fork on the
|
||||
embedded loop when the parent loop forks.
|
||||
- new function: ev_now_update (loop).
|
||||
- verify_watcher was not marked static.
|
||||
- improve the "associating..." manpage section.
|
||||
- documentation tweaks here and there.
|
||||
|
||||
3.43 Sun Jul 6 05:34:41 CEST 2008
|
||||
- include more include files on windows to get struct _stati64
|
||||
(reported by Chris Hulbert, but doesn't quite fix his issue).
|
||||
- add missing #include <io.h> in ev.c on windows (reported by
|
||||
Matt Tolton).
|
||||
|
||||
3.42 Tue Jun 17 12:12:07 CEST 2008
|
||||
- work around yet another windows bug: FD_SET actually adds fd's
|
||||
multiple times to the fd_*SET*, despite official MSN docs claiming
|
||||
otherwise. Reported and well-analysed by Matt Tolton.
|
||||
- define NFDBITS to 0 when EV_SELECT_IS_WINSOCKET to make it compile
|
||||
(reported any analysed by Chris Hulbert).
|
||||
- fix a bug in ev_ebadf (this function is only used to catch
|
||||
programming errors in the libev user). reported by Matt Tolton.
|
||||
- fix a bug in fd_intern on win32 (could lead to compile errors
|
||||
under some circumstances, but would work correctly if it compiles).
|
||||
reported by Matt Tolton.
|
||||
- (try to) work around missing lstat on windows.
|
||||
- pass in the write fd set as except fd set under windows. windows
|
||||
is so uncontrollably lame that it requires this. this means that
|
||||
switching off oobinline is not supported (but tcp/ip doesn't
|
||||
have oob, so that would be stupid anyways.
|
||||
- use posix module symbol to auto-detect monotonic clock presence
|
||||
and some other default values.
|
||||
|
||||
3.41 Fri May 23 18:42:54 CEST 2008
|
||||
- work around an obscure bug in winsocket select: if you
|
||||
provide only empty fd sets then select returns WSAEINVAL. how sucky.
|
||||
- improve timer scheduling stability and reduce use of time_epsilon.
|
||||
- use 1-based 2-heap for EV_MINIMAL, simplifies code, reduces
|
||||
codesize and makes for better cache-efficiency.
|
||||
- use 3-based 4-heap for !EV_MINIMAL. this makes better use
|
||||
of cpu cache lines and gives better growth behaviour than
|
||||
2-based heaps.
|
||||
- cache timestamp within heap for !EV_MINIMAL, to avoid random
|
||||
memory accesses.
|
||||
- document/add EV_USE_4HEAP and EV_HEAP_CACHE_AT.
|
||||
- fix a potential aliasing issue in ev_timer_again.
|
||||
- add/document ev_periodic_at, retract direct access to ->at.
|
||||
- improve ev_stat docs.
|
||||
- add portability requirements section.
|
||||
- fix manpage headers etc.
|
||||
- normalise WSA error codes to lower range on windows.
|
||||
- add consistency check code that can be called automatically
|
||||
or on demand to check for internal structures (ev_loop_verify).
|
||||
|
||||
3.31 Wed Apr 16 20:45:04 CEST 2008
|
||||
- added last minute fix for ev_poll.c by Brandon Black.
|
||||
|
||||
3.3 Wed Apr 16 19:04:10 CEST 2008
|
||||
- event_base_loopexit should return 0 on success
|
||||
(W.C.A. Wijngaards).
|
||||
- added linux eventfd support.
|
||||
- try to autodetect epoll and inotify support
|
||||
by libc header version if not using autoconf.
|
||||
- new symbols: EV_DEFAULT_UC and EV_DEFAULT_UC_.
|
||||
- declare functions defined in ev.h as inline if
|
||||
C99 or gcc are available.
|
||||
- enable inlining with gcc versions 2 and 3.
|
||||
- work around broken poll implementations potentially
|
||||
not clearing revents field in ev_poll (Brandon Black)
|
||||
(no such systems are known at this time).
|
||||
- work around a bug in realloc on openbsd and darwin,
|
||||
also makes the erroneous valgrind complaints
|
||||
go away (noted by various people).
|
||||
- fix ev_async_pending, add c++ wrapper for ev_async
|
||||
(based on patch sent by Johannes Deisenhofer).
|
||||
- add sensible set method to ev::embed.
|
||||
- made integer constants type int in ev.h.
|
||||
|
||||
3.2 Wed Apr 2 17:11:19 CEST 2008
|
||||
- fix a 64 bit overflow issue in the select backend,
|
||||
by using fd_mask instead of int for the mask.
|
||||
- rename internal sighandler to avoid clash with very old perls.
|
||||
- entering ev_loop will not clear the ONESHOT or NONBLOCKING
|
||||
flags of any outer loops anymore.
|
||||
- add ev_async_pending.
|
||||
|
||||
3.1 Thu Mar 13 13:45:22 CET 2008
|
||||
- implement ev_async watchers.
|
||||
- only initialise signal pipe on demand.
|
||||
- make use of sig_atomic_t configurable.
|
||||
- improved documentation.
|
||||
|
||||
3.0 Mon Jan 28 13:14:47 CET 2008
|
||||
- API/ABI bump to version 3.0.
|
||||
- ev++.h includes "ev.h" by default now, not <ev.h>.
|
||||
- slightly improved documentation.
|
||||
- speed up signal detection after a fork.
|
||||
- only optionally return trace status changed in ev_child
|
||||
watchers.
|
||||
- experimental (and undocumented) loop wrappers for ev++.h.
|
||||
|
||||
2.01 Tue Dec 25 08:04:41 CET 2007
|
||||
- separate Changes file.
|
||||
- fix ev_path_set => ev_stat_set typo.
|
||||
- remove event_compat.h from the libev tarball.
|
||||
- change how include files are found.
|
||||
- doc updates.
|
||||
- update licenses, explicitly allow for GPL relicensing.
|
||||
|
||||
2.0 Sat Dec 22 17:47:03 CET 2007
|
||||
- new ev_sleep, ev_set_(io|timeout)_collect_interval.
|
||||
- removed epoll from embeddable fd set.
|
||||
- fix embed watchers.
|
||||
- renamed ev_embed.loop to other.
|
||||
- added exported Symbol tables.
|
||||
- undefine member wrapper macros at the end of ev.c.
|
||||
- respect EV_H in ev++.h.
|
||||
|
||||
1.86 Tue Dec 18 02:36:57 CET 2007
|
||||
- fix memleak on loop destroy (not relevant for perl).
|
||||
|
||||
1.85 Fri Dec 14 20:32:40 CET 2007
|
||||
- fix some aliasing issues w.r.t. timers and periodics
|
||||
(not relevant for perl).
|
||||
|
||||
(for historic versions refer to EV/Changes, found in the Perl interface)
|
||||
|
||||
0.1 Wed Oct 31 21:31:48 CET 2007
|
||||
- original version; hacked together in <24h.
|
||||
|
37
libev/LICENSE
Normal file
37
libev/LICENSE
Normal file
@ -0,0 +1,37 @@
|
||||
All files in libev are
|
||||
Copyright (c)2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Alternatively, the contents of this package may be used under the terms
|
||||
of the GNU General Public License ("GPL") version 2 or any later version,
|
||||
in which case the provisions of the GPL are applicable instead of the
|
||||
above. If you wish to allow the use of your version of this package only
|
||||
under the terms of the GPL and not to allow others to use your version of
|
||||
this file under the BSD license, indicate your decision by deleting the
|
||||
provisions above and replace them with the notice and other provisions
|
||||
required by the GPL in this and the other files of this package. If you do
|
||||
not delete the provisions above, a recipient may use your version of this
|
||||
file under either the BSD or the GPL.
|
20
libev/Makefile.am
Normal file
20
libev/Makefile.am
Normal file
@ -0,0 +1,20 @@
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
|
||||
VERSION_INFO = 4:0:0
|
||||
|
||||
EXTRA_DIST = LICENSE Changes libev.m4 autogen.sh \
|
||||
ev_vars.h ev_wrap.h \
|
||||
ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_win32.c \
|
||||
ev.3 ev.pod Symbols.ev Symbols.event
|
||||
|
||||
man_MANS = ev.3
|
||||
|
||||
include_HEADERS = ev.h ev++.h event.h
|
||||
|
||||
lib_LTLIBRARIES = libev.la
|
||||
|
||||
libev_la_SOURCES = ev.c event.c
|
||||
libev_la_LDFLAGS = -version-info $(VERSION_INFO)
|
||||
|
||||
ev.3: ev.pod
|
||||
pod2man -n LIBEV -r "libev-$(VERSION)" -c "libev - high performance full featured event loop" -s3 <$< >$@
|
921
libev/Makefile.in
Normal file
921
libev/Makefile.in
Normal file
@ -0,0 +1,921 @@
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = .
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/libev.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
|
||||
$(am__configure_deps) $(include_HEADERS) $(am__DIST_COMMON)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" \
|
||||
"$(DESTDIR)$(includedir)"
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libev_la_LIBADD =
|
||||
am_libev_la_OBJECTS = ev.lo event.lo
|
||||
libev_la_OBJECTS = $(am_libev_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
am__v_lt_1 =
|
||||
libev_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(libev_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_@AM_V@)
|
||||
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
am__v_CC_1 =
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = $(libev_la_SOURCES)
|
||||
DIST_SOURCES = $(libev_la_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
man3dir = $(mandir)/man3
|
||||
NROFF = nroff
|
||||
MANS = $(man_MANS)
|
||||
HEADERS = $(include_HEADERS)
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
|
||||
$(LISP)config.h.in
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
CSCOPE = cscope
|
||||
AM_RECURSIVE_TARGETS = cscope
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in README \
|
||||
TODO compile config.guess config.sub depcomp install-sh \
|
||||
ltmain.sh missing mkinstalldirs
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
am__remove_distdir = \
|
||||
if test -d "$(distdir)"; then \
|
||||
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
&& rm -rf "$(distdir)" \
|
||||
|| { sleep 5 && rm -rf "$(distdir)"; }; \
|
||||
else :; fi
|
||||
am__post_remove_distdir = $(am__remove_distdir)
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
DIST_TARGETS = dist-gzip
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
|
||||
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
|
||||
distcleancheck_listfiles = find . -type f -print
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
VERSION_INFO = 4:0:0
|
||||
EXTRA_DIST = LICENSE Changes libev.m4 autogen.sh \
|
||||
ev_vars.h ev_wrap.h \
|
||||
ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_win32.c \
|
||||
ev.3 ev.pod Symbols.ev Symbols.event
|
||||
|
||||
man_MANS = ev.3
|
||||
include_HEADERS = ev.h ev++.h event.h
|
||||
lib_LTLIBRARIES = libev.la
|
||||
libev_la_SOURCES = ev.c event.c
|
||||
libev_la_LDFLAGS = -version-info $(VERSION_INFO)
|
||||
all: config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
am--refresh: Makefile
|
||||
@:
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
config.h: stamp-h1
|
||||
@test -f $@ || rm -f stamp-h1
|
||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
|
||||
|
||||
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
|
||||
@rm -f stamp-h1
|
||||
cd $(top_builddir) && $(SHELL) ./config.status config.h
|
||||
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
|
||||
rm -f stamp-h1
|
||||
touch $@
|
||||
|
||||
distclean-hdr:
|
||||
-rm -f config.h stamp-h1
|
||||
|
||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
|
||||
list2=; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
list2="$$list2 $$p"; \
|
||||
else :; fi; \
|
||||
done; \
|
||||
test -z "$$list2" || { \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
|
||||
}
|
||||
|
||||
uninstall-libLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
|
||||
for p in $$list; do \
|
||||
$(am__strip_dir) \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
|
||||
done
|
||||
|
||||
clean-libLTLIBRARIES:
|
||||
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||
@list='$(lib_LTLIBRARIES)'; \
|
||||
locs=`for p in $$list; do echo $$p; done | \
|
||||
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
|
||||
sort -u`; \
|
||||
test -z "$$locs" || { \
|
||||
echo rm -f $${locs}; \
|
||||
rm -f $${locs}; \
|
||||
}
|
||||
|
||||
libev.la: $(libev_la_OBJECTS) $(libev_la_DEPENDENCIES) $(EXTRA_libev_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libev_la_LINK) -rpath $(libdir) $(libev_la_OBJECTS) $(libev_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ev.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
install-man3: $(man_MANS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list1=''; \
|
||||
list2='$(man_MANS)'; \
|
||||
test -n "$(man3dir)" \
|
||||
&& test -n "`echo $$list1$$list2`" \
|
||||
|| exit 0; \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \
|
||||
{ for i in $$list1; do echo "$$i"; done; \
|
||||
if test -n "$$list2"; then \
|
||||
for i in $$list2; do echo "$$i"; done \
|
||||
| sed -n '/\.3[a-z]*$$/p'; \
|
||||
fi; \
|
||||
} | while read p; do \
|
||||
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; echo "$$p"; \
|
||||
done | \
|
||||
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
|
||||
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
|
||||
sed 'N;N;s,\n, ,g' | { \
|
||||
list=; while read file base inst; do \
|
||||
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
|
||||
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
|
||||
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \
|
||||
fi; \
|
||||
done; \
|
||||
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \
|
||||
$(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \
|
||||
done; }
|
||||
|
||||
uninstall-man3:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list=''; test -n "$(man3dir)" || exit 0; \
|
||||
files=`{ for i in $$list; do echo "$$i"; done; \
|
||||
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
|
||||
sed -n '/\.3[a-z]*$$/p'; \
|
||||
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
|
||||
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
|
||||
dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir)
|
||||
install-includeHEADERS: $(include_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
|
||||
fi; \
|
||||
for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; \
|
||||
done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
|
||||
$(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
|
||||
done
|
||||
|
||||
uninstall-includeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
|
||||
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
|
||||
dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscope: cscope.files
|
||||
test ! -s cscope.files \
|
||||
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
|
||||
clean-cscope:
|
||||
-rm -f cscope.files
|
||||
cscope.files: clean-cscope cscopelist
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(am__remove_distdir)
|
||||
test -d "$(distdir)" || mkdir "$(distdir)"
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
-test -n "$(am__skip_mode_fix)" \
|
||||
|| find "$(distdir)" -type d ! -perm -755 \
|
||||
-exec chmod u+rwx,go+rx {} \; -o \
|
||||
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||
|| chmod -R a+r "$(distdir)"
|
||||
dist-gzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-bzip2: distdir
|
||||
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-lzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
@echo WARNING: "Support for distribution archives compressed with" \
|
||||
"legacy program 'compress' is deprecated." >&2
|
||||
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-shar: distdir
|
||||
@echo WARNING: "Support for shar distribution archives is" \
|
||||
"deprecated." >&2
|
||||
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
|
||||
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-zip: distdir
|
||||
-rm -f $(distdir).zip
|
||||
zip -rq $(distdir).zip $(distdir)
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist dist-all:
|
||||
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
case '$(DIST_ARCHIVES)' in \
|
||||
*.tar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
|
||||
*.tar.bz2*) \
|
||||
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.lz*) \
|
||||
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
|
||||
*.tar.xz*) \
|
||||
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
|
||||
*.tar.Z*) \
|
||||
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
*.shar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
|
||||
*.zip*) \
|
||||
unzip $(distdir).zip ;;\
|
||||
esac
|
||||
chmod -R a-w $(distdir)
|
||||
chmod u+w $(distdir)
|
||||
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build/sub \
|
||||
&& ../../configure \
|
||||
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
--srcdir=../.. --prefix="$$dc_install_base" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
|
||||
distuninstallcheck \
|
||||
&& chmod -R a-w "$$dc_install_base" \
|
||||
&& ({ \
|
||||
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
|
||||
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
|
||||
} || { rm -rf "$$dc_destdir"; exit 1; }) \
|
||||
&& rm -rf "$$dc_destdir" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||
&& rm -rf $(DIST_ARCHIVES) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
|
||||
&& cd "$$am__cwd" \
|
||||
|| exit 1
|
||||
$(am__post_remove_distdir)
|
||||
@(echo "$(distdir) archives ready for distribution: "; \
|
||||
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
|
||||
distuninstallcheck:
|
||||
@test -n '$(distuninstallcheck_dir)' || { \
|
||||
echo 'ERROR: trying to run $@ with an empty' \
|
||||
'$$(distuninstallcheck_dir)' >&2; \
|
||||
exit 1; \
|
||||
}; \
|
||||
$(am__cd) '$(distuninstallcheck_dir)' || { \
|
||||
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
|
||||
exit 1; \
|
||||
}; \
|
||||
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left after uninstall:" ; \
|
||||
if test -n "$(DESTDIR)"; then \
|
||||
echo " (check DESTDIR support)"; \
|
||||
fi ; \
|
||||
$(distuninstallcheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
distcleancheck: distclean
|
||||
@if test '$(srcdir)' = . ; then \
|
||||
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left in build directory after distclean:" ; \
|
||||
$(distcleancheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(MANS) $(HEADERS) config.h
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(includedir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-includeHEADERS install-man
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-libLTLIBRARIES
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man: install-man3
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \
|
||||
uninstall-man
|
||||
|
||||
uninstall-man: uninstall-man3
|
||||
|
||||
.MAKE: all install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \
|
||||
clean-cscope clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
|
||||
dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
|
||||
distcheck distclean distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-libtool distclean-tags distcleancheck \
|
||||
distdir distuninstallcheck dvi dvi-am html html-am info \
|
||||
info-am install install-am install-data install-data-am \
|
||||
install-dvi install-dvi-am install-exec install-exec-am \
|
||||
install-html install-html-am install-includeHEADERS \
|
||||
install-info install-info-am install-libLTLIBRARIES \
|
||||
install-man install-man3 install-pdf install-pdf-am install-ps \
|
||||
install-ps-am install-strip installcheck installcheck-am \
|
||||
installdirs maintainer-clean maintainer-clean-generic \
|
||||
mostlyclean mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
|
||||
uninstall-am uninstall-includeHEADERS uninstall-libLTLIBRARIES \
|
||||
uninstall-man uninstall-man3
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
ev.3: ev.pod
|
||||
pod2man -n LIBEV -r "libev-$(VERSION)" -c "libev - high performance full featured event loop" -s3 <$< >$@
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
58
libev/README
Normal file
58
libev/README
Normal file
@ -0,0 +1,58 @@
|
||||
libev is a high-performance event loop/event model with lots of features.
|
||||
(see benchmark at http://libev.schmorp.de/bench.html)
|
||||
|
||||
|
||||
ABOUT
|
||||
|
||||
Homepage: http://software.schmorp.de/pkg/libev
|
||||
Mailinglist: libev@lists.schmorp.de
|
||||
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
|
||||
Library Documentation: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod
|
||||
|
||||
Libev is modelled (very losely) after libevent and the Event perl
|
||||
module, but is faster, scales better and is more correct, and also more
|
||||
featureful. And also smaller. Yay.
|
||||
|
||||
Some of the specialties of libev not commonly found elsewhere are:
|
||||
|
||||
- extensive and detailed, readable documentation (not doxygen garbage).
|
||||
- fully supports fork, can detect fork in various ways and automatically
|
||||
re-arms kernel mechanisms that do not support fork.
|
||||
- highly optimised select, poll, epoll, kqueue and event ports backends.
|
||||
- filesystem object (path) watching (with optional linux inotify support).
|
||||
- wallclock-based times (using absolute time, cron-like).
|
||||
- relative timers/timeouts (handle time jumps).
|
||||
- fast intra-thread communication between multiple
|
||||
event loops (with optional fast linux eventfd backend).
|
||||
- extremely easy to embed (fully documented, no dependencies,
|
||||
autoconf supported but optional).
|
||||
- very small codebase, no bloated library, simple code.
|
||||
- fully extensible by being able to plug into the event loop,
|
||||
integrate other event loops, integrate other event loop users.
|
||||
- very little memory use (small watchers, small event loop data).
|
||||
- optional C++ interface allowing method and function callbacks
|
||||
at no extra memory or runtime overhead.
|
||||
- optional Perl interface with similar characteristics (capable
|
||||
of running Glib/Gtk2 on libev).
|
||||
- support for other languages (multiple C++ interfaces, D, Ruby,
|
||||
Python) available from third-parties.
|
||||
|
||||
Examples of programs that embed libev: the EV perl module, node.js,
|
||||
auditd, rxvt-unicode, gvpe (GNU Virtual Private Ethernet), the
|
||||
Deliantra MMORPG server (http://www.deliantra.net/), Rubinius (a
|
||||
next-generation Ruby VM), the Ebb web server, the Rev event toolkit.
|
||||
|
||||
|
||||
CONTRIBUTORS
|
||||
|
||||
libev was written and designed by Marc Lehmann and Emanuele Giaquinta.
|
||||
|
||||
The following people sent in patches or made other noteworthy
|
||||
contributions to the design (for minor patches, see the Changes
|
||||
file. If I forgot to include you, please shout at me, it was an
|
||||
accident):
|
||||
|
||||
W.C.A. Wijngaards
|
||||
Christopher Layne
|
||||
Chris Brody
|
||||
|
73
libev/Symbols.ev
Normal file
73
libev/Symbols.ev
Normal file
@ -0,0 +1,73 @@
|
||||
ev_async_send
|
||||
ev_async_start
|
||||
ev_async_stop
|
||||
ev_backend
|
||||
ev_break
|
||||
ev_check_start
|
||||
ev_check_stop
|
||||
ev_child_start
|
||||
ev_child_stop
|
||||
ev_cleanup_start
|
||||
ev_cleanup_stop
|
||||
ev_clear_pending
|
||||
ev_default_loop
|
||||
ev_default_loop_ptr
|
||||
ev_depth
|
||||
ev_embed_start
|
||||
ev_embed_stop
|
||||
ev_embed_sweep
|
||||
ev_embeddable_backends
|
||||
ev_feed_event
|
||||
ev_feed_fd_event
|
||||
ev_feed_signal
|
||||
ev_feed_signal_event
|
||||
ev_fork_start
|
||||
ev_fork_stop
|
||||
ev_idle_start
|
||||
ev_idle_stop
|
||||
ev_invoke
|
||||
ev_invoke_pending
|
||||
ev_io_start
|
||||
ev_io_stop
|
||||
ev_iteration
|
||||
ev_loop_destroy
|
||||
ev_loop_fork
|
||||
ev_loop_new
|
||||
ev_now
|
||||
ev_now_update
|
||||
ev_once
|
||||
ev_pending_count
|
||||
ev_periodic_again
|
||||
ev_periodic_start
|
||||
ev_periodic_stop
|
||||
ev_prepare_start
|
||||
ev_prepare_stop
|
||||
ev_recommended_backends
|
||||
ev_ref
|
||||
ev_resume
|
||||
ev_run
|
||||
ev_set_allocator
|
||||
ev_set_invoke_pending_cb
|
||||
ev_set_io_collect_interval
|
||||
ev_set_loop_release_cb
|
||||
ev_set_syserr_cb
|
||||
ev_set_timeout_collect_interval
|
||||
ev_set_userdata
|
||||
ev_signal_start
|
||||
ev_signal_stop
|
||||
ev_sleep
|
||||
ev_stat_start
|
||||
ev_stat_stat
|
||||
ev_stat_stop
|
||||
ev_supported_backends
|
||||
ev_suspend
|
||||
ev_time
|
||||
ev_timer_again
|
||||
ev_timer_remaining
|
||||
ev_timer_start
|
||||
ev_timer_stop
|
||||
ev_unref
|
||||
ev_userdata
|
||||
ev_verify
|
||||
ev_version_major
|
||||
ev_version_minor
|
24
libev/Symbols.event
Normal file
24
libev/Symbols.event
Normal file
@ -0,0 +1,24 @@
|
||||
event_active
|
||||
event_add
|
||||
event_base_dispatch
|
||||
event_base_free
|
||||
event_base_get_method
|
||||
event_base_loop
|
||||
event_base_loopexit
|
||||
event_base_new
|
||||
event_base_once
|
||||
event_base_priority_init
|
||||
event_base_set
|
||||
event_del
|
||||
event_dispatch
|
||||
event_get_callback
|
||||
event_get_method
|
||||
event_get_version
|
||||
event_init
|
||||
event_loop
|
||||
event_loopexit
|
||||
event_once
|
||||
event_pending
|
||||
event_priority_init
|
||||
event_priority_set
|
||||
event_set
|
14
libev/TODO
Normal file
14
libev/TODO
Normal file
@ -0,0 +1,14 @@
|
||||
TODO: ev_loop_wakeup
|
||||
TODO: EV_STANDALONE == NO_HASSLE (do not use clock_gettime in ev_standalone)
|
||||
TODO: faq, process a thing in each iteration
|
||||
TODO: dbeugging tips, ev_verify, ev_init twice
|
||||
TODO: ev_break for immediate exit (EVBREAK_NOW?)
|
||||
TODO: ev_feed_child_event
|
||||
TODO: document the special problem of signals around fork.
|
||||
TODO: store pid for each signal
|
||||
TODO: document file descriptor usage per loop
|
||||
TODO: store loop pid_t and compare isndie signal handler,store 1 for same, 2 for differign pid, clean up in loop_fork
|
||||
TODO: embed watchers need updating when fd changes
|
||||
TODO: document portability requirements for atomic pointer access
|
||||
TODO: document requirements for function pointers and calling conventions.
|
||||
|
9790
libev/aclocal.m4
vendored
Normal file
9790
libev/aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
libev/autogen.sh
Normal file
3
libev/autogen.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
autoreconf --install --symlink --force
|
347
libev/compile
Executable file
347
libev/compile
Executable file
@ -0,0 +1,347 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-10-14.11; # UTC
|
||||
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
1420
libev/config.guess
vendored
Executable file
1420
libev/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
125
libev/config.h.in
Normal file
125
libev/config.h.in
Normal file
@ -0,0 +1,125 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the `clock_gettime' function. */
|
||||
#undef HAVE_CLOCK_GETTIME
|
||||
|
||||
/* Define to 1 to use the syscall interface for clock_gettime */
|
||||
#undef HAVE_CLOCK_SYSCALL
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the `epoll_ctl' function. */
|
||||
#undef HAVE_EPOLL_CTL
|
||||
|
||||
/* Define to 1 if you have the `eventfd' function. */
|
||||
#undef HAVE_EVENTFD
|
||||
|
||||
/* Define to 1 if the floor function is available */
|
||||
#undef HAVE_FLOOR
|
||||
|
||||
/* Define to 1 if you have the `inotify_init' function. */
|
||||
#undef HAVE_INOTIFY_INIT
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `kqueue' function. */
|
||||
#undef HAVE_KQUEUE
|
||||
|
||||
/* Define to 1 if you have the `rt' library (-lrt). */
|
||||
#undef HAVE_LIBRT
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `nanosleep' function. */
|
||||
#undef HAVE_NANOSLEEP
|
||||
|
||||
/* Define to 1 if you have the `poll' function. */
|
||||
#undef HAVE_POLL
|
||||
|
||||
/* Define to 1 if you have the <poll.h> header file. */
|
||||
#undef HAVE_POLL_H
|
||||
|
||||
/* Define to 1 if you have the `port_create' function. */
|
||||
#undef HAVE_PORT_CREATE
|
||||
|
||||
/* Define to 1 if you have the <port.h> header file. */
|
||||
#undef HAVE_PORT_H
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define to 1 if you have the `signalfd' function. */
|
||||
#undef HAVE_SIGNALFD
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/epoll.h> header file. */
|
||||
#undef HAVE_SYS_EPOLL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/eventfd.h> header file. */
|
||||
#undef HAVE_SYS_EVENTFD_H
|
||||
|
||||
/* Define to 1 if you have the <sys/event.h> header file. */
|
||||
#undef HAVE_SYS_EVENT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/inotify.h> header file. */
|
||||
#undef HAVE_SYS_INOTIFY_H
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/signalfd.h> header file. */
|
||||
#undef HAVE_SYS_SIGNALFD_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
1799
libev/config.sub
vendored
Executable file
1799
libev/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
14133
libev/configure
vendored
Executable file
14133
libev/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
27
libev/configure.ac
Normal file
27
libev/configure.ac
Normal file
@ -0,0 +1,27 @@
|
||||
AC_INIT
|
||||
|
||||
orig_CFLAGS="$CFLAGS"
|
||||
|
||||
AC_CONFIG_SRCDIR([ev_epoll.c])
|
||||
|
||||
dnl also update ev.h!
|
||||
AM_INIT_AUTOMAKE(libev,4.24)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_CC
|
||||
|
||||
dnl Supply default CFLAGS, if not specified
|
||||
if test -z "$orig_CFLAGS"; then
|
||||
if test x$GCC = xyes; then
|
||||
CFLAGS="-g -O3"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
m4_include([libev.m4])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
791
libev/depcomp
Executable file
791
libev/depcomp
Executable file
@ -0,0 +1,791 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2013-05-30.07; # UTC
|
||||
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the directory component of the given path, and save it in the
|
||||
# global variables '$dir'. Note that this directory component will
|
||||
# be either empty or ending with a '/' character. This is deliberate.
|
||||
set_dir_from ()
|
||||
{
|
||||
case $1 in
|
||||
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
|
||||
*) dir=;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the suffix-stripped basename of the given path, and save it the
|
||||
# global variable '$base'.
|
||||
set_base_from ()
|
||||
{
|
||||
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
|
||||
}
|
||||
|
||||
# If no dependency file was actually created by the compiler invocation,
|
||||
# we still have to create a dummy depfile, to avoid errors with the
|
||||
# Makefile "include basename.Plo" scheme.
|
||||
make_dummy_depfile ()
|
||||
{
|
||||
echo "#dummy" > "$depfile"
|
||||
}
|
||||
|
||||
# Factor out some common post-processing of the generated depfile.
|
||||
# Requires the auxiliary global variable '$tmpdepfile' to be set.
|
||||
aix_post_process_depfile ()
|
||||
{
|
||||
# If the compiler actually managed to produce a dependency file,
|
||||
# post-process it.
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependency.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# $object: dependency.h
|
||||
# and one to simply output
|
||||
# dependency.h:
|
||||
# which is needed to avoid the deleted-header problem.
|
||||
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
|
||||
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
|
||||
} > "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
}
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
# Character ranges might be problematic outside the C locale.
|
||||
# These definitions help.
|
||||
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
lower=abcdefghijklmnopqrstuvwxyz
|
||||
digits=0123456789
|
||||
alpha=${upper}${lower}
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Avoid interferences from the environment.
|
||||
gccflag= dashmflag=
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
|
||||
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
|
||||
## (see the conditional assignment to $gccflag above).
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say). Also, it might not be
|
||||
## supported by the other compilers which use the 'gcc' depmode.
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The second -e expression handles DOS-style file names with drive
|
||||
# letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
|
||||
| tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
tcc)
|
||||
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
|
||||
# FIXME: That version still under development at the moment of writing.
|
||||
# Make that this statement remains true also for stable, released
|
||||
# versions.
|
||||
# It will wrap lines (doesn't matter whether long or short) with a
|
||||
# trailing '\', as in:
|
||||
#
|
||||
# foo.o : \
|
||||
# foo.c \
|
||||
# foo.h \
|
||||
#
|
||||
# It will put a trailing '\' even on the last line, and will use leading
|
||||
# spaces rather than leading tabs (at least since its commit 0394caf7
|
||||
# "Emit spaces for -MD").
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
|
||||
# We have to change lines of the first kind to '$object: \'.
|
||||
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
|
||||
# And for each line of the second kind, we have to emit a 'dep.h:'
|
||||
# dummy dependency, to avoid the deleted-header problem.
|
||||
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
## The order of this option in the case statement is important, since the
|
||||
## shell code in configure will try each of these formats in the order
|
||||
## listed in this file. A plain '-MD' option would be understood by many
|
||||
## compilers, so we must ensure this comes after the gcc and icc options.
|
||||
pgcc)
|
||||
# Portland's C compiler understands '-MD'.
|
||||
# Will always output deps to 'file.d' where file is the root name of the
|
||||
# source file under compilation, even if file resides in a subdirectory.
|
||||
# The object file name does not affect the name of the '.d' file.
|
||||
# pgcc 10.2 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using '\' :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
set_dir_from "$object"
|
||||
# Use the source, not the object, to determine the base name, since
|
||||
# that's sadly what pgcc will do too.
|
||||
set_base_from "$source"
|
||||
tmpdepfile=$base.d
|
||||
|
||||
# For projects that build the same source file twice into different object
|
||||
# files, the pgcc approach of using the *source* file root name can cause
|
||||
# problems in parallel builds. Use a locking strategy to avoid stomping on
|
||||
# the same $tmpdepfile.
|
||||
lockdir=$base.d-lock
|
||||
trap "
|
||||
echo '$0: caught signal, cleaning up...' >&2
|
||||
rmdir '$lockdir'
|
||||
exit 1
|
||||
" 1 2 13 15
|
||||
numtries=100
|
||||
i=$numtries
|
||||
while test $i -gt 0; do
|
||||
# mkdir is a portable test-and-set.
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
# This process acquired the lock.
|
||||
"$@" -MD
|
||||
stat=$?
|
||||
# Release the lock.
|
||||
rmdir "$lockdir"
|
||||
break
|
||||
else
|
||||
# If the lock is being held by a different process, wait
|
||||
# until the winning process is done or we timeout.
|
||||
while test -d "$lockdir" && test $i -gt 0; do
|
||||
sleep 1
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
fi
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
trap - 1 2 13 15
|
||||
if test $i -le 0; then
|
||||
echo "$0: failed to acquire lock after $numtries attempts" >&2
|
||||
echo "$0: check lockdir '$lockdir'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# Libtool generates 2 separate objects for the 2 libraries. These
|
||||
# two compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
|
||||
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
# Same post-processing that is required for AIX mode.
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this sed invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process the last invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed '1,2d' "$tmpdepfile" \
|
||||
| tr ' ' "$nl" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E \
|
||||
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
| sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
816
libev/ev++.h
Normal file
816
libev/ev++.h
Normal file
@ -0,0 +1,816 @@
|
||||
/*
|
||||
* libev simple C++ wrapper classes
|
||||
*
|
||||
* Copyright (c) 2007,2008,2010 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#ifndef EVPP_H__
|
||||
#define EVPP_H__
|
||||
|
||||
#ifdef EV_H
|
||||
# include EV_H
|
||||
#else
|
||||
# include "ev.h"
|
||||
#endif
|
||||
|
||||
#ifndef EV_USE_STDEXCEPT
|
||||
# define EV_USE_STDEXCEPT 1
|
||||
#endif
|
||||
|
||||
#if EV_USE_STDEXCEPT
|
||||
# include <stdexcept>
|
||||
#endif
|
||||
|
||||
namespace ev {
|
||||
|
||||
typedef ev_tstamp tstamp;
|
||||
|
||||
enum {
|
||||
UNDEF = EV_UNDEF,
|
||||
NONE = EV_NONE,
|
||||
READ = EV_READ,
|
||||
WRITE = EV_WRITE,
|
||||
#if EV_COMPAT3
|
||||
TIMEOUT = EV_TIMEOUT,
|
||||
#endif
|
||||
TIMER = EV_TIMER,
|
||||
PERIODIC = EV_PERIODIC,
|
||||
SIGNAL = EV_SIGNAL,
|
||||
CHILD = EV_CHILD,
|
||||
STAT = EV_STAT,
|
||||
IDLE = EV_IDLE,
|
||||
CHECK = EV_CHECK,
|
||||
PREPARE = EV_PREPARE,
|
||||
FORK = EV_FORK,
|
||||
ASYNC = EV_ASYNC,
|
||||
EMBED = EV_EMBED,
|
||||
# undef ERROR // some systems stupidly #define ERROR
|
||||
ERROR = EV_ERROR
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AUTO = EVFLAG_AUTO,
|
||||
NOENV = EVFLAG_NOENV,
|
||||
FORKCHECK = EVFLAG_FORKCHECK,
|
||||
|
||||
SELECT = EVBACKEND_SELECT,
|
||||
POLL = EVBACKEND_POLL,
|
||||
EPOLL = EVBACKEND_EPOLL,
|
||||
KQUEUE = EVBACKEND_KQUEUE,
|
||||
DEVPOLL = EVBACKEND_DEVPOLL,
|
||||
PORT = EVBACKEND_PORT
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
#if EV_COMPAT3
|
||||
NONBLOCK = EVLOOP_NONBLOCK,
|
||||
ONESHOT = EVLOOP_ONESHOT,
|
||||
#endif
|
||||
NOWAIT = EVRUN_NOWAIT,
|
||||
ONCE = EVRUN_ONCE
|
||||
};
|
||||
|
||||
enum how_t
|
||||
{
|
||||
ONE = EVBREAK_ONE,
|
||||
ALL = EVBREAK_ALL
|
||||
};
|
||||
|
||||
struct bad_loop
|
||||
#if EV_USE_STDEXCEPT
|
||||
: std::runtime_error
|
||||
#endif
|
||||
{
|
||||
#if EV_USE_STDEXCEPT
|
||||
bad_loop ()
|
||||
: std::runtime_error ("libev event loop cannot be initialized, bad value of LIBEV_FLAGS?")
|
||||
{
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef EV_AX
|
||||
# undef EV_AX
|
||||
#endif
|
||||
|
||||
#ifdef EV_AX_
|
||||
# undef EV_AX_
|
||||
#endif
|
||||
|
||||
#if EV_MULTIPLICITY
|
||||
# define EV_AX raw_loop
|
||||
# define EV_AX_ raw_loop,
|
||||
#else
|
||||
# define EV_AX
|
||||
# define EV_AX_
|
||||
#endif
|
||||
|
||||
struct loop_ref
|
||||
{
|
||||
loop_ref (EV_P) throw ()
|
||||
#if EV_MULTIPLICITY
|
||||
: EV_AX (EV_A)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
bool operator == (const loop_ref &other) const throw ()
|
||||
{
|
||||
#if EV_MULTIPLICITY
|
||||
return EV_AX == other.EV_AX;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool operator != (const loop_ref &other) const throw ()
|
||||
{
|
||||
#if EV_MULTIPLICITY
|
||||
return ! (*this == other);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if EV_MULTIPLICITY
|
||||
bool operator == (const EV_P) const throw ()
|
||||
{
|
||||
return this->EV_AX == EV_A;
|
||||
}
|
||||
|
||||
bool operator != (const EV_P) const throw ()
|
||||
{
|
||||
return (*this == EV_A);
|
||||
}
|
||||
|
||||
operator struct ev_loop * () const throw ()
|
||||
{
|
||||
return EV_AX;
|
||||
}
|
||||
|
||||
operator const struct ev_loop * () const throw ()
|
||||
{
|
||||
return EV_AX;
|
||||
}
|
||||
|
||||
bool is_default () const throw ()
|
||||
{
|
||||
return EV_AX == ev_default_loop (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if EV_COMPAT3
|
||||
void loop (int flags = 0)
|
||||
{
|
||||
ev_run (EV_AX_ flags);
|
||||
}
|
||||
|
||||
void unloop (how_t how = ONE) throw ()
|
||||
{
|
||||
ev_break (EV_AX_ how);
|
||||
}
|
||||
#endif
|
||||
|
||||
void run (int flags = 0)
|
||||
{
|
||||
ev_run (EV_AX_ flags);
|
||||
}
|
||||
|
||||
void break_loop (how_t how = ONE) throw ()
|
||||
{
|
||||
ev_break (EV_AX_ how);
|
||||
}
|
||||
|
||||
void post_fork () throw ()
|
||||
{
|
||||
ev_loop_fork (EV_AX);
|
||||
}
|
||||
|
||||
unsigned int backend () const throw ()
|
||||
{
|
||||
return ev_backend (EV_AX);
|
||||
}
|
||||
|
||||
tstamp now () const throw ()
|
||||
{
|
||||
return ev_now (EV_AX);
|
||||
}
|
||||
|
||||
void ref () throw ()
|
||||
{
|
||||
ev_ref (EV_AX);
|
||||
}
|
||||
|
||||
void unref () throw ()
|
||||
{
|
||||
ev_unref (EV_AX);
|
||||
}
|
||||
|
||||
#if EV_FEATURE_API
|
||||
unsigned int iteration () const throw ()
|
||||
{
|
||||
return ev_iteration (EV_AX);
|
||||
}
|
||||
|
||||
unsigned int depth () const throw ()
|
||||
{
|
||||
return ev_depth (EV_AX);
|
||||
}
|
||||
|
||||
void set_io_collect_interval (tstamp interval) throw ()
|
||||
{
|
||||
ev_set_io_collect_interval (EV_AX_ interval);
|
||||
}
|
||||
|
||||
void set_timeout_collect_interval (tstamp interval) throw ()
|
||||
{
|
||||
ev_set_timeout_collect_interval (EV_AX_ interval);
|
||||
}
|
||||
#endif
|
||||
|
||||
// function callback
|
||||
void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) throw ()
|
||||
{
|
||||
ev_once (EV_AX_ fd, events, timeout, cb, arg);
|
||||
}
|
||||
|
||||
// method callback
|
||||
template<class K, void (K::*method)(int)>
|
||||
void once (int fd, int events, tstamp timeout, K *object) throw ()
|
||||
{
|
||||
once (fd, events, timeout, method_thunk<K, method>, object);
|
||||
}
|
||||
|
||||
// default method == operator ()
|
||||
template<class K>
|
||||
void once (int fd, int events, tstamp timeout, K *object) throw ()
|
||||
{
|
||||
once (fd, events, timeout, method_thunk<K, &K::operator ()>, object);
|
||||
}
|
||||
|
||||
template<class K, void (K::*method)(int)>
|
||||
static void method_thunk (int revents, void *arg)
|
||||
{
|
||||
(static_cast<K *>(arg)->*method)
|
||||
(revents);
|
||||
}
|
||||
|
||||
// no-argument method callback
|
||||
template<class K, void (K::*method)()>
|
||||
void once (int fd, int events, tstamp timeout, K *object) throw ()
|
||||
{
|
||||
once (fd, events, timeout, method_noargs_thunk<K, method>, object);
|
||||
}
|
||||
|
||||
template<class K, void (K::*method)()>
|
||||
static void method_noargs_thunk (int revents, void *arg)
|
||||
{
|
||||
(static_cast<K *>(arg)->*method)
|
||||
();
|
||||
}
|
||||
|
||||
// simpler function callback
|
||||
template<void (*cb)(int)>
|
||||
void once (int fd, int events, tstamp timeout) throw ()
|
||||
{
|
||||
once (fd, events, timeout, simpler_func_thunk<cb>);
|
||||
}
|
||||
|
||||
template<void (*cb)(int)>
|
||||
static void simpler_func_thunk (int revents, void *arg)
|
||||
{
|
||||
(*cb)
|
||||
(revents);
|
||||
}
|
||||
|
||||
// simplest function callback
|
||||
template<void (*cb)()>
|
||||
void once (int fd, int events, tstamp timeout) throw ()
|
||||
{
|
||||
once (fd, events, timeout, simplest_func_thunk<cb>);
|
||||
}
|
||||
|
||||
template<void (*cb)()>
|
||||
static void simplest_func_thunk (int revents, void *arg)
|
||||
{
|
||||
(*cb)
|
||||
();
|
||||
}
|
||||
|
||||
void feed_fd_event (int fd, int revents) throw ()
|
||||
{
|
||||
ev_feed_fd_event (EV_AX_ fd, revents);
|
||||
}
|
||||
|
||||
void feed_signal_event (int signum) throw ()
|
||||
{
|
||||
ev_feed_signal_event (EV_AX_ signum);
|
||||
}
|
||||
|
||||
#if EV_MULTIPLICITY
|
||||
struct ev_loop* EV_AX;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#if EV_MULTIPLICITY
|
||||
struct dynamic_loop : loop_ref
|
||||
{
|
||||
|
||||
dynamic_loop (unsigned int flags = AUTO) throw (bad_loop)
|
||||
: loop_ref (ev_loop_new (flags))
|
||||
{
|
||||
if (!EV_AX)
|
||||
throw bad_loop ();
|
||||
}
|
||||
|
||||
~dynamic_loop () throw ()
|
||||
{
|
||||
ev_loop_destroy (EV_AX);
|
||||
EV_AX = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
dynamic_loop (const dynamic_loop &);
|
||||
|
||||
dynamic_loop & operator= (const dynamic_loop &);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
struct default_loop : loop_ref
|
||||
{
|
||||
default_loop (unsigned int flags = AUTO) throw (bad_loop)
|
||||
#if EV_MULTIPLICITY
|
||||
: loop_ref (ev_default_loop (flags))
|
||||
#endif
|
||||
{
|
||||
if (
|
||||
#if EV_MULTIPLICITY
|
||||
!EV_AX
|
||||
#else
|
||||
!ev_default_loop (flags)
|
||||
#endif
|
||||
)
|
||||
throw bad_loop ();
|
||||
}
|
||||
|
||||
private:
|
||||
default_loop (const default_loop &);
|
||||
default_loop &operator = (const default_loop &);
|
||||
};
|
||||
|
||||
inline loop_ref get_default_loop () throw ()
|
||||
{
|
||||
#if EV_MULTIPLICITY
|
||||
return ev_default_loop (0);
|
||||
#else
|
||||
return loop_ref ();
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef EV_AX
|
||||
#undef EV_AX_
|
||||
|
||||
#undef EV_PX
|
||||
#undef EV_PX_
|
||||
#if EV_MULTIPLICITY
|
||||
# define EV_PX loop_ref EV_A
|
||||
# define EV_PX_ loop_ref EV_A_
|
||||
#else
|
||||
# define EV_PX
|
||||
# define EV_PX_
|
||||
#endif
|
||||
|
||||
template<class ev_watcher, class watcher>
|
||||
struct base : ev_watcher
|
||||
{
|
||||
#if EV_MULTIPLICITY
|
||||
EV_PX;
|
||||
|
||||
// loop set
|
||||
void set (EV_P) throw ()
|
||||
{
|
||||
this->EV_A = EV_A;
|
||||
}
|
||||
#endif
|
||||
|
||||
base (EV_PX) throw ()
|
||||
#if EV_MULTIPLICITY
|
||||
: EV_A (EV_A)
|
||||
#endif
|
||||
{
|
||||
ev_init (this, 0);
|
||||
}
|
||||
|
||||
void set_ (const void *data, void (*cb)(EV_P_ ev_watcher *w, int revents)) throw ()
|
||||
{
|
||||
this->data = (void *)data;
|
||||
ev_set_cb (static_cast<ev_watcher *>(this), cb);
|
||||
}
|
||||
|
||||
// function callback
|
||||
template<void (*function)(watcher &w, int)>
|
||||
void set (void *data = 0) throw ()
|
||||
{
|
||||
set_ (data, function_thunk<function>);
|
||||
}
|
||||
|
||||
template<void (*function)(watcher &w, int)>
|
||||
static void function_thunk (EV_P_ ev_watcher *w, int revents)
|
||||
{
|
||||
function
|
||||
(*static_cast<watcher *>(w), revents);
|
||||
}
|
||||
|
||||
// method callback
|
||||
template<class K, void (K::*method)(watcher &w, int)>
|
||||
void set (K *object) throw ()
|
||||
{
|
||||
set_ (object, method_thunk<K, method>);
|
||||
}
|
||||
|
||||
// default method == operator ()
|
||||
template<class K>
|
||||
void set (K *object) throw ()
|
||||
{
|
||||
set_ (object, method_thunk<K, &K::operator ()>);
|
||||
}
|
||||
|
||||
template<class K, void (K::*method)(watcher &w, int)>
|
||||
static void method_thunk (EV_P_ ev_watcher *w, int revents)
|
||||
{
|
||||
(static_cast<K *>(w->data)->*method)
|
||||
(*static_cast<watcher *>(w), revents);
|
||||
}
|
||||
|
||||
// no-argument callback
|
||||
template<class K, void (K::*method)()>
|
||||
void set (K *object) throw ()
|
||||
{
|
||||
set_ (object, method_noargs_thunk<K, method>);
|
||||
}
|
||||
|
||||
template<class K, void (K::*method)()>
|
||||
static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents)
|
||||
{
|
||||
(static_cast<K *>(w->data)->*method)
|
||||
();
|
||||
}
|
||||
|
||||
void operator ()(int events = EV_UNDEF)
|
||||
{
|
||||
return
|
||||
ev_cb (static_cast<ev_watcher *>(this))
|
||||
(static_cast<ev_watcher *>(this), events);
|
||||
}
|
||||
|
||||
bool is_active () const throw ()
|
||||
{
|
||||
return ev_is_active (static_cast<const ev_watcher *>(this));
|
||||
}
|
||||
|
||||
bool is_pending () const throw ()
|
||||
{
|
||||
return ev_is_pending (static_cast<const ev_watcher *>(this));
|
||||
}
|
||||
|
||||
void feed_event (int revents) throw ()
|
||||
{
|
||||
ev_feed_event (EV_A_ static_cast<ev_watcher *>(this), revents);
|
||||
}
|
||||
};
|
||||
|
||||
inline tstamp now (EV_P) throw ()
|
||||
{
|
||||
return ev_now (EV_A);
|
||||
}
|
||||
|
||||
inline void delay (tstamp interval) throw ()
|
||||
{
|
||||
ev_sleep (interval);
|
||||
}
|
||||
|
||||
inline int version_major () throw ()
|
||||
{
|
||||
return ev_version_major ();
|
||||
}
|
||||
|
||||
inline int version_minor () throw ()
|
||||
{
|
||||
return ev_version_minor ();
|
||||
}
|
||||
|
||||
inline unsigned int supported_backends () throw ()
|
||||
{
|
||||
return ev_supported_backends ();
|
||||
}
|
||||
|
||||
inline unsigned int recommended_backends () throw ()
|
||||
{
|
||||
return ev_recommended_backends ();
|
||||
}
|
||||
|
||||
inline unsigned int embeddable_backends () throw ()
|
||||
{
|
||||
return ev_embeddable_backends ();
|
||||
}
|
||||
|
||||
inline void set_allocator (void *(*cb)(void *ptr, long size) throw ()) throw ()
|
||||
{
|
||||
ev_set_allocator (cb);
|
||||
}
|
||||
|
||||
inline void set_syserr_cb (void (*cb)(const char *msg) throw ()) throw ()
|
||||
{
|
||||
ev_set_syserr_cb (cb);
|
||||
}
|
||||
|
||||
#if EV_MULTIPLICITY
|
||||
#define EV_CONSTRUCT(cppstem,cstem) \
|
||||
(EV_PX = get_default_loop ()) throw () \
|
||||
: base<ev_ ## cstem, cppstem> (EV_A) \
|
||||
{ \
|
||||
}
|
||||
#else
|
||||
#define EV_CONSTRUCT(cppstem,cstem) \
|
||||
() throw () \
|
||||
{ \
|
||||
}
|
||||
#endif
|
||||
|
||||
/* using a template here would require quite a few more lines,
|
||||
* so a macro solution was chosen */
|
||||
#define EV_BEGIN_WATCHER(cppstem,cstem) \
|
||||
\
|
||||
struct cppstem : base<ev_ ## cstem, cppstem> \
|
||||
{ \
|
||||
void start () throw () \
|
||||
{ \
|
||||
ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \
|
||||
} \
|
||||
\
|
||||
void stop () throw () \
|
||||
{ \
|
||||
ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \
|
||||
} \
|
||||
\
|
||||
cppstem EV_CONSTRUCT(cppstem,cstem) \
|
||||
\
|
||||
~cppstem () throw () \
|
||||
{ \
|
||||
stop (); \
|
||||
} \
|
||||
\
|
||||
using base<ev_ ## cstem, cppstem>::set; \
|
||||
\
|
||||
private: \
|
||||
\
|
||||
cppstem (const cppstem &o); \
|
||||
\
|
||||
cppstem &operator =(const cppstem &o); \
|
||||
\
|
||||
public:
|
||||
|
||||
#define EV_END_WATCHER(cppstem,cstem) \
|
||||
};
|
||||
|
||||
EV_BEGIN_WATCHER (io, io)
|
||||
void set (int fd, int events) throw ()
|
||||
{
|
||||
int active = is_active ();
|
||||
if (active) stop ();
|
||||
ev_io_set (static_cast<ev_io *>(this), fd, events);
|
||||
if (active) start ();
|
||||
}
|
||||
|
||||
void set (int events) throw ()
|
||||
{
|
||||
int active = is_active ();
|
||||
if (active) stop ();
|
||||
ev_io_set (static_cast<ev_io *>(this), fd, events);
|
||||
if (active) start ();
|
||||
}
|
||||
|
||||
void start (int fd, int events) throw ()
|
||||
{
|
||||
set (fd, events);
|
||||
start ();
|
||||
}
|
||||
EV_END_WATCHER (io, io)
|
||||
|
||||
EV_BEGIN_WATCHER (timer, timer)
|
||||
void set (ev_tstamp after, ev_tstamp repeat = 0.) throw ()
|
||||
{
|
||||
int active = is_active ();
|
||||
if (active) stop ();
|
||||
ev_timer_set (static_cast<ev_timer *>(this), after, repeat);
|
||||
if (active) start ();
|
||||
}
|
||||
|
||||
void start (ev_tstamp after, ev_tstamp repeat = 0.) throw ()
|
||||
{
|
||||
set (after, repeat);
|
||||
start ();
|
||||
}
|
||||
|
||||
void again () throw ()
|
||||
{
|
||||
ev_timer_again (EV_A_ static_cast<ev_timer *>(this));
|
||||
}
|
||||
|
||||
ev_tstamp remaining ()
|
||||
{
|
||||
return ev_timer_remaining (EV_A_ static_cast<ev_timer *>(this));
|
||||
}
|
||||
EV_END_WATCHER (timer, timer)
|
||||
|
||||
#if EV_PERIODIC_ENABLE
|
||||
EV_BEGIN_WATCHER (periodic, periodic)
|
||||
void set (ev_tstamp at, ev_tstamp interval = 0.) throw ()
|
||||
{
|
||||
int active = is_active ();
|
||||
if (active) stop ();
|
||||
ev_periodic_set (static_cast<ev_periodic *>(this), at, interval, 0);
|
||||
if (active) start ();
|
||||
}
|
||||
|
||||
void start (ev_tstamp at, ev_tstamp interval = 0.) throw ()
|
||||
{
|
||||
set (at, interval);
|
||||
start ();
|
||||
}
|
||||
|
||||
void again () throw ()
|
||||
{
|
||||
ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
|
||||
}
|
||||
EV_END_WATCHER (periodic, periodic)
|
||||
#endif
|
||||
|
||||
#if EV_SIGNAL_ENABLE
|
||||
EV_BEGIN_WATCHER (sig, signal)
|
||||
void set (int signum) throw ()
|
||||
{
|
||||
int active = is_active ();
|
||||
if (active) stop ();
|
||||
ev_signal_set (static_cast<ev_signal *>(this), signum);
|
||||
if (active) start ();
|
||||
}
|
||||
|
||||
void start (int signum) throw ()
|
||||
{
|
||||
set (signum);
|
||||
start ();
|
||||
}
|
||||
EV_END_WATCHER (sig, signal)
|
||||
#endif
|
||||
|
||||
#if EV_CHILD_ENABLE
|
||||
EV_BEGIN_WATCHER (child, child)
|
||||
void set (int pid, int trace = 0) throw ()
|
||||
{
|
||||
int active = is_active ();
|
||||
if (active) stop ();
|
||||
ev_child_set (static_cast<ev_child *>(this), pid, trace);
|
||||
if (active) start ();
|
||||
}
|
||||
|
||||
void start (int pid, int trace = 0) throw ()
|
||||
{
|
||||
set (pid, trace);
|
||||
start ();
|
||||
}
|
||||
EV_END_WATCHER (child, child)
|
||||
#endif
|
||||
|
||||
#if EV_STAT_ENABLE
|
||||
EV_BEGIN_WATCHER (stat, stat)
|
||||
void set (const char *path, ev_tstamp interval = 0.) throw ()
|
||||
{
|
||||
int active = is_active ();
|
||||
if (active) stop ();
|
||||
ev_stat_set (static_cast<ev_stat *>(this), path, interval);
|
||||
if (active) start ();
|
||||
}
|
||||
|
||||
void start (const char *path, ev_tstamp interval = 0.) throw ()
|
||||
{
|
||||
stop ();
|
||||
set (path, interval);
|
||||
start ();
|
||||
}
|
||||
|
||||
void update () throw ()
|
||||
{
|
||||
ev_stat_stat (EV_A_ static_cast<ev_stat *>(this));
|
||||
}
|
||||
EV_END_WATCHER (stat, stat)
|
||||
#endif
|
||||
|
||||
#if EV_IDLE_ENABLE
|
||||
EV_BEGIN_WATCHER (idle, idle)
|
||||
void set () throw () { }
|
||||
EV_END_WATCHER (idle, idle)
|
||||
#endif
|
||||
|
||||
#if EV_PREPARE_ENABLE
|
||||
EV_BEGIN_WATCHER (prepare, prepare)
|
||||
void set () throw () { }
|
||||
EV_END_WATCHER (prepare, prepare)
|
||||
#endif
|
||||
|
||||
#if EV_CHECK_ENABLE
|
||||
EV_BEGIN_WATCHER (check, check)
|
||||
void set () throw () { }
|
||||
EV_END_WATCHER (check, check)
|
||||
#endif
|
||||
|
||||
#if EV_EMBED_ENABLE
|
||||
EV_BEGIN_WATCHER (embed, embed)
|
||||
void set_embed (struct ev_loop *embedded_loop) throw ()
|
||||
{
|
||||
int active = is_active ();
|
||||
if (active) stop ();
|
||||
ev_embed_set (static_cast<ev_embed *>(this), embedded_loop);
|
||||
if (active) start ();
|
||||
}
|
||||
|
||||
void start (struct ev_loop *embedded_loop) throw ()
|
||||
{
|
||||
set (embedded_loop);
|
||||
start ();
|
||||
}
|
||||
|
||||
void sweep ()
|
||||
{
|
||||
ev_embed_sweep (EV_A_ static_cast<ev_embed *>(this));
|
||||
}
|
||||
EV_END_WATCHER (embed, embed)
|
||||
#endif
|
||||
|
||||
#if EV_FORK_ENABLE
|
||||
EV_BEGIN_WATCHER (fork, fork)
|
||||
void set () throw () { }
|
||||
EV_END_WATCHER (fork, fork)
|
||||
#endif
|
||||
|
||||
#if EV_ASYNC_ENABLE
|
||||
EV_BEGIN_WATCHER (async, async)
|
||||
void send () throw ()
|
||||
{
|
||||
ev_async_send (EV_A_ static_cast<ev_async *>(this));
|
||||
}
|
||||
|
||||
bool async_pending () throw ()
|
||||
{
|
||||
return ev_async_pending (static_cast<ev_async *>(this));
|
||||
}
|
||||
EV_END_WATCHER (async, async)
|
||||
#endif
|
||||
|
||||
#undef EV_PX
|
||||
#undef EV_PX_
|
||||
#undef EV_CONSTRUCT
|
||||
#undef EV_BEGIN_WATCHER
|
||||
#undef EV_END_WATCHER
|
||||
}
|
||||
|
||||
#endif
|
||||
|
5647
libev/ev.3
Normal file
5647
libev/ev.3
Normal file
File diff suppressed because it is too large
Load Diff
5143
libev/ev.c
Normal file
5143
libev/ev.c
Normal file
File diff suppressed because it is too large
Load Diff
854
libev/ev.h
Normal file
854
libev/ev.h
Normal file
@ -0,0 +1,854 @@
|
||||
/*
|
||||
* libev native API header
|
||||
*
|
||||
* Copyright (c) 2007,2008,2009,2010,2011,2012,2015 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#ifndef EV_H_
|
||||
#define EV_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EV_CPP(x) x
|
||||
# if __cplusplus >= 201103L
|
||||
# define EV_THROW noexcept
|
||||
# else
|
||||
# define EV_THROW throw ()
|
||||
# endif
|
||||
#else
|
||||
# define EV_CPP(x)
|
||||
# define EV_THROW
|
||||
#endif
|
||||
|
||||
EV_CPP(extern "C" {)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* pre-4.0 compatibility */
|
||||
#ifndef EV_COMPAT3
|
||||
# define EV_COMPAT3 1
|
||||
#endif
|
||||
|
||||
#ifndef EV_FEATURES
|
||||
# if defined __OPTIMIZE_SIZE__
|
||||
# define EV_FEATURES 0x7c
|
||||
# else
|
||||
# define EV_FEATURES 0x7f
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define EV_FEATURE_CODE ((EV_FEATURES) & 1)
|
||||
#define EV_FEATURE_DATA ((EV_FEATURES) & 2)
|
||||
#define EV_FEATURE_CONFIG ((EV_FEATURES) & 4)
|
||||
#define EV_FEATURE_API ((EV_FEATURES) & 8)
|
||||
#define EV_FEATURE_WATCHERS ((EV_FEATURES) & 16)
|
||||
#define EV_FEATURE_BACKENDS ((EV_FEATURES) & 32)
|
||||
#define EV_FEATURE_OS ((EV_FEATURES) & 64)
|
||||
|
||||
/* these priorities are inclusive, higher priorities will be invoked earlier */
|
||||
#ifndef EV_MINPRI
|
||||
# define EV_MINPRI (EV_FEATURE_CONFIG ? -2 : 0)
|
||||
#endif
|
||||
#ifndef EV_MAXPRI
|
||||
# define EV_MAXPRI (EV_FEATURE_CONFIG ? +2 : 0)
|
||||
#endif
|
||||
|
||||
#ifndef EV_MULTIPLICITY
|
||||
# define EV_MULTIPLICITY EV_FEATURE_CONFIG
|
||||
#endif
|
||||
|
||||
#ifndef EV_PERIODIC_ENABLE
|
||||
# define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_STAT_ENABLE
|
||||
# define EV_STAT_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_PREPARE_ENABLE
|
||||
# define EV_PREPARE_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_CHECK_ENABLE
|
||||
# define EV_CHECK_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_IDLE_ENABLE
|
||||
# define EV_IDLE_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_FORK_ENABLE
|
||||
# define EV_FORK_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_CLEANUP_ENABLE
|
||||
# define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_SIGNAL_ENABLE
|
||||
# define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_CHILD_ENABLE
|
||||
# ifdef _WIN32
|
||||
# define EV_CHILD_ENABLE 0
|
||||
# else
|
||||
# define EV_CHILD_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EV_ASYNC_ENABLE
|
||||
# define EV_ASYNC_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_EMBED_ENABLE
|
||||
# define EV_EMBED_ENABLE EV_FEATURE_WATCHERS
|
||||
#endif
|
||||
|
||||
#ifndef EV_WALK_ENABLE
|
||||
# define EV_WALK_ENABLE 0 /* not yet */
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#if EV_CHILD_ENABLE && !EV_SIGNAL_ENABLE
|
||||
# undef EV_SIGNAL_ENABLE
|
||||
# define EV_SIGNAL_ENABLE 1
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef double ev_tstamp;
|
||||
|
||||
#include <string.h> /* for memmove */
|
||||
|
||||
#ifndef EV_ATOMIC_T
|
||||
# include <signal.h>
|
||||
# define EV_ATOMIC_T sig_atomic_t volatile
|
||||
#endif
|
||||
|
||||
#if EV_STAT_ENABLE
|
||||
# ifdef _WIN32
|
||||
# include <time.h>
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
/* support multiple event loops? */
|
||||
#if EV_MULTIPLICITY
|
||||
struct ev_loop;
|
||||
# define EV_P struct ev_loop *loop /* a loop as sole parameter in a declaration */
|
||||
# define EV_P_ EV_P, /* a loop as first of multiple parameters */
|
||||
# define EV_A loop /* a loop as sole argument to a function call */
|
||||
# define EV_A_ EV_A, /* a loop as first of multiple arguments */
|
||||
# define EV_DEFAULT_UC ev_default_loop_uc_ () /* the default loop, if initialised, as sole arg */
|
||||
# define EV_DEFAULT_UC_ EV_DEFAULT_UC, /* the default loop as first of multiple arguments */
|
||||
# define EV_DEFAULT ev_default_loop (0) /* the default loop as sole arg */
|
||||
# define EV_DEFAULT_ EV_DEFAULT, /* the default loop as first of multiple arguments */
|
||||
#else
|
||||
# define EV_P void
|
||||
# define EV_P_
|
||||
# define EV_A
|
||||
# define EV_A_
|
||||
# define EV_DEFAULT
|
||||
# define EV_DEFAULT_
|
||||
# define EV_DEFAULT_UC
|
||||
# define EV_DEFAULT_UC_
|
||||
# undef EV_EMBED_ENABLE
|
||||
#endif
|
||||
|
||||
/* EV_INLINE is used for functions in header files */
|
||||
#if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3
|
||||
# define EV_INLINE static inline
|
||||
#else
|
||||
# define EV_INLINE static
|
||||
#endif
|
||||
|
||||
#ifdef EV_API_STATIC
|
||||
# define EV_API_DECL static
|
||||
#else
|
||||
# define EV_API_DECL extern
|
||||
#endif
|
||||
|
||||
/* EV_PROTOTYPES can be used to switch of prototype declarations */
|
||||
#ifndef EV_PROTOTYPES
|
||||
# define EV_PROTOTYPES 1
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define EV_VERSION_MAJOR 4
|
||||
#define EV_VERSION_MINOR 24
|
||||
|
||||
/* eventmask, revents, events... */
|
||||
enum {
|
||||
EV_UNDEF = (int)0xFFFFFFFF, /* guaranteed to be invalid */
|
||||
EV_NONE = 0x00, /* no events */
|
||||
EV_READ = 0x01, /* ev_io detected read will not block */
|
||||
EV_WRITE = 0x02, /* ev_io detected write will not block */
|
||||
EV__IOFDSET = 0x80, /* internal use only */
|
||||
EV_IO = EV_READ, /* alias for type-detection */
|
||||
EV_TIMER = 0x00000100, /* timer timed out */
|
||||
#if EV_COMPAT3
|
||||
EV_TIMEOUT = EV_TIMER, /* pre 4.0 API compatibility */
|
||||
#endif
|
||||
EV_PERIODIC = 0x00000200, /* periodic timer timed out */
|
||||
EV_SIGNAL = 0x00000400, /* signal was received */
|
||||
EV_CHILD = 0x00000800, /* child/pid had status change */
|
||||
EV_STAT = 0x00001000, /* stat data changed */
|
||||
EV_IDLE = 0x00002000, /* event loop is idling */
|
||||
EV_PREPARE = 0x00004000, /* event loop about to poll */
|
||||
EV_CHECK = 0x00008000, /* event loop finished poll */
|
||||
EV_EMBED = 0x00010000, /* embedded event loop needs sweep */
|
||||
EV_FORK = 0x00020000, /* event loop resumed in child */
|
||||
EV_CLEANUP = 0x00040000, /* event loop resumed in child */
|
||||
EV_ASYNC = 0x00080000, /* async intra-loop signal */
|
||||
EV_CUSTOM = 0x01000000, /* for use by user code */
|
||||
EV_ERROR = (int)0x80000000 /* sent when an error occurs */
|
||||
};
|
||||
|
||||
/* can be used to add custom fields to all watchers, while losing binary compatibility */
|
||||
#ifndef EV_COMMON
|
||||
# define EV_COMMON void *data;
|
||||
#endif
|
||||
|
||||
#ifndef EV_CB_DECLARE
|
||||
# define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents);
|
||||
#endif
|
||||
#ifndef EV_CB_INVOKE
|
||||
# define EV_CB_INVOKE(watcher,revents) (watcher)->cb (EV_A_ (watcher), (revents))
|
||||
#endif
|
||||
|
||||
/* not official, do not use */
|
||||
#define EV_CB(type,name) void name (EV_P_ struct ev_ ## type *w, int revents)
|
||||
|
||||
/*
|
||||
* struct member types:
|
||||
* private: you may look at them, but not change them,
|
||||
* and they might not mean anything to you.
|
||||
* ro: can be read anytime, but only changed when the watcher isn't active.
|
||||
* rw: can be read and modified anytime, even when the watcher is active.
|
||||
*
|
||||
* some internal details that might be helpful for debugging:
|
||||
*
|
||||
* active is either 0, which means the watcher is not active,
|
||||
* or the array index of the watcher (periodics, timers)
|
||||
* or the array index + 1 (most other watchers)
|
||||
* or simply 1 for watchers that aren't in some array.
|
||||
* pending is either 0, in which case the watcher isn't,
|
||||
* or the array index + 1 in the pendings array.
|
||||
*/
|
||||
|
||||
#if EV_MINPRI == EV_MAXPRI
|
||||
# define EV_DECL_PRIORITY
|
||||
#elif !defined (EV_DECL_PRIORITY)
|
||||
# define EV_DECL_PRIORITY int priority;
|
||||
#endif
|
||||
|
||||
/* shared by all watchers */
|
||||
#define EV_WATCHER(type) \
|
||||
int active; /* private */ \
|
||||
int pending; /* private */ \
|
||||
EV_DECL_PRIORITY /* private */ \
|
||||
EV_COMMON /* rw */ \
|
||||
EV_CB_DECLARE (type) /* private */
|
||||
|
||||
#define EV_WATCHER_LIST(type) \
|
||||
EV_WATCHER (type) \
|
||||
struct ev_watcher_list *next; /* private */
|
||||
|
||||
#define EV_WATCHER_TIME(type) \
|
||||
EV_WATCHER (type) \
|
||||
ev_tstamp at; /* private */
|
||||
|
||||
/* base class, nothing to see here unless you subclass */
|
||||
typedef struct ev_watcher
|
||||
{
|
||||
EV_WATCHER (ev_watcher)
|
||||
} ev_watcher;
|
||||
|
||||
/* base class, nothing to see here unless you subclass */
|
||||
typedef struct ev_watcher_list
|
||||
{
|
||||
EV_WATCHER_LIST (ev_watcher_list)
|
||||
} ev_watcher_list;
|
||||
|
||||
/* base class, nothing to see here unless you subclass */
|
||||
typedef struct ev_watcher_time
|
||||
{
|
||||
EV_WATCHER_TIME (ev_watcher_time)
|
||||
} ev_watcher_time;
|
||||
|
||||
/* invoked when fd is either EV_READable or EV_WRITEable */
|
||||
/* revent EV_READ, EV_WRITE */
|
||||
typedef struct ev_io
|
||||
{
|
||||
EV_WATCHER_LIST (ev_io)
|
||||
|
||||
int fd; /* ro */
|
||||
int events; /* ro */
|
||||
} ev_io;
|
||||
|
||||
/* invoked after a specific time, repeatable (based on monotonic clock) */
|
||||
/* revent EV_TIMEOUT */
|
||||
typedef struct ev_timer
|
||||
{
|
||||
EV_WATCHER_TIME (ev_timer)
|
||||
|
||||
ev_tstamp repeat; /* rw */
|
||||
} ev_timer;
|
||||
|
||||
/* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */
|
||||
/* revent EV_PERIODIC */
|
||||
typedef struct ev_periodic
|
||||
{
|
||||
EV_WATCHER_TIME (ev_periodic)
|
||||
|
||||
ev_tstamp offset; /* rw */
|
||||
ev_tstamp interval; /* rw */
|
||||
ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) EV_THROW; /* rw */
|
||||
} ev_periodic;
|
||||
|
||||
/* invoked when the given signal has been received */
|
||||
/* revent EV_SIGNAL */
|
||||
typedef struct ev_signal
|
||||
{
|
||||
EV_WATCHER_LIST (ev_signal)
|
||||
|
||||
int signum; /* ro */
|
||||
} ev_signal;
|
||||
|
||||
/* invoked when sigchld is received and waitpid indicates the given pid */
|
||||
/* revent EV_CHILD */
|
||||
/* does not support priorities */
|
||||
typedef struct ev_child
|
||||
{
|
||||
EV_WATCHER_LIST (ev_child)
|
||||
|
||||
int flags; /* private */
|
||||
int pid; /* ro */
|
||||
int rpid; /* rw, holds the received pid */
|
||||
int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */
|
||||
} ev_child;
|
||||
|
||||
#if EV_STAT_ENABLE
|
||||
/* st_nlink = 0 means missing file or other error */
|
||||
# ifdef _WIN32
|
||||
typedef struct _stati64 ev_statdata;
|
||||
# else
|
||||
typedef struct stat ev_statdata;
|
||||
# endif
|
||||
|
||||
/* invoked each time the stat data changes for a given path */
|
||||
/* revent EV_STAT */
|
||||
typedef struct ev_stat
|
||||
{
|
||||
EV_WATCHER_LIST (ev_stat)
|
||||
|
||||
ev_timer timer; /* private */
|
||||
ev_tstamp interval; /* ro */
|
||||
const char *path; /* ro */
|
||||
ev_statdata prev; /* ro */
|
||||
ev_statdata attr; /* ro */
|
||||
|
||||
int wd; /* wd for inotify, fd for kqueue */
|
||||
} ev_stat;
|
||||
#endif
|
||||
|
||||
#if EV_IDLE_ENABLE
|
||||
/* invoked when the nothing else needs to be done, keeps the process from blocking */
|
||||
/* revent EV_IDLE */
|
||||
typedef struct ev_idle
|
||||
{
|
||||
EV_WATCHER (ev_idle)
|
||||
} ev_idle;
|
||||
#endif
|
||||
|
||||
/* invoked for each run of the mainloop, just before the blocking call */
|
||||
/* you can still change events in any way you like */
|
||||
/* revent EV_PREPARE */
|
||||
typedef struct ev_prepare
|
||||
{
|
||||
EV_WATCHER (ev_prepare)
|
||||
} ev_prepare;
|
||||
|
||||
/* invoked for each run of the mainloop, just after the blocking call */
|
||||
/* revent EV_CHECK */
|
||||
typedef struct ev_check
|
||||
{
|
||||
EV_WATCHER (ev_check)
|
||||
} ev_check;
|
||||
|
||||
#if EV_FORK_ENABLE
|
||||
/* the callback gets invoked before check in the child process when a fork was detected */
|
||||
/* revent EV_FORK */
|
||||
typedef struct ev_fork
|
||||
{
|
||||
EV_WATCHER (ev_fork)
|
||||
} ev_fork;
|
||||
#endif
|
||||
|
||||
#if EV_CLEANUP_ENABLE
|
||||
/* is invoked just before the loop gets destroyed */
|
||||
/* revent EV_CLEANUP */
|
||||
typedef struct ev_cleanup
|
||||
{
|
||||
EV_WATCHER (ev_cleanup)
|
||||
} ev_cleanup;
|
||||
#endif
|
||||
|
||||
#if EV_EMBED_ENABLE
|
||||
/* used to embed an event loop inside another */
|
||||
/* the callback gets invoked when the event loop has handled events, and can be 0 */
|
||||
typedef struct ev_embed
|
||||
{
|
||||
EV_WATCHER (ev_embed)
|
||||
|
||||
struct ev_loop *other; /* ro */
|
||||
ev_io io; /* private */
|
||||
ev_prepare prepare; /* private */
|
||||
ev_check check; /* unused */
|
||||
ev_timer timer; /* unused */
|
||||
ev_periodic periodic; /* unused */
|
||||
ev_idle idle; /* unused */
|
||||
ev_fork fork; /* private */
|
||||
#if EV_CLEANUP_ENABLE
|
||||
ev_cleanup cleanup; /* unused */
|
||||
#endif
|
||||
} ev_embed;
|
||||
#endif
|
||||
|
||||
#if EV_ASYNC_ENABLE
|
||||
/* invoked when somebody calls ev_async_send on the watcher */
|
||||
/* revent EV_ASYNC */
|
||||
typedef struct ev_async
|
||||
{
|
||||
EV_WATCHER (ev_async)
|
||||
|
||||
EV_ATOMIC_T sent; /* private */
|
||||
} ev_async;
|
||||
|
||||
# define ev_async_pending(w) (+(w)->sent)
|
||||
#endif
|
||||
|
||||
/* the presence of this union forces similar struct layout */
|
||||
union ev_any_watcher
|
||||
{
|
||||
struct ev_watcher w;
|
||||
struct ev_watcher_list wl;
|
||||
|
||||
struct ev_io io;
|
||||
struct ev_timer timer;
|
||||
struct ev_periodic periodic;
|
||||
struct ev_signal signal;
|
||||
struct ev_child child;
|
||||
#if EV_STAT_ENABLE
|
||||
struct ev_stat stat;
|
||||
#endif
|
||||
#if EV_IDLE_ENABLE
|
||||
struct ev_idle idle;
|
||||
#endif
|
||||
struct ev_prepare prepare;
|
||||
struct ev_check check;
|
||||
#if EV_FORK_ENABLE
|
||||
struct ev_fork fork;
|
||||
#endif
|
||||
#if EV_CLEANUP_ENABLE
|
||||
struct ev_cleanup cleanup;
|
||||
#endif
|
||||
#if EV_EMBED_ENABLE
|
||||
struct ev_embed embed;
|
||||
#endif
|
||||
#if EV_ASYNC_ENABLE
|
||||
struct ev_async async;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* flag bits for ev_default_loop and ev_loop_new */
|
||||
enum {
|
||||
/* the default */
|
||||
EVFLAG_AUTO = 0x00000000U, /* not quite a mask */
|
||||
/* flag bits */
|
||||
EVFLAG_NOENV = 0x01000000U, /* do NOT consult environment */
|
||||
EVFLAG_FORKCHECK = 0x02000000U, /* check for a fork in each iteration */
|
||||
/* debugging/feature disable */
|
||||
EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */
|
||||
#if EV_COMPAT3
|
||||
EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */
|
||||
#endif
|
||||
EVFLAG_SIGNALFD = 0x00200000U, /* attempt to use signalfd */
|
||||
EVFLAG_NOSIGMASK = 0x00400000U /* avoid modifying the signal mask */
|
||||
};
|
||||
|
||||
/* method bits to be ored together */
|
||||
enum {
|
||||
EVBACKEND_SELECT = 0x00000001U, /* available just about anywhere */
|
||||
EVBACKEND_POLL = 0x00000002U, /* !win, !aix, broken on osx */
|
||||
EVBACKEND_EPOLL = 0x00000004U, /* linux */
|
||||
EVBACKEND_KQUEUE = 0x00000008U, /* bsd, broken on osx */
|
||||
EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */
|
||||
EVBACKEND_PORT = 0x00000020U, /* solaris 10 */
|
||||
EVBACKEND_ALL = 0x0000003FU, /* all known backends */
|
||||
EVBACKEND_MASK = 0x0000FFFFU /* all future backends */
|
||||
};
|
||||
|
||||
#if EV_PROTOTYPES
|
||||
EV_API_DECL int ev_version_major (void) EV_THROW;
|
||||
EV_API_DECL int ev_version_minor (void) EV_THROW;
|
||||
|
||||
EV_API_DECL unsigned int ev_supported_backends (void) EV_THROW;
|
||||
EV_API_DECL unsigned int ev_recommended_backends (void) EV_THROW;
|
||||
EV_API_DECL unsigned int ev_embeddable_backends (void) EV_THROW;
|
||||
|
||||
EV_API_DECL ev_tstamp ev_time (void) EV_THROW;
|
||||
EV_API_DECL void ev_sleep (ev_tstamp delay) EV_THROW; /* sleep for a while */
|
||||
|
||||
/* Sets the allocation function to use, works like realloc.
|
||||
* It is used to allocate and free memory.
|
||||
* If it returns zero when memory needs to be allocated, the library might abort
|
||||
* or take some potentially destructive action.
|
||||
* The default is your system realloc function.
|
||||
*/
|
||||
EV_API_DECL void ev_set_allocator (void *(*cb)(void *ptr, long size) EV_THROW) EV_THROW;
|
||||
|
||||
/* set the callback function to call on a
|
||||
* retryable syscall error
|
||||
* (such as failed select, poll, epoll_wait)
|
||||
*/
|
||||
EV_API_DECL void ev_set_syserr_cb (void (*cb)(const char *msg) EV_THROW) EV_THROW;
|
||||
|
||||
#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 */
|
||||
EV_API_DECL struct ev_loop *ev_default_loop (unsigned int flags EV_CPP (= 0)) EV_THROW;
|
||||
|
||||
#ifdef EV_API_STATIC
|
||||
EV_API_DECL struct ev_loop *ev_default_loop_ptr;
|
||||
#endif
|
||||
|
||||
EV_INLINE struct ev_loop *
|
||||
ev_default_loop_uc_ (void) EV_THROW
|
||||
{
|
||||
extern struct ev_loop *ev_default_loop_ptr;
|
||||
|
||||
return ev_default_loop_ptr;
|
||||
}
|
||||
|
||||
EV_INLINE int
|
||||
ev_is_default_loop (EV_P) EV_THROW
|
||||
{
|
||||
return EV_A == EV_DEFAULT_UC;
|
||||
}
|
||||
|
||||
/* create and destroy alternative loops that don't handle signals */
|
||||
EV_API_DECL struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)) EV_THROW;
|
||||
|
||||
EV_API_DECL ev_tstamp ev_now (EV_P) EV_THROW; /* time w.r.t. timers and the eventloop, updated after each poll */
|
||||
|
||||
#else
|
||||
|
||||
EV_API_DECL int ev_default_loop (unsigned int flags EV_CPP (= 0)) EV_THROW; /* returns true when successful */
|
||||
|
||||
EV_API_DECL ev_tstamp ev_rt_now;
|
||||
|
||||
EV_INLINE ev_tstamp
|
||||
ev_now (void) EV_THROW
|
||||
{
|
||||
return ev_rt_now;
|
||||
}
|
||||
|
||||
/* looks weird, but ev_is_default_loop (EV_A) still works if this exists */
|
||||
EV_INLINE int
|
||||
ev_is_default_loop (void) EV_THROW
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* multiplicity */
|
||||
|
||||
/* destroy event loops, also works for the default loop */
|
||||
EV_API_DECL void ev_loop_destroy (EV_P);
|
||||
|
||||
/* this needs to be called after fork, to duplicate the loop */
|
||||
/* when you want to re-use it in the child */
|
||||
/* you can call it in either the parent or the child */
|
||||
/* you can actually call it at any time, anywhere :) */
|
||||
EV_API_DECL void ev_loop_fork (EV_P) EV_THROW;
|
||||
|
||||
EV_API_DECL unsigned int ev_backend (EV_P) EV_THROW; /* backend in use by loop */
|
||||
|
||||
EV_API_DECL void ev_now_update (EV_P) EV_THROW; /* update event loop time */
|
||||
|
||||
#if EV_WALK_ENABLE
|
||||
/* walk (almost) all watchers in the loop of a given type, invoking the */
|
||||
/* callback on every such watcher. The callback might stop the watcher, */
|
||||
/* but do nothing else with the loop */
|
||||
EV_API_DECL void ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_THROW;
|
||||
#endif
|
||||
|
||||
#endif /* prototypes */
|
||||
|
||||
/* ev_run flags values */
|
||||
enum {
|
||||
EVRUN_NOWAIT = 1, /* do not block/wait */
|
||||
EVRUN_ONCE = 2 /* block *once* only */
|
||||
};
|
||||
|
||||
/* ev_break how values */
|
||||
enum {
|
||||
EVBREAK_CANCEL = 0, /* undo unloop */
|
||||
EVBREAK_ONE = 1, /* unloop once */
|
||||
EVBREAK_ALL = 2 /* unloop all loops */
|
||||
};
|
||||
|
||||
#if EV_PROTOTYPES
|
||||
EV_API_DECL int ev_run (EV_P_ int flags EV_CPP (= 0));
|
||||
EV_API_DECL void ev_break (EV_P_ int how EV_CPP (= EVBREAK_ONE)) EV_THROW; /* break out of the loop */
|
||||
|
||||
/*
|
||||
* ref/unref can be used to add or remove a refcount on the mainloop. every watcher
|
||||
* keeps one reference. if you have a long-running watcher you never unregister that
|
||||
* should not keep ev_loop from running, unref() after starting, and ref() before stopping.
|
||||
*/
|
||||
EV_API_DECL void ev_ref (EV_P) EV_THROW;
|
||||
EV_API_DECL void ev_unref (EV_P) EV_THROW;
|
||||
|
||||
/*
|
||||
* convenience function, wait for a single event, without registering an event watcher
|
||||
* if timeout is < 0, do wait indefinitely
|
||||
*/
|
||||
EV_API_DECL void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_THROW;
|
||||
|
||||
# if EV_FEATURE_API
|
||||
EV_API_DECL unsigned int ev_iteration (EV_P) EV_THROW; /* number of loop iterations */
|
||||
EV_API_DECL unsigned int ev_depth (EV_P) EV_THROW; /* #ev_loop enters - #ev_loop leaves */
|
||||
EV_API_DECL void ev_verify (EV_P) EV_THROW; /* abort if loop data corrupted */
|
||||
|
||||
EV_API_DECL void ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_THROW; /* sleep at least this time, default 0 */
|
||||
EV_API_DECL void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_THROW; /* sleep at least this time, default 0 */
|
||||
|
||||
/* advanced stuff for threading etc. support, see docs */
|
||||
EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW;
|
||||
EV_API_DECL void *ev_userdata (EV_P) EV_THROW;
|
||||
typedef void (*ev_loop_callback)(EV_P);
|
||||
EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW;
|
||||
/* C++ doesn't allow the use of the ev_loop_callback typedef here, so we need to spell it out */
|
||||
EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW;
|
||||
|
||||
EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */
|
||||
EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */
|
||||
|
||||
/*
|
||||
* stop/start the timer handling.
|
||||
*/
|
||||
EV_API_DECL void ev_suspend (EV_P) EV_THROW;
|
||||
EV_API_DECL void ev_resume (EV_P) EV_THROW;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* these may evaluate ev multiple times, and the other arguments at most once */
|
||||
/* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */
|
||||
#define ev_init(ev,cb_) do { \
|
||||
((ev_watcher *)(void *)(ev))->active = \
|
||||
((ev_watcher *)(void *)(ev))->pending = 0; \
|
||||
ev_set_priority ((ev), 0); \
|
||||
ev_set_cb ((ev), cb_); \
|
||||
} while (0)
|
||||
|
||||
#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0)
|
||||
#define ev_timer_set(ev,after_,repeat_) do { ((ev_watcher_time *)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0)
|
||||
#define ev_periodic_set(ev,ofs_,ival_,rcb_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb = (rcb_); } while (0)
|
||||
#define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
|
||||
#define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0)
|
||||
#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0)
|
||||
#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */
|
||||
#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */
|
||||
#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */
|
||||
#define ev_embed_set(ev,other_) do { (ev)->other = (other_); } while (0)
|
||||
#define ev_fork_set(ev) /* nop, yes, this is a serious in-joke */
|
||||
#define ev_cleanup_set(ev) /* nop, yes, this is a serious in-joke */
|
||||
#define ev_async_set(ev) /* nop, yes, this is a serious in-joke */
|
||||
|
||||
#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)
|
||||
#define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0)
|
||||
#define ev_periodic_init(ev,cb,ofs,ival,rcb) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(ofs),(ival),(rcb)); } while (0)
|
||||
#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
|
||||
#define ev_child_init(ev,cb,pid,trace) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid),(trace)); } while (0)
|
||||
#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_stat_set ((ev),(path),(interval)); } while (0)
|
||||
#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0)
|
||||
#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
|
||||
#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
|
||||
#define ev_embed_init(ev,cb,other) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(other)); } while (0)
|
||||
#define ev_fork_init(ev,cb) do { ev_init ((ev), (cb)); ev_fork_set ((ev)); } while (0)
|
||||
#define ev_cleanup_init(ev,cb) do { ev_init ((ev), (cb)); ev_cleanup_set ((ev)); } while (0)
|
||||
#define ev_async_init(ev,cb) do { ev_init ((ev), (cb)); ev_async_set ((ev)); } while (0)
|
||||
|
||||
#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
|
||||
#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
|
||||
|
||||
#define ev_cb_(ev) (ev)->cb /* rw */
|
||||
#define ev_cb(ev) (memmove (&ev_cb_ (ev), &((ev_watcher *)(ev))->cb, sizeof (ev_cb_ (ev))), (ev)->cb)
|
||||
|
||||
#if EV_MINPRI == EV_MAXPRI
|
||||
# define ev_priority(ev) ((ev), EV_MINPRI)
|
||||
# define ev_set_priority(ev,pri) ((ev), (pri))
|
||||
#else
|
||||
# define ev_priority(ev) (+(((ev_watcher *)(void *)(ev))->priority))
|
||||
# define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri)
|
||||
#endif
|
||||
|
||||
#define ev_periodic_at(ev) (+((ev_watcher_time *)(ev))->at)
|
||||
|
||||
#ifndef ev_set_cb
|
||||
# define ev_set_cb(ev,cb_) (ev_cb_ (ev) = (cb_), memmove (&((ev_watcher *)(ev))->cb, &ev_cb_ (ev), sizeof (ev_cb_ (ev))))
|
||||
#endif
|
||||
|
||||
/* stopping (enabling, adding) a watcher does nothing if it is already running */
|
||||
/* stopping (disabling, deleting) a watcher does nothing unless it's already running */
|
||||
#if EV_PROTOTYPES
|
||||
|
||||
/* feeds an event into a watcher as if the event actually occurred */
|
||||
/* accepts any ev_watcher type */
|
||||
EV_API_DECL void ev_feed_event (EV_P_ void *w, int revents) EV_THROW;
|
||||
EV_API_DECL void ev_feed_fd_event (EV_P_ int fd, int revents) EV_THROW;
|
||||
#if EV_SIGNAL_ENABLE
|
||||
EV_API_DECL void ev_feed_signal (int signum) EV_THROW;
|
||||
EV_API_DECL void ev_feed_signal_event (EV_P_ int signum) EV_THROW;
|
||||
#endif
|
||||
EV_API_DECL void ev_invoke (EV_P_ void *w, int revents);
|
||||
EV_API_DECL int ev_clear_pending (EV_P_ void *w) EV_THROW;
|
||||
|
||||
EV_API_DECL void ev_io_start (EV_P_ ev_io *w) EV_THROW;
|
||||
EV_API_DECL void ev_io_stop (EV_P_ ev_io *w) EV_THROW;
|
||||
|
||||
EV_API_DECL void ev_timer_start (EV_P_ ev_timer *w) EV_THROW;
|
||||
EV_API_DECL void ev_timer_stop (EV_P_ ev_timer *w) EV_THROW;
|
||||
/* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */
|
||||
EV_API_DECL void ev_timer_again (EV_P_ ev_timer *w) EV_THROW;
|
||||
/* return remaining time */
|
||||
EV_API_DECL ev_tstamp ev_timer_remaining (EV_P_ ev_timer *w) EV_THROW;
|
||||
|
||||
#if EV_PERIODIC_ENABLE
|
||||
EV_API_DECL void ev_periodic_start (EV_P_ ev_periodic *w) EV_THROW;
|
||||
EV_API_DECL void ev_periodic_stop (EV_P_ ev_periodic *w) EV_THROW;
|
||||
EV_API_DECL void ev_periodic_again (EV_P_ ev_periodic *w) EV_THROW;
|
||||
#endif
|
||||
|
||||
/* only supported in the default loop */
|
||||
#if EV_SIGNAL_ENABLE
|
||||
EV_API_DECL void ev_signal_start (EV_P_ ev_signal *w) EV_THROW;
|
||||
EV_API_DECL void ev_signal_stop (EV_P_ ev_signal *w) EV_THROW;
|
||||
#endif
|
||||
|
||||
/* only supported in the default loop */
|
||||
# if EV_CHILD_ENABLE
|
||||
EV_API_DECL void ev_child_start (EV_P_ ev_child *w) EV_THROW;
|
||||
EV_API_DECL void ev_child_stop (EV_P_ ev_child *w) EV_THROW;
|
||||
# endif
|
||||
|
||||
# if EV_STAT_ENABLE
|
||||
EV_API_DECL void ev_stat_start (EV_P_ ev_stat *w) EV_THROW;
|
||||
EV_API_DECL void ev_stat_stop (EV_P_ ev_stat *w) EV_THROW;
|
||||
EV_API_DECL void ev_stat_stat (EV_P_ ev_stat *w) EV_THROW;
|
||||
# endif
|
||||
|
||||
# if EV_IDLE_ENABLE
|
||||
EV_API_DECL void ev_idle_start (EV_P_ ev_idle *w) EV_THROW;
|
||||
EV_API_DECL void ev_idle_stop (EV_P_ ev_idle *w) EV_THROW;
|
||||
# endif
|
||||
|
||||
#if EV_PREPARE_ENABLE
|
||||
EV_API_DECL void ev_prepare_start (EV_P_ ev_prepare *w) EV_THROW;
|
||||
EV_API_DECL void ev_prepare_stop (EV_P_ ev_prepare *w) EV_THROW;
|
||||
#endif
|
||||
|
||||
#if EV_CHECK_ENABLE
|
||||
EV_API_DECL void ev_check_start (EV_P_ ev_check *w) EV_THROW;
|
||||
EV_API_DECL void ev_check_stop (EV_P_ ev_check *w) EV_THROW;
|
||||
#endif
|
||||
|
||||
# if EV_FORK_ENABLE
|
||||
EV_API_DECL void ev_fork_start (EV_P_ ev_fork *w) EV_THROW;
|
||||
EV_API_DECL void ev_fork_stop (EV_P_ ev_fork *w) EV_THROW;
|
||||
# endif
|
||||
|
||||
# if EV_CLEANUP_ENABLE
|
||||
EV_API_DECL void ev_cleanup_start (EV_P_ ev_cleanup *w) EV_THROW;
|
||||
EV_API_DECL void ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_THROW;
|
||||
# endif
|
||||
|
||||
# if EV_EMBED_ENABLE
|
||||
/* only supported when loop to be embedded is in fact embeddable */
|
||||
EV_API_DECL void ev_embed_start (EV_P_ ev_embed *w) EV_THROW;
|
||||
EV_API_DECL void ev_embed_stop (EV_P_ ev_embed *w) EV_THROW;
|
||||
EV_API_DECL void ev_embed_sweep (EV_P_ ev_embed *w) EV_THROW;
|
||||
# endif
|
||||
|
||||
# if EV_ASYNC_ENABLE
|
||||
EV_API_DECL void ev_async_start (EV_P_ ev_async *w) EV_THROW;
|
||||
EV_API_DECL void ev_async_stop (EV_P_ ev_async *w) EV_THROW;
|
||||
EV_API_DECL void ev_async_send (EV_P_ ev_async *w) EV_THROW;
|
||||
# endif
|
||||
|
||||
#if EV_COMPAT3
|
||||
#define EVLOOP_NONBLOCK EVRUN_NOWAIT
|
||||
#define EVLOOP_ONESHOT EVRUN_ONCE
|
||||
#define EVUNLOOP_CANCEL EVBREAK_CANCEL
|
||||
#define EVUNLOOP_ONE EVBREAK_ONE
|
||||
#define EVUNLOOP_ALL EVBREAK_ALL
|
||||
#if EV_PROTOTYPES
|
||||
EV_INLINE void ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); }
|
||||
EV_INLINE void ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); }
|
||||
EV_INLINE void ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); }
|
||||
EV_INLINE void ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); }
|
||||
#if EV_FEATURE_API
|
||||
EV_INLINE unsigned int ev_loop_count (EV_P) { return ev_iteration (EV_A); }
|
||||
EV_INLINE unsigned int ev_loop_depth (EV_P) { return ev_depth (EV_A); }
|
||||
EV_INLINE void ev_loop_verify (EV_P) { ev_verify (EV_A); }
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
typedef struct ev_loop ev_loop;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
EV_CPP(})
|
||||
|
||||
#endif
|
||||
|
5569
libev/ev.pod
Normal file
5569
libev/ev.pod
Normal file
File diff suppressed because it is too large
Load Diff
285
libev/ev_epoll.c
Normal file
285
libev/ev_epoll.c
Normal file
@ -0,0 +1,285 @@
|
||||
/*
|
||||
* libev epoll fd activity backend
|
||||
*
|
||||
* 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-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
/*
|
||||
* general notes about epoll:
|
||||
*
|
||||
* a) epoll silently removes fds from the fd set. as nothing tells us
|
||||
* that an fd has been removed otherwise, we have to continually
|
||||
* "rearm" fds that we suspect *might* have changed (same
|
||||
* problem with kqueue, but much less costly there).
|
||||
* b) the fact that ADD != MOD creates a lot of extra syscalls due to a)
|
||||
* and seems not to have any advantage.
|
||||
* c) the inability to handle fork or file descriptors (think dup)
|
||||
* limits the applicability over poll, so this is not a generic
|
||||
* poll replacement.
|
||||
* d) epoll doesn't work the same as select with many file descriptors
|
||||
* (such as files). while not critical, no other advanced interface
|
||||
* seems to share this (rather non-unixy) limitation.
|
||||
* e) epoll claims to be embeddable, but in practise you never get
|
||||
* a ready event for the epoll fd (broken: <=2.6.26, working: >=2.6.32).
|
||||
* f) epoll_ctl returning EPERM means the fd is always ready.
|
||||
*
|
||||
* lots of "weird code" and complication handling in this file is due
|
||||
* to these design problems with epoll, as we try very hard to avoid
|
||||
* epoll_ctl syscalls for common usage patterns and handle the breakage
|
||||
* ensuing from receiving events for closed and otherwise long gone
|
||||
* file descriptors.
|
||||
*/
|
||||
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#define EV_EMASK_EPERM 0x80
|
||||
|
||||
static void
|
||||
epoll_modify (EV_P_ int fd, int oev, int nev)
|
||||
{
|
||||
struct epoll_event ev;
|
||||
unsigned char oldmask;
|
||||
|
||||
/*
|
||||
* we handle EPOLL_CTL_DEL by ignoring it here
|
||||
* on the assumption that the fd is gone anyways
|
||||
* if that is wrong, we have to handle the spurious
|
||||
* event in epoll_poll.
|
||||
* if the fd is added again, we try to ADD it, and, if that
|
||||
* fails, we assume it still has the same eventmask.
|
||||
*/
|
||||
if (!nev)
|
||||
return;
|
||||
|
||||
oldmask = anfds [fd].emask;
|
||||
anfds [fd].emask = nev;
|
||||
|
||||
/* store the generation counter in the upper 32 bits, the fd in the lower 32 bits */
|
||||
ev.data.u64 = (uint64_t)(uint32_t)fd
|
||||
| ((uint64_t)(uint32_t)++anfds [fd].egen << 32);
|
||||
ev.events = (nev & EV_READ ? EPOLLIN : 0)
|
||||
| (nev & EV_WRITE ? EPOLLOUT : 0);
|
||||
|
||||
if (expect_true (!epoll_ctl (backend_fd, oev && oldmask != nev ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd, &ev)))
|
||||
return;
|
||||
|
||||
if (expect_true (errno == ENOENT))
|
||||
{
|
||||
/* if ENOENT then the fd went away, so try to do the right thing */
|
||||
if (!nev)
|
||||
goto dec_egen;
|
||||
|
||||
if (!epoll_ctl (backend_fd, EPOLL_CTL_ADD, fd, &ev))
|
||||
return;
|
||||
}
|
||||
else if (expect_true (errno == EEXIST))
|
||||
{
|
||||
/* EEXIST means we ignored a previous DEL, but the fd is still active */
|
||||
/* if the kernel mask is the same as the new mask, we assume it hasn't changed */
|
||||
if (oldmask == nev)
|
||||
goto dec_egen;
|
||||
|
||||
if (!epoll_ctl (backend_fd, EPOLL_CTL_MOD, fd, &ev))
|
||||
return;
|
||||
}
|
||||
else if (expect_true (errno == EPERM))
|
||||
{
|
||||
/* EPERM means the fd is always ready, but epoll is too snobbish */
|
||||
/* to handle it, unlike select or poll. */
|
||||
anfds [fd].emask = EV_EMASK_EPERM;
|
||||
|
||||
/* add fd to epoll_eperms, if not already inside */
|
||||
if (!(oldmask & EV_EMASK_EPERM))
|
||||
{
|
||||
array_needsize (int, epoll_eperms, epoll_epermmax, epoll_epermcnt + 1, EMPTY2);
|
||||
epoll_eperms [epoll_epermcnt++] = fd;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fd_kill (EV_A_ fd);
|
||||
|
||||
dec_egen:
|
||||
/* we didn't successfully call epoll_ctl, so decrement the generation counter again */
|
||||
--anfds [fd].egen;
|
||||
}
|
||||
|
||||
static void
|
||||
epoll_poll (EV_P_ ev_tstamp timeout)
|
||||
{
|
||||
int i;
|
||||
int eventcnt;
|
||||
|
||||
if (expect_false (epoll_epermcnt))
|
||||
timeout = 0.;
|
||||
|
||||
/* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */
|
||||
/* the default libev max wait time, however. */
|
||||
EV_RELEASE_CB;
|
||||
eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, timeout * 1e3);
|
||||
EV_ACQUIRE_CB;
|
||||
|
||||
if (expect_false (eventcnt < 0))
|
||||
{
|
||||
if (errno != EINTR)
|
||||
ev_syserr ("(libev) epoll_wait");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < eventcnt; ++i)
|
||||
{
|
||||
struct epoll_event *ev = epoll_events + i;
|
||||
|
||||
int fd = (uint32_t)ev->data.u64; /* mask out the lower 32 bits */
|
||||
int want = anfds [fd].events;
|
||||
int got = (ev->events & (EPOLLOUT | EPOLLERR | EPOLLHUP) ? EV_WRITE : 0)
|
||||
| (ev->events & (EPOLLIN | EPOLLERR | EPOLLHUP) ? EV_READ : 0);
|
||||
|
||||
/*
|
||||
* check for spurious notification.
|
||||
* this only finds spurious notifications on egen updates
|
||||
* other spurious notifications will be found by epoll_ctl, below
|
||||
* we assume that fd is always in range, as we never shrink the anfds array
|
||||
*/
|
||||
if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >> 32)))
|
||||
{
|
||||
/* recreate kernel state */
|
||||
postfork |= 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (expect_false (got & ~want))
|
||||
{
|
||||
anfds [fd].emask = want;
|
||||
|
||||
/*
|
||||
* we received an event but are not interested in it, try mod or del
|
||||
* this often happens because we optimistically do not unregister fds
|
||||
* when we are no longer interested in them, but also when we get spurious
|
||||
* notifications for fds from another process. this is partially handled
|
||||
* above with the gencounter check (== our fd is not the event fd), and
|
||||
* partially here, when epoll_ctl returns an error (== a child has the fd
|
||||
* but we closed it).
|
||||
*/
|
||||
ev->events = (want & EV_READ ? EPOLLIN : 0)
|
||||
| (want & EV_WRITE ? EPOLLOUT : 0);
|
||||
|
||||
/* pre-2.6.9 kernels require a non-null pointer with EPOLL_CTL_DEL, */
|
||||
/* which is fortunately easy to do for us. */
|
||||
if (epoll_ctl (backend_fd, want ? EPOLL_CTL_MOD : EPOLL_CTL_DEL, fd, ev))
|
||||
{
|
||||
postfork |= 2; /* an error occurred, recreate kernel state */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fd_event (EV_A_ fd, got);
|
||||
}
|
||||
|
||||
/* if the receive array was full, increase its size */
|
||||
if (expect_false (eventcnt == epoll_eventmax))
|
||||
{
|
||||
ev_free (epoll_events);
|
||||
epoll_eventmax = array_nextsize (sizeof (struct epoll_event), epoll_eventmax, epoll_eventmax + 1);
|
||||
epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
|
||||
}
|
||||
|
||||
/* now synthesize events for all fds where epoll fails, while select works... */
|
||||
for (i = epoll_epermcnt; i--; )
|
||||
{
|
||||
int fd = epoll_eperms [i];
|
||||
unsigned char events = anfds [fd].events & (EV_READ | EV_WRITE);
|
||||
|
||||
if (anfds [fd].emask & EV_EMASK_EPERM && events)
|
||||
fd_event (EV_A_ fd, events);
|
||||
else
|
||||
{
|
||||
epoll_eperms [i] = epoll_eperms [--epoll_epermcnt];
|
||||
anfds [fd].emask = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline_size
|
||||
int
|
||||
epoll_init (EV_P_ int flags)
|
||||
{
|
||||
#ifdef EPOLL_CLOEXEC
|
||||
backend_fd = epoll_create1 (EPOLL_CLOEXEC);
|
||||
|
||||
if (backend_fd < 0 && (errno == EINVAL || errno == ENOSYS))
|
||||
#endif
|
||||
backend_fd = epoll_create (256);
|
||||
|
||||
if (backend_fd < 0)
|
||||
return 0;
|
||||
|
||||
fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
backend_mintime = 1e-3; /* epoll does sometimes return early, this is just to avoid the worst */
|
||||
backend_modify = epoll_modify;
|
||||
backend_poll = epoll_poll;
|
||||
|
||||
epoll_eventmax = 64; /* initial number of events receivable per poll */
|
||||
epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) * epoll_eventmax);
|
||||
|
||||
return EVBACKEND_EPOLL;
|
||||
}
|
||||
|
||||
inline_size
|
||||
void
|
||||
epoll_destroy (EV_P)
|
||||
{
|
||||
ev_free (epoll_events);
|
||||
array_free (epoll_eperm, EMPTY);
|
||||
}
|
||||
|
||||
inline_size
|
||||
void
|
||||
epoll_fork (EV_P)
|
||||
{
|
||||
close (backend_fd);
|
||||
|
||||
while ((backend_fd = epoll_create (256)) < 0)
|
||||
ev_syserr ("(libev) epoll_create");
|
||||
|
||||
fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
fd_rearm_all (EV_A);
|
||||
}
|
||||
|
218
libev/ev_kqueue.c
Normal file
218
libev/ev_kqueue.c
Normal file
@ -0,0 +1,218 @@
|
||||
/*
|
||||
* libev kqueue backend
|
||||
*
|
||||
* Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/event.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
inline_speed
|
||||
void
|
||||
kqueue_change (EV_P_ int fd, int filter, int flags, int fflags)
|
||||
{
|
||||
++kqueue_changecnt;
|
||||
array_needsize (struct kevent, kqueue_changes, kqueue_changemax, kqueue_changecnt, EMPTY2);
|
||||
|
||||
EV_SET (&kqueue_changes [kqueue_changecnt - 1], fd, filter, flags, fflags, 0, 0);
|
||||
}
|
||||
|
||||
/* OS X at least needs this */
|
||||
#ifndef EV_ENABLE
|
||||
# define EV_ENABLE 0
|
||||
#endif
|
||||
#ifndef NOTE_EOF
|
||||
# define NOTE_EOF 0
|
||||
#endif
|
||||
|
||||
static void
|
||||
kqueue_modify (EV_P_ int fd, int oev, int nev)
|
||||
{
|
||||
if (oev != nev)
|
||||
{
|
||||
if (oev & EV_READ)
|
||||
kqueue_change (EV_A_ fd, EVFILT_READ , EV_DELETE, 0);
|
||||
|
||||
if (oev & EV_WRITE)
|
||||
kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_DELETE, 0);
|
||||
}
|
||||
|
||||
/* to detect close/reopen reliably, we have to re-add */
|
||||
/* event requests even when oev == nev */
|
||||
|
||||
if (nev & EV_READ)
|
||||
kqueue_change (EV_A_ fd, EVFILT_READ , EV_ADD | EV_ENABLE, NOTE_EOF);
|
||||
|
||||
if (nev & EV_WRITE)
|
||||
kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_ADD | EV_ENABLE, NOTE_EOF);
|
||||
}
|
||||
|
||||
static void
|
||||
kqueue_poll (EV_P_ ev_tstamp timeout)
|
||||
{
|
||||
int res, i;
|
||||
struct timespec ts;
|
||||
|
||||
/* need to resize so there is enough space for errors */
|
||||
if (kqueue_changecnt > kqueue_eventmax)
|
||||
{
|
||||
ev_free (kqueue_events);
|
||||
kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_changecnt);
|
||||
kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
|
||||
}
|
||||
|
||||
EV_RELEASE_CB;
|
||||
EV_TS_SET (ts, timeout);
|
||||
res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts);
|
||||
EV_ACQUIRE_CB;
|
||||
kqueue_changecnt = 0;
|
||||
|
||||
if (expect_false (res < 0))
|
||||
{
|
||||
if (errno != EINTR)
|
||||
ev_syserr ("(libev) kevent");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < res; ++i)
|
||||
{
|
||||
int fd = kqueue_events [i].ident;
|
||||
|
||||
if (expect_false (kqueue_events [i].flags & EV_ERROR))
|
||||
{
|
||||
int err = kqueue_events [i].data;
|
||||
|
||||
/* we are only interested in errors for fds that we are interested in :) */
|
||||
if (anfds [fd].events)
|
||||
{
|
||||
if (err == ENOENT) /* resubmit changes on ENOENT */
|
||||
kqueue_modify (EV_A_ fd, 0, anfds [fd].events);
|
||||
else if (err == EBADF) /* on EBADF, we re-check the fd */
|
||||
{
|
||||
if (fd_valid (fd))
|
||||
kqueue_modify (EV_A_ fd, 0, anfds [fd].events);
|
||||
else
|
||||
fd_kill (EV_A_ fd);
|
||||
}
|
||||
else /* on all other errors, we error out on the fd */
|
||||
fd_kill (EV_A_ fd);
|
||||
}
|
||||
}
|
||||
else
|
||||
fd_event (
|
||||
EV_A_
|
||||
fd,
|
||||
kqueue_events [i].filter == EVFILT_READ ? EV_READ
|
||||
: kqueue_events [i].filter == EVFILT_WRITE ? EV_WRITE
|
||||
: 0
|
||||
);
|
||||
}
|
||||
|
||||
if (expect_false (res == kqueue_eventmax))
|
||||
{
|
||||
ev_free (kqueue_events);
|
||||
kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_eventmax + 1);
|
||||
kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
|
||||
}
|
||||
}
|
||||
|
||||
inline_size
|
||||
int
|
||||
kqueue_init (EV_P_ int flags)
|
||||
{
|
||||
/* initialize the kernel queue */
|
||||
kqueue_fd_pid = getpid ();
|
||||
if ((backend_fd = kqueue ()) < 0)
|
||||
return 0;
|
||||
|
||||
fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
|
||||
|
||||
backend_mintime = 1e-9; /* apparently, they did the right thing in freebsd */
|
||||
backend_modify = kqueue_modify;
|
||||
backend_poll = kqueue_poll;
|
||||
|
||||
kqueue_eventmax = 64; /* initial number of events receivable per poll */
|
||||
kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
|
||||
|
||||
kqueue_changes = 0;
|
||||
kqueue_changemax = 0;
|
||||
kqueue_changecnt = 0;
|
||||
|
||||
return EVBACKEND_KQUEUE;
|
||||
}
|
||||
|
||||
inline_size
|
||||
void
|
||||
kqueue_destroy (EV_P)
|
||||
{
|
||||
ev_free (kqueue_events);
|
||||
ev_free (kqueue_changes);
|
||||
}
|
||||
|
||||
inline_size
|
||||
void
|
||||
kqueue_fork (EV_P)
|
||||
{
|
||||
/* some BSD kernels don't just destroy the kqueue itself,
|
||||
* but also close the fd, which isn't documented, and
|
||||
* impossible to support properly.
|
||||
* we remember the pid of the kqueue call and only close
|
||||
* the fd if the pid is still the same.
|
||||
* this leaks fds on sane kernels, but BSD interfaces are
|
||||
* notoriously buggy and rarely get fixed.
|
||||
*/
|
||||
pid_t newpid = getpid ();
|
||||
|
||||
if (newpid == kqueue_fd_pid)
|
||||
close (backend_fd);
|
||||
|
||||
kqueue_fd_pid = newpid;
|
||||
while ((backend_fd = kqueue ()) < 0)
|
||||
ev_syserr ("(libev) kqueue");
|
||||
|
||||
fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
/* re-register interest in fds */
|
||||
fd_rearm_all (EV_A);
|
||||
}
|
||||
|
||||
/* sys/event.h defines EV_ERROR */
|
||||
#undef EV_ERROR
|
||||
|
151
libev/ev_poll.c
Normal file
151
libev/ev_poll.c
Normal file
@ -0,0 +1,151 @@
|
||||
/*
|
||||
* libev poll fd activity backend
|
||||
*
|
||||
* 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-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#include <poll.h>
|
||||
|
||||
inline_size
|
||||
void
|
||||
pollidx_init (int *base, int count)
|
||||
{
|
||||
/* consider using memset (.., -1, ...), which is practically guaranteed
|
||||
* to work on all systems implementing poll */
|
||||
while (count--)
|
||||
*base++ = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
poll_modify (EV_P_ int fd, int oev, int nev)
|
||||
{
|
||||
int idx;
|
||||
|
||||
if (oev == nev)
|
||||
return;
|
||||
|
||||
array_needsize (int, pollidxs, pollidxmax, fd + 1, pollidx_init);
|
||||
|
||||
idx = pollidxs [fd];
|
||||
|
||||
if (idx < 0) /* need to allocate a new pollfd */
|
||||
{
|
||||
pollidxs [fd] = idx = pollcnt++;
|
||||
array_needsize (struct pollfd, polls, pollmax, pollcnt, EMPTY2);
|
||||
polls [idx].fd = fd;
|
||||
}
|
||||
|
||||
assert (polls [idx].fd == fd);
|
||||
|
||||
if (nev)
|
||||
polls [idx].events =
|
||||
(nev & EV_READ ? POLLIN : 0)
|
||||
| (nev & EV_WRITE ? POLLOUT : 0);
|
||||
else /* remove pollfd */
|
||||
{
|
||||
pollidxs [fd] = -1;
|
||||
|
||||
if (expect_true (idx < --pollcnt))
|
||||
{
|
||||
polls [idx] = polls [pollcnt];
|
||||
pollidxs [polls [idx].fd] = idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
poll_poll (EV_P_ ev_tstamp timeout)
|
||||
{
|
||||
struct pollfd *p;
|
||||
int res;
|
||||
|
||||
EV_RELEASE_CB;
|
||||
res = poll (polls, pollcnt, timeout * 1e3);
|
||||
EV_ACQUIRE_CB;
|
||||
|
||||
if (expect_false (res < 0))
|
||||
{
|
||||
if (errno == EBADF)
|
||||
fd_ebadf (EV_A);
|
||||
else if (errno == ENOMEM && !syserr_cb)
|
||||
fd_enomem (EV_A);
|
||||
else if (errno != EINTR)
|
||||
ev_syserr ("(libev) poll");
|
||||
}
|
||||
else
|
||||
for (p = polls; res; ++p)
|
||||
{
|
||||
assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
|
||||
|
||||
if (expect_false (p->revents)) /* this expect is debatable */
|
||||
{
|
||||
--res;
|
||||
|
||||
if (expect_false (p->revents & POLLNVAL))
|
||||
fd_kill (EV_A_ p->fd);
|
||||
else
|
||||
fd_event (
|
||||
EV_A_
|
||||
p->fd,
|
||||
(p->revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0)
|
||||
| (p->revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline_size
|
||||
int
|
||||
poll_init (EV_P_ int flags)
|
||||
{
|
||||
backend_mintime = 1e-3;
|
||||
backend_modify = poll_modify;
|
||||
backend_poll = poll_poll;
|
||||
|
||||
pollidxs = 0; pollidxmax = 0;
|
||||
polls = 0; pollmax = 0; pollcnt = 0;
|
||||
|
||||
return EVBACKEND_POLL;
|
||||
}
|
||||
|
||||
inline_size
|
||||
void
|
||||
poll_destroy (EV_P)
|
||||
{
|
||||
ev_free (pollidxs);
|
||||
ev_free (polls);
|
||||
}
|
||||
|
189
libev/ev_port.c
Normal file
189
libev/ev_port.c
Normal file
@ -0,0 +1,189 @@
|
||||
/*
|
||||
* libev solaris event port backend
|
||||
*
|
||||
* 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-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
/* useful reading:
|
||||
*
|
||||
* http://bugs.opensolaris.org/view_bug.do?bug_id=6268715 (random results)
|
||||
* http://bugs.opensolaris.org/view_bug.do?bug_id=6455223 (just totally broken)
|
||||
* http://bugs.opensolaris.org/view_bug.do?bug_id=6873782 (manpage ETIME)
|
||||
* http://bugs.opensolaris.org/view_bug.do?bug_id=6874410 (implementation ETIME)
|
||||
* http://www.mail-archive.com/networking-discuss@opensolaris.org/msg11898.html ETIME vs. nget
|
||||
* http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/event_port.c (libc)
|
||||
* http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/fs/portfs/port.c#1325 (kernel)
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <poll.h>
|
||||
#include <port.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
inline_speed
|
||||
void
|
||||
port_associate_and_check (EV_P_ int fd, int ev)
|
||||
{
|
||||
if (0 >
|
||||
port_associate (
|
||||
backend_fd, PORT_SOURCE_FD, fd,
|
||||
(ev & EV_READ ? POLLIN : 0)
|
||||
| (ev & EV_WRITE ? POLLOUT : 0),
|
||||
0
|
||||
)
|
||||
)
|
||||
{
|
||||
if (errno == EBADFD)
|
||||
fd_kill (EV_A_ fd);
|
||||
else
|
||||
ev_syserr ("(libev) port_associate");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
port_modify (EV_P_ int fd, int oev, int nev)
|
||||
{
|
||||
/* we need to reassociate no matter what, as closes are
|
||||
* once more silently being discarded.
|
||||
*/
|
||||
if (!nev)
|
||||
{
|
||||
if (oev)
|
||||
port_dissociate (backend_fd, PORT_SOURCE_FD, fd);
|
||||
}
|
||||
else
|
||||
port_associate_and_check (EV_A_ fd, nev);
|
||||
}
|
||||
|
||||
static void
|
||||
port_poll (EV_P_ ev_tstamp timeout)
|
||||
{
|
||||
int res, i;
|
||||
struct timespec ts;
|
||||
uint_t nget = 1;
|
||||
|
||||
/* we initialise this to something we will skip in the loop, as */
|
||||
/* port_getn can return with nget unchanged, but no indication */
|
||||
/* whether it was the original value or has been updated :/ */
|
||||
port_events [0].portev_source = 0;
|
||||
|
||||
EV_RELEASE_CB;
|
||||
EV_TS_SET (ts, timeout);
|
||||
res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts);
|
||||
EV_ACQUIRE_CB;
|
||||
|
||||
/* port_getn may or may not set nget on error */
|
||||
/* so we rely on port_events [0].portev_source not being updated */
|
||||
if (res == -1 && errno != ETIME && errno != EINTR)
|
||||
ev_syserr ("(libev) port_getn (see http://bugs.opensolaris.org/view_bug.do?bug_id=6268715, try LIBEV_FLAGS=3 env variable)");
|
||||
|
||||
for (i = 0; i < nget; ++i)
|
||||
{
|
||||
if (port_events [i].portev_source == PORT_SOURCE_FD)
|
||||
{
|
||||
int fd = port_events [i].portev_object;
|
||||
|
||||
fd_event (
|
||||
EV_A_
|
||||
fd,
|
||||
(port_events [i].portev_events & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0)
|
||||
| (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0)
|
||||
);
|
||||
|
||||
fd_change (EV_A_ fd, EV__IOFDSET);
|
||||
}
|
||||
}
|
||||
|
||||
if (expect_false (nget == port_eventmax))
|
||||
{
|
||||
ev_free (port_events);
|
||||
port_eventmax = array_nextsize (sizeof (port_event_t), port_eventmax, port_eventmax + 1);
|
||||
port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax);
|
||||
}
|
||||
}
|
||||
|
||||
inline_size
|
||||
int
|
||||
port_init (EV_P_ int flags)
|
||||
{
|
||||
/* Initialize the kernel queue */
|
||||
if ((backend_fd = port_create ()) < 0)
|
||||
return 0;
|
||||
|
||||
assert (("libev: PORT_SOURCE_FD must not be zero", PORT_SOURCE_FD));
|
||||
|
||||
fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
|
||||
|
||||
/* if my reading of the opensolaris kernel sources are correct, then
|
||||
* opensolaris does something very stupid: it checks if the time has already
|
||||
* elapsed and doesn't round up if that is the case,m otherwise it DOES round
|
||||
* up. Since we can't know what the case is, we need to guess by using a
|
||||
* "large enough" timeout. Normally, 1e-9 would be correct.
|
||||
*/
|
||||
backend_mintime = 1e-3; /* needed to compensate for port_getn returning early */
|
||||
backend_modify = port_modify;
|
||||
backend_poll = port_poll;
|
||||
|
||||
port_eventmax = 64; /* initial number of events receivable per poll */
|
||||
port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax);
|
||||
|
||||
return EVBACKEND_PORT;
|
||||
}
|
||||
|
||||
inline_size
|
||||
void
|
||||
port_destroy (EV_P)
|
||||
{
|
||||
ev_free (port_events);
|
||||
}
|
||||
|
||||
inline_size
|
||||
void
|
||||
port_fork (EV_P)
|
||||
{
|
||||
close (backend_fd);
|
||||
|
||||
while ((backend_fd = port_create ()) < 0)
|
||||
ev_syserr ("(libev) port");
|
||||
|
||||
fcntl (backend_fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
/* re-register interest in fds */
|
||||
fd_rearm_all (EV_A);
|
||||
}
|
||||
|
316
libev/ev_select.c
Normal file
316
libev/ev_select.c
Normal file
@ -0,0 +1,316 @@
|
||||
/*
|
||||
* libev select fd activity backend
|
||||
*
|
||||
* 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-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
/* for unix systems */
|
||||
# include <inttypes.h>
|
||||
# ifndef __hpux
|
||||
/* for REAL unix systems */
|
||||
# include <sys/select.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef EV_SELECT_USE_FD_SET
|
||||
# ifdef NFDBITS
|
||||
# define EV_SELECT_USE_FD_SET 0
|
||||
# else
|
||||
# define EV_SELECT_USE_FD_SET 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if EV_SELECT_IS_WINSOCKET
|
||||
# undef EV_SELECT_USE_FD_SET
|
||||
# define EV_SELECT_USE_FD_SET 1
|
||||
# undef NFDBITS
|
||||
# define NFDBITS 0
|
||||
#endif
|
||||
|
||||
#if !EV_SELECT_USE_FD_SET
|
||||
# define NFDBYTES (NFDBITS / 8)
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static void
|
||||
select_modify (EV_P_ int fd, int oev, int nev)
|
||||
{
|
||||
if (oev == nev)
|
||||
return;
|
||||
|
||||
{
|
||||
#if EV_SELECT_USE_FD_SET
|
||||
|
||||
#if EV_SELECT_IS_WINSOCKET
|
||||
SOCKET handle = anfds [fd].handle;
|
||||
#else
|
||||
int handle = fd;
|
||||
#endif
|
||||
|
||||
assert (("libev: fd >= FD_SETSIZE passed to fd_set-based select backend", fd < FD_SETSIZE));
|
||||
|
||||
/* FD_SET is broken on windows (it adds the fd to a set twice or more,
|
||||
* which eventually leads to overflows). Need to call it only on changes.
|
||||
*/
|
||||
#if EV_SELECT_IS_WINSOCKET
|
||||
if ((oev ^ nev) & EV_READ)
|
||||
#endif
|
||||
if (nev & EV_READ)
|
||||
FD_SET (handle, (fd_set *)vec_ri);
|
||||
else
|
||||
FD_CLR (handle, (fd_set *)vec_ri);
|
||||
|
||||
#if EV_SELECT_IS_WINSOCKET
|
||||
if ((oev ^ nev) & EV_WRITE)
|
||||
#endif
|
||||
if (nev & EV_WRITE)
|
||||
FD_SET (handle, (fd_set *)vec_wi);
|
||||
else
|
||||
FD_CLR (handle, (fd_set *)vec_wi);
|
||||
|
||||
#else
|
||||
|
||||
int word = fd / NFDBITS;
|
||||
fd_mask mask = 1UL << (fd % NFDBITS);
|
||||
|
||||
if (expect_false (vec_max <= word))
|
||||
{
|
||||
int new_max = word + 1;
|
||||
|
||||
vec_ri = ev_realloc (vec_ri, new_max * NFDBYTES);
|
||||
vec_ro = ev_realloc (vec_ro, new_max * NFDBYTES); /* could free/malloc */
|
||||
vec_wi = ev_realloc (vec_wi, new_max * NFDBYTES);
|
||||
vec_wo = ev_realloc (vec_wo, new_max * NFDBYTES); /* could free/malloc */
|
||||
#ifdef _WIN32
|
||||
vec_eo = ev_realloc (vec_eo, new_max * NFDBYTES); /* could free/malloc */
|
||||
#endif
|
||||
|
||||
for (; vec_max < new_max; ++vec_max)
|
||||
((fd_mask *)vec_ri) [vec_max] =
|
||||
((fd_mask *)vec_wi) [vec_max] = 0;
|
||||
}
|
||||
|
||||
((fd_mask *)vec_ri) [word] |= mask;
|
||||
if (!(nev & EV_READ))
|
||||
((fd_mask *)vec_ri) [word] &= ~mask;
|
||||
|
||||
((fd_mask *)vec_wi) [word] |= mask;
|
||||
if (!(nev & EV_WRITE))
|
||||
((fd_mask *)vec_wi) [word] &= ~mask;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
select_poll (EV_P_ ev_tstamp timeout)
|
||||
{
|
||||
struct timeval tv;
|
||||
int res;
|
||||
int fd_setsize;
|
||||
|
||||
EV_RELEASE_CB;
|
||||
EV_TV_SET (tv, timeout);
|
||||
|
||||
#if EV_SELECT_USE_FD_SET
|
||||
fd_setsize = sizeof (fd_set);
|
||||
#else
|
||||
fd_setsize = vec_max * NFDBYTES;
|
||||
#endif
|
||||
|
||||
memcpy (vec_ro, vec_ri, fd_setsize);
|
||||
memcpy (vec_wo, vec_wi, fd_setsize);
|
||||
|
||||
#ifdef _WIN32
|
||||
/* pass in the write set as except set.
|
||||
* the idea behind this is to work around a windows bug that causes
|
||||
* errors to be reported as an exception and not by setting
|
||||
* the writable bit. this is so uncontrollably lame.
|
||||
*/
|
||||
memcpy (vec_eo, vec_wi, fd_setsize);
|
||||
res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, (fd_set *)vec_eo, &tv);
|
||||
#elif EV_SELECT_USE_FD_SET
|
||||
fd_setsize = anfdmax < FD_SETSIZE ? anfdmax : FD_SETSIZE;
|
||||
res = select (fd_setsize, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv);
|
||||
#else
|
||||
res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv);
|
||||
#endif
|
||||
EV_ACQUIRE_CB;
|
||||
|
||||
if (expect_false (res < 0))
|
||||
{
|
||||
#if EV_SELECT_IS_WINSOCKET
|
||||
errno = WSAGetLastError ();
|
||||
#endif
|
||||
#ifdef WSABASEERR
|
||||
/* on windows, select returns incompatible error codes, fix this */
|
||||
if (errno >= WSABASEERR && errno < WSABASEERR + 1000)
|
||||
if (errno == WSAENOTSOCK)
|
||||
errno = EBADF;
|
||||
else
|
||||
errno -= WSABASEERR;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* select on windows erroneously returns EINVAL when no fd sets have been
|
||||
* provided (this is documented). what microsoft doesn't tell you that this bug
|
||||
* exists even when the fd sets _are_ provided, so we have to check for this bug
|
||||
* here and emulate by sleeping manually.
|
||||
* we also get EINVAL when the timeout is invalid, but we ignore this case here
|
||||
* and assume that EINVAL always means: you have to wait manually.
|
||||
*/
|
||||
if (errno == EINVAL)
|
||||
{
|
||||
if (timeout)
|
||||
{
|
||||
unsigned long ms = timeout * 1e3;
|
||||
Sleep (ms ? ms : 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (errno == EBADF)
|
||||
fd_ebadf (EV_A);
|
||||
else if (errno == ENOMEM && !syserr_cb)
|
||||
fd_enomem (EV_A);
|
||||
else if (errno != EINTR)
|
||||
ev_syserr ("(libev) select");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#if EV_SELECT_USE_FD_SET
|
||||
|
||||
{
|
||||
int fd;
|
||||
|
||||
for (fd = 0; fd < anfdmax; ++fd)
|
||||
if (anfds [fd].events)
|
||||
{
|
||||
int events = 0;
|
||||
#if EV_SELECT_IS_WINSOCKET
|
||||
SOCKET handle = anfds [fd].handle;
|
||||
#else
|
||||
int handle = fd;
|
||||
#endif
|
||||
|
||||
if (FD_ISSET (handle, (fd_set *)vec_ro)) events |= EV_READ;
|
||||
if (FD_ISSET (handle, (fd_set *)vec_wo)) events |= EV_WRITE;
|
||||
#ifdef _WIN32
|
||||
if (FD_ISSET (handle, (fd_set *)vec_eo)) events |= EV_WRITE;
|
||||
#endif
|
||||
|
||||
if (expect_true (events))
|
||||
fd_event (EV_A_ fd, events);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
{
|
||||
int word, bit;
|
||||
for (word = vec_max; word--; )
|
||||
{
|
||||
fd_mask word_r = ((fd_mask *)vec_ro) [word];
|
||||
fd_mask word_w = ((fd_mask *)vec_wo) [word];
|
||||
#ifdef _WIN32
|
||||
word_w |= ((fd_mask *)vec_eo) [word];
|
||||
#endif
|
||||
|
||||
if (word_r || word_w)
|
||||
for (bit = NFDBITS; bit--; )
|
||||
{
|
||||
fd_mask mask = 1UL << bit;
|
||||
int events = 0;
|
||||
|
||||
events |= word_r & mask ? EV_READ : 0;
|
||||
events |= word_w & mask ? EV_WRITE : 0;
|
||||
|
||||
if (expect_true (events))
|
||||
fd_event (EV_A_ word * NFDBITS + bit, events);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline_size
|
||||
int
|
||||
select_init (EV_P_ int flags)
|
||||
{
|
||||
backend_mintime = 1e-6;
|
||||
backend_modify = select_modify;
|
||||
backend_poll = select_poll;
|
||||
|
||||
#if EV_SELECT_USE_FD_SET
|
||||
vec_ri = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_ri);
|
||||
vec_ro = ev_malloc (sizeof (fd_set));
|
||||
vec_wi = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_wi);
|
||||
vec_wo = ev_malloc (sizeof (fd_set));
|
||||
#ifdef _WIN32
|
||||
vec_eo = ev_malloc (sizeof (fd_set));
|
||||
#endif
|
||||
#else
|
||||
vec_max = 0;
|
||||
vec_ri = 0;
|
||||
vec_ro = 0;
|
||||
vec_wi = 0;
|
||||
vec_wo = 0;
|
||||
#ifdef _WIN32
|
||||
vec_eo = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return EVBACKEND_SELECT;
|
||||
}
|
||||
|
||||
inline_size
|
||||
void
|
||||
select_destroy (EV_P)
|
||||
{
|
||||
ev_free (vec_ri);
|
||||
ev_free (vec_ro);
|
||||
ev_free (vec_wi);
|
||||
ev_free (vec_wo);
|
||||
#ifdef _WIN32
|
||||
ev_free (vec_eo);
|
||||
#endif
|
||||
}
|
||||
|
204
libev/ev_vars.h
Normal file
204
libev/ev_vars.h
Normal file
@ -0,0 +1,204 @@
|
||||
/*
|
||||
* loop member variable declarations
|
||||
*
|
||||
* Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#define VARx(type,name) VAR(name, type name)
|
||||
|
||||
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)
|
||||
|
||||
VARx(int, backend)
|
||||
VARx(int, activecnt) /* total number of active events ("refcount") */
|
||||
VARx(EV_ATOMIC_T, loop_done) /* signal by ev_break */
|
||||
|
||||
VARx(int, backend_fd)
|
||||
VARx(ev_tstamp, backend_mintime) /* assumed typical timer resolution */
|
||||
VAR (backend_modify, void (*backend_modify)(EV_P_ int fd, int oev, int nev))
|
||||
VAR (backend_poll , void (*backend_poll)(EV_P_ ev_tstamp timeout))
|
||||
|
||||
VARx(ANFD *, anfds)
|
||||
VARx(int, anfdmax)
|
||||
|
||||
VAR (evpipe, int evpipe [2])
|
||||
VARx(ev_io, pipe_w)
|
||||
VARx(EV_ATOMIC_T, pipe_write_wanted)
|
||||
VARx(EV_ATOMIC_T, pipe_write_skipped)
|
||||
|
||||
#if !defined(_WIN32) || EV_GENWRAP
|
||||
VARx(pid_t, curpid)
|
||||
#endif
|
||||
|
||||
VARx(char, postfork) /* true if we need to recreate kernel state after fork */
|
||||
|
||||
#if EV_USE_SELECT || EV_GENWRAP
|
||||
VARx(void *, vec_ri)
|
||||
VARx(void *, vec_ro)
|
||||
VARx(void *, vec_wi)
|
||||
VARx(void *, vec_wo)
|
||||
#if defined(_WIN32) || EV_GENWRAP
|
||||
VARx(void *, vec_eo)
|
||||
#endif
|
||||
VARx(int, vec_max)
|
||||
#endif
|
||||
|
||||
#if EV_USE_POLL || EV_GENWRAP
|
||||
VARx(struct pollfd *, polls)
|
||||
VARx(int, pollmax)
|
||||
VARx(int, pollcnt)
|
||||
VARx(int *, pollidxs) /* maps fds into structure indices */
|
||||
VARx(int, pollidxmax)
|
||||
#endif
|
||||
|
||||
#if EV_USE_EPOLL || EV_GENWRAP
|
||||
VARx(struct epoll_event *, epoll_events)
|
||||
VARx(int, epoll_eventmax)
|
||||
VARx(int *, epoll_eperms)
|
||||
VARx(int, epoll_epermcnt)
|
||||
VARx(int, epoll_epermmax)
|
||||
#endif
|
||||
|
||||
#if EV_USE_KQUEUE || EV_GENWRAP
|
||||
VARx(pid_t, kqueue_fd_pid)
|
||||
VARx(struct kevent *, kqueue_changes)
|
||||
VARx(int, kqueue_changemax)
|
||||
VARx(int, kqueue_changecnt)
|
||||
VARx(struct kevent *, kqueue_events)
|
||||
VARx(int, kqueue_eventmax)
|
||||
#endif
|
||||
|
||||
#if EV_USE_PORT || EV_GENWRAP
|
||||
VARx(struct port_event *, port_events)
|
||||
VARx(int, port_eventmax)
|
||||
#endif
|
||||
|
||||
#if EV_USE_IOCP || EV_GENWRAP
|
||||
VARx(HANDLE, iocp)
|
||||
#endif
|
||||
|
||||
VARx(int *, fdchanges)
|
||||
VARx(int, fdchangemax)
|
||||
VARx(int, fdchangecnt)
|
||||
|
||||
VARx(ANHE *, timers)
|
||||
VARx(int, timermax)
|
||||
VARx(int, timercnt)
|
||||
|
||||
#if EV_PERIODIC_ENABLE || EV_GENWRAP
|
||||
VARx(ANHE *, periodics)
|
||||
VARx(int, periodicmax)
|
||||
VARx(int, periodiccnt)
|
||||
#endif
|
||||
|
||||
#if EV_IDLE_ENABLE || EV_GENWRAP
|
||||
VAR (idles, ev_idle **idles [NUMPRI])
|
||||
VAR (idlemax, int idlemax [NUMPRI])
|
||||
VAR (idlecnt, int idlecnt [NUMPRI])
|
||||
#endif
|
||||
VARx(int, idleall) /* total number */
|
||||
|
||||
VARx(struct ev_prepare **, prepares)
|
||||
VARx(int, preparemax)
|
||||
VARx(int, preparecnt)
|
||||
|
||||
VARx(struct ev_check **, checks)
|
||||
VARx(int, checkmax)
|
||||
VARx(int, checkcnt)
|
||||
|
||||
#if EV_FORK_ENABLE || EV_GENWRAP
|
||||
VARx(struct ev_fork **, forks)
|
||||
VARx(int, forkmax)
|
||||
VARx(int, forkcnt)
|
||||
#endif
|
||||
|
||||
#if EV_CLEANUP_ENABLE || EV_GENWRAP
|
||||
VARx(struct ev_cleanup **, cleanups)
|
||||
VARx(int, cleanupmax)
|
||||
VARx(int, cleanupcnt)
|
||||
#endif
|
||||
|
||||
#if EV_ASYNC_ENABLE || EV_GENWRAP
|
||||
VARx(EV_ATOMIC_T, async_pending)
|
||||
VARx(struct ev_async **, asyncs)
|
||||
VARx(int, asyncmax)
|
||||
VARx(int, asynccnt)
|
||||
#endif
|
||||
|
||||
#if EV_USE_INOTIFY || EV_GENWRAP
|
||||
VARx(int, fs_fd)
|
||||
VARx(ev_io, fs_w)
|
||||
VARx(char, fs_2625) /* whether we are running in linux 2.6.25 or newer */
|
||||
VAR (fs_hash, ANFS fs_hash [EV_INOTIFY_HASHSIZE])
|
||||
#endif
|
||||
|
||||
VARx(EV_ATOMIC_T, sig_pending)
|
||||
#if EV_USE_SIGNALFD || EV_GENWRAP
|
||||
VARx(int, sigfd)
|
||||
VARx(ev_io, sigfd_w)
|
||||
VARx(sigset_t, sigfd_set)
|
||||
#endif
|
||||
|
||||
VARx(unsigned int, origflags) /* original loop flags */
|
||||
|
||||
#if EV_FEATURE_API || EV_GENWRAP
|
||||
VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */
|
||||
VARx(unsigned int, loop_depth) /* #ev_run enters - #ev_run leaves */
|
||||
|
||||
VARx(void *, userdata)
|
||||
/* C++ doesn't support the ev_loop_callback typedef here. stinks. */
|
||||
VAR (release_cb, void (*release_cb)(EV_P) EV_THROW)
|
||||
VAR (acquire_cb, void (*acquire_cb)(EV_P) EV_THROW)
|
||||
VAR (invoke_cb , ev_loop_callback invoke_cb)
|
||||
#endif
|
||||
|
||||
#undef VARx
|
||||
|
162
libev/ev_win32.c
Normal file
162
libev/ev_win32.c
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* libev win32 compatibility cruft (_not_ a backend)
|
||||
*
|
||||
* Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* note: the comment below could not be substantiated, but what would I care */
|
||||
/* MSDN says this is required to handle SIGFPE */
|
||||
/* my wild guess would be that using something floating-pointy is required */
|
||||
/* for the crt to do something about it */
|
||||
volatile double SIGFPE_REQ = 0.0f;
|
||||
|
||||
static SOCKET
|
||||
ev_tcp_socket (void)
|
||||
{
|
||||
#if EV_USE_WSASOCKET
|
||||
return WSASocket (AF_INET, SOCK_STREAM, 0, 0, 0, 0);
|
||||
#else
|
||||
return socket (AF_INET, SOCK_STREAM, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* oh, the humanity! */
|
||||
static int
|
||||
ev_pipe (int filedes [2])
|
||||
{
|
||||
struct sockaddr_in addr = { 0 };
|
||||
int addr_size = sizeof (addr);
|
||||
struct sockaddr_in adr2;
|
||||
int adr2_size = sizeof (adr2);
|
||||
SOCKET listener;
|
||||
SOCKET sock [2] = { -1, -1 };
|
||||
|
||||
if ((listener = ev_tcp_socket ()) == INVALID_SOCKET)
|
||||
return -1;
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
||||
addr.sin_port = 0;
|
||||
|
||||
if (bind (listener, (struct sockaddr *)&addr, addr_size))
|
||||
goto fail;
|
||||
|
||||
if (getsockname (listener, (struct sockaddr *)&addr, &addr_size))
|
||||
goto fail;
|
||||
|
||||
if (listen (listener, 1))
|
||||
goto fail;
|
||||
|
||||
if ((sock [0] = ev_tcp_socket ()) == INVALID_SOCKET)
|
||||
goto fail;
|
||||
|
||||
if (connect (sock [0], (struct sockaddr *)&addr, addr_size))
|
||||
goto fail;
|
||||
|
||||
/* TODO: returns INVALID_SOCKET on winsock accept, not < 0. fix it */
|
||||
/* when convenient, probably by just removing error checking altogether? */
|
||||
if ((sock [1] = accept (listener, 0, 0)) < 0)
|
||||
goto fail;
|
||||
|
||||
/* windows vista returns fantasy port numbers for sockets:
|
||||
* example for two interconnected tcp sockets:
|
||||
*
|
||||
* (Socket::unpack_sockaddr_in getsockname $sock0)[0] == 53364
|
||||
* (Socket::unpack_sockaddr_in getpeername $sock0)[0] == 53363
|
||||
* (Socket::unpack_sockaddr_in getsockname $sock1)[0] == 53363
|
||||
* (Socket::unpack_sockaddr_in getpeername $sock1)[0] == 53365
|
||||
*
|
||||
* wow! tridirectional sockets!
|
||||
*
|
||||
* this way of checking ports seems to work:
|
||||
*/
|
||||
if (getpeername (sock [0], (struct sockaddr *)&addr, &addr_size))
|
||||
goto fail;
|
||||
|
||||
if (getsockname (sock [1], (struct sockaddr *)&adr2, &adr2_size))
|
||||
goto fail;
|
||||
|
||||
errno = WSAEINVAL;
|
||||
if (addr_size != adr2_size
|
||||
|| addr.sin_addr.s_addr != adr2.sin_addr.s_addr /* just to be sure, I mean, it's windows */
|
||||
|| addr.sin_port != adr2.sin_port)
|
||||
goto fail;
|
||||
|
||||
closesocket (listener);
|
||||
|
||||
#if EV_SELECT_IS_WINSOCKET
|
||||
filedes [0] = EV_WIN32_HANDLE_TO_FD (sock [0]);
|
||||
filedes [1] = EV_WIN32_HANDLE_TO_FD (sock [1]);
|
||||
#else
|
||||
/* when select isn't winsocket, we also expect socket, connect, accept etc.
|
||||
* to work on fds */
|
||||
filedes [0] = sock [0];
|
||||
filedes [1] = sock [1];
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
closesocket (listener);
|
||||
|
||||
if (sock [0] != INVALID_SOCKET) closesocket (sock [0]);
|
||||
if (sock [1] != INVALID_SOCKET) closesocket (sock [1]);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#undef pipe
|
||||
#define pipe(filedes) ev_pipe (filedes)
|
||||
|
||||
#define EV_HAVE_EV_TIME 1
|
||||
ev_tstamp
|
||||
ev_time (void)
|
||||
{
|
||||
FILETIME ft;
|
||||
ULARGE_INTEGER ui;
|
||||
|
||||
GetSystemTimeAsFileTime (&ft);
|
||||
ui.u.LowPart = ft.dwLowDateTime;
|
||||
ui.u.HighPart = ft.dwHighDateTime;
|
||||
|
||||
/* msvc cannot convert ulonglong to double... yes, it is that sucky */
|
||||
return (LONGLONG)(ui.QuadPart - 116444736000000000) * 1e-7;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
200
libev/ev_wrap.h
Normal file
200
libev/ev_wrap.h
Normal file
@ -0,0 +1,200 @@
|
||||
/* DO NOT EDIT, automatically generated by update_ev_wrap */
|
||||
#ifndef EV_WRAP_H
|
||||
#define EV_WRAP_H
|
||||
#define acquire_cb ((loop)->acquire_cb)
|
||||
#define activecnt ((loop)->activecnt)
|
||||
#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 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 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_skipped ((loop)->pipe_write_skipped)
|
||||
#define pipe_write_wanted ((loop)->pipe_write_wanted)
|
||||
#define pollcnt ((loop)->pollcnt)
|
||||
#define pollidxmax ((loop)->pollidxmax)
|
||||
#define pollidxs ((loop)->pollidxs)
|
||||
#define pollmax ((loop)->pollmax)
|
||||
#define polls ((loop)->polls)
|
||||
#define port_eventmax ((loop)->port_eventmax)
|
||||
#define port_events ((loop)->port_events)
|
||||
#define postfork ((loop)->postfork)
|
||||
#define preparecnt ((loop)->preparecnt)
|
||||
#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_set ((loop)->sigfd_set)
|
||||
#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 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 acquire_cb
|
||||
#undef activecnt
|
||||
#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 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 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_skipped
|
||||
#undef pipe_write_wanted
|
||||
#undef pollcnt
|
||||
#undef pollidxmax
|
||||
#undef pollidxs
|
||||
#undef pollmax
|
||||
#undef polls
|
||||
#undef port_eventmax
|
||||
#undef port_events
|
||||
#undef postfork
|
||||
#undef preparecnt
|
||||
#undef preparemax
|
||||
#undef prepares
|
||||
#undef release_cb
|
||||
#undef rfeedcnt
|
||||
#undef rfeedmax
|
||||
#undef rfeeds
|
||||
#undef rtmn_diff
|
||||
#undef sig_pending
|
||||
#undef sigfd
|
||||
#undef sigfd_set
|
||||
#undef sigfd_w
|
||||
#undef timeout_blocktime
|
||||
#undef timercnt
|
||||
#undef timermax
|
||||
#undef timers
|
||||
#undef userdata
|
||||
#undef vec_eo
|
||||
#undef vec_max
|
||||
#undef vec_ri
|
||||
#undef vec_ro
|
||||
#undef vec_wi
|
||||
#undef vec_wo
|
||||
#endif
|
425
libev/event.c
Normal file
425
libev/event.c
Normal file
@ -0,0 +1,425 @@
|
||||
/*
|
||||
* libevent compatibility layer
|
||||
*
|
||||
* Copyright (c) 2007,2008,2009,2010,2012 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef EV_EVENT_H
|
||||
# include EV_EVENT_H
|
||||
#else
|
||||
# include "event.h"
|
||||
#endif
|
||||
|
||||
#if EV_MULTIPLICITY
|
||||
# define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base
|
||||
# define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base
|
||||
#else
|
||||
# define dLOOPev
|
||||
# define dLOOPbase
|
||||
#endif
|
||||
|
||||
/* never accessed, will always be cast from/to ev_loop */
|
||||
struct event_base
|
||||
{
|
||||
int dummy;
|
||||
};
|
||||
|
||||
static struct event_base *ev_x_cur;
|
||||
|
||||
static ev_tstamp
|
||||
ev_tv_get (struct timeval *tv)
|
||||
{
|
||||
if (tv)
|
||||
{
|
||||
ev_tstamp after = tv->tv_sec + tv->tv_usec * 1e-6;
|
||||
return after ? after : 1e-6;
|
||||
}
|
||||
else
|
||||
return -1.;
|
||||
}
|
||||
|
||||
#define EVENT_STRINGIFY(s) # s
|
||||
#define EVENT_VERSION(a,b) EVENT_STRINGIFY (a) "." EVENT_STRINGIFY (b)
|
||||
|
||||
const char *
|
||||
event_get_version (void)
|
||||
{
|
||||
/* returns ABI, not API or library, version */
|
||||
return EVENT_VERSION (EV_VERSION_MAJOR, EV_VERSION_MINOR);
|
||||
}
|
||||
|
||||
const char *
|
||||
event_get_method (void)
|
||||
{
|
||||
return "libev";
|
||||
}
|
||||
|
||||
void *event_init (void)
|
||||
{
|
||||
#if EV_MULTIPLICITY
|
||||
if (ev_x_cur)
|
||||
ev_x_cur = (struct event_base *)ev_loop_new (EVFLAG_AUTO);
|
||||
else
|
||||
ev_x_cur = (struct event_base *)ev_default_loop (EVFLAG_AUTO);
|
||||
#else
|
||||
assert (("libev: multiple event bases not supported when not compiled with EV_MULTIPLICITY", !ev_x_cur));
|
||||
|
||||
ev_x_cur = (struct event_base *)(long)ev_default_loop (EVFLAG_AUTO);
|
||||
#endif
|
||||
|
||||
return ev_x_cur;
|
||||
}
|
||||
|
||||
const char *
|
||||
event_base_get_method (const struct event_base *base)
|
||||
{
|
||||
return "libev";
|
||||
}
|
||||
|
||||
struct event_base *
|
||||
event_base_new (void)
|
||||
{
|
||||
#if EV_MULTIPLICITY
|
||||
return (struct event_base *)ev_loop_new (EVFLAG_AUTO);
|
||||
#else
|
||||
assert (("libev: multiple event bases not supported when not compiled with EV_MULTIPLICITY"));
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void event_base_free (struct event_base *base)
|
||||
{
|
||||
dLOOPbase;
|
||||
|
||||
#if EV_MULTIPLICITY
|
||||
if (!ev_is_default_loop (loop))
|
||||
ev_loop_destroy (loop);
|
||||
#endif
|
||||
}
|
||||
|
||||
int event_dispatch (void)
|
||||
{
|
||||
return event_base_dispatch (ev_x_cur);
|
||||
}
|
||||
|
||||
#ifdef EV_STANDALONE
|
||||
void event_set_log_callback (event_log_cb cb)
|
||||
{
|
||||
/* nop */
|
||||
}
|
||||
#endif
|
||||
|
||||
int event_loop (int flags)
|
||||
{
|
||||
return event_base_loop (ev_x_cur, flags);
|
||||
}
|
||||
|
||||
int event_loopexit (struct timeval *tv)
|
||||
{
|
||||
return event_base_loopexit (ev_x_cur, tv);
|
||||
}
|
||||
|
||||
event_callback_fn event_get_callback
|
||||
(const struct event *ev)
|
||||
{
|
||||
return ev->ev_callback;
|
||||
}
|
||||
|
||||
static void
|
||||
ev_x_cb (struct event *ev, int revents)
|
||||
{
|
||||
revents &= EV_READ | EV_WRITE | EV_TIMER | EV_SIGNAL;
|
||||
|
||||
ev->ev_res = revents;
|
||||
ev->ev_callback (ev->ev_fd, (short)revents, ev->ev_arg);
|
||||
}
|
||||
|
||||
static void
|
||||
ev_x_cb_sig (EV_P_ struct ev_signal *w, int revents)
|
||||
{
|
||||
struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.sig));
|
||||
|
||||
if (revents & EV_ERROR)
|
||||
event_del (ev);
|
||||
|
||||
ev_x_cb (ev, revents);
|
||||
}
|
||||
|
||||
static void
|
||||
ev_x_cb_io (EV_P_ struct ev_io *w, int revents)
|
||||
{
|
||||
struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.io));
|
||||
|
||||
if ((revents & EV_ERROR) || !(ev->ev_events & EV_PERSIST))
|
||||
event_del (ev);
|
||||
|
||||
ev_x_cb (ev, revents);
|
||||
}
|
||||
|
||||
static void
|
||||
ev_x_cb_to (EV_P_ struct ev_timer *w, int revents)
|
||||
{
|
||||
struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, to));
|
||||
|
||||
event_del (ev);
|
||||
|
||||
ev_x_cb (ev, revents);
|
||||
}
|
||||
|
||||
void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg)
|
||||
{
|
||||
if (events & EV_SIGNAL)
|
||||
ev_init (&ev->iosig.sig, ev_x_cb_sig);
|
||||
else
|
||||
ev_init (&ev->iosig.io, ev_x_cb_io);
|
||||
|
||||
ev_init (&ev->to, ev_x_cb_to);
|
||||
|
||||
ev->ev_base = ev_x_cur; /* not threadsafe, but it's how libevent works */
|
||||
ev->ev_fd = fd;
|
||||
ev->ev_events = events;
|
||||
ev->ev_pri = 0;
|
||||
ev->ev_callback = cb;
|
||||
ev->ev_arg = arg;
|
||||
ev->ev_res = 0;
|
||||
ev->ev_flags = EVLIST_INIT;
|
||||
}
|
||||
|
||||
int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv)
|
||||
{
|
||||
return event_base_once (ev_x_cur, fd, events, cb, arg, tv);
|
||||
}
|
||||
|
||||
int event_add (struct event *ev, struct timeval *tv)
|
||||
{
|
||||
dLOOPev;
|
||||
|
||||
if (ev->ev_events & EV_SIGNAL)
|
||||
{
|
||||
if (!ev_is_active (&ev->iosig.sig))
|
||||
{
|
||||
ev_signal_set (&ev->iosig.sig, ev->ev_fd);
|
||||
ev_signal_start (EV_A_ &ev->iosig.sig);
|
||||
|
||||
ev->ev_flags |= EVLIST_SIGNAL;
|
||||
}
|
||||
}
|
||||
else if (ev->ev_events & (EV_READ | EV_WRITE))
|
||||
{
|
||||
if (!ev_is_active (&ev->iosig.io))
|
||||
{
|
||||
ev_io_set (&ev->iosig.io, ev->ev_fd, ev->ev_events & (EV_READ | EV_WRITE));
|
||||
ev_io_start (EV_A_ &ev->iosig.io);
|
||||
|
||||
ev->ev_flags |= EVLIST_INSERTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (tv)
|
||||
{
|
||||
ev->to.repeat = ev_tv_get (tv);
|
||||
ev_timer_again (EV_A_ &ev->to);
|
||||
ev->ev_flags |= EVLIST_TIMEOUT;
|
||||
}
|
||||
else
|
||||
{
|
||||
ev_timer_stop (EV_A_ &ev->to);
|
||||
ev->ev_flags &= ~EVLIST_TIMEOUT;
|
||||
}
|
||||
|
||||
ev->ev_flags |= EVLIST_ACTIVE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int event_del (struct event *ev)
|
||||
{
|
||||
dLOOPev;
|
||||
|
||||
if (ev->ev_events & EV_SIGNAL)
|
||||
ev_signal_stop (EV_A_ &ev->iosig.sig);
|
||||
else if (ev->ev_events & (EV_READ | EV_WRITE))
|
||||
ev_io_stop (EV_A_ &ev->iosig.io);
|
||||
|
||||
if (ev_is_active (&ev->to))
|
||||
ev_timer_stop (EV_A_ &ev->to);
|
||||
|
||||
ev->ev_flags = EVLIST_INIT;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void event_active (struct event *ev, int res, short ncalls)
|
||||
{
|
||||
dLOOPev;
|
||||
|
||||
if (res & EV_TIMEOUT)
|
||||
ev_feed_event (EV_A_ &ev->to, res & EV_TIMEOUT);
|
||||
|
||||
if (res & EV_SIGNAL)
|
||||
ev_feed_event (EV_A_ &ev->iosig.sig, res & EV_SIGNAL);
|
||||
|
||||
if (res & (EV_READ | EV_WRITE))
|
||||
ev_feed_event (EV_A_ &ev->iosig.io, res & (EV_READ | EV_WRITE));
|
||||
}
|
||||
|
||||
int event_pending (struct event *ev, short events, struct timeval *tv)
|
||||
{
|
||||
short revents = 0;
|
||||
dLOOPev;
|
||||
|
||||
if (ev->ev_events & EV_SIGNAL)
|
||||
{
|
||||
/* sig */
|
||||
if (ev_is_active (&ev->iosig.sig) || ev_is_pending (&ev->iosig.sig))
|
||||
revents |= EV_SIGNAL;
|
||||
}
|
||||
else if (ev->ev_events & (EV_READ | EV_WRITE))
|
||||
{
|
||||
/* io */
|
||||
if (ev_is_active (&ev->iosig.io) || ev_is_pending (&ev->iosig.io))
|
||||
revents |= ev->ev_events & (EV_READ | EV_WRITE);
|
||||
}
|
||||
|
||||
if (ev->ev_events & EV_TIMEOUT || ev_is_active (&ev->to) || ev_is_pending (&ev->to))
|
||||
{
|
||||
revents |= EV_TIMEOUT;
|
||||
|
||||
if (tv)
|
||||
{
|
||||
ev_tstamp at = ev_now (EV_A);
|
||||
|
||||
tv->tv_sec = (long)at;
|
||||
tv->tv_usec = (long)((at - (ev_tstamp)tv->tv_sec) * 1e6);
|
||||
}
|
||||
}
|
||||
|
||||
return events & revents;
|
||||
}
|
||||
|
||||
int event_priority_init (int npri)
|
||||
{
|
||||
return event_base_priority_init (ev_x_cur, npri);
|
||||
}
|
||||
|
||||
int event_priority_set (struct event *ev, int pri)
|
||||
{
|
||||
ev->ev_pri = pri;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int event_base_set (struct event_base *base, struct event *ev)
|
||||
{
|
||||
ev->ev_base = base;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int event_base_loop (struct event_base *base, int flags)
|
||||
{
|
||||
dLOOPbase;
|
||||
|
||||
return !ev_run (EV_A_ flags);
|
||||
}
|
||||
|
||||
int event_base_dispatch (struct event_base *base)
|
||||
{
|
||||
return event_base_loop (base, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ev_x_loopexit_cb (int revents, void *base)
|
||||
{
|
||||
dLOOPbase;
|
||||
|
||||
ev_break (EV_A_ EVBREAK_ONE);
|
||||
}
|
||||
|
||||
int event_base_loopexit (struct event_base *base, struct timeval *tv)
|
||||
{
|
||||
ev_tstamp after = ev_tv_get (tv);
|
||||
dLOOPbase;
|
||||
|
||||
ev_once (EV_A_ -1, 0, after >= 0. ? after : 0., ev_x_loopexit_cb, (void *)base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ev_x_once
|
||||
{
|
||||
int fd;
|
||||
void (*cb)(int, short, void *);
|
||||
void *arg;
|
||||
};
|
||||
|
||||
static void
|
||||
ev_x_once_cb (int revents, void *arg)
|
||||
{
|
||||
struct ev_x_once *once = (struct ev_x_once *)arg;
|
||||
|
||||
once->cb (once->fd, (short)revents, once->arg);
|
||||
free (once);
|
||||
}
|
||||
|
||||
int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv)
|
||||
{
|
||||
struct ev_x_once *once = (struct ev_x_once *)malloc (sizeof (struct ev_x_once));
|
||||
dLOOPbase;
|
||||
|
||||
if (!once)
|
||||
return -1;
|
||||
|
||||
once->fd = fd;
|
||||
once->cb = cb;
|
||||
once->arg = arg;
|
||||
|
||||
ev_once (EV_A_ fd, events & (EV_READ | EV_WRITE), ev_tv_get (tv), ev_x_once_cb, (void *)once);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int event_base_priority_init (struct event_base *base, int npri)
|
||||
{
|
||||
/*dLOOPbase;*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
177
libev/event.h
Normal file
177
libev/event.h
Normal file
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* libevent compatibility header, only core events supported
|
||||
*
|
||||
* Copyright (c) 2007,2008,2010,2012 Marc Alexander Lehmann <libev@schmorp.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modifica-
|
||||
* tion, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
||||
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
||||
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
||||
* in which case the provisions of the GPL are applicable instead of
|
||||
* the above. If you wish to allow the use of your version of this file
|
||||
* only under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the BSD license, indicate your decision
|
||||
* by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete the
|
||||
* provisions above, a recipient may use your version of this file under
|
||||
* either the BSD or the GPL.
|
||||
*/
|
||||
|
||||
#ifndef EVENT_H_
|
||||
#define EVENT_H_
|
||||
|
||||
#ifdef EV_H
|
||||
# include EV_H
|
||||
#else
|
||||
# include "ev.h"
|
||||
#endif
|
||||
|
||||
#ifndef EVLOOP_NONBLOCK
|
||||
# define EVLOOP_NONBLOCK EVRUN_NOWAIT
|
||||
#endif
|
||||
#ifndef EVLOOP_ONESHOT
|
||||
# define EVLOOP_ONESHOT EVRUN_ONCE
|
||||
#endif
|
||||
#ifndef EV_TIMEOUT
|
||||
# define EV_TIMEOUT EV_TIMER
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* we need sys/time.h for struct timeval only */
|
||||
#if !defined (WIN32) || defined (__MINGW32__)
|
||||
# include <time.h> /* mingw seems to need this, for whatever reason */
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
struct event_base;
|
||||
|
||||
#define EVLIST_TIMEOUT 0x01
|
||||
#define EVLIST_INSERTED 0x02
|
||||
#define EVLIST_SIGNAL 0x04
|
||||
#define EVLIST_ACTIVE 0x08
|
||||
#define EVLIST_INTERNAL 0x10
|
||||
#define EVLIST_INIT 0x80
|
||||
|
||||
typedef void (*event_callback_fn)(int, short, void *);
|
||||
|
||||
struct event
|
||||
{
|
||||
/* libev watchers we map onto */
|
||||
union {
|
||||
struct ev_io io;
|
||||
struct ev_signal sig;
|
||||
} iosig;
|
||||
struct ev_timer to;
|
||||
|
||||
/* compatibility slots */
|
||||
struct event_base *ev_base;
|
||||
event_callback_fn ev_callback;
|
||||
void *ev_arg;
|
||||
int ev_fd;
|
||||
int ev_pri;
|
||||
int ev_res;
|
||||
int ev_flags;
|
||||
short ev_events;
|
||||
};
|
||||
|
||||
event_callback_fn event_get_callback (const struct event *ev);
|
||||
|
||||
#define EV_READ EV_READ
|
||||
#define EV_WRITE EV_WRITE
|
||||
#define EV_PERSIST 0x10
|
||||
#define EV_ET 0x20 /* nop */
|
||||
|
||||
#define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd)
|
||||
#define EVENT_FD(ev) ((int) (ev)->ev_fd)
|
||||
|
||||
#define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
|
||||
|
||||
#define evtimer_add(ev,tv) event_add (ev, tv)
|
||||
#define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data)
|
||||
#define evtimer_del(ev) event_del (ev)
|
||||
#define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv)
|
||||
#define evtimer_initialized(ev) event_initialized (ev)
|
||||
|
||||
#define timeout_add(ev,tv) evtimer_add (ev, tv)
|
||||
#define timeout_set(ev,cb,data) evtimer_set (ev, cb, data)
|
||||
#define timeout_del(ev) evtimer_del (ev)
|
||||
#define timeout_pending(ev,tv) evtimer_pending (ev, tv)
|
||||
#define timeout_initialized(ev) evtimer_initialized (ev)
|
||||
|
||||
#define signal_add(ev,tv) event_add (ev, tv)
|
||||
#define signal_set(ev,sig,cb,data) event_set (ev, sig, EV_SIGNAL | EV_PERSIST, cb, data)
|
||||
#define signal_del(ev) event_del (ev)
|
||||
#define signal_pending(ev,tv) event_pending (ev, EV_SIGNAL, tv)
|
||||
#define signal_initialized(ev) event_initialized (ev)
|
||||
#define _EVENT_VERSION "4.24" /*TODO: compat*/
|
||||
const char *event_get_version (void);
|
||||
const char *event_get_method (void);
|
||||
|
||||
void *event_init (void);
|
||||
void event_base_free (struct event_base *base);
|
||||
|
||||
#define EVLOOP_ONCE EVLOOP_ONESHOT
|
||||
int event_loop (int);
|
||||
int event_loopexit (struct timeval *tv);
|
||||
int event_dispatch (void);
|
||||
|
||||
#define _EVENT_LOG_DEBUG 0
|
||||
#define _EVENT_LOG_MSG 1
|
||||
#define _EVENT_LOG_WARN 2
|
||||
#define _EVENT_LOG_ERR 3
|
||||
typedef void (*event_log_cb)(int severity, const char *msg);
|
||||
void event_set_log_callback(event_log_cb cb);
|
||||
|
||||
void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg);
|
||||
int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv);
|
||||
|
||||
int event_add (struct event *ev, struct timeval *tv);
|
||||
int event_del (struct event *ev);
|
||||
void event_active (struct event *ev, int res, short ncalls); /* ncalls is being ignored */
|
||||
|
||||
int event_pending (struct event *ev, short, struct timeval *tv);
|
||||
|
||||
int event_priority_init (int npri);
|
||||
int event_priority_set (struct event *ev, int pri);
|
||||
|
||||
struct event_base *event_base_new (void);
|
||||
const char *event_base_get_method (const struct event_base *);
|
||||
int event_base_set (struct event_base *base, struct event *ev);
|
||||
int event_base_loop (struct event_base *base, int);
|
||||
int event_base_loopexit (struct event_base *base, struct timeval *tv);
|
||||
int event_base_dispatch (struct event_base *base);
|
||||
int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv);
|
||||
int event_base_priority_init (struct event_base *base, int fd);
|
||||
|
||||
/* next line is different in the libevent+libev version */
|
||||
/*libevent-include*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
508
libev/install-sh
Executable file
508
libev/install-sh
Executable file
@ -0,0 +1,508 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2014-09-12.12; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
tab=' '
|
||||
nl='
|
||||
'
|
||||
IFS=" $tab$nl"
|
||||
|
||||
# Set DOITPROG to "echo" to test this script.
|
||||
|
||||
doit=${DOITPROG-}
|
||||
doit_exec=${doit:-exec}
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
is_target_a_directory=possibly
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t)
|
||||
is_target_a_directory=always
|
||||
dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) is_target_a_directory=never;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# We allow the use of options -d and -T together, by making -d
|
||||
# take the precedence; this is for compatibility with GNU install.
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
if test -n "$dst_arg"; then
|
||||
echo "$0: target directory not allowed when installing a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||
if test ! -d "$dst_arg"; then
|
||||
echo "$0: $dst_arg: Is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test "$is_target_a_directory" = never; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
dstdir=`dirname "$dst"`
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
# $RANDOM is not portable (e.g. dash); use it when possible to
|
||||
# lower collision chance
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
# As "mkdir -p" follows symlinks and we work in /tmp possibly; so
|
||||
# create the $tmpdir first (and fail if unsuccessful) to make sure
|
||||
# that nobody tries to guess the $tmpdir name.
|
||||
if (umask $mkdir_umask &&
|
||||
$mkdirprog $mkdir_mode "$tmpdir" &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
test_tmpdir="$tmpdir/a"
|
||||
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
set +f &&
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
42
libev/libev.m4
Normal file
42
libev/libev.m4
Normal file
@ -0,0 +1,42 @@
|
||||
dnl this file is part of libev, do not make local modifications
|
||||
dnl http://software.schmorp.de/pkg/libev
|
||||
|
||||
dnl libev support
|
||||
AC_CHECK_HEADERS(sys/inotify.h sys/epoll.h sys/event.h port.h poll.h sys/select.h sys/eventfd.h sys/signalfd.h)
|
||||
|
||||
AC_CHECK_FUNCS(inotify_init epoll_ctl kqueue port_create poll select eventfd signalfd)
|
||||
|
||||
AC_CHECK_FUNCS(clock_gettime, [], [
|
||||
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 <unistd.h>
|
||||
#include <sys/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, Define to 1 to use the 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)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_CHECK_FUNCS(nanosleep, [], [
|
||||
if test -z "$LIBEV_M4_AVOID_LIBRT"; then
|
||||
AC_CHECK_LIB(rt, nanosleep)
|
||||
unset ac_cv_func_nanosleep
|
||||
AC_CHECK_FUNCS(nanosleep)
|
||||
fi
|
||||
])
|
||||
|
||||
if test -z "$LIBEV_M4_AVOID_LIBM"; then
|
||||
LIBM=m
|
||||
fi
|
||||
AC_SEARCH_LIBS(floor, $LIBM, [AC_DEFINE(HAVE_FLOOR, 1, Define to 1 if the floor function is available)])
|
||||
|
9661
libev/ltmain.sh
Normal file
9661
libev/ltmain.sh
Normal file
File diff suppressed because it is too large
Load Diff
215
libev/missing
Executable file
215
libev/missing
Executable file
@ -0,0 +1,215 @@
|
||||
#! /bin/sh
|
||||
# Common wrapper for a few potentially missing GNU programs.
|
||||
|
||||
scriptversion=2013-10-28.13; # UTC
|
||||
|
||||
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
|
||||
--is-lightweight)
|
||||
# Used by our autoconf macros to check whether the available missing
|
||||
# script is modern enough.
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--run)
|
||||
# Back-compat with the calling convention used by older automake.
|
||||
shift
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
|
||||
to PROGRAM being missing or too old.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal autoconf autoheader autom4te automake makeinfo
|
||||
bison yacc flex lex help2man
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
|
||||
'g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: unknown '$1' option"
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# Run the given program, remember its exit status.
|
||||
"$@"; st=$?
|
||||
|
||||
# If it succeeded, we are done.
|
||||
test $st -eq 0 && exit 0
|
||||
|
||||
# Also exit now if we it failed (or wasn't found), and '--version' was
|
||||
# passed; such an option is passed most likely to detect whether the
|
||||
# program is present and works.
|
||||
case $2 in --version|--help) exit $st;; esac
|
||||
|
||||
# Exit code 63 means version mismatch. This often happens when the user
|
||||
# tries to use an ancient version of a tool on a file that requires a
|
||||
# minimum version.
|
||||
if test $st -eq 63; then
|
||||
msg="probably too old"
|
||||
elif test $st -eq 127; then
|
||||
# Program was missing.
|
||||
msg="missing on your system"
|
||||
else
|
||||
# Program was found and executed, but failed. Give up.
|
||||
exit $st
|
||||
fi
|
||||
|
||||
perl_URL=http://www.perl.org/
|
||||
flex_URL=http://flex.sourceforge.net/
|
||||
gnu_software_URL=http://www.gnu.org/software
|
||||
|
||||
program_details ()
|
||||
{
|
||||
case $1 in
|
||||
aclocal|automake)
|
||||
echo "The '$1' program is part of the GNU Automake package:"
|
||||
echo "<$gnu_software_URL/automake>"
|
||||
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/autoconf>"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
autoconf|autom4te|autoheader)
|
||||
echo "The '$1' program is part of the GNU Autoconf package:"
|
||||
echo "<$gnu_software_URL/autoconf/>"
|
||||
echo "It also requires GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
give_advice ()
|
||||
{
|
||||
# Normalize program name to check for.
|
||||
normalized_program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
printf '%s\n' "'$1' is $msg."
|
||||
|
||||
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
|
||||
case $normalized_program in
|
||||
autoconf*)
|
||||
echo "You should only need it if you modified 'configure.ac',"
|
||||
echo "or m4 files included by it."
|
||||
program_details 'autoconf'
|
||||
;;
|
||||
autoheader*)
|
||||
echo "You should only need it if you modified 'acconfig.h' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'autoheader'
|
||||
;;
|
||||
automake*)
|
||||
echo "You should only need it if you modified 'Makefile.am' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'automake'
|
||||
;;
|
||||
aclocal*)
|
||||
echo "You should only need it if you modified 'acinclude.m4' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'aclocal'
|
||||
;;
|
||||
autom4te*)
|
||||
echo "You might have modified some maintainer files that require"
|
||||
echo "the 'autom4te' program to be rebuilt."
|
||||
program_details 'autom4te'
|
||||
;;
|
||||
bison*|yacc*)
|
||||
echo "You should only need it if you modified a '.y' file."
|
||||
echo "You may want to install the GNU Bison package:"
|
||||
echo "<$gnu_software_URL/bison/>"
|
||||
;;
|
||||
lex*|flex*)
|
||||
echo "You should only need it if you modified a '.l' file."
|
||||
echo "You may want to install the Fast Lexical Analyzer package:"
|
||||
echo "<$flex_URL>"
|
||||
;;
|
||||
help2man*)
|
||||
echo "You should only need it if you modified a dependency" \
|
||||
"of a man page."
|
||||
echo "You may want to install the GNU Help2man package:"
|
||||
echo "<$gnu_software_URL/help2man/>"
|
||||
;;
|
||||
makeinfo*)
|
||||
echo "You should only need it if you modified a '.texi' file, or"
|
||||
echo "any other file indirectly affecting the aspect of the manual."
|
||||
echo "You might want to install the Texinfo package:"
|
||||
echo "<$gnu_software_URL/texinfo/>"
|
||||
echo "The spurious makeinfo call might also be the consequence of"
|
||||
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
|
||||
echo "want to install GNU make:"
|
||||
echo "<$gnu_software_URL/make/>"
|
||||
;;
|
||||
*)
|
||||
echo "You might have modified some files without having the proper"
|
||||
echo "tools for further handling them. Check the 'README' file, it"
|
||||
echo "often tells you about the needed prerequisites for installing"
|
||||
echo "this package. You may also peek at any GNU archive site, in"
|
||||
echo "case some other package contains this missing '$1' program."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
give_advice "$1" | sed -e '1s/^/WARNING: /' \
|
||||
-e '2,$s/^/ /' >&2
|
||||
|
||||
# Propagate the correct exit status (expected to be 127 for a program
|
||||
# not found, 63 for a program that failed due to version mismatch).
|
||||
exit $st
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
162
libev/mkinstalldirs
Executable file
162
libev/mkinstalldirs
Executable file
@ -0,0 +1,162 @@
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain.
|
||||
#
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
errstatus=0
|
||||
dirmode=
|
||||
|
||||
usage="\
|
||||
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
|
||||
|
||||
Create each directory DIR (with mode MODE, if specified), including all
|
||||
leading file name components.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>."
|
||||
|
||||
# process command line arguments
|
||||
while test $# -gt 0 ; do
|
||||
case $1 in
|
||||
-h | --help | --h*) # -h for help
|
||||
echo "$usage"
|
||||
exit $?
|
||||
;;
|
||||
-m) # -m PERM arg
|
||||
shift
|
||||
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
|
||||
dirmode=$1
|
||||
shift
|
||||
;;
|
||||
--version)
|
||||
echo "$0 $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
--) # stop option processing
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*) # unknown option
|
||||
echo "$usage" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
*) # first non-opt arg
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for file
|
||||
do
|
||||
if test -d "$file"; then
|
||||
shift
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
case $# in
|
||||
0) exit 0 ;;
|
||||
esac
|
||||
|
||||
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
|
||||
# mkdir -p a/c at the same time, both will detect that a is missing,
|
||||
# one will create a, then the other will try to create a and die with
|
||||
# a "File exists" error. This is a problem when calling mkinstalldirs
|
||||
# from a parallel make. We use --version in the probe to restrict
|
||||
# ourselves to GNU mkdir, which is thread-safe.
|
||||
case $dirmode in
|
||||
'')
|
||||
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
|
||||
echo "mkdir -p -- $*"
|
||||
exec mkdir -p -- "$@"
|
||||
else
|
||||
# On NextStep and OpenStep, the 'mkdir' command does not
|
||||
# recognize any option. It will interpret all options as
|
||||
# directories to create, and then abort because '.' already
|
||||
# exists.
|
||||
test -d ./-p && rmdir ./-p
|
||||
test -d ./--version && rmdir ./--version
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
|
||||
test ! -d ./--version; then
|
||||
echo "mkdir -m $dirmode -p -- $*"
|
||||
exec mkdir -m "$dirmode" -p -- "$@"
|
||||
else
|
||||
# Clean up after NextStep and OpenStep mkdir.
|
||||
for d in ./-m ./-p ./--version "./$dirmode";
|
||||
do
|
||||
test -d $d && rmdir $d
|
||||
done
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
for file
|
||||
do
|
||||
case $file in
|
||||
/*) pathcomp=/ ;;
|
||||
*) pathcomp= ;;
|
||||
esac
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set fnord $file
|
||||
shift
|
||||
IFS=$oIFS
|
||||
|
||||
for d
|
||||
do
|
||||
test "x$d" = x && continue
|
||||
|
||||
pathcomp=$pathcomp$d
|
||||
case $pathcomp in
|
||||
-*) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp"
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
else
|
||||
if test ! -z "$dirmode"; then
|
||||
echo "chmod $dirmode $pathcomp"
|
||||
lasterr=
|
||||
chmod "$dirmode" "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -z "$lasterr"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
@ -20,10 +20,9 @@
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) # for config.h
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
|
||||
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libev)
|
||||
INCLUDE_DIRECTORIES(${GLIB_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIRS})
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
@ -23,10 +23,9 @@ INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) # for config.h
|
||||
include_directories(${PROJECT_SOURCE_DIR}/lib)
|
||||
include_directories(${PROJECT_BINARY_DIR}/lib)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/libev)
|
||||
INCLUDE_DIRECTORIES(${GLIB_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIRS})
|
||||
|
||||
LINK_DIRECTORIES(${GLIB_LIBRARY_DIRS})
|
||||
LINK_DIRECTORIES(${LIBINTL_LIBRARY_DIRS})
|
||||
|
@ -22,11 +22,11 @@ INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) # for config.h
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/lib)
|
||||
include_directories(${PROJECT_BINARY_DIR}/lib)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/libev)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
|
||||
|
||||
INCLUDE_DIRECTORIES(${GLIB_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIRS})
|
||||
|
||||
LINK_DIRECTORIES(${GLIB_LIBRARY_DIRS})
|
||||
LINK_DIRECTORIES(${LIBINTL_LIBRARY_DIRS})
|
||||
|
@ -32,11 +32,10 @@ LINK_DIRECTORIES(${GLIB_LIBRARY_DIRS})
|
||||
INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${MYSQL_LIBRARY_DIRS})
|
||||
|
||||
INCLUDE_DIRECTORIES(${EVENT_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${EVENT_LIBRARY_DIRS})
|
||||
|
||||
LINK_DIRECTORIES(${LIBINTL_LIBRARY_DIRS})
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/libev)
|
||||
|
||||
STRING(REPLACE "." "" SHARED_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
ADD_DEFINITIONS(-DSHARED_LIBRARY_SUFFIX="${SHARED_LIBRARY_SUFFIX}")
|
||||
|
||||
@ -130,8 +129,8 @@ if(HAVE_TCMALLOC)
|
||||
${GLIB_LIBRARIES}
|
||||
${GMODULE_LIBRARIES}
|
||||
${GTHREAD_LIBRARIES}
|
||||
${EVENT_LIBRARIES}
|
||||
${MYSQL_LIBRARIES}
|
||||
ev-cetus
|
||||
tcmalloc
|
||||
mysql-chassis-timing
|
||||
mysql-chassis-glibext
|
||||
@ -156,9 +155,9 @@ if(HAVE_TCMALLOC)
|
||||
${GLIB_LIBRARIES}
|
||||
${GMODULE_LIBRARIES}
|
||||
${GTHREAD_LIBRARIES}
|
||||
${EVENT_LIBRARIES}
|
||||
${MYSQL_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
ev-cetus
|
||||
)
|
||||
|
||||
else(HAVE_TCMALLOC)
|
||||
@ -179,8 +178,8 @@ else(HAVE_TCMALLOC)
|
||||
TARGET_LINK_LIBRARIES(mysql-chassis
|
||||
${GLIB_LIBRARIES}
|
||||
${GMODULE_LIBRARIES}
|
||||
${GTHREAD_LIBRARIES}
|
||||
${EVENT_LIBRARIES}
|
||||
${GTHREAD_LIBRARIES}
|
||||
ev-cetus
|
||||
${MYSQL_LIBRARIES}
|
||||
mysql-chassis-timing
|
||||
mysql-chassis-glibext
|
||||
@ -203,7 +202,7 @@ else(HAVE_TCMALLOC)
|
||||
${GLIB_LIBRARIES}
|
||||
${GMODULE_LIBRARIES}
|
||||
${GTHREAD_LIBRARIES}
|
||||
${EVENT_LIBRARIES}
|
||||
ev-cetus
|
||||
${MYSQL_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
)
|
||||
|
@ -63,16 +63,16 @@ chassis_check_version(const char *lib_version, const char *hdr_version)
|
||||
int hdr_maj, hdr_min, hdr_pat;
|
||||
int scanned_fields;
|
||||
|
||||
if (3 != (scanned_fields = sscanf(lib_version, "%d.%d.%d%*s", &lib_maj, &lib_min, &lib_pat))) {
|
||||
if (2 != (scanned_fields = sscanf(lib_version, "%d.%d", &lib_maj, &lib_min))) {
|
||||
g_critical("%s: library version %s failed to parse: %d", G_STRLOC, lib_version, scanned_fields);
|
||||
return -1;
|
||||
}
|
||||
if (3 != (scanned_fields = sscanf(hdr_version, "%d.%d.%d%*s", &hdr_maj, &hdr_min, &hdr_pat))) {
|
||||
if (2 != (scanned_fields = sscanf(hdr_version, "%d.%d", &hdr_maj, &hdr_min))) {
|
||||
g_critical("%s: header version %s failed to parse: %d", G_STRLOC, hdr_version, scanned_fields);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lib_maj == hdr_maj && lib_min == hdr_min && lib_pat >= hdr_pat) {
|
||||
if (lib_maj == hdr_maj && lib_min == hdr_min) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user