diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2014-09-18 18:55:44 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2014-09-18 18:55:44 +0000 |
commit | 3534b428629be185e096be99e3bd5fdfe32d5544 (patch) | |
tree | 210ef3198ed66bc7f7b7bf6a85e4579f455e5a36 /src/libstddjb/iopause_ppoll.c | |
download | skalibs-3534b428629be185e096be99e3bd5fdfe32d5544.tar.xz |
initial commit with rc for skalibs-2.0.0.0
Diffstat (limited to 'src/libstddjb/iopause_ppoll.c')
-rw-r--r-- | src/libstddjb/iopause_ppoll.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/libstddjb/iopause_ppoll.c b/src/libstddjb/iopause_ppoll.c new file mode 100644 index 0000000..b181d0a --- /dev/null +++ b/src/libstddjb/iopause_ppoll.c @@ -0,0 +1,44 @@ +/* ISC license. */ + +#include <skalibs/sysdeps.h> + +#ifdef SKALIBS_HASPPOLL + +#define _GNU_SOURCE +#include <errno.h> +#include <time.h> +#include <poll.h> +#include <skalibs/tai.h> +#include <skalibs/iopause.h> + +int iopause_ppoll (iopause_fd *x, unsigned int len, tain_t const *deadline, tain_t const *stamp) +{ + struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 } ; + if (deadline && tain_less(stamp, deadline)) + { + tain_t delta ; + tain_sub(&delta, deadline, stamp) ; + if (!timespec_from_tain_relative(&ts, &delta)) + { + if (errno != ERANGE) return -1 ; + else deadline = 0 ; + } + } + return ppoll(x, len, deadline ? &ts : 0, 0) ; +} + +#else + +#include <errno.h> +#include <skalibs/iopause.h> + +int iopause_ppoll (iopause_fd *x, unsigned int len, tain_t const *deadline, tain_t const *stamp) +{ + (void)x ; + (void)len ; + (void)deadline ; + (void)stamp ; + return (errno = ENOSYS, -1) ; +} + +#endif |