aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan Nicolaescu2010-11-14 22:10:35 -0800
committerDan Nicolaescu2010-11-14 22:10:35 -0800
commit12e610e89e2a3ae9de569e12a57d310102952ce6 (patch)
treeb946605e1027b2a7c76e89cf7aab0abb962721e5 /src
parent92d3ab7e328831b39967bd92ad51c123a66756ce (diff)
downloademacs-12e610e89e2a3ae9de569e12a57d310102952ce6.tar.gz
emacs-12e610e89e2a3ae9de569e12a57d310102952ce6.zip
Clean up src/systty.h macros.
* systty.h (EMACS_GET_TTY_PGRP, EMACS_SET_TTY_PGRP, EMACS_GET_TTY) (EMACS_SET_TTY): Remove unneeded abstraction, instead inline the definition in all uses. (EMACS_TTY_TABS_OK): Remove, it has a single user. * src/sysdep.c (discard_tty_input, child_setup_tty) (init_sys_modes, tabs_safe_p, reset_sys_modes): * src/emacs.c (shut_down_emacs): * src/callproc.c (child_setup): * src/term.c (dissociate_if_controlling_tty): Inline removed macros.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/callproc.c4
-rw-r--r--src/emacs.c6
-rw-r--r--src/sysdep.c26
-rw-r--r--src/systty.h52
-rw-r--r--src/term.c7
6 files changed, 33 insertions, 73 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 84490e6db96..7bfd266b4d8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,16 @@
12010-11-15 Dan Nicolaescu <dann@ics.uci.edu> 12010-11-15 Dan Nicolaescu <dann@ics.uci.edu>
2 2
3 Clean up systty.h macros.
4 * systty.h (EMACS_GET_TTY_PGRP, EMACS_SET_TTY_PGRP, EMACS_GET_TTY)
5 (EMACS_SET_TTY): Remove unneeded abstraction, instead inline the
6 definition in all uses.
7 (EMACS_TTY_TABS_OK): Remove, it has a single user.
8 * sysdep.c (discard_tty_input, child_setup_tty)
9 (init_sys_modes, tabs_safe_p, reset_sys_modes):
10 * emacs.c (shut_down_emacs):
11 * callproc.c (child_setup):
12 * term.c (dissociate_if_controlling_tty): Inline removed macros.
13
3 * data.c (sign_extend_temp, sign_extend_lisp_int): Remove, unused. 14 * data.c (sign_extend_temp, sign_extend_lisp_int): Remove, unused.
4 15
52010-11-14 Chong Yidong <cyd@stupidchicken.com> 162010-11-14 Chong Yidong <cyd@stupidchicken.com>
diff --git a/src/callproc.c b/src/callproc.c
index ee0872b5562..5941f8180ff 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1221,7 +1221,7 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L
1221 return cpid; 1221 return cpid;
1222#else /* not WINDOWSNT */ 1222#else /* not WINDOWSNT */
1223 /* setpgrp_of_tty is incorrect here; it uses input_fd. */ 1223 /* setpgrp_of_tty is incorrect here; it uses input_fd. */
1224 EMACS_SET_TTY_PGRP (0, &pid); 1224 tcsetpgrp (0, pid);
1225 1225
1226 /* execvp does not accept an environment arg so the only way 1226 /* execvp does not accept an environment arg so the only way
1227 to pass this environment is to set environ. Our caller 1227 to pass this environment is to set environ. Our caller
@@ -1609,5 +1609,3 @@ See `setenv' and `getenv'. */);
1609 defsubr (&Scall_process_region); 1609 defsubr (&Scall_process_region);
1610} 1610}
1611 1611
1612/* arch-tag: 769b8045-1df7-4d2b-8968-e3fb49017f95
1613 (do not change this comment) */
diff --git a/src/emacs.c b/src/emacs.c
index 64da350e22c..97ffd1a74c7 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2053,10 +2053,8 @@ shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
2053#ifndef DOS_NT 2053#ifndef DOS_NT
2054 { 2054 {
2055 int pgrp = EMACS_GETPGRP (0); 2055 int pgrp = EMACS_GETPGRP (0);
2056 2056 int tpgrp = tcgetpgrp (0);
2057 int tpgrp; 2057 if ((tpgrp != -1) && tpgrp == pgrp)
2058 if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1
2059 && tpgrp == pgrp)
2060 { 2058 {
2061 reset_all_sys_modes (); 2059 reset_all_sys_modes ();
2062 if (sig && sig != SIGTERM) 2060 if (sig && sig != SIGTERM)
diff --git a/src/sysdep.c b/src/sysdep.c
index 84fa6d6b3b7..0c291dd80ac 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -229,8 +229,8 @@ discard_tty_input (void)
229 { 229 {
230 if (tty->input) /* Is the device suspended? */ 230 if (tty->input) /* Is the device suspended? */
231 { 231 {
232 EMACS_GET_TTY (fileno (tty->input), &buf); 232 emacs_get_tty (fileno (tty->input), &buf);
233 EMACS_SET_TTY (fileno (tty->input), &buf, 0); 233 emacs_set_tty (fileno (tty->input), &buf, 0);
234 } 234 }
235 } 235 }
236 } 236 }
@@ -366,7 +366,7 @@ child_setup_tty (int out)
366#ifndef WINDOWSNT 366#ifndef WINDOWSNT
367 struct emacs_tty s; 367 struct emacs_tty s;
368 368
369 EMACS_GET_TTY (out, &s); 369 emacs_get_tty (out, &s);
370 s.main.c_oflag |= OPOST; /* Enable output postprocessing */ 370 s.main.c_oflag |= OPOST; /* Enable output postprocessing */
371 s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */ 371 s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */
372#ifdef NLDLY 372#ifdef NLDLY
@@ -444,7 +444,7 @@ child_setup_tty (int out)
444 s.main.c_cc[VTIME] = 0; 444 s.main.c_cc[VTIME] = 0;
445#endif 445#endif
446 446
447 EMACS_SET_TTY (out, &s, 0); 447 emacs_set_tty (out, &s, 0);
448#endif /* not WINDOWSNT */ 448#endif /* not WINDOWSNT */
449} 449}
450#endif /* not MSDOS */ 450#endif /* not MSDOS */
@@ -856,7 +856,7 @@ init_sys_modes (struct tty_display_info *tty_out)
856 if (! tty_out->old_tty) 856 if (! tty_out->old_tty)
857 tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty)); 857 tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
858 858
859 EMACS_GET_TTY (fileno (tty_out->input), tty_out->old_tty); 859 emacs_get_tty (fileno (tty_out->input), tty_out->old_tty);
860 860
861 tty = *tty_out->old_tty; 861 tty = *tty_out->old_tty;
862 862
@@ -1002,7 +1002,7 @@ init_sys_modes (struct tty_display_info *tty_out)
1002 dos_ttraw (tty_out); 1002 dos_ttraw (tty_out);
1003#endif 1003#endif
1004 1004
1005 EMACS_SET_TTY (fileno (tty_out->input), &tty, 0); 1005 emacs_set_tty (fileno (tty_out->input), &tty, 0);
1006 1006
1007 /* This code added to insure that, if flow-control is not to be used, 1007 /* This code added to insure that, if flow-control is not to be used,
1008 we have an unlocked terminal at the start. */ 1008 we have an unlocked terminal at the start. */
@@ -1094,8 +1094,16 @@ tabs_safe_p (int fd)
1094{ 1094{
1095 struct emacs_tty etty; 1095 struct emacs_tty etty;
1096 1096
1097 EMACS_GET_TTY (fd, &etty); 1097 emacs_get_tty (fd, &etty);
1098 return EMACS_TTY_TABS_OK (&etty); 1098#ifndef DOS_NT
1099#ifdef TABDLY
1100 return ((etty.main.c_oflag & TABDLY) != TAB3);
1101#else /* not TABDLY */
1102 return 1;
1103#endif /* not TABDLY */
1104#else /* DOS_NT */
1105 return 0;
1106#endif /* DOS_NT */
1099} 1107}
1100 1108
1101/* Get terminal size from system. 1109/* Get terminal size from system.
@@ -1257,7 +1265,7 @@ reset_sys_modes (struct tty_display_info *tty_out)
1257#endif /* F_SETFL */ 1265#endif /* F_SETFL */
1258 1266
1259 if (tty_out->old_tty) 1267 if (tty_out->old_tty)
1260 while (EMACS_SET_TTY (fileno (tty_out->input), 1268 while (emacs_set_tty (fileno (tty_out->input),
1261 tty_out->old_tty, 0) < 0 && errno == EINTR) 1269 tty_out->old_tty, 0) < 0 && errno == EINTR)
1262 ; 1270 ;
1263 1271
diff --git a/src/systty.h b/src/systty.h
index 8c46411cedb..9cecbab4f0e 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -86,17 +86,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
86 86
87/* Manipulate a terminal's current process group. */ 87/* Manipulate a terminal's current process group. */
88 88
89/* EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
90 current process group. Return -1 if there is an error.
91
92 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
93 current process group to *PGID. Return -1 if there is an error. */
94
95#ifndef DOS_NT
96#define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
97#define EMACS_SET_TTY_PGRP(fd, pgid) (tcsetpgrp ((fd), *(pgid)))
98#endif /* not DOS_NT */
99
100/* EMACS_GETPGRP (arg) returns the process group of the process. */ 89/* EMACS_GETPGRP (arg) returns the process group of the process. */
101 90
102#if defined (GETPGRP_VOID) 91#if defined (GETPGRP_VOID)
@@ -112,21 +101,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
112 state, for example a struct tchars, a struct sgttyb, a struct 101 state, for example a struct tchars, a struct sgttyb, a struct
113 tchars, a struct ltchars, and a struct pagechars, struct 102 tchars, a struct ltchars, and a struct pagechars, struct
114 emacs_tty should contain an element for each parameter struct 103 emacs_tty should contain an element for each parameter struct
115 that Emacs may change. 104 that Emacs may change. */
116
117 EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the parameters
118 of the tty on FD in *P. Return zero if all's well, or -1 if we ran
119 into an error we couldn't deal with.
120
121 EMACS_SET_TTY (int FD, struct emacs_tty *P, int flushp)
122 sets the parameters of the tty on FD according to the contents of
123 *P. If flushp is non-zero, we discard queued input to be
124 written before making the change.
125 Return 0 if all went well, and -1 if anything failed.
126
127 EMACS_TTY_TABS_OK (struct emacs_tty *P) is false if the kernel
128 expands tabs to spaces upon output; in that case, there is no
129 advantage to using tabs over spaces. */
130 105
131 106
132/* For each tty parameter structure that Emacs might want to save and restore, 107/* For each tty parameter structure that Emacs might want to save and restore,
@@ -145,31 +120,6 @@ struct emacs_tty {
145#endif /* DOS_NT */ 120#endif /* DOS_NT */
146}; 121};
147 122
148/* Define EMACS_GET_TTY and EMACS_SET_TTY,
149 the macros for reading and setting parts of `struct emacs_tty'.
150
151 These got pretty unmanageable (huge macros are hard to debug), and
152 finally needed some code which couldn't be done as part of an
153 expression, so we moved them out to their own functions in sysdep.c. */
154#define EMACS_GET_TTY(fd, p) (emacs_get_tty ((fd), (p)))
155#define EMACS_SET_TTY(fd, p, waitp) (emacs_set_tty ((fd), (p), (waitp)))
156extern int emacs_get_tty (int, struct emacs_tty *); 123extern int emacs_get_tty (int, struct emacs_tty *);
157extern int emacs_set_tty (int, struct emacs_tty *, int); 124extern int emacs_set_tty (int, struct emacs_tty *, int);
158 125
159
160/* Define EMACS_TTY_TABS_OK. */
161
162#ifndef DOS_NT
163
164#ifdef TABDLY
165#define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
166#else /* not TABDLY */
167#define EMACS_TTY_TABS_OK(p) 1
168#endif /* not TABDLY */
169
170#else /* DOS_NT */
171#define EMACS_TTY_TABS_OK(p) 0
172#endif /* DOS_NT */
173
174/* arch-tag: cf4b90bc-be41-401c-be98-40619178a712
175 (do not change this comment) */
diff --git a/src/term.c b/src/term.c
index 71df92822ac..4d452ed3e00 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3087,8 +3087,7 @@ static void
3087dissociate_if_controlling_tty (int fd) 3087dissociate_if_controlling_tty (int fd)
3088{ 3088{
3089#ifndef DOS_NT 3089#ifndef DOS_NT
3090 int pgid; 3090 int pgid = tcgetpgrp (fd); /* If tcgetpgrp succeeds, fd is the ctty. */
3091 EMACS_GET_TTY_PGRP (fd, &pgid); /* If tcgetpgrp succeeds, fd is the ctty. */
3092 if (pgid != -1) 3091 if (pgid != -1)
3093 { 3092 {
3094#if defined (USG5) 3093#if defined (USG5)
@@ -3832,7 +3831,3 @@ bigger, or it may make it blink, or it may do nothing at all. */);
3832 encode_terminal_dst = NULL; 3831 encode_terminal_dst = NULL;
3833} 3832}
3834 3833
3835
3836
3837/* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193
3838 (do not change this comment) */