summaryrefslogtreecommitdiff
path: root/src/iopause.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/iopause.c')
-rw-r--r--src/iopause.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/iopause.c b/src/iopause.c
index 94a6fea..0baad2a 100644
--- a/src/iopause.c
+++ b/src/iopause.c
@@ -1,7 +1,9 @@
+#include "iopause.h"
+
#include <poll.h>
-#include "taia.h"
+
#include "select.h"
-#include "iopause.h"
+#include "taia.h"
/**
@file iopause.c
@@ -11,29 +13,28 @@
@return > 0 if successful
*/
-int iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *stamp)
+int iopause(iopause_fd *x, unsigned int len, struct taia *deadline, struct taia *stamp)
{
struct taia t;
int millisecs;
double d;
int i, r;
- if (taia_less(deadline,stamp))
+ if (taia_less(deadline, stamp))
millisecs = 0;
else {
t = *stamp;
- taia_sub(&t,deadline,&t);
+ taia_sub(&t, deadline, &t);
d = taia_approx(&t);
if (d > 1000.0) d = 1000.0;
millisecs = d * 1000.0 + 20.0;
if (millisecs < 0) millisecs = 20.0;
}
- for (i = 0; i < len; ++i)
- x[i].revents = 0;
+ for (i = 0; i < len; ++i) x[i].revents = 0;
#ifdef IOPAUSE_POLL
- r = poll(x,len,millisecs);
+ r = poll(x, len, millisecs);
/* XXX: some kernels apparently need x[0] even if len is 0 */
/* XXX: how to handle EAGAIN? are kernels really this dumb? */
@@ -56,14 +57,14 @@ int iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *st
if (fd >= 8 * sizeof(fd_set)) continue; /*XXX*/
if (fd >= nfds) nfds = fd + 1;
- if (x[i].events & IOPAUSE_READ) FD_SET(fd,&rfds);
- if (x[i].events & IOPAUSE_WRITE) FD_SET(fd,&wfds);
+ if (x[i].events & IOPAUSE_READ) FD_SET(fd, &rfds);
+ if (x[i].events & IOPAUSE_WRITE) FD_SET(fd, &wfds);
}
tv.tv_sec = millisecs / 1000;
tv.tv_usec = 1000 * (millisecs % 1000);
- r = select(nfds,&rfds,&wfds,(fd_set *) 0,&tv);
+ r = select(nfds, &rfds, &wfds, (fd_set *)0, &tv);
if (r <= 0) return r;
/* XXX: for EBADF, could seek out and destroy the bad descriptor */
@@ -74,9 +75,9 @@ int iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *st
if (fd >= 8 * sizeof(fd_set)) continue; /*XXX*/
if (x[i].events & IOPAUSE_READ)
- if (FD_ISSET(fd,&rfds)) x[i].revents |= IOPAUSE_READ;
+ if (FD_ISSET(fd, &rfds)) x[i].revents |= IOPAUSE_READ;
if (x[i].events & IOPAUSE_WRITE)
- if (FD_ISSET(fd,&wfds)) x[i].revents |= IOPAUSE_WRITE;
+ if (FD_ISSET(fd, &wfds)) x[i].revents |= IOPAUSE_WRITE;
}
#endif