--- libev/ev.3 2018/12/21 07:03:02 1.109 +++ libev/ev.3 2019/06/20 22:44:59 1.110 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) +.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -46,7 +46,7 @@ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" -.\" If the F register is turned on, we'll generate index entries on stderr for +.\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. @@ -56,12 +56,12 @@ .. .nr rF 0 .if \n(.g .if rF .nr rF 1 -.if (\n(rF:(\n(.g==0)) \{ -. if \nF \{ +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{ +. if !\nF==2 \{\ . nr % 0 . nr F 2 . \} @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "LIBEV 3" -.TH LIBEV 3 "2018-12-21" "libev-4.25" "libev - high performance full featured event loop" +.TH LIBEV 3 "2019-06-20" "libev-4.25" "libev - high performance full featured event loop" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -394,13 +394,35 @@ free some memory if it cannot allocate memory, to use a special allocator, or even to sleep a while and retry until some memory is available. .Sp +Example: The following is the \f(CW\*(C`realloc\*(C'\fR function that libev itself uses +which should work with \f(CW\*(C`realloc\*(C'\fR and \f(CW\*(C`free\*(C'\fR functions of all kinds and +is probably a good basis for your own implementation. +.Sp +.Vb 5 +\& static void * +\& ev_realloc_emul (void *ptr, long size) EV_NOEXCEPT +\& { +\& if (size) +\& return realloc (ptr, size); +\& +\& free (ptr); +\& return 0; +\& } +.Ve +.Sp Example: Replace the libev allocator with one that waits a bit and then -retries (example requires a standards-compliant \f(CW\*(C`realloc\*(C'\fR). +retries. .Sp -.Vb 6 +.Vb 8 \& static void * \& persistent_realloc (void *ptr, size_t size) \& { +\& if (!size) +\& { +\& free (ptr); +\& return 0; +\& } +\& \& for (;;) \& { \& void *newptr = realloc (ptr, size); @@ -587,7 +609,7 @@ .ie n .IP """EVBACKEND_SELECT"" (value 1, portable select backend)" 4 .el .IP "\f(CWEVBACKEND_SELECT\fR (value 1, portable select backend)" 4 .IX Item "EVBACKEND_SELECT (value 1, portable select backend)" -This is your standard \fIselect\fR\|(2) backend. Not \fIcompletely\fR standard, as +This is your standard \fBselect\fR\|(2) backend. Not \fIcompletely\fR standard, as libev tries to roll its own fd_set with no limits on the number of fds, but if that fails, expect a fairly low limit on the number of fds when using this backend. It doesn't scale too well (O(highest_fd)), but its @@ -606,7 +628,7 @@ .ie n .IP """EVBACKEND_POLL"" (value 2, poll backend, available everywhere except on windows)" 4 .el .IP "\f(CWEVBACKEND_POLL\fR (value 2, poll backend, available everywhere except on windows)" 4 .IX Item "EVBACKEND_POLL (value 2, poll backend, available everywhere except on windows)" -And this is your standard \fIpoll\fR\|(2) backend. It's more complicated +And this is your standard \fBpoll\fR\|(2) backend. It's more complicated than select, but handles sparse fds better and has no artificial limit on the number of fds you can use (except it will slow down considerably with a lot of inactive fds). It scales similarly to select, @@ -618,7 +640,7 @@ .ie n .IP """EVBACKEND_EPOLL"" (value 4, Linux)" 4 .el .IP "\f(CWEVBACKEND_EPOLL\fR (value 4, Linux)" 4 .IX Item "EVBACKEND_EPOLL (value 4, Linux)" -Use the linux-specific \fIepoll\fR\|(7) interface (for both pre\- and post\-2.6.9 +Use the linux-specific \fBepoll\fR\|(7) interface (for both pre\- and post\-2.6.9 kernels). .Sp For few fds, this backend is a bit little slower than poll and select, but @@ -1367,7 +1389,7 @@ Libev will usually signal a few \*(L"dummy\*(R" events together with an error, for example it might indicate that a fd is readable or writable, and if your callbacks is well-written it can just attempt the operation and cope with -the error from \fIread()\fR or \fIwrite()\fR. This will not work in multi-threaded +the error from \fBread()\fR or \fBwrite()\fR. This will not work in multi-threaded programs, though, as the fd could already be closed and reused for another thing, so beware. .SS "\s-1GENERIC WATCHER FUNCTIONS\s0" @@ -1813,13 +1835,13 @@ this is sensible behaviour, for daemons, this is usually undesirable. .PP So when you encounter spurious, unexplained daemon exits, make sure you -ignore \s-1SIGPIPE \s0(and maybe make sure you log the exit status of your daemon +ignore \s-1SIGPIPE\s0 (and maybe make sure you log the exit status of your daemon somewhere, as that would have given you a big clue). .PP -\fIThe special problem of \fIaccept()\fIing when you can't\fR +\fIThe special problem of \f(BIaccept()\fIing when you can't\fR .IX Subsection "The special problem of accept()ing when you can't" .PP -Many implementations of the \s-1POSIX \s0\f(CW\*(C`accept\*(C'\fR function (for example, +Many implementations of the \s-1POSIX\s0 \f(CW\*(C`accept\*(C'\fR function (for example, found in post\-2004 Linux) have the peculiar behaviour of not removing a connection from the pending queue in all error cases. .PP @@ -2436,7 +2458,7 @@ reschedule callback will be called with the watcher as first, and the current time as second argument. .Sp -\&\s-1NOTE: \s0\fIThis callback \s-1MUST NOT\s0 stop or destroy any periodic watcher, ever, +\&\s-1NOTE:\s0 \fIThis callback \s-1MUST NOT\s0 stop or destroy any periodic watcher, ever, or make \s-1ANY\s0 other event loop modifications whatsoever, unless explicitly allowed by documentation here\fR. .Sp @@ -2460,7 +2482,7 @@ will usually be called just before the callback will be triggered, but might be called at other times, too. .Sp -\&\s-1NOTE: \s0\fIThis callback must always return a time that is higher than or +\&\s-1NOTE:\s0 \fIThis callback must always return a time that is higher than or equal to the passed \f(CI\*(C`now\*(C'\fI value\fR. .Sp This can be used to create very complex timers, such as a timer that @@ -2615,7 +2637,7 @@ catch fork calls done by libraries (such as the libc) as well. .PP In current versions of libev, the signal will not be blocked indefinitely -unless you use the \f(CW\*(C`signalfd\*(C'\fR \s-1API \s0(\f(CW\*(C`EV_SIGNALFD\*(C'\fR). While this reduces +unless you use the \f(CW\*(C`signalfd\*(C'\fR \s-1API\s0 (\f(CW\*(C`EV_SIGNALFD\*(C'\fR). While this reduces the window of opportunity for problems, it will not go away, as libev \&\fIhas\fR to modify the signal mask, at least temporarily. .PP @@ -4520,7 +4542,7 @@ .PP This will automatically include \fIev.h\fR, too, and should be done in a single C source file only to provide the function implementations. To use -it, do the same for \fIev.h\fR in all files wishing to use this \s-1API \s0(best +it, do the same for \fIev.h\fR in all files wishing to use this \s-1API\s0 (best done by writing a wrapper around \fIev.h\fR that you can include instead and where you can put other configuration options): .PP @@ -4603,7 +4625,7 @@ to a compiled library. All other symbols change the \s-1ABI,\s0 which means all users of libev and the libev code itself must be compiled with compatible settings. -.IP "\s-1EV_COMPAT3 \s0(h)" 4 +.IP "\s-1EV_COMPAT3\s0 (h)" 4 .IX Item "EV_COMPAT3 (h)" Backwards compatibility is a major concern for libev. This is why this release of libev comes with wrappers for the functions and symbols that @@ -4618,7 +4640,7 @@ In some future version, the default for \f(CW\*(C`EV_COMPAT3\*(C'\fR will become \f(CW0\fR, and in some even more future version the compatibility code will be removed completely. -.IP "\s-1EV_STANDALONE \s0(h)" 4 +.IP "\s-1EV_STANDALONE\s0 (h)" 4 .IX Item "EV_STANDALONE (h)" Must always be \f(CW1\fR if you do not use autoconf configuration, which keeps libev from including \fIconfig.h\fR, and it also defines dummy @@ -4786,21 +4808,21 @@ .Sp In the absence of this define, libev will use \f(CW\*(C`sig_atomic_t volatile\*(C'\fR (from \fIsignal.h\fR), which is usually good enough on most platforms. -.IP "\s-1EV_H \s0(h)" 4 +.IP "\s-1EV_H\s0 (h)" 4 .IX Item "EV_H (h)" The name of the \fIev.h\fR header file used to include it. The default if undefined is \f(CW"ev.h"\fR in \fIevent.h\fR, \fIev.c\fR and \fIev++.h\fR. This can be used to virtually rename the \fIev.h\fR header file in case of conflicts. -.IP "\s-1EV_CONFIG_H \s0(h)" 4 +.IP "\s-1EV_CONFIG_H\s0 (h)" 4 .IX Item "EV_CONFIG_H (h)" If \f(CW\*(C`EV_STANDALONE\*(C'\fR isn't \f(CW1\fR, this variable can be used to override \&\fIev.c\fR's idea of where to find the \fIconfig.h\fR file, similarly to \&\f(CW\*(C`EV_H\*(C'\fR, above. -.IP "\s-1EV_EVENT_H \s0(h)" 4 +.IP "\s-1EV_EVENT_H\s0 (h)" 4 .IX Item "EV_EVENT_H (h)" Similarly to \f(CW\*(C`EV_H\*(C'\fR, this macro can be used to override \fIevent.c\fR's idea of how the \fIevent.h\fR header can be found, the default is \f(CW"event.h"\fR. -.IP "\s-1EV_PROTOTYPES \s0(h)" 4 +.IP "\s-1EV_PROTOTYPES\s0 (h)" 4 .IX Item "EV_PROTOTYPES (h)" If defined to be \f(CW0\fR, then \fIev.h\fR will not define any function prototypes, but still define all the structs and other symbols. This is @@ -5019,10 +5041,10 @@ \& SV *self; /* contains this struct */ \e \& SV *cb_sv, *fh /* note no trailing ";" */ .Ve -.IP "\s-1EV_CB_DECLARE \s0(type)" 4 +.IP "\s-1EV_CB_DECLARE\s0 (type)" 4 .IX Item "EV_CB_DECLARE (type)" .PD 0 -.IP "\s-1EV_CB_INVOKE \s0(watcher, revents)" 4 +.IP "\s-1EV_CB_INVOKE\s0 (watcher, revents)" 4 .IX Item "EV_CB_INVOKE (watcher, revents)" .IP "ev_set_cb (ev, cb)" 4 .IX Item "ev_set_cb (ev, cb)" @@ -5035,7 +5057,7 @@ method calls instead of plain function calls in \*(C+. .SS "\s-1EXPORTED API SYMBOLS\s0" .IX Subsection "EXPORTED API SYMBOLS" -If you need to re-export the \s-1API \s0(e.g. via a \s-1DLL\s0) and you need a list of +If you need to re-export the \s-1API\s0 (e.g. via a \s-1DLL\s0) and you need a list of exported symbols, you can use the provided \fISymbol.*\fR files which list all public symbols, one per line: .PP @@ -5277,7 +5299,7 @@ .IX Subsection "select is buggy" .PP All that's left is \f(CW\*(C`select\*(C'\fR, and of course Apple found a way to fuck this -one up as well: On \s-1OS/X, \s0\f(CW\*(C`select\*(C'\fR actively limits the number of file +one up as well: On \s-1OS/X,\s0 \f(CW\*(C`select\*(C'\fR actively limits the number of file descriptors you can pass in to 1024 \- your program suddenly crashes when you use more. .PP