Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/usermode add thunk_pollchar



details:   https://anonhg.NetBSD.org/src/rev/b6acc3f58724
branches:  trunk
changeset: 771963:b6acc3f58724
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Dec 11 22:33:49 2011 +0000

description:
add thunk_pollchar

diffstat:

 sys/arch/usermode/include/thunk.h  |   3 ++-
 sys/arch/usermode/usermode/thunk.c |  23 +++++++++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diffs (66 lines):

diff -r 8e548230d602 -r b6acc3f58724 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Sun Dec 11 22:07:26 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Sun Dec 11 22:33:49 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.35 2011/11/27 21:23:46 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.36 2011/12/11 22:33:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -92,6 +92,7 @@
 int    thunk_tcgetattr(int, struct thunk_termios *);
 int    thunk_tcsetattr(int, int, const struct thunk_termios *);
 
+int    thunk_pollchar(void);
 int    thunk_getchar(void);
 void   thunk_putchar(int);
 
diff -r 8e548230d602 -r b6acc3f58724 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Sun Dec 11 22:07:26 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Sun Dec 11 22:33:49 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.40 2011/11/27 21:23:47 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.41 2011/12/11 22:33:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,12 +28,13 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.40 2011/11/27 21:23:47 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.41 2011/12/11 22:33:49 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/reboot.h>
+#include <sys/poll.h>
 #include <machine/vmparam.h>
 
 #include <aio.h>
@@ -320,6 +321,24 @@
 }
 
 int
+thunk_pollchar(void)
+{
+       struct pollfd fds[1];
+
+       fds[0].fd = STDIN_FILENO;
+       fds[0].events = POLLIN;
+       fds[0].revents = 0;
+
+       if (poll(fds, __arraycount(fds), 0) > 0) {
+               if (fds[0].revents & POLLIN) {
+                       return getchar();
+               }
+       }
+
+       return EOF;
+}
+
+int
 thunk_getchar(void)
 {
        return getchar();



Home | Main Index | Thread Index | Old Index