freebsd-ports/emulators/dlx/files/patch-io-termios
Martin Wilke db5190e781 - The emulators/dlx port is one of the last remaining ports that uses
sgtty exclusively. We'd better port it to termios, to make it work
  without the COMPAT_43TTY kernel switch.

PR:		122884
Submitted by:	Ed Schouten <ed@80386.nl>
2008-05-16 14:10:38 +00:00

65 lines
1.7 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--- 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. */