aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1997-09-14 02:40:46 +0000
committerPeter Wemm <peter@FreeBSD.org>1997-09-14 02:40:46 +0000
commit6183953301149ee7b348aaee3ced0226a7be15ff (patch)
treee5b96bade8a9e66e71cbcc28d015d8f40a3f84ec /sys/kern/tty.c
parent6b8e64f55f0d326e23c4820c7f1e4caa5282b001 (diff)
downloadsrc-6183953301149ee7b348aaee3ced0226a7be15ff.tar.gz
src-6183953301149ee7b348aaee3ced0226a7be15ff.zip
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)
Notes
Notes: svn path=/head/; revision=29354
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c44
1 files changed, 22 insertions, 22 deletions
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 <sys/fcntl.h>
#include <sys/conf.h>
#include <sys/dkstat.h>
+#include <sys/poll.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/signalvar.h>
@@ -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);
}
/*