Module Name: src
Committed By: jmcneill
Date: Sun Dec 11 22:33:49 UTC 2011
Modified Files:
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: thunk.c
Log Message:
add thunk_pollchar
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/usermode/usermode/thunk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.35 src/sys/arch/usermode/include/thunk.h:1.36
--- src/sys/arch/usermode/include/thunk.h:1.35 Sun Nov 27 21:23:46 2011
+++ src/sys/arch/usermode/include/thunk.h Sun Dec 11 22:33:49 2011
@@ -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 <[email protected]>
@@ -92,6 +92,7 @@ int thunk_swapcontext(ucontext_t *, ucon
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);
Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.40 src/sys/arch/usermode/usermode/thunk.c:1.41
--- src/sys/arch/usermode/usermode/thunk.c:1.40 Sun Nov 27 21:23:47 2011
+++ src/sys/arch/usermode/usermode/thunk.c Sun Dec 11 22:33:49 2011
@@ -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 <[email protected]>
@@ -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 @@ thunk_tcsetattr(int fd, int action, cons
}
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();