MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / ttydev_poll

Function ttydev_poll

components/lwp/terminal/freebsd/tty.c:657–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

655}
656
657static int ttydev_poll(struct lwp_tty *tp, rt_pollreq_t *req, struct rt_thread *td)
658{
659 int events = req->_key;
660 int error, revents = 0;
661
662 error = ttydev_enter(tp);
663 if (error)
664 return ((events & (POLLIN | POLLRDNORM)) | POLLHUP);
665
666 if (events & (POLLIN | POLLRDNORM))
667 {
668 /* See if we can read something. */
669 if (ttydisc_read_poll(tp) > 0)
670 revents |= events & (POLLIN | POLLRDNORM);
671 }
672
673 if (tp->t_flags & TF_ZOMBIE)
674 {
675 /* Hangup flag on zombie state. */
676 revents |= POLLHUP;
677 }
678 else if (events & (POLLOUT | POLLWRNORM))
679 {
680 /* See if we can write something. */
681 if (ttydisc_write_poll(tp) > 0)
682 revents |= events & (POLLOUT | POLLWRNORM);
683 }
684
685 if (revents == 0)
686 {
687 if (events & (POLLIN | POLLRDNORM))
688 rt_poll_add(&tp->t_inpoll, req);
689 if (events & (POLLOUT | POLLWRNORM))
690 rt_poll_add(&tp->t_outpoll, req);
691 }
692
693 tty_unlock(tp);
694
695 return revents;
696}
697
698static struct cdevsw ttydev_cdevsw = {
699 .d_open = ttydev_open,

Callers

nothing calls this directly

Calls 4

ttydev_enterFunction · 0.85
ttydisc_read_pollFunction · 0.85
ttydisc_write_pollFunction · 0.85
rt_poll_addFunction · 0.85

Tested by

no test coverage detected