aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
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/>. */
35#endif 35#endif
36 36
37#include "lisp.h" 37#include "lisp.h"
38/* Including stdlib.h isn't necessarily enough to get srandom
39 declared, e.g. without __USE_XOPEN_EXTENDED with glibc 2. */
40
41/* The w32 build defines select stuff in w32.h, which is included by
42 sys/select.h (included below). */
43#ifndef WINDOWSNT
44#include "sysselect.h" 38#include "sysselect.h"
45#endif
46
47#include "blockinput.h" 39#include "blockinput.h"
48 40
49#ifdef WINDOWSNT 41#ifdef WINDOWSNT
@@ -84,17 +76,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
84#include <fcntl.h> 76#include <fcntl.h>
85#endif 77#endif
86 78
87#ifndef MSDOS
88#include <sys/ioctl.h>
89#endif
90
91#include "systty.h" 79#include "systty.h"
92#include "syswait.h" 80#include "syswait.h"
93 81
94#if defined (USG) 82#ifdef HAVE_SYS_UTSNAME_H
95#include <sys/utsname.h> 83#include <sys/utsname.h>
96#include <memory.h> 84#include <memory.h>
97#endif /* USG */ 85#endif /* HAVE_SYS_UTSNAME_H */
98 86
99#include "keyboard.h" 87#include "keyboard.h"
100#include "frame.h" 88#include "frame.h"
@@ -149,17 +137,6 @@ static const int baud_convert[] =
149 1800, 2400, 4800, 9600, 19200, 38400 137 1800, 2400, 4800, 9600, 19200, 38400
150 }; 138 };
151 139
152#ifdef HAVE_SPEED_T
153#include <termios.h>
154#else
155#if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T)
156#else
157#if defined (HAVE_TERMIOS_H) && defined (GNU_LINUX)
158#include <termios.h>
159#endif
160#endif
161#endif
162
163int emacs_ospeed; 140int emacs_ospeed;
164 141
165void croak (char *) NO_RETURN; 142void croak (char *) NO_RETURN;
@@ -308,32 +285,11 @@ init_baud_rate (int fd)
308#ifdef DOS_NT 285#ifdef DOS_NT
309 emacs_ospeed = 15; 286 emacs_ospeed = 15;
310#else /* not DOS_NT */ 287#else /* not DOS_NT */
311#ifdef HAVE_TERMIOS
312 struct termios sg; 288 struct termios sg;
313 289
314 sg.c_cflag = B9600; 290 sg.c_cflag = B9600;
315 tcgetattr (fd, &sg); 291 tcgetattr (fd, &sg);
316 emacs_ospeed = cfgetospeed (&sg); 292 emacs_ospeed = cfgetospeed (&sg);
317#else /* not TERMIOS */
318#ifdef HAVE_TERMIO
319 struct termio sg;
320
321 sg.c_cflag = B9600;
322#ifdef HAVE_TCATTR
323 tcgetattr (fd, &sg);
324#else
325 ioctl (fd, TCGETA, &sg);
326#endif
327 emacs_ospeed = sg.c_cflag & CBAUD;
328#else /* neither TERMIOS nor TERMIO */
329 struct sgttyb sg;
330
331 sg.sg_ospeed = B9600;
332 if (ioctl (fd, TIOCGETP, &sg) < 0)
333 abort ();
334 emacs_ospeed = sg.sg_ospeed;
335#endif /* not HAVE_TERMIO */
336#endif /* not HAVE_TERMIOS */
337#endif /* not DOS_NT */ 293#endif /* not DOS_NT */
338 } 294 }
339 295
@@ -417,7 +373,7 @@ wait_for_termination (int pid)
417void 373void
418flush_pending_output (int channel) 374flush_pending_output (int channel)
419{ 375{
420#ifdef HAVE_TERMIOS 376#ifndef DOS_NT
421 /* If we try this, we get hit with SIGTTIN, because 377 /* If we try this, we get hit with SIGTTIN, because
422 the child's tty belongs to the child's pgrp. */ 378 the child's tty belongs to the child's pgrp. */
423#else 379#else
@@ -447,8 +403,6 @@ child_setup_tty (int out)
447 struct emacs_tty s; 403 struct emacs_tty s;
448 404
449 EMACS_GET_TTY (out, &s); 405 EMACS_GET_TTY (out, &s);
450
451#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
452 s.main.c_oflag |= OPOST; /* Enable output postprocessing */ 406 s.main.c_oflag |= OPOST; /* Enable output postprocessing */
453 s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */ 407 s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */
454#ifdef NLDLY 408#ifdef NLDLY
@@ -526,19 +480,7 @@ child_setup_tty (int out)
526 s.main.c_cc[VTIME] = 0; 480 s.main.c_cc[VTIME] = 0;
527#endif 481#endif
528 482
529#else /* not HAVE_TERMIO */
530
531 s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE
532 | CBREAK | TANDEM);
533 s.main.sg_flags |= LPASS8;
534 s.main.sg_erase = 0377;
535 s.main.sg_kill = 0377;
536 s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */
537
538#endif /* not HAVE_TERMIO */
539
540 EMACS_SET_TTY (out, &s, 0); 483 EMACS_SET_TTY (out, &s, 0);
541
542#endif /* not WINDOWSNT */ 484#endif /* not WINDOWSNT */
543} 485}
544#endif /* MSDOS */ 486#endif /* MSDOS */
@@ -841,38 +783,11 @@ int
841emacs_get_tty (int fd, struct emacs_tty *settings) 783emacs_get_tty (int fd, struct emacs_tty *settings)
842{ 784{
843 /* Retrieve the primary parameters - baud rate, character size, etcetera. */ 785 /* Retrieve the primary parameters - baud rate, character size, etcetera. */
844#ifdef HAVE_TCATTR 786#ifndef DOS_NT
845 /* We have those nifty POSIX tcmumbleattr functions. */ 787 /* We have those nifty POSIX tcmumbleattr functions. */
846 memset (&settings->main, 0, sizeof (settings->main)); 788 memset (&settings->main, 0, sizeof (settings->main));
847 if (tcgetattr (fd, &settings->main) < 0) 789 if (tcgetattr (fd, &settings->main) < 0)
848 return -1; 790 return -1;
849
850#else
851#ifdef HAVE_TERMIO
852 /* The SYSV-style interface? */
853 if (ioctl (fd, TCGETA, &settings->main) < 0)
854 return -1;
855
856#else
857#ifndef DOS_NT
858 /* I give up - I hope you have the BSD ioctls. */
859 if (ioctl (fd, TIOCGETP, &settings->main) < 0)
860 return -1;
861#endif /* not DOS_NT */
862#endif
863#endif
864
865 /* Suivant - Do we have to get struct ltchars data? */
866#ifdef HAVE_LTCHARS
867 if (ioctl (fd, TIOCGLTC, &settings->ltchars) < 0)
868 return -1;
869#endif
870
871 /* How about a struct tchars and a wordful of lmode bits? */
872#ifdef HAVE_TCHARS
873 if (ioctl (fd, TIOCGETC, &settings->tchars) < 0
874 || ioctl (fd, TIOCLGET, &settings->lmode) < 0)
875 return -1;
876#endif 791#endif
877 792
878 /* We have survived the tempest. */ 793 /* We have survived the tempest. */
@@ -888,7 +803,7 @@ int
888emacs_set_tty (int fd, struct emacs_tty *settings, int flushp) 803emacs_set_tty (int fd, struct emacs_tty *settings, int flushp)
889{ 804{
890 /* Set the primary parameters - baud rate, character size, etcetera. */ 805 /* Set the primary parameters - baud rate, character size, etcetera. */
891#ifdef HAVE_TCATTR 806#ifndef DOS_NT
892 int i; 807 int i;
893 /* We have those nifty POSIX tcmumbleattr functions. 808 /* We have those nifty POSIX tcmumbleattr functions.
894 William J. Smith <wjs@wiis.wang.com> writes: 809 William J. Smith <wjs@wiis.wang.com> writes:
@@ -926,34 +841,6 @@ emacs_set_tty (int fd, struct emacs_tty *settings, int flushp)
926 else 841 else
927 continue; 842 continue;
928 } 843 }
929
930#else
931#ifdef HAVE_TERMIO
932 /* The SYSV-style interface? */
933 if (ioctl (fd, flushp ? TCSETAF : TCSETAW, &settings->main) < 0)
934 return -1;
935
936#else
937#ifndef DOS_NT
938 /* I give up - I hope you have the BSD ioctls. */
939 if (ioctl (fd, (flushp) ? TIOCSETP : TIOCSETN, &settings->main) < 0)
940 return -1;
941#endif /* not DOS_NT */
942
943#endif
944#endif
945
946 /* Suivant - Do we have to get struct ltchars data? */
947#ifdef HAVE_LTCHARS
948 if (ioctl (fd, TIOCSLTC, &settings->ltchars) < 0)
949 return -1;
950#endif
951
952 /* How about a struct tchars and a wordful of lmode bits? */
953#ifdef HAVE_TCHARS
954 if (ioctl (fd, TIOCSETC, &settings->tchars) < 0
955 || ioctl (fd, TIOCLSET, &settings->lmode) < 0)
956 return -1;
957#endif 844#endif
958 845
959 /* We have survived the tempest. */ 846 /* We have survived the tempest. */
@@ -976,13 +863,6 @@ unsigned char _sobuf[BUFSIZ+8];
976char _sobuf[BUFSIZ]; 863char _sobuf[BUFSIZ];
977#endif 864#endif
978 865
979#ifdef HAVE_LTCHARS
980static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1};
981#endif
982#ifdef HAVE_TCHARS
983static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
984#endif
985
986/* Initialize the terminal mode on all tty devices that are currently 866/* Initialize the terminal mode on all tty devices that are currently
987 open. */ 867 open. */
988 868
@@ -1016,7 +896,7 @@ init_sys_modes (struct tty_display_info *tty_out)
1016 896
1017 tty = *tty_out->old_tty; 897 tty = *tty_out->old_tty;
1018 898
1019#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) 899#if !defined (DOS_NT)
1020 XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]); 900 XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]);
1021 901
1022 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */ 902 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */
@@ -1088,12 +968,11 @@ init_sys_modes (struct tty_display_info *tty_out)
1088 of C-z */ 968 of C-z */
1089#endif /* VSWTCH */ 969#endif /* VSWTCH */
1090 970
1091#if defined (__mips__) || defined (HAVE_TCATTR)
1092#ifdef VSUSP 971#ifdef VSUSP
1093 tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */ 972 tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off handling of C-z. */
1094#endif /* VSUSP */ 973#endif /* VSUSP */
1095#ifdef V_DSUSP 974#ifdef V_DSUSP
1096 tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */ 975 tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off handling of C-y. */
1097#endif /* V_DSUSP */ 976#endif /* V_DSUSP */
1098#ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */ 977#ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */
1099 tty.main.c_cc[VDSUSP] = CDISABLE; 978 tty.main.c_cc[VDSUSP] = CDISABLE;
@@ -1129,7 +1008,6 @@ init_sys_modes (struct tty_display_info *tty_out)
1129 tty.main.c_cc[VSTOP] = CDISABLE; 1008 tty.main.c_cc[VSTOP] = CDISABLE;
1130#endif /* VSTOP */ 1009#endif /* VSTOP */
1131 } 1010 }
1132#endif /* mips or HAVE_TCATTR */
1133 1011
1134#ifdef AIX 1012#ifdef AIX
1135 tty.main.c_cc[VSTRT] = CDISABLE; 1013 tty.main.c_cc[VSTRT] = CDISABLE;
@@ -1152,41 +1030,8 @@ init_sys_modes (struct tty_display_info *tty_out)
1152 tty.main.c_iflag &= ~IGNBRK; 1030 tty.main.c_iflag &= ~IGNBRK;
1153 tty.main.c_iflag &= ~BRKINT; 1031 tty.main.c_iflag &= ~BRKINT;
1154#endif 1032#endif
1155#else /* if not HAVE_TERMIO */
1156#ifndef DOS_NT
1157 XSETINT (Vtty_erase_char, tty.main.sg_erase);
1158 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS);
1159 if (meta_key)
1160 tty.main.sg_flags |= ANYP;
1161 tty.main.sg_flags |= interrupt_input ? RAW : CBREAK;
1162#endif /* not DOS_NT */ 1033#endif /* not DOS_NT */
1163#endif /* not HAVE_TERMIO */
1164
1165 /* If going to use CBREAK mode, we must request C-g to interrupt
1166 and turn off start and stop chars, etc. If not going to use
1167 CBREAK mode, do this anyway so as to turn off local flow
1168 control for user coming over network on 4.2; in this case,
1169 only t_stopc and t_startc really matter. */
1170#ifndef HAVE_TERMIO
1171#ifdef HAVE_TCHARS
1172 /* Note: if not using CBREAK mode, it makes no difference how we
1173 set this */
1174 tty.tchars = new_tchars;
1175 tty.tchars.t_intrc = quit_char;
1176 if (tty_out->flow_control)
1177 {
1178 tty.tchars.t_startc = '\021';
1179 tty.tchars.t_stopc = '\023';
1180 }
1181 1034
1182 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
1183
1184#endif /* HAVE_TCHARS */
1185#endif /* not HAVE_TERMIO */
1186
1187#ifdef HAVE_LTCHARS
1188 tty.ltchars = new_ltchars;
1189#endif /* HAVE_LTCHARS */
1190#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ 1035#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */
1191 if (!tty_out->term_initted) 1036 if (!tty_out->term_initted)
1192 internal_terminal_init (); 1037 internal_terminal_init ();
@@ -1205,7 +1050,7 @@ init_sys_modes (struct tty_display_info *tty_out)
1205 if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0); 1050 if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0);
1206#endif 1051#endif
1207 1052
1208#if defined (HAVE_TERMIOS) || defined (HPUX) 1053#if !defined (DOS_NT)
1209#ifdef TCOON 1054#ifdef TCOON
1210 if (!tty_out->flow_control) tcflow (fileno (tty_out->input), TCOON); 1055 if (!tty_out->flow_control) tcflow (fileno (tty_out->input), TCOON);
1211#endif 1056#endif
@@ -2688,7 +2533,7 @@ strsignal (int code)
2688} 2533}
2689#endif /* HAVE_STRSIGNAL */ 2534#endif /* HAVE_STRSIGNAL */
2690 2535
2691#ifdef HAVE_TERMIOS 2536#ifndef DOS_NT
2692/* For make-serial-process */ 2537/* For make-serial-process */
2693int 2538int
2694serial_open (char *port) 2539serial_open (char *port)
@@ -2717,9 +2562,6 @@ serial_open (char *port)
2717 2562
2718 return fd; 2563 return fd;
2719} 2564}
2720#endif /* TERMIOS */
2721
2722#ifdef HAVE_TERMIOS
2723 2565
2724#if !defined (HAVE_CFMAKERAW) 2566#if !defined (HAVE_CFMAKERAW)
2725/* Workaround for targets which are missing cfmakeraw. */ 2567/* Workaround for targets which are missing cfmakeraw. */
@@ -2906,7 +2748,7 @@ serial_configure (struct Lisp_Process *p,
2906 p->childp = childp2; 2748 p->childp = childp2;
2907 2749
2908} 2750}
2909#endif /* TERMIOS */ 2751#endif /* not DOS_NT */
2910 2752
2911/* System depended enumeration of and access to system processes a-la ps(1). */ 2753/* System depended enumeration of and access to system processes a-la ps(1). */
2912 2754