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

Function ttydev_write

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

Source from the content-addressed store, hash-verified

516}
517
518static int ttydev_write(struct lwp_tty *tp, struct uio *uio, int ioflag)
519{
520#ifdef USING_BSD_DEFER_STOP
521 int defer;
522#endif
523 int error;
524
525 error = ttydev_enter(tp);
526 if (error)
527 return error;
528
529 if (tp->t_termios.c_lflag & TOSTOP)
530 {
531 error = tty_wait_background(tp, curthread, SIGTTOU);
532 if (error)
533 goto done;
534 }
535
536 if (ioflag & IO_NDELAY && tp->t_flags & TF_BUSY_OUT)
537 {
538 /* Allow non-blocking writes to bypass serialization. */
539 error = ttydisc_write(tp, uio, ioflag);
540 }
541 else
542 {
543 /* Serialize write() calls. */
544 while (tp->t_flags & TF_BUSY_OUT)
545 {
546 error = tty_wait(tp, &tp->t_outserwait);
547 if (error)
548 goto done;
549 }
550
551 tp->t_flags |= TF_BUSY_OUT;
552#ifdef USING_BSD_DEFER_STOP
553 defer = sigdeferstop(SIGDEFERSTOP_ERESTART);
554#endif
555 error = ttydisc_write(tp, uio, ioflag);
556#ifdef USING_BSD_DEFER_STOP
557 sigallowstop(defer);
558#endif
559 tp->t_flags &= ~TF_BUSY_OUT;
560 cv_signal(&tp->t_outserwait);
561 }
562
563done:
564 tty_unlock(tp);
565 return error;
566}
567
568static int ttydev_ioctl(struct lwp_tty *tp, rt_ubase_t cmd, rt_caddr_t data, int fflag,
569 struct rt_thread *td)

Callers

nothing calls this directly

Calls 4

ttydev_enterFunction · 0.85
tty_wait_backgroundFunction · 0.85
ttydisc_writeFunction · 0.85
tty_waitFunction · 0.85

Tested by

no test coverage detected