Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha/stand/common In putchar(), don't open-code tw...



details:   https://anonhg.NetBSD.org/src/rev/9c6e3832630b
branches:  trunk
changeset: 467921:9c6e3832630b
user:      cgd <cgd%NetBSD.org@localhost>
date:      Wed Mar 31 03:10:00 1999 +0000

description:
In putchar(), don't open-code two calls to the prom puts routine.  Instead,
call a helper function (putonechar()).  Savings: 64 bytes.  Cha-ching!

diffstat:

 sys/arch/alpha/stand/common/prom.c |  31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diffs (60 lines):

diff -r 9eae43b04448 -r 9c6e3832630b sys/arch/alpha/stand/common/prom.c
--- a/sys/arch/alpha/stand/common/prom.c        Wed Mar 31 03:04:21 1999 +0000
+++ b/sys/arch/alpha/stand/common/prom.c        Wed Mar 31 03:10:00 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prom.c,v 1.5 1998/10/15 01:02:15 ross Exp $ */
+/* $NetBSD: prom.c,v 1.6 1999/03/31 03:10:00 cgd Exp $ */
 
 /*  
  * Mach Operating System
@@ -36,6 +36,7 @@
 int console;
 
 static int test_getchar(prom_return_t *, int *);
+static void putonechar(int c);
 
 void
 init_prom_calls()
@@ -81,26 +82,30 @@
        }
 }
 
+static void
+putonechar(c)
+       int c;
+{
+       prom_return_t ret;
+       char cbuf = c;
+
+       do {
+               ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1);
+       } while ((ret.u.retval & 1) == 0);
+}
+
 void
 putchar(c)
        int c;
 {
        prom_return_t ret;
-       char cbuf;
        int typed_c;
 
        if (c == '\r' || c == '\n') {
-               cbuf = '\r';
-               do {
-                       ret.bits = prom_dispatch(PROM_R_PUTS, console,
-                           &cbuf, 1);
-               } while ((ret.u.retval & 1) == 0);
-               cbuf = '\n';
-       } else
-               cbuf = c;
-       do {
-               ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1);
-       } while ((ret.u.retval & 1) == 0);
+               putonechar('\r');
+               c = '\n';
+       }
+       putonechar(c);
        ret.bits = prom_dispatch(PROM_R_GETC, console);
        if (ret.u.status == 0 || ret.u.status == 1)
                if (ret.u.retval == 3)



Home | Main Index | Thread Index | Old Index