From 6183953301149ee7b348aaee3ced0226a7be15ff Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sun, 14 Sep 1997 02:40:46 +0000 Subject: Extend to use poll backend. If memory serves correctly, most of this was adapted from NetBSD.. However, there are some differences in the tty system that are big enough to cause their code to not fit comfortably. Obtained from: NetBSD (I think) --- sys/kern/tty.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'sys/kern/tty.c') diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 0c023ea24a57..0be04a0c3553 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)tty.c 8.8 (Berkeley) 1/21/94 - * $Id: tty.c,v 1.94 1997/03/24 12:02:59 bde Exp $ + * $Id: tty.c,v 1.95 1997/09/02 20:05:54 bde Exp $ */ /*- @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include @@ -1031,35 +1032,34 @@ ttioctl(tp, cmd, data, flag) } int -ttyselect(tp, rw, p) +ttypoll(tp, events, p) struct tty *tp; - int rw; + int events; struct proc *p; { int s; + int revents = 0; - if (tp == NULL) - return (ENXIO); + if (tp == NULL) /* XXX used to return ENXIO, but that means true! */ + return ((events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)) + | POLLHUP); s = spltty(); - switch (rw) { - case FREAD: + if (events & (POLLIN | POLLRDNORM)) if (ttnread(tp) > 0 || ISSET(tp->t_state, TS_ZOMBIE)) - goto win; - selrecord(p, &tp->t_rsel); - break; - case FWRITE: + revents |= events & (POLLIN | POLLRDNORM); + else + selrecord(p, &tp->t_rsel); + + if (events & (POLLOUT | POLLWRNORM)) if ((tp->t_outq.c_cc <= tp->t_lowat && ISSET(tp->t_state, TS_CONNECTED)) - || ISSET(tp->t_state, TS_ZOMBIE)) { -win: splx(s); - return (1); - } - selrecord(p, &tp->t_wsel); - break; - } + || ISSET(tp->t_state, TS_ZOMBIE)) + revents |= events & (POLLOUT | POLLWRNORM); + else + selrecord(p, &tp->t_wsel); splx(s); - return (0); + return (revents); } /* @@ -1067,12 +1067,12 @@ win: splx(s); * cdevsw. It relies on a proper xxxdevtotty routine. */ int -ttselect(dev, rw, p) +ttpoll(dev, events, p) dev_t dev; - int rw; + int events; struct proc *p; { - return ttyselect((*cdevsw[major(dev)]->d_devtotty)(dev), rw, p); + return ttypoll((*cdevsw[major(dev)]->d_devtotty)(dev), events, p); } /* -- cgit v1.2.3