1) Port NetBSD VMIN/VTIME stuff:
fix bug in case VMIN=0 && rawq len == 0,
fix bug with missing untimeouts.
2) Fixes from bde:
o Don't export private functions.
o Don't declare externs inside functions. I moved the declaration
of `nldisp' to the top of tty.c; it should be declared in some
header.
o Moved ttywait() deadlock fix from sio.c to here so it doesn't
harm efficiency and so it works with other drivers.
o Use "cuddle else style" ( "} else" not "}\n\t..else" ).
o Don't clear TS_TBLOCK before it is used in ttyflush() (your version
had this from a previous incomplete fix).
o Added long comment about probable botch of TS_ISOPEN and TS_WOPEN
flags when CLOCAL drops while there is no carrier.
o Added comment about races in ttnread(). Only some callers use
spltty(). ttselect() doesn't.
o Fixed use of random types (int, long) instead of tcflags_t and
use of u_char instead of cc_t (you missed the changes in my
previous diffs).
o "int alt = lflag&ALTWERASE" had the wrong type. It's only used
once, so don't use a flag variable for it.
o Fixed (? :-) use of MIN() and min() on integral types. MIN()
expands to min() and min() is an (inline) function that really
only works for u_int types. "gcc -Wconversion" told me about
the sign botches. Of course, a min of -1 would be fatal as
the count arg for bcopy or bzero.
o Fixed missing loop exit after uiomove() failure in ttwrite()
(bug introduced in my previous version :-().
o Fixed serious races in ttwrite(). The old clist buffer access
functions apparently called spltty()/splx() (NetBSD's getc()
and putc() do it) although this makes them slow. Lots of
races were introduced by the non-locking RB_* access macros.
o Cleaned up fix for ECHONL again.
o tp->t_gen is now int; use int for `gen' copy of it too.