summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-09-14 02:40:46 +0000
committerpeter <peter@FreeBSD.org>1997-09-14 02:40:46 +0000
commitfbe30e0a2cc277a18dacc18fd5a92709eba6225f (patch)
treec5f5d7bad730b55dcdaf0a8c962f1c84cd47cf9e /sys/kern/tty.c
parent28a822ce34dfd8139083885152dca89380a32229 (diff)
downloadFreeBSD-src-fbe30e0a2cc277a18dacc18fd5a92709eba6225f.zip
FreeBSD-src-fbe30e0a2cc277a18dacc18fd5a92709eba6225f.tar.gz
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)
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 0c023ea..0be04a0 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);
}
/*
OpenPOWER on IntegriCloud