Skip to content

Commit 819cd66

Browse files
committed
iopause: assume poll() is available
Since poll() is available on all platforms we care about, we don't need to check if it is. This gets rid of trypoll.c, the last configure-time check that required to be run on the host (messing with cross). We also get rid of trysysel.c, since select() was only used as a fallback when poll() isn't avaialble.
1 parent 006296c commit 819cd66

7 files changed

Lines changed: 0 additions & 161 deletions

File tree

configure

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -426,25 +426,6 @@ if test -n "$HASDIRENT"; then
426426
echo "CPPFLAGS += -DHASDIRENT" >> $CONFIG_MK
427427
fi
428428

429-
#
430-
# Check for sys/dirent.h.
431-
#
432-
printf "Checking for sys/select.h ... "
433-
if test -n "$HASSYSSEL"; then
434-
echo "yes (cached)."
435-
else
436-
if $XCC configure_tests/trysysel.c -o trysysel 2>/dev/null; then
437-
echo yes.
438-
HASSYSSEL=1
439-
else
440-
echo no.
441-
fi
442-
rm -f trysysel
443-
fi
444-
if test -n "$HASSYSSEL"; then
445-
echo "CPPFLAGS += -DHASSYSSEL" >> $CONFIG_MK
446-
fi
447-
448429
#
449430
# Check for one argument reboot().
450431
#
@@ -464,26 +445,6 @@ if test -n "$HASONEARGREBOOT"; then
464445
echo "CPPFLAGS += -DHASONEARGREBOOT" >> $CONFIG_MK
465446
fi
466447

467-
#
468-
# Check for suitable poll().
469-
# XXX: Very bad, this should not need to run. Do we have alternatives?
470-
#
471-
printf "Checking for suitable poll() ... "
472-
if test -n "$HASGOODPOLL"; then
473-
echo "yes (cached)."
474-
else
475-
if $XCC configure_tests/trypoll.c -o trypoll 2>/dev/null && ./trypoll; then
476-
echo yes.
477-
HASGOODPOLL=1
478-
else
479-
echo no.
480-
fi
481-
rm -f trypoll
482-
fi
483-
if test -n "$HASGOODPOLL"; then
484-
echo "CPPFLAGS += -DHASGOODPOLL" >> $CONFIG_MK
485-
fi
486-
487448
# If --enable-static enabled, build static binaries.
488449
if [ "$BUILD_STATIC" = "yes" ]; then
489450
echo "BUILD_STATIC = -static" >>$CONFIG_MK

configure_tests/trypoll.c

Lines changed: 0 additions & 21 deletions
This file was deleted.

configure_tests/trysysel.c

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/iopause.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* Public domain. */
22

33
#include "taia.h"
4-
#include "select.h"
54
#include "iopause.h"
65

76
void iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *stamp)
@@ -24,55 +23,9 @@ void iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *s
2423
for (i = 0;i < len;++i)
2524
x[i].revents = 0;
2625

27-
#ifdef IOPAUSE_POLL
28-
2926
poll(x,len,millisecs);
3027
/* XXX: some kernels apparently need x[0] even if len is 0 */
3128
/* XXX: how to handle EAGAIN? are kernels really this dumb? */
3229
/* XXX: how to handle EINVAL? when exactly can this happen? */
3330

34-
#else
35-
{
36-
37-
struct timeval tv;
38-
fd_set rfds;
39-
fd_set wfds;
40-
int nfds;
41-
int fd;
42-
43-
FD_ZERO(&rfds);
44-
FD_ZERO(&wfds);
45-
46-
nfds = 1;
47-
for (i = 0;i < len;++i) {
48-
fd = x[i].fd;
49-
if (fd < 0) continue;
50-
if (fd >= 8 * sizeof(fd_set)) continue; /*XXX*/
51-
52-
if (fd >= nfds) nfds = fd + 1;
53-
if (x[i].events & IOPAUSE_READ) FD_SET(fd,&rfds);
54-
if (x[i].events & IOPAUSE_WRITE) FD_SET(fd,&wfds);
55-
}
56-
57-
tv.tv_sec = millisecs / 1000;
58-
tv.tv_usec = 1000 * (millisecs % 1000);
59-
60-
if (select(nfds,&rfds,&wfds,(fd_set *) 0,&tv) <= 0)
61-
return;
62-
/* XXX: for EBADF, could seek out and destroy the bad descriptor */
63-
64-
for (i = 0;i < len;++i) {
65-
fd = x[i].fd;
66-
if (fd < 0) continue;
67-
if (fd >= 8 * sizeof(fd_set)) continue; /*XXX*/
68-
69-
if (x[i].events & IOPAUSE_READ)
70-
if (FD_ISSET(fd,&rfds)) x[i].revents |= IOPAUSE_READ;
71-
if (x[i].events & IOPAUSE_WRITE)
72-
if (FD_ISSET(fd,&wfds)) x[i].revents |= IOPAUSE_WRITE;
73-
}
74-
75-
}
76-
#endif
77-
7831
}

src/iopause.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,13 @@
33
#ifndef IOPAUSE_H
44
#define IOPAUSE_H
55

6-
#ifdef HASGOODPOLL
7-
8-
#define IOPAUSE_POLL
9-
106
#include <sys/types.h>
117
#include <poll.h>
128

139
typedef struct pollfd iopause_fd;
1410
#define IOPAUSE_READ POLLIN
1511
#define IOPAUSE_WRITE POLLOUT
1612

17-
#else
18-
19-
typedef struct {
20-
int fd;
21-
short events;
22-
short revents;
23-
} iopause_fd;
24-
25-
#define IOPAUSE_READ 1
26-
#define IOPAUSE_WRITE 4
27-
28-
#endif
29-
3013
#include "taia.h"
3114

3215
extern void iopause(iopause_fd *,unsigned int,struct taia *,struct taia *);

src/runit.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ int main (int argc, const char * const *argv, char * const *envp) {
5454
int wstat;
5555
int st;
5656
iopause_fd x;
57-
#ifndef IOPAUSE_POLL
58-
fd_set rfds;
59-
struct timeval t;
60-
#endif
6157
char ch;
6258
int ttyfd;
6359
struct stat s;
@@ -152,14 +148,7 @@ int main (int argc, const char * const *argv, char * const *envp) {
152148
sig_unblock(sig_child);
153149
sig_unblock(sig_cont);
154150
sig_unblock(sig_int);
155-
#ifdef IOPAUSE_POLL
156151
poll(&x, 1, 14000);
157-
#else
158-
t.tv_sec =14; t.tv_usec =0;
159-
FD_ZERO(&rfds);
160-
FD_SET(x.fd, &rfds);
161-
select(x.fd +1, &rfds, (fd_set*)0, (fd_set*)0, &t);
162-
#endif
163152
sig_block(sig_cont);
164153
sig_block(sig_child);
165154
sig_block(sig_int);

src/select.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)