summaryrefslogtreecommitdiff
path: root/emulators/dlx/files/patch-io-termios
blob: c9a268944ee112a7e446e22afdcd58ff5e0ba949 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--- dlxsim/io.c
+++ dlxsim/io.c
@@ -18,6 +18,8 @@
 static char rcsid[] = "$Header: /user1/ouster/mipsim/RCS/io.c,v 1.3 89/12/07 18:00:21 ouster Exp $ SPRITE (Berkeley)";
 #endif /* not lint */
 
+#include <sys/ioctl.h>
+
 #include <ctype.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -283,17 +285,19 @@
     register DLX *machPtr;		/* Machine being simulated. */
 {
     int flags;
+    struct termios newState;
 
     /*
      * Save terminal state, and put it into a raw-er mode during
      * the simulation.
      */
 
-    ioctl(0, TIOCGETP, (char *) &(machPtr->ioState.savedState));
-    flags = machPtr->ioState.savedState.sg_flags;
-    machPtr->ioState.savedState.sg_flags = (flags | CBREAK) & ~ECHO;
-    ioctl(0, TIOCSETP, (char *) &machPtr->ioState.savedState);
-    machPtr->ioState.savedState.sg_flags = flags;
+    tcgetattr(0, &newState);
+    machPtr->ioState.savedState = newState;
+    newState.c_lflag &= ~(ICANON|ECHO);
+    newState.c_cc[VMIN] = 0;
+    newState.c_cc[VTIME] = 0;
+    tcsetattr(0, TCSANOW, &newState);
 }
 
 /*
@@ -325,7 +329,7 @@
      */
 
     CheckInput(machPtr);
-    ioctl(0, TIOCSETP, (char *) &machPtr->ioState.savedState);
+    tcsetattr(0, TCSANOW, &machPtr->ioState.savedState);
 }
 
 /*
--- dlxsim/io.h
+++ dlxsim/io.h
@@ -19,7 +19,7 @@
 #ifndef _MIPSIM_IO
 #define _MIPSIM_IO
 
-#include <sgtty.h>
+#include <termios.h>
 
 /*
  * The following structure is part of each DLX machine, and describes
@@ -27,7 +27,7 @@
  */
 
 typedef struct IoState {
-    struct sgttyb savedState;	/* Used to save original terminal state
+    struct termios savedState;	/* Used to save original terminal state
 				 * so terminal can be put into CBREAK
 				 * mode during simulation and then be
 				 * restored when simulation stops. */