Source-Changes-HG archive

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

[src/trunk]: src/sys call cnpollc(1) and cnpollc(0) around cngetc().



details:   https://anonhg.NetBSD.org/src/rev/a785e1e9caac
branches:  trunk
changeset: 993553:a785e1e9caac
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Sep 16 23:18:55 2018 +0000

description:
call cnpollc(1) and cnpollc(0) around cngetc().

(christos has a good idea to add a function that does all 3,
and we should switch all the callers in this sequence to use
it (and fix the MD ones missing it still).  not all can, as
eg, line-grabbing functions can use cngetsn(), which only
calls cnpollc() twice.)

diffstat:

 sys/ddb/db_command.c     |  15 ++++++++++-----
 sys/ddb/db_output.c      |   6 +++---
 sys/kern/subr_userconf.c |   8 ++++++--
 3 files changed, 19 insertions(+), 10 deletions(-)

diffs (117 lines):

diff -r 31516c825a79 -r a785e1e9caac sys/ddb/db_command.c
--- a/sys/ddb/db_command.c      Sun Sep 16 22:37:24 2018 +0000
+++ b/sys/ddb/db_command.c      Sun Sep 16 23:18:55 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_command.c,v 1.158 2018/09/15 08:48:18 mrg Exp $     */
+/*     $NetBSD: db_command.c,v 1.159 2018/09/16 23:18:55 mrg Exp $     */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.158 2018/09/15 08:48:18 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.159 2018/09/16 23:18:55 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -90,9 +90,9 @@
 #include <sys/module.h>
 #include <sys/kernhist.h>
 #include <sys/socketvar.h>
+#include <sys/queue.h>
 
-/*include queue macros*/
-#include <sys/queue.h>
+#include <dev/cons.h>
 
 #include <ddb/ddb.h>
 
@@ -542,7 +542,10 @@
        return ENOENT;
 }
 
-/* This function is called from machine trap code. */
+/*
+ * This function is called via db_trap() or directly from
+ * machine trap code.
+ */
 void
 db_command_loop(void)
 {
@@ -579,7 +582,9 @@
                if (db_print_position() != 0)
                        db_printf("\n");
                db_output_line = 0;
+               cnpollc(1);
                (void) db_read_line();
+               cnpollc(0);
                db_command(&db_last_command);
        }
 
diff -r 31516c825a79 -r a785e1e9caac sys/ddb/db_output.c
--- a/sys/ddb/db_output.c       Sun Sep 16 22:37:24 2018 +0000
+++ b/sys/ddb/db_output.c       Sun Sep 16 23:18:55 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_output.c,v 1.33 2012/09/01 01:13:51 matt Exp $      */
+/*     $NetBSD: db_output.c,v 1.34 2018/09/16 23:18:55 mrg Exp $       */
 
 /*
  * Mach Operating System
@@ -35,7 +35,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_output.c,v 1.33 2012/09/01 01:13:51 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_output.c,v 1.34 2018/09/16 23:18:55 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -111,7 +111,7 @@
 
        for (p = "--db_more--"; *p; p++)
                cnputc(*p);
-       switch(cngetc()) {
+       switch (cngetc()) {
        case ' ':
                db_output_line = 0;
                break;
diff -r 31516c825a79 -r a785e1e9caac sys/kern/subr_userconf.c
--- a/sys/kern/subr_userconf.c  Sun Sep 16 22:37:24 2018 +0000
+++ b/sys/kern/subr_userconf.c  Sun Sep 16 23:18:55 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_userconf.c,v 1.26 2013/12/23 15:34:16 skrll Exp $ */
+/*     $NetBSD: subr_userconf.c,v 1.27 2018/09/16 23:18:55 mrg Exp $   */
 
 /*
  * Copyright (c) 1996 Mats O Jansson <moj%stacken.kth.se@localhost>
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_userconf.c,v 1.26 2013/12/23 15:34:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_userconf.c,v 1.27 2018/09/16 23:18:55 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -103,7 +103,9 @@
        if (userconf_cnt != -1) {
                if (userconf_cnt == userconf_lines) {
                        printf("-- more --");
+                       cnpollc(1);
                        c = cngetc();
+                       cnpollc(0);
                        userconf_cnt = 0;
                        printf("\r            \r");
                }
@@ -391,7 +393,9 @@
 
                while (c != 'y' && c != 'Y' && c != 'n' && c != 'N') {
                        printf("change (y/n) ?");
+                       cnpollc(1);
                        c = cngetc();
+                       cnpollc(0);
                        printf("\n");
                }
 



Home | Main Index | Thread Index | Old Index