summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1995-07-31 19:17:19 +0000
committerbde <bde@FreeBSD.org>1995-07-31 19:17:19 +0000
commitfc2f9d98283b5feb3a2c1173667335cdc22e809b (patch)
tree7c7edc185c9eb9bc48b9630fa837fadba4010d5e /sys
parent105a5302c8d514bac00d9a43e536c2d1cf348e7f (diff)
downloadFreeBSD-src-fc2f9d98283b5feb3a2c1173667335cdc22e809b.zip
FreeBSD-src-fc2f9d98283b5feb3a2c1173667335cdc22e809b.tar.gz
Assorted cosmetic changes:
Make more functions static. tty.c: Use tcflag_t (u_long) and cc_t instead of u_char and int/long. Don't record values that are only evaluated once. Compare ints using imin(), not min(). min() is for comparing u_ints. Old versions of tty.c used the type-safe but multiple-evaluation-unsafe macro MIN(). The args are apparently never negative; otherwise this change would be non-cosmetic. Don't repeat the loop test in ttywait(). tty.h: Improve English in and formatting of comments.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/tty.c55
-rw-r--r--sys/sys/tty.h19
2 files changed, 33 insertions, 41 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 940a75b..22d510e 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.60 1995/07/30 13:52:56 bde Exp $
+ * $Id: tty.c,v 1.61 1995/07/31 18:29:28 bde Exp $
*/
/*-
@@ -92,11 +92,14 @@
#include <vm/vm.h>
-
static int proc_compare __P((struct proc *p1, struct proc *p2));
-static int ttnread __P((struct tty *));
-static void ttyecho __P((int, struct tty *tp));
-static void ttyrubo __P((struct tty *, int));
+static int ttnread __P((struct tty *tp));
+static void ttyecho __P((int c, struct tty *tp));
+static int ttyoutput __P((int c, register struct tty *tp));
+static void ttypend __P((struct tty *tp));
+static void ttyretype __P((struct tty *tp));
+static void ttyrub __P((int c, struct tty *tp));
+static void ttyrubo __P((struct tty *tp, int cnt));
static void ttyunblock __P((struct tty *tp));
/*
@@ -271,8 +274,8 @@ ttyinput(c, tp)
register int c;
register struct tty *tp;
{
- register int iflag, lflag;
- register u_char *cc;
+ register tcflag_t iflag, lflag;
+ register cc_t *cc;
int i, err;
/*
@@ -478,7 +481,6 @@ parmrk:
* word erase (^W)
*/
if (CCEQ(cc[VWERASE], c)) {
- int alt = ISSET(lflag, ALTWERASE);
int ctype;
/*
@@ -510,7 +512,7 @@ parmrk:
if (c == -1)
goto endcase;
} while (c != ' ' && c != '\t' &&
- (alt == 0 || ISALPHA(c) == ctype));
+ (!ISSET(lflag, ALTWERASE) || ISALPHA(c) == ctype));
(void)putc(c, &tp->t_rawq);
goto endcase;
}
@@ -577,7 +579,7 @@ input_overflow:
/*
* Place the cursor over the '^' of the ^D.
*/
- i = min(2, tp->t_column - i);
+ i = imin(2, tp->t_column - i);
while (i > 0) {
(void)ttyoutput('\b', tp);
i--;
@@ -604,12 +606,12 @@ startoutput:
* Returns < 0 if succeeds, otherwise returns char to resend.
* Must be recursive.
*/
-int
+static int
ttyoutput(c, tp)
register int c;
register struct tty *tp;
{
- register long oflag;
+ register tcflag_t oflag;
register int col, s;
oflag = tp->t_oflag;
@@ -1008,7 +1010,7 @@ ttyselect(tp, rw, p)
int rw;
struct proc *p;
{
- int nread, s;
+ int s;
if (tp == NULL)
return (ENXIO);
@@ -1016,8 +1018,7 @@ ttyselect(tp, rw, p)
s = spltty();
switch (rw) {
case FREAD:
- nread = ttnread(tp);
- if (nread > 0 || (!ISSET(tp->t_cflag, CLOCAL) &&
+ if (ttnread(tp) > 0 || (!ISSET(tp->t_cflag, CLOCAL) &&
!ISSET(tp->t_state, TS_CARR_ON)))
goto win;
selrecord(p, &tp->t_rsel);
@@ -1088,11 +1089,13 @@ ttywait(tp)
error = ttysleep(tp, TSA_OCOMPLETE(tp),
TTOPRI | PCATCH, "ttywai",
tp->t_timeout);
- if (error == EWOULDBLOCK)
- error = EIO;
- if (error)
+ if (error) {
+ if (error == EWOULDBLOCK)
+ error = EIO;
break;
- }
+ }
+ } else
+ break;
}
if (!error && (tp->t_outq.c_cc || ISSET(tp->t_state, TS_BUSY)))
error = EIO;
@@ -1323,12 +1326,12 @@ ttymodem(tp, flag)
* Reinput pending characters after state switch
* call at spltty().
*/
-void
+static void
ttypend(tp)
register struct tty *tp;
{
struct clist tq;
- register c;
+ register int c;
CLR(tp->t_lflag, PENDIN);
SET(tp->t_state, TS_TYPEN);
@@ -1541,7 +1544,7 @@ read:
char ibuf[IBUFSIZ];
int icc;
- icc = min(uio->uio_resid, IBUFSIZ);
+ icc = imin(uio->uio_resid, IBUFSIZ);
icc = q_to_b(qp, ibuf, icc);
if (icc <= 0) {
if (first)
@@ -1675,7 +1678,7 @@ ttwrite(tp, uio, flag)
register struct uio *uio;
int flag;
{
- register char *cp = 0;
+ register char *cp = NULL;
register int cc, ce;
register struct proc *p;
int i, hiwat, cnt, error, s;
@@ -1738,7 +1741,7 @@ loop:
* leftover from last time.
*/
if (cc == 0) {
- cc = min(uio->uio_resid, OBUFSIZ);
+ cc = imin(uio->uio_resid, OBUFSIZ);
cp = obuf;
error = uiomove(cp, cc, uio);
if (error) {
@@ -1866,7 +1869,7 @@ ovhiwat:
* Rubout one character from the rawq of tp
* as cleanly as possible.
*/
-void
+static void
ttyrub(c, tp)
register int c;
register struct tty *tp;
@@ -1969,7 +1972,7 @@ ttyrubo(tp, cnt)
* Reprint the rawq line. Note, it is assumed that c_cc has already
* been checked.
*/
-void
+static void
ttyretype(tp)
register struct tty *tp;
{
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index fb6c977..7e50099 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.h 8.6 (Berkeley) 1/21/94
- * $Id: tty.h,v 1.26 1995/07/30 12:39:42 bde Exp $
+ * $Id: tty.h,v 1.27 1995/07/31 18:29:37 bde Exp $
*/
#ifndef _SYS_TTY_H_
@@ -139,7 +139,7 @@ struct tty {
#define TS_TBLOCK 0x00040 /* Further input blocked. */
#define TS_TIMEOUT 0x00080 /* Wait for output char processing. */
#define TS_TTSTOP 0x00100 /* Output paused. */
-#if 0
+#ifdef notyet
#define TS_WOPEN 0x00200 /* Open in progress. */
#endif
#define TS_XCLUDE 0x00400 /* Tty requires exclusivity. */
@@ -151,17 +151,10 @@ struct tty {
#define TS_LNCH 0x04000 /* Next character is literal. */
#define TS_TYPEN 0x08000 /* Retyping suspended input (PENDIN). */
#define TS_LOCAL (TS_BKSL | TS_CNTTB | TS_ERASE | TS_LNCH | TS_TYPEN)
-/*
- * Snoop state,we need this as we have no other indication of
- * begin snoopped.
- */
-#define TS_SNOOP 0x10000 /* There is snoop on device */
-/*
- * States for serial devices
- */
-#define TS_CAN_BYPASS_L_RINT 0x20000 /* device in "raw" mode */
/* Extras. */
+#define TS_CAN_BYPASS_L_RINT 0x010000 /* Device in "raw" mode. */
+#define TS_SNOOP 0x040000 /* Device is being snooped on. */
#define TS_SO_OCOMPLETE 0x080000 /* Wake up when output completes. */
/* Character type information. */
@@ -251,10 +244,6 @@ int ttyinput __P((int c, struct tty *tp));
int ttylclose __P((struct tty *tp, int flag));
int ttymodem __P((struct tty *tp, int flag));
int ttyopen __P((dev_t device, struct tty *tp));
-int ttyoutput __P((int c, struct tty *tp));
-void ttypend __P((struct tty *tp));
-void ttyretype __P((struct tty *tp));
-void ttyrub __P((int c, struct tty *tp));
int ttysleep __P((struct tty *tp,
void *chan, int pri, char *wmesg, int timeout));
int ttywait __P((struct tty *tp));
OpenPOWER on IntegriCloud