summaryrefslogtreecommitdiff
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorDan Nicolaescu <dann@ics.uci.edu>2010-08-22 08:14:37 -0700
committerDan Nicolaescu <dann@ics.uci.edu>2010-08-22 08:14:37 -0700
commit5681012f450592997e68c8b4e3e9b2d3d43ea5dd (patch)
tree17a346930765172d5402489f637167dcd865506b /src/sysdep.c
parenta31a6859b63499c31301aba0081ac7a4c0b4826a (diff)
downloademacs-5681012f450592997e68c8b4e3e9b2d3d43ea5dd.tar.gz
Simplify termio code.
All non-MSDOS non-WINDOWSNT platforms define HAVE_TERMIOS, so HAVE_TERMIO code is obsolete. Replace HAVE_TERMIOS conditionals with !DOS_NT. * src/systty.h: Do not define HAVE_TCATTR. Remove HAVE_TERMIO, HAVE_LTCHARS and HAVE_TCHARS code. Do not define EMACS_HAVE_TTY_PGRP. Only define EMACS_GET_TTY_PGRP for !DOS_NT. * src/sysdep.c: Include sysselect.h unconditionally. Do not include sys/ioctl.h and termios.h, systty.h does it. Use HAVE_SYS_UTSNAME_H instead of USG as an include guard. (init_baud_rate): Remove HAVE_TERMIO code. (child_setup_tty): Remove HAVE_TERMIO code. (emacs_get_tty, emacs_set_tty): Remove HAVE_TERMIO, HAVE_TCHARS and HAVE_LTCHARS code. Use !DOS_NT instead of HAVE_TCATTR. (new_ltchars, new_tchars): Remove, unused. (init_sys_modes): Remove HAVE_TERMIO, HAVE_TCHARS and HAVE_LTCHARS code. Remove special casing for __mips__, it was a no-op. Remove HAVE_TCATTR conditional, it is implied by HAVE_TERMIOS. (init_sys_modes): Remove HPUX special case. * src/process.c: Include stdlib.h unconditionally. Do not include fcntl.h, systty.h does it. Remove conditional code for HAVE_SERIAL, it is always true. (process_send_signal): Remove HAVE_TERMIOS conditional, it's always true when SIGNALS_VIA_CHARACTERS is true. (Fcontinue_process, Fprocess_send_eof): Simplify conditionals: !WINDOWSNT means HAVE_TERMIOS. (create_process): Remove HAVE_TERMIOS, it's inside a HAVE_PTYS conditional, which is true for all HAVE_TERMIOS systems. * src/keyboard.c (init_keyboard): Do not use HAVE_TERMIO, use !DOS_NT instead of HAVE_TERMIOS. * src/emacs.c (shut_down_emacs): Use !defined DOS_NT instead of EMACS_HAVE_TTY_PGRP. * src/callproc.c (child_setup): Move EMACS_SET_TTY_PGRP use to the non-MSDOS, non-WINDOWSNT code, it's only defined for such systems anyway.
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c180
1 files changed, 11 insertions, 169 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 2ae3c509522..e7d35d46bf7 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -35,15 +35,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif
#include "lisp.h"
-/* Including stdlib.h isn't necessarily enough to get srandom
- declared, e.g. without __USE_XOPEN_EXTENDED with glibc 2. */
-
-/* The w32 build defines select stuff in w32.h, which is included by
- sys/select.h (included below). */
-#ifndef WINDOWSNT
#include "sysselect.h"
-#endif
-
#include "blockinput.h"
#ifdef WINDOWSNT
@@ -84,17 +76,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <fcntl.h>
#endif
-#ifndef MSDOS
-#include <sys/ioctl.h>
-#endif
-
#include "systty.h"
#include "syswait.h"
-#if defined (USG)
+#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#include <memory.h>
-#endif /* USG */
+#endif /* HAVE_SYS_UTSNAME_H */
#include "keyboard.h"
#include "frame.h"
@@ -149,17 +137,6 @@ static const int baud_convert[] =
1800, 2400, 4800, 9600, 19200, 38400
};
-#ifdef HAVE_SPEED_T
-#include <termios.h>
-#else
-#if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T)
-#else
-#if defined (HAVE_TERMIOS_H) && defined (GNU_LINUX)
-#include <termios.h>
-#endif
-#endif
-#endif
-
int emacs_ospeed;
void croak (char *) NO_RETURN;
@@ -308,32 +285,11 @@ init_baud_rate (int fd)
#ifdef DOS_NT
emacs_ospeed = 15;
#else /* not DOS_NT */
-#ifdef HAVE_TERMIOS
struct termios sg;
sg.c_cflag = B9600;
tcgetattr (fd, &sg);
emacs_ospeed = cfgetospeed (&sg);
-#else /* not TERMIOS */
-#ifdef HAVE_TERMIO
- struct termio sg;
-
- sg.c_cflag = B9600;
-#ifdef HAVE_TCATTR
- tcgetattr (fd, &sg);
-#else
- ioctl (fd, TCGETA, &sg);
-#endif
- emacs_ospeed = sg.c_cflag & CBAUD;
-#else /* neither TERMIOS nor TERMIO */
- struct sgttyb sg;
-
- sg.sg_ospeed = B9600;
- if (ioctl (fd, TIOCGETP, &sg) < 0)
- abort ();
- emacs_ospeed = sg.sg_ospeed;
-#endif /* not HAVE_TERMIO */
-#endif /* not HAVE_TERMIOS */
#endif /* not DOS_NT */
}
@@ -417,7 +373,7 @@ wait_for_termination (int pid)
void
flush_pending_output (int channel)
{
-#ifdef HAVE_TERMIOS
+#ifndef DOS_NT
/* If we try this, we get hit with SIGTTIN, because
the child's tty belongs to the child's pgrp. */
#else
@@ -447,8 +403,6 @@ child_setup_tty (int out)
struct emacs_tty s;
EMACS_GET_TTY (out, &s);
-
-#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
s.main.c_oflag |= OPOST; /* Enable output postprocessing */
s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */
#ifdef NLDLY
@@ -526,19 +480,7 @@ child_setup_tty (int out)
s.main.c_cc[VTIME] = 0;
#endif
-#else /* not HAVE_TERMIO */
-
- s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE
- | CBREAK | TANDEM);
- s.main.sg_flags |= LPASS8;
- s.main.sg_erase = 0377;
- s.main.sg_kill = 0377;
- s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */
-
-#endif /* not HAVE_TERMIO */
-
EMACS_SET_TTY (out, &s, 0);
-
#endif /* not WINDOWSNT */
}
#endif /* MSDOS */
@@ -841,38 +783,11 @@ int
emacs_get_tty (int fd, struct emacs_tty *settings)
{
/* Retrieve the primary parameters - baud rate, character size, etcetera. */
-#ifdef HAVE_TCATTR
+#ifndef DOS_NT
/* We have those nifty POSIX tcmumbleattr functions. */
memset (&settings->main, 0, sizeof (settings->main));
if (tcgetattr (fd, &settings->main) < 0)
return -1;
-
-#else
-#ifdef HAVE_TERMIO
- /* The SYSV-style interface? */
- if (ioctl (fd, TCGETA, &settings->main) < 0)
- return -1;
-
-#else
-#ifndef DOS_NT
- /* I give up - I hope you have the BSD ioctls. */
- if (ioctl (fd, TIOCGETP, &settings->main) < 0)
- return -1;
-#endif /* not DOS_NT */
-#endif
-#endif
-
- /* Suivant - Do we have to get struct ltchars data? */
-#ifdef HAVE_LTCHARS
- if (ioctl (fd, TIOCGLTC, &settings->ltchars) < 0)
- return -1;
-#endif
-
- /* How about a struct tchars and a wordful of lmode bits? */
-#ifdef HAVE_TCHARS
- if (ioctl (fd, TIOCGETC, &settings->tchars) < 0
- || ioctl (fd, TIOCLGET, &settings->lmode) < 0)
- return -1;
#endif
/* We have survived the tempest. */
@@ -888,7 +803,7 @@ int
emacs_set_tty (int fd, struct emacs_tty *settings, int flushp)
{
/* Set the primary parameters - baud rate, character size, etcetera. */
-#ifdef HAVE_TCATTR
+#ifndef DOS_NT
int i;
/* We have those nifty POSIX tcmumbleattr functions.
William J. Smith <wjs@wiis.wang.com> writes:
@@ -926,34 +841,6 @@ emacs_set_tty (int fd, struct emacs_tty *settings, int flushp)
else
continue;
}
-
-#else
-#ifdef HAVE_TERMIO
- /* The SYSV-style interface? */
- if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0)
- return -1;
-
-#else
-#ifndef DOS_NT
- /* I give up - I hope you have the BSD ioctls. */
- if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0)
- return -1;
-#endif /* not DOS_NT */
-
-#endif
-#endif
-
- /* Suivant - Do we have to get struct ltchars data? */
-#ifdef HAVE_LTCHARS
- if (ioctl (fd, TIOCSLTC, &settings->ltchars) < 0)
- return -1;
-#endif
-
- /* How about a struct tchars and a wordful of lmode bits? */
-#ifdef HAVE_TCHARS
- if (ioctl (fd, TIOCSETC, &settings->tchars) < 0
- || ioctl (fd, TIOCLSET, &settings->lmode) < 0)
- return -1;
#endif
/* We have survived the tempest. */
@@ -976,13 +863,6 @@ unsigned char _sobuf[BUFSIZ+8];
char _sobuf[BUFSIZ];
#endif
-#ifdef HAVE_LTCHARS
-static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1};
-#endif
-#ifdef HAVE_TCHARS
-static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
-#endif
-
/* Initialize the terminal mode on all tty devices that are currently
open. */
@@ -1016,7 +896,7 @@ init_sys_modes (struct tty_display_info *tty_out)
tty = *tty_out->old_tty;
-#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
+#if !defined (DOS_NT)
XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]);
tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */
@@ -1088,12 +968,11 @@ init_sys_modes (struct tty_display_info *tty_out)
of C-z */
#endif /* VSWTCH */
-#if defined (__mips__) || defined (HAVE_TCATTR)
#ifdef VSUSP
- tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */
+ tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off handling of C-z. */
#endif /* VSUSP */
#ifdef V_DSUSP
- tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */
+ tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off handling of C-y. */
#endif /* V_DSUSP */
#ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */
tty.main.c_cc[VDSUSP] = CDISABLE;
@@ -1129,7 +1008,6 @@ init_sys_modes (struct tty_display_info *tty_out)
tty.main.c_cc[VSTOP] = CDISABLE;
#endif /* VSTOP */
}
-#endif /* mips or HAVE_TCATTR */
#ifdef AIX
tty.main.c_cc[VSTRT] = CDISABLE;
@@ -1152,41 +1030,8 @@ init_sys_modes (struct tty_display_info *tty_out)
tty.main.c_iflag &= ~IGNBRK;
tty.main.c_iflag &= ~BRKINT;
#endif
-#else /* if not HAVE_TERMIO */
-#ifndef DOS_NT
- XSETINT (Vtty_erase_char, tty.main.sg_erase);
- tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
- if (meta_key)
- tty.main.sg_flags |= ANYP;
- tty.main.sg_flags |= interrupt_input ? RAW : CBREAK;
#endif /* not DOS_NT */
-#endif /* not HAVE_TERMIO */
-
- /* If going to use CBREAK mode, we must request C-g to interrupt
- and turn off start and stop chars, etc. If not going to use
- CBREAK mode, do this anyway so as to turn off local flow
- control for user coming over network on 4.2; in this case,
- only t_stopc and t_startc really matter. */
-#ifndef HAVE_TERMIO
-#ifdef HAVE_TCHARS
- /* Note: if not using CBREAK mode, it makes no difference how we
- set this */
- tty.tchars = new_tchars;
- tty.tchars.t_intrc = quit_char;
- if (tty_out->flow_control)
- {
- tty.tchars.t_startc = '\021';
- tty.tchars.t_stopc = '\023';
- }
- tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
-
-#endif /* HAVE_TCHARS */
-#endif /* not HAVE_TERMIO */
-
-#ifdef HAVE_LTCHARS
- tty.ltchars = new_ltchars;
-#endif /* HAVE_LTCHARS */
#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */
if (!tty_out->term_initted)
internal_terminal_init ();
@@ -1205,7 +1050,7 @@ init_sys_modes (struct tty_display_info *tty_out)
if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0);
#endif
-#if defined (HAVE_TERMIOS) || defined (HPUX)
+#if !defined (DOS_NT)
#ifdef TCOON
if (!tty_out->flow_control) tcflow (fileno (tty_out->input), TCOON);
#endif
@@ -2688,7 +2533,7 @@ strsignal (int code)
}
#endif /* HAVE_STRSIGNAL */
-#ifdef HAVE_TERMIOS
+#ifndef DOS_NT
/* For make-serial-process */
int
serial_open (char *port)
@@ -2717,9 +2562,6 @@ serial_open (char *port)
return fd;
}
-#endif /* TERMIOS */
-
-#ifdef HAVE_TERMIOS
#if !defined (HAVE_CFMAKERAW)
/* Workaround for targets which are missing cfmakeraw. */
@@ -2906,7 +2748,7 @@ serial_configure (struct Lisp_Process *p,
p->childp = childp2;
}
-#endif /* TERMIOS */
+#endif /* not DOS_NT */
/* System depended enumeration of and access to system processes a-la ps(1). */