X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/secnet/blobdiff_plain/cf5f1149caccf65c700e73fc0e9212c916df3610..ee697dd98d0f9aca6b9df7ffb32d3a15b4e33d6d:/secnet.h diff --git a/secnet.h b/secnet.h index 629851b..0e2e1f7 100644 --- a/secnet.h +++ b/secnet.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -200,6 +201,16 @@ typedef int beforepoll_fn(void *st, struct pollfd *fds, int *nfds_io, int *timeout_io); typedef void afterpoll_fn(void *st, struct pollfd *fds, int nfds); +/* void BEFOREPOLL_WANT_FDS(int want); + * Expects: int *nfds_io; + * Can perform non-local exit. + * Checks whether there is space for want fds. If so, sets *nfds_io. + * If not, sets *nfds_io and returns. */ +#define BEFOREPOLL_WANT_FDS(want) do{ \ + if (*nfds_io<(want)) { *nfds_io=(want); return ERANGE; } \ + *nfds_io=(want); \ + }while(0) + /* Register interest in the main loop of the program. Before a call to poll() your supplied beforepoll function will be called. After the call to poll() the supplied afterpoll function will be called.