aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-09-12 19:21:28 -0700
committerPaul Eggert2012-09-12 19:21:28 -0700
commit4a4bbad21472cc0ede4691cbdbf8117b655b574f (patch)
tree5c74092d854ca8b770578b8b7f99f5f3a9e65ca2 /src
parentbd8d610845a89c2cf5d7d75ff552df572b30f5e7 (diff)
downloademacs-4a4bbad21472cc0ede4691cbdbf8117b655b574f.tar.gz
emacs-4a4bbad21472cc0ede4691cbdbf8117b655b574f.zip
Simplify SIGIO usage.
The code that dealt with SIGIO was crufty and confusing, e.g., it played tricks like "#undef SIGIO" but these tricks were not used consistently. Simplify mostly by not #undeffing standard symbols, e.g., use "defined USABLE_SIGIO" (our symbol, which we can define or not as we please) rather than "defined SIGIO" (standard symbol that we probably shouldn't #undef). * configure.ac (NO_TERMIO, BROKEN_FIONREAD, BROKEN_SIGAIO) (BROKEN_SIGPOLL, BROKEN_SIGPTY): Remove. (USABLE_FIONREAD, USABLE_SIGIO): New symbols. All uses of 'defined SIGIO' replaced with 'defined USABLE_SIGIO', with no need to #undef SIGIO now (which was error-prone). Likewise, all uses of 'defined FIONREAD' replaced with 'defined USABLE_FIONREAD'. * src/admin/CPP_DEFINES (BROKEN_SIGAIO, BROKEN_SIGIO, BROKEN_SIGPOLL) (BROKEN_SIGPTY, NO_TERMIO): Remove. * src/conf_post.h [USG5_4]: Do not include <sys/wait.h> here. Modules that need it can include it. [USG5_4 && emacs]: Likewise, do not include the streams stuff here. * src/dispextern.h (ignore_sigio): New decl. * src/emacs.c (shut_down_emacs): Invoke unrequest_sigio unconditionally, since it's now a no-op if !USABLE_SIGIO. * src/emacs.c (shut_down_emacs): * src/keyboard.c (kbd_buffer_store_event_hold): Use ignore_sigio rather than invoking 'signal' directly. * src/keyboard.c (USABLE_FIONREAD && USG5_4): Include <sys/filio.h>, for FIONREAD. (FIONREAD, SIGIO): Do not #undef. (tty_read_avail_input): Use #error rather than a syntax error. * src/process.c [USG5_4]: Include <sys/stream.h> and <sys/stropts.h>, for I_PIPE, used by SETUP_SLAVE_PTY. (DATAGRAM_SOCKETS): Simplify defn, based on USABLE_FIONREAD. * src/sysdep.c (croak): Remove; no longer needed. This bit of temporary code, with Fred N. Fish's comment that it's temporary, has been in Emacs since at least 1992! (init_sigio, reset_sigio, request_sigio, unrequest_sigio): Arrange for them to be no-ops in all cases when ! USABLE_SIGIO. * src/syssignal.h (croak): Remove decl. (SIGIO, SIGPOO, SIGAIO, SIGPTY): Do not #undef; that's too fragile. * src/systty.h [!NO_TERMIO]: Do not include <termio.h>; no longer needed now that we're termios-only. (FIONREAD, ASYNC) [BROKEN_FIONREAD]: Do not #undef. * src/term.c (dissociate_if_controlling_tty): Use #error rather than a run-time error. Fixes: debbugs:12408
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog36
-rw-r--r--src/blockinput.h13
-rw-r--r--src/conf_post.h16
-rw-r--r--src/dispextern.h1
-rw-r--r--src/dispnew.c2
-rw-r--r--src/emacs.c4
-rw-r--r--src/keyboard.c71
-rw-r--r--src/process.c29
-rw-r--r--src/sound.c12
-rw-r--r--src/sysdep.c98
-rw-r--r--src/syssignal.h21
-rw-r--r--src/systty.h13
-rw-r--r--src/term.c3
-rw-r--r--src/xterm.c4
14 files changed, 112 insertions, 211 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 29e8ea4232e..c8588b973f8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,41 @@
12012-09-13 Paul Eggert <eggert@cs.ucla.edu> 12012-09-13 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Simplify SIGIO usage (Bug#12408).
4 The code that dealt with SIGIO was crufty and confusing, e.g., it
5 played tricks like "#undef SIGIO" but these tricks were not used
6 consistently. Simplify mostly by not #undeffing standard symbols,
7 e.g., use "defined USABLE_SIGIO" (our symbol, which we can define
8 or not as we please) rather than "defined SIGIO" (standard symbol
9 that we probably shouldn't #undef).
10 * conf_post.h [USG5_4]: Do not include <sys/wait.h> here.
11 Modules that need it can include it.
12 [USG5_4 && emacs]: Likewise, do not include the streams stuff here.
13 * dispextern.h (ignore_sigio): New decl.
14 * emacs.c (shut_down_emacs): Invoke unrequest_sigio
15 unconditionally, since it's now a no-op if !USABLE_SIGIO.
16 * emacs.c (shut_down_emacs):
17 * keyboard.c (kbd_buffer_store_event_hold):
18 Use ignore_sigio rather than invoking 'signal' directly.
19 * keyboard.c (USABLE_FIONREAD && USG5_4): Include <sys/filio.h>,
20 for FIONREAD.
21 (FIONREAD, SIGIO): Do not #undef.
22 (tty_read_avail_input): Use #error rather than a syntax error.
23 * process.c [USG5_4]: Include <sys/stream.h> and <sys/stropts.h>,
24 for I_PIPE, used by SETUP_SLAVE_PTY.
25 (DATAGRAM_SOCKETS): Simplify defn, based on USABLE_FIONREAD.
26 * sysdep.c (croak): Remove; no longer needed. This bit of
27 temporary code, with Fred N. Fish's comment that it's temporary,
28 has been in Emacs since at least 1992!
29 (init_sigio, reset_sigio, request_sigio, unrequest_sigio):
30 Arrange for them to be no-ops in all cases when ! USABLE_SIGIO.
31 * syssignal.h (croak): Remove decl.
32 (SIGIO, SIGPOO, SIGAIO, SIGPTY): Do not #undef; that's too fragile.
33 * systty.h [!NO_TERMIO]: Do not include <termio.h>; no longer needed
34 now that we're termios-only.
35 (FIONREAD, ASYNC) [BROKEN_FIONREAD]: Do not #undef.
36 * term.c (dissociate_if_controlling_tty): Use #error rather than
37 a run-time error.
38
3 Work around GCC and GNOME bugs when --enable-gcc-warnings. 39 Work around GCC and GNOME bugs when --enable-gcc-warnings.
4 * emacsgtkfixed.c (G_STATIC_ASSERT): Redefine to use 'verify', 40 * emacsgtkfixed.c (G_STATIC_ASSERT): Redefine to use 'verify',
5 to work around GNOME bug 683906. 41 to work around GNOME bug 683906.
diff --git a/src/blockinput.h b/src/blockinput.h
index 3f61b2b27b9..7501bfc91a0 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -67,15 +67,10 @@ extern int pending_atimers;
67 If doing signal-driven input, and a signal came in when input was 67 If doing signal-driven input, and a signal came in when input was
68 blocked, reinvoke the signal handler now to deal with it. 68 blocked, reinvoke the signal handler now to deal with it.
69 69
70 We used to have two possible definitions of this macro - one for 70 Always test interrupt_input_pending; that's not too expensive, and
71 when SIGIO was #defined, and one for when it wasn't; when SIGIO 71 it'll never get set if we don't need to resignal. This is simpler
72 wasn't #defined, we wouldn't bother to check if we should re-invoke 72 than dealing here with every configuration option that might affect
73 the signal handler. But that doesn't work very well; some of the 73 whether interrupt_input_pending can be nonzero. */
74 files which use this macro don't #include the right files to get
75 SIGIO.
76
77 So, we always test interrupt_input_pending now; that's not too
78 expensive, and it'll never get set if we don't need to resignal. */
79 74
80#define UNBLOCK_INPUT \ 75#define UNBLOCK_INPUT \
81 do \ 76 do \
diff --git a/src/conf_post.h b/src/conf_post.h
index 1bf40af260b..94934ffeadf 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -133,22 +133,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
133#endif 133#endif
134#endif /* MSDOS */ 134#endif /* MSDOS */
135 135
136#ifdef USG5_4
137/* Get FIONREAD from <sys/filio.h>. Get <sys/ttold.h> to get struct tchars.
138 But get <termio.h> first to make sure ttold.h doesn't interfere. */
139#include <sys/wait.h>
140
141#ifdef emacs
142#include <sys/filio.h>
143#include <termio.h>
144#include <sys/ttold.h>
145#include <signal.h>
146#include <sys/stream.h>
147#include <sys/stropts.h>
148#include <sys/termios.h>
149#endif
150#endif /* USG5_4 */
151
152/* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs, 136/* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs,
153 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */ 137 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */
154#ifdef HAVE_NS 138#ifdef HAVE_NS
diff --git a/src/dispextern.h b/src/dispextern.h
index 73f3350713f..365e8bcdcee 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3193,6 +3193,7 @@ void unrequest_sigio (void);
3193int tabs_safe_p (int); 3193int tabs_safe_p (int);
3194void init_baud_rate (int); 3194void init_baud_rate (int);
3195void init_sigio (int); 3195void init_sigio (int);
3196void ignore_sigio (void);
3196 3197
3197/* Defined in xfaces.c */ 3198/* Defined in xfaces.c */
3198 3199
diff --git a/src/dispnew.c b/src/dispnew.c
index fae415dcaf2..f6186e86048 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5971,7 +5971,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display)
5971 wrong_type_argument (Qnumberp, timeout); 5971 wrong_type_argument (Qnumberp, timeout);
5972 5972
5973 5973
5974#ifdef SIGIO 5974#ifdef USABLE_SIGIO
5975 gobble_input (0); 5975 gobble_input (0);
5976#endif 5976#endif
5977 5977
diff --git a/src/emacs.c b/src/emacs.c
index deaed25d9e8..e8150631311 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2035,12 +2035,10 @@ shut_down_emacs (int sig, Lisp_Object stuff)
2035 unlock_all_files (); 2035 unlock_all_files ();
2036#endif 2036#endif
2037 2037
2038#ifdef SIGIO
2039 /* There is a tendency for a SIGIO signal to arrive within exit, 2038 /* There is a tendency for a SIGIO signal to arrive within exit,
2040 and cause a SIGHUP because the input descriptor is already closed. */ 2039 and cause a SIGHUP because the input descriptor is already closed. */
2041 unrequest_sigio (); 2040 unrequest_sigio ();
2042 signal (SIGIO, SIG_IGN); 2041 ignore_sigio ();
2043#endif
2044 2042
2045#ifdef WINDOWSNT 2043#ifdef WINDOWSNT
2046 term_ntproc (); 2044 term_ntproc ();
diff --git a/src/keyboard.c b/src/keyboard.c
index 7be3e9e118e..aec9028ae94 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -56,6 +56,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
56#include <sys/ioctl.h> 56#include <sys/ioctl.h>
57#endif /* not MSDOS */ 57#endif /* not MSDOS */
58 58
59#if defined USABLE_FIONREAD && defined USG5_4
60# include <sys/filio.h>
61#endif
62
59#include "syssignal.h" 63#include "syssignal.h"
60 64
61#include <sys/types.h> 65#include <sys/types.h>
@@ -385,19 +389,6 @@ int interrupt_input;
385/* Nonzero while interrupts are temporarily deferred during redisplay. */ 389/* Nonzero while interrupts are temporarily deferred during redisplay. */
386int interrupts_deferred; 390int interrupts_deferred;
387 391
388/* Allow configure to inhibit use of FIONREAD. */
389#ifdef BROKEN_FIONREAD
390#undef FIONREAD
391#endif
392
393/* We are unable to use interrupts if FIONREAD is not available,
394 so flush SIGIO so we won't try. */
395#if !defined (FIONREAD)
396#ifdef SIGIO
397#undef SIGIO
398#endif
399#endif
400
401/* If we support a window system, turn on the code to poll periodically 392/* If we support a window system, turn on the code to poll periodically
402 to detect C-g. It isn't actually used when doing interrupt input. */ 393 to detect C-g. It isn't actually used when doing interrupt input. */
403#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) 394#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS)
@@ -448,7 +439,7 @@ static void restore_getcjmp (jmp_buf);
448static Lisp_Object apply_modifiers (int, Lisp_Object); 439static Lisp_Object apply_modifiers (int, Lisp_Object);
449static void clear_event (struct input_event *); 440static void clear_event (struct input_event *);
450static Lisp_Object restore_kboard_configuration (Lisp_Object); 441static Lisp_Object restore_kboard_configuration (Lisp_Object);
451#ifdef SIGIO 442#ifdef USABLE_SIGIO
452static void deliver_input_available_signal (int signo); 443static void deliver_input_available_signal (int signo);
453#endif 444#endif
454static void handle_interrupt (void); 445static void handle_interrupt (void);
@@ -3646,10 +3637,8 @@ kbd_buffer_store_event_hold (register struct input_event *event,
3646 /* Don't read keyboard input until we have processed kbd_buffer. 3637 /* Don't read keyboard input until we have processed kbd_buffer.
3647 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ 3638 This happens when pasting text longer than KBD_BUFFER_SIZE/2. */
3648 hold_keyboard_input (); 3639 hold_keyboard_input ();
3649#ifdef SIGIO
3650 if (!noninteractive) 3640 if (!noninteractive)
3651 signal (SIGIO, SIG_IGN); 3641 ignore_sigio ();
3652#endif
3653 stop_polling (); 3642 stop_polling ();
3654 } 3643 }
3655#endif /* subprocesses */ 3644#endif /* subprocesses */
@@ -3818,14 +3807,14 @@ kbd_buffer_get_event (KBOARD **kbp,
3818 /* Start reading input again, we have processed enough so we can 3807 /* Start reading input again, we have processed enough so we can
3819 accept new events again. */ 3808 accept new events again. */
3820 unhold_keyboard_input (); 3809 unhold_keyboard_input ();
3821#ifdef SIGIO 3810#ifdef USABLE_SIGIO
3822 if (!noninteractive) 3811 if (!noninteractive)
3823 { 3812 {
3824 struct sigaction action; 3813 struct sigaction action;
3825 emacs_sigaction_init (&action, deliver_input_available_signal); 3814 emacs_sigaction_init (&action, deliver_input_available_signal);
3826 sigaction (SIGIO, &action, 0); 3815 sigaction (SIGIO, &action, 0);
3827 } 3816 }
3828#endif /* SIGIO */ 3817#endif
3829 start_polling (); 3818 start_polling ();
3830 } 3819 }
3831#endif /* subprocesses */ 3820#endif /* subprocesses */
@@ -3867,10 +3856,9 @@ kbd_buffer_get_event (KBOARD **kbp,
3867 /* One way or another, wait until input is available; then, if 3856 /* One way or another, wait until input is available; then, if
3868 interrupt handlers have not read it, read it now. */ 3857 interrupt handlers have not read it, read it now. */
3869 3858
3870/* Note SIGIO has been undef'd if FIONREAD is missing. */ 3859#ifdef USABLE_SIGIO
3871#ifdef SIGIO
3872 gobble_input (0); 3860 gobble_input (0);
3873#endif /* SIGIO */ 3861#endif
3874 if (kbd_fetch_ptr != kbd_store_ptr) 3862 if (kbd_fetch_ptr != kbd_store_ptr)
3875 break; 3863 break;
3876#if defined (HAVE_MOUSE) || defined (HAVE_GPM) 3864#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
@@ -6769,7 +6757,7 @@ get_input_pending (int *addr, int flags)
6769void 6757void
6770gobble_input (int expected) 6758gobble_input (int expected)
6771{ 6759{
6772#ifdef SIGIO 6760#ifdef USABLE_SIGIO
6773 if (interrupt_input) 6761 if (interrupt_input)
6774 { 6762 {
6775 sigset_t blocked, procmask; 6763 sigset_t blocked, procmask;
@@ -6824,7 +6812,7 @@ record_asynch_buffer_change (void)
6824 return; 6812 return;
6825 6813
6826 /* Make sure no interrupt happens while storing the event. */ 6814 /* Make sure no interrupt happens while storing the event. */
6827#ifdef SIGIO 6815#ifdef USABLE_SIGIO
6828 if (interrupt_input) 6816 if (interrupt_input)
6829 { 6817 {
6830 sigset_t blocked, procmask; 6818 sigset_t blocked, procmask;
@@ -7050,7 +7038,7 @@ tty_read_avail_input (struct terminal *terminal,
7050#endif /* HAVE_GPM */ 7038#endif /* HAVE_GPM */
7051 7039
7052/* Determine how many characters we should *try* to read. */ 7040/* Determine how many characters we should *try* to read. */
7053#ifdef FIONREAD 7041#ifdef USABLE_FIONREAD
7054 /* Find out how much input is available. */ 7042 /* Find out how much input is available. */
7055 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) 7043 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
7056 { 7044 {
@@ -7063,14 +7051,12 @@ tty_read_avail_input (struct terminal *terminal,
7063 return 0; 7051 return 0;
7064 if (n_to_read > sizeof cbuf) 7052 if (n_to_read > sizeof cbuf)
7065 n_to_read = sizeof cbuf; 7053 n_to_read = sizeof cbuf;
7066#else /* no FIONREAD */ 7054#elif defined USG || defined CYGWIN
7067#if defined (USG) || defined (CYGWIN)
7068 /* Read some input if available, but don't wait. */ 7055 /* Read some input if available, but don't wait. */
7069 n_to_read = sizeof cbuf; 7056 n_to_read = sizeof cbuf;
7070 fcntl (fileno (tty->input), F_SETFL, O_NDELAY); 7057 fcntl (fileno (tty->input), F_SETFL, O_NDELAY);
7071#else 7058#else
7072 you lose; 7059# error "Cannot read without possibly delaying"
7073#endif
7074#endif 7060#endif
7075 7061
7076#ifdef subprocesses 7062#ifdef subprocesses
@@ -7119,7 +7105,7 @@ tty_read_avail_input (struct terminal *terminal,
7119#endif 7105#endif
7120 ); 7106 );
7121 7107
7122#ifndef FIONREAD 7108#ifndef USABLE_FIONREAD
7123#if defined (USG) || defined (CYGWIN) 7109#if defined (USG) || defined (CYGWIN)
7124 fcntl (fileno (tty->input), F_SETFL, 0); 7110 fcntl (fileno (tty->input), F_SETFL, 0);
7125#endif /* USG or CYGWIN */ 7111#endif /* USG or CYGWIN */
@@ -7190,7 +7176,7 @@ tty_read_avail_input (struct terminal *terminal,
7190 return nread; 7176 return nread;
7191} 7177}
7192 7178
7193#if defined SYNC_INPUT || defined SIGIO 7179#if defined SYNC_INPUT || defined USABLE_SIGIO
7194static void 7180static void
7195handle_async_input (void) 7181handle_async_input (void)
7196{ 7182{
@@ -7217,7 +7203,7 @@ handle_async_input (void)
7217 --handling_signal; 7203 --handling_signal;
7218#endif 7204#endif
7219} 7205}
7220#endif /* SYNC_INPUT || SIGIO */ 7206#endif /* SYNC_INPUT || USABLE_SIGIO */
7221 7207
7222#ifdef SYNC_INPUT 7208#ifdef SYNC_INPUT
7223void 7209void
@@ -7229,8 +7215,7 @@ process_pending_signals (void)
7229} 7215}
7230#endif 7216#endif
7231 7217
7232#ifdef SIGIO /* for entire page */ 7218#ifdef USABLE_SIGIO
7233/* Note SIGIO has been undef'd if FIONREAD is missing. */
7234 7219
7235static void 7220static void
7236handle_input_available_signal (int sig) 7221handle_input_available_signal (int sig)
@@ -7253,7 +7238,7 @@ deliver_input_available_signal (int sig)
7253{ 7238{
7254 handle_on_main_thread (sig, handle_input_available_signal); 7239 handle_on_main_thread (sig, handle_input_available_signal);
7255} 7240}
7256#endif /* SIGIO */ 7241#endif /* USABLE_SIGIO */
7257 7242
7258/* Send ourselves a SIGIO. 7243/* Send ourselves a SIGIO.
7259 7244
@@ -7264,7 +7249,7 @@ deliver_input_available_signal (int sig)
7264void 7249void
7265reinvoke_input_signal (void) 7250reinvoke_input_signal (void)
7266{ 7251{
7267#ifdef SIGIO 7252#ifdef USABLE_SIGIO
7268 handle_async_input (); 7253 handle_async_input ();
7269#endif 7254#endif
7270} 7255}
@@ -7338,7 +7323,7 @@ handle_user_signal (int sig)
7338 } 7323 }
7339 7324
7340 p->npending++; 7325 p->npending++;
7341#ifdef SIGIO 7326#ifdef USABLE_SIGIO
7342 if (interrupt_input) 7327 if (interrupt_input)
7343 kill (getpid (), SIGIO); 7328 kill (getpid (), SIGIO);
7344 else 7329 else
@@ -11007,8 +10992,7 @@ See also `current-input-mode'. */)
11007 (Lisp_Object interrupt) 10992 (Lisp_Object interrupt)
11008{ 10993{
11009 int new_interrupt_input; 10994 int new_interrupt_input;
11010#ifdef SIGIO 10995#ifdef USABLE_SIGIO
11011/* Note SIGIO has been undef'd if FIONREAD is missing. */
11012#ifdef HAVE_X_WINDOWS 10996#ifdef HAVE_X_WINDOWS
11013 if (x_display_list != NULL) 10997 if (x_display_list != NULL)
11014 { 10998 {
@@ -11019,9 +11003,9 @@ See also `current-input-mode'. */)
11019 else 11003 else
11020#endif /* HAVE_X_WINDOWS */ 11004#endif /* HAVE_X_WINDOWS */
11021 new_interrupt_input = !NILP (interrupt); 11005 new_interrupt_input = !NILP (interrupt);
11022#else /* not SIGIO */ 11006#else /* not USABLE_SIGIO */
11023 new_interrupt_input = 0; 11007 new_interrupt_input = 0;
11024#endif /* not SIGIO */ 11008#endif /* not USABLE_SIGIO */
11025 11009
11026 if (new_interrupt_input != interrupt_input) 11010 if (new_interrupt_input != interrupt_input)
11027 { 11011 {
@@ -11415,15 +11399,14 @@ init_keyboard (void)
11415 sigaction (SIGQUIT, &action, 0); 11399 sigaction (SIGQUIT, &action, 0);
11416#endif /* not DOS_NT */ 11400#endif /* not DOS_NT */
11417 } 11401 }
11418/* Note SIGIO has been undef'd if FIONREAD is missing. */ 11402#ifdef USABLE_SIGIO
11419#ifdef SIGIO
11420 if (!noninteractive) 11403 if (!noninteractive)
11421 { 11404 {
11422 struct sigaction action; 11405 struct sigaction action;
11423 emacs_sigaction_init (&action, deliver_input_available_signal); 11406 emacs_sigaction_init (&action, deliver_input_available_signal);
11424 sigaction (SIGIO, &action, 0); 11407 sigaction (SIGIO, &action, 0);
11425 } 11408 }
11426#endif /* SIGIO */ 11409#endif
11427 11410
11428/* Use interrupt input by default, if it works and noninterrupt input 11411/* Use interrupt input by default, if it works and noninterrupt input
11429 has deficiencies. */ 11412 has deficiencies. */
diff --git a/src/process.c b/src/process.c
index f80b5e80c76..b4b05a4b2e2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -75,6 +75,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
75#include <bsdtty.h> 75#include <bsdtty.h>
76#endif 76#endif
77 77
78#ifdef USG5_4
79# include <sys/stream.h>
80# include <sys/stropts.h>
81#endif
82
78#ifdef HAVE_RES_INIT 83#ifdef HAVE_RES_INIT
79#include <netinet/in.h> 84#include <netinet/in.h>
80#include <arpa/nameser.h> 85#include <arpa/nameser.h>
@@ -212,17 +217,13 @@ static EMACS_INT update_tick;
212 "non-destructive" select. So we require either native select, 217 "non-destructive" select. So we require either native select,
213 or emulation of select using FIONREAD. */ 218 or emulation of select using FIONREAD. */
214 219
215#ifdef BROKEN_DATAGRAM_SOCKETS 220#ifndef BROKEN_DATAGRAM_SOCKETS
216#undef DATAGRAM_SOCKETS 221# if defined HAVE_SELECT || defined USABLE_FIONREAD
217#else 222# if defined HAVE_SENDTO && defined HAVE_RECVFROM && defined EMSGSIZE
218#ifndef DATAGRAM_SOCKETS 223# define DATAGRAM_SOCKETS
219#if defined (HAVE_SELECT) || defined (FIONREAD) 224# endif
220#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE) 225# endif
221#define DATAGRAM_SOCKETS 226#endif
222#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */
223#endif /* HAVE_SELECT || FIONREAD */
224#endif /* DATAGRAM_SOCKETS */
225#endif /* BROKEN_DATAGRAM_SOCKETS */
226 227
227#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS 228#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS
228# define HAVE_SEQPACKET 229# define HAVE_SEQPACKET
@@ -251,7 +252,7 @@ static int process_output_skip;
251#endif 252#endif
252 253
253static void create_process (Lisp_Object, char **, Lisp_Object); 254static void create_process (Lisp_Object, char **, Lisp_Object);
254#ifdef SIGIO 255#ifdef USABLE_SIGIO
255static int keyboard_bit_set (SELECT_TYPE *); 256static int keyboard_bit_set (SELECT_TYPE *);
256#endif 257#endif
257static void deactivate_process (Lisp_Object); 258static void deactivate_process (Lisp_Object);
@@ -4836,7 +4837,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4836 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 4837 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4837 break; 4838 break;
4838 4839
4839#ifdef SIGIO 4840#ifdef USABLE_SIGIO
4840 /* If we think we have keyboard input waiting, but didn't get SIGIO, 4841 /* If we think we have keyboard input waiting, but didn't get SIGIO,
4841 go read it. This can happen with X on BSD after logging out. 4842 go read it. This can happen with X on BSD after logging out.
4842 In that case, there really is no input and no SIGIO, 4843 In that case, there really is no input and no SIGIO,
@@ -6853,7 +6854,7 @@ delete_gpm_wait_descriptor (int desc)
6853 6854
6854# endif 6855# endif
6855 6856
6856# ifdef SIGIO 6857# ifdef USABLE_SIGIO
6857 6858
6858/* Return nonzero if *MASK has a bit set 6859/* Return nonzero if *MASK has a bit set
6859 that corresponds to one of the keyboard input descriptors. */ 6860 that corresponds to one of the keyboard input descriptors. */
diff --git a/src/sound.c b/src/sound.c
index 5729d704b6a..fe48bb277b2 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -314,7 +314,7 @@ sound_perror (const char *msg)
314 int saved_errno = errno; 314 int saved_errno = errno;
315 315
316 turn_on_atimers (1); 316 turn_on_atimers (1);
317#ifdef SIGIO 317#ifdef USABLE_SIGIO
318 { 318 {
319 sigset_t unblocked; 319 sigset_t unblocked;
320 sigemptyset (&unblocked); 320 sigemptyset (&unblocked);
@@ -732,7 +732,7 @@ static void
732vox_configure (struct sound_device *sd) 732vox_configure (struct sound_device *sd)
733{ 733{
734 int val; 734 int val;
735#ifdef SIGIO 735#ifdef USABLE_SIGIO
736 sigset_t blocked; 736 sigset_t blocked;
737#endif 737#endif
738 738
@@ -742,7 +742,7 @@ vox_configure (struct sound_device *sd)
742 interrupted by a signal. Block the ones we know to cause 742 interrupted by a signal. Block the ones we know to cause
743 troubles. */ 743 troubles. */
744 turn_on_atimers (0); 744 turn_on_atimers (0);
745#ifdef SIGIO 745#ifdef USABLE_SIGIO
746 sigemptyset (&blocked); 746 sigemptyset (&blocked);
747 sigaddset (&blocked, SIGIO); 747 sigaddset (&blocked, SIGIO);
748 pthread_sigmask (SIG_BLOCK, &blocked, 0); 748 pthread_sigmask (SIG_BLOCK, &blocked, 0);
@@ -778,7 +778,7 @@ vox_configure (struct sound_device *sd)
778 } 778 }
779 779
780 turn_on_atimers (1); 780 turn_on_atimers (1);
781#ifdef SIGIO 781#ifdef USABLE_SIGIO
782 pthread_sigmask (SIG_UNBLOCK, &blocked, 0); 782 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
783#endif 783#endif
784} 784}
@@ -794,7 +794,7 @@ vox_close (struct sound_device *sd)
794 /* On GNU/Linux, it seems that the device driver doesn't like to 794 /* On GNU/Linux, it seems that the device driver doesn't like to
795 be interrupted by a signal. Block the ones we know to cause 795 be interrupted by a signal. Block the ones we know to cause
796 troubles. */ 796 troubles. */
797#ifdef SIGIO 797#ifdef USABLE_SIGIO
798 sigset_t blocked; 798 sigset_t blocked;
799 sigemptyset (&blocked); 799 sigemptyset (&blocked);
800 sigaddset (&blocked, SIGIO); 800 sigaddset (&blocked, SIGIO);
@@ -806,7 +806,7 @@ vox_close (struct sound_device *sd)
806 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); 806 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);
807 807
808 turn_on_atimers (1); 808 turn_on_atimers (1);
809#ifdef SIGIO 809#ifdef USABLE_SIGIO
810 pthread_sigmask (SIG_UNBLOCK, &blocked, 0); 810 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
811#endif 811#endif
812 812
diff --git a/src/sysdep.c b/src/sysdep.c
index 0f16d1a7645..b8f35e79146 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -107,9 +107,6 @@ extern char *getwd (char *);
107 107
108static int emacs_get_tty (int, struct emacs_tty *); 108static int emacs_get_tty (int, struct emacs_tty *);
109static int emacs_set_tty (int, struct emacs_tty *, int); 109static int emacs_set_tty (int, struct emacs_tty *, int);
110#if defined TIOCNOTTY || defined USG5 || defined CYGWIN
111static _Noreturn void croak (char *);
112#endif
113 110
114/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ 111/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */
115#ifndef ULLONG_MAX 112#ifndef ULLONG_MAX
@@ -513,7 +510,7 @@ sys_subshell (void)
513 saved_handlers[0].code = SIGINT; 510 saved_handlers[0].code = SIGINT;
514 saved_handlers[1].code = SIGQUIT; 511 saved_handlers[1].code = SIGQUIT;
515 saved_handlers[2].code = SIGTERM; 512 saved_handlers[2].code = SIGTERM;
516#ifdef SIGIO 513#ifdef USABLE_SIGIO
517 saved_handlers[3].code = SIGIO; 514 saved_handlers[3].code = SIGIO;
518 saved_handlers[4].code = 0; 515 saved_handlers[4].code = 0;
519#else 516#else
@@ -642,121 +639,75 @@ restore_signal_handlers (struct save_signal *saved_handlers)
642 } 639 }
643} 640}
644 641
645#ifndef SIGIO 642#ifdef USABLE_SIGIO
646/* If SIGIO is broken, don't do anything. */
647void
648init_sigio (int fd)
649{
650}
651
652static void
653reset_sigio (int fd)
654{
655}
656
657void
658request_sigio (void)
659{
660}
661
662void
663unrequest_sigio (void)
664{
665}
666
667#else
668#ifdef F_SETFL
669
670static int old_fcntl_flags[MAXDESC]; 643static int old_fcntl_flags[MAXDESC];
644#endif
671 645
672void 646void
673init_sigio (int fd) 647init_sigio (int fd)
674{ 648{
675#ifdef FASYNC 649#ifdef USABLE_SIGIO
676 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; 650 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC;
677 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); 651 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC);
678#endif
679 interrupts_deferred = 0; 652 interrupts_deferred = 0;
653#endif
680} 654}
681 655
682static void 656static void
683reset_sigio (int fd) 657reset_sigio (int fd)
684{ 658{
685#ifdef FASYNC 659#ifdef USABLE_SIGIO
686 fcntl (fd, F_SETFL, old_fcntl_flags[fd]); 660 fcntl (fd, F_SETFL, old_fcntl_flags[fd]);
687#endif 661#endif
688} 662}
689 663
690#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */
691/* XXX Uhm, FASYNC is not used anymore here. */
692/* XXX Yeah, but you need it for SIGIO, don't you? */
693
694void 664void
695request_sigio (void) 665request_sigio (void)
696{ 666{
667#ifdef USABLE_SIGIO
697 sigset_t unblocked; 668 sigset_t unblocked;
698 669
699 if (noninteractive) 670 if (noninteractive)
700 return; 671 return;
701 672
702 sigemptyset (&unblocked); 673 sigemptyset (&unblocked);
703#ifdef SIGWINCH 674# ifdef SIGWINCH
704 sigaddset (&unblocked, SIGWINCH); 675 sigaddset (&unblocked, SIGWINCH);
705#endif 676# endif
706 sigaddset (&unblocked, SIGIO); 677 sigaddset (&unblocked, SIGIO);
707 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); 678 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
708 679
709 interrupts_deferred = 0; 680 interrupts_deferred = 0;
681#endif
710} 682}
711 683
712void 684void
713unrequest_sigio (void) 685unrequest_sigio (void)
714{ 686{
687#ifdef USABLE_SIGIO
715 sigset_t blocked; 688 sigset_t blocked;
716 689
717 if (noninteractive) 690 if (noninteractive)
718 return; 691 return;
719 692
720#if 0 /* XXX What's wrong with blocking SIGIO under X? */
721 if (x_display_list)
722 return;
723#endif
724
725 sigemptyset (&blocked); 693 sigemptyset (&blocked);
726#ifdef SIGWINCH 694# ifdef SIGWINCH
727 sigaddset (&blocked, SIGWINCH); 695 sigaddset (&blocked, SIGWINCH);
728#endif 696# endif
729 sigaddset (&blocked, SIGIO); 697 sigaddset (&blocked, SIGIO);
730 pthread_sigmask (SIG_BLOCK, &blocked, 0); 698 pthread_sigmask (SIG_BLOCK, &blocked, 0);
731 interrupts_deferred = 1; 699 interrupts_deferred = 1;
732} 700#endif
733
734#else /* no FASYNC */
735#ifndef MSDOS
736
737void
738request_sigio (void)
739{
740 if (noninteractive || read_socket_hook)
741 return;
742
743 croak ("request_sigio");
744} 701}
745 702
746void 703void
747unrequest_sigio (void) 704ignore_sigio (void)
748{ 705{
749 if (noninteractive || read_socket_hook) 706#ifdef USABLE_SIGIO
750 return; 707 signal (SIGIO, SIG_IGN);
751 708#endif
752 croak ("unrequest_sigio");
753} 709}
754 710
755#endif /* MSDOS */
756#endif /* FASYNC */
757#endif /* F_SETFL */
758#endif /* SIGIO */
759
760 711
761/* Getting and setting emacs_tty structures. */ 712/* Getting and setting emacs_tty structures. */
762 713
@@ -2051,19 +2002,6 @@ getwd (char *pathname)
2051} 2002}
2052 2003
2053#endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */ 2004#endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */
2054
2055/*
2056 * This function will go away as soon as all the stubs fixed. (fnf)
2057 */
2058
2059void
2060croak (char *badfunc)
2061{
2062 printf ("%s not yet implemented\r\n", badfunc);
2063 reset_all_sys_modes ();
2064 exit (1);
2065}
2066
2067#endif /* USG */ 2005#endif /* USG */
2068 2006
2069/* Directory routines for systems that don't have them. */ 2007/* Directory routines for systems that don't have them. */
diff --git a/src/syssignal.h b/src/syssignal.h
index c5529ae718a..5e733dd812d 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -34,27 +34,6 @@ typedef void (*signal_handler_t) (int);
34 34
35extern void emacs_sigaction_init (struct sigaction *, signal_handler_t); 35extern void emacs_sigaction_init (struct sigaction *, signal_handler_t);
36 36
37#if ! (defined TIOCNOTTY || defined USG5 || defined CYGWIN)
38_Noreturn void croak (char *);
39#endif
40
41/* Interrupt input is not used if there is no FIONREAD. */
42#include <sys/ioctl.h>
43#if defined BROKEN_SIGIO || ! defined FIONREAD || defined BROKEN_FIONREAD
44# undef SIGIO
45#endif
46
47/* These are only used by AIX */
48#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
49#undef SIGPOLL
50#endif
51#if defined (SIGAIO) && defined (BROKEN_SIGAIO)
52#undef SIGAIO
53#endif
54#if defined (SIGPTY) && defined (BROKEN_SIGPTY)
55#undef SIGPTY
56#endif
57
58#if NSIG < NSIG_MINIMUM 37#if NSIG < NSIG_MINIMUM
59# undef NSIG 38# undef NSIG
60# define NSIG NSIG_MINIMUM 39# define NSIG NSIG_MINIMUM
diff --git a/src/systty.h b/src/systty.h
index b660441a91e..b7f36c6c259 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -17,10 +17,8 @@ You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18 18
19/* Include the proper files. */ 19/* Include the proper files. */
20
20#ifndef DOS_NT 21#ifndef DOS_NT
21#ifndef NO_TERMIO
22#include <termio.h>
23#endif /* not NO_TERMIO */
24#include <termios.h> 22#include <termios.h>
25#include <fcntl.h> 23#include <fcntl.h>
26#endif /* not DOS_NT */ 24#endif /* not DOS_NT */
@@ -39,15 +37,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
39#include <unistd.h> 37#include <unistd.h>
40 38
41 39
42/* Special cases - inhibiting the use of certain features. */
43
44/* Allow configure to inhibit use of FIONREAD. */
45#ifdef BROKEN_FIONREAD
46#undef FIONREAD
47#undef ASYNC
48#endif
49
50
51/* Try to establish the correct character to disable terminal functions 40/* Try to establish the correct character to disable terminal functions
52 in a system-independent manner. Note that USG (at least) define 41 in a system-independent manner. Note that USG (at least) define
53 _POSIX_VDISABLE as 0! */ 42 _POSIX_VDISABLE as 0! */
diff --git a/src/term.c b/src/term.c
index 0eaf76a13df..47bde5ac240 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2944,8 +2944,7 @@ dissociate_if_controlling_tty (int fd)
2944 emacs_close (fd); 2944 emacs_close (fd);
2945 pthread_sigmask (SIG_UNBLOCK, &blocked, 0); 2945 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
2946#else 2946#else
2947 /* Unknown system. */ 2947# error "Unknown system."
2948 croak ();
2949#endif /* ! TIOCNOTTY */ 2948#endif /* ! TIOCNOTTY */
2950#endif /* ! USG */ 2949#endif /* ! USG */
2951 } 2950 }
diff --git a/src/xterm.c b/src/xterm.c
index e5a5932beae..54d4f14bdd0 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7878,7 +7878,7 @@ For details, see etc/PROBLEMS.\n",
7878 { 7878 {
7879 sigset_t unblocked; 7879 sigset_t unblocked;
7880 sigemptyset (&unblocked); 7880 sigemptyset (&unblocked);
7881#ifdef SIGIO 7881#ifdef USABLE_SIGIO
7882 sigaddset (&unblocked, SIGIO); 7882 sigaddset (&unblocked, SIGIO);
7883#endif 7883#endif
7884 sigaddset (&unblocked, SIGALRM); 7884 sigaddset (&unblocked, SIGALRM);
@@ -10421,10 +10421,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10421 fcntl (connection, F_SETOWN, getpid ()); 10421 fcntl (connection, F_SETOWN, getpid ());
10422#endif /* ! defined (F_SETOWN) */ 10422#endif /* ! defined (F_SETOWN) */
10423 10423
10424#ifdef SIGIO
10425 if (interrupt_input) 10424 if (interrupt_input)
10426 init_sigio (connection); 10425 init_sigio (connection);
10427#endif /* ! defined (SIGIO) */
10428 10426
10429#ifdef USE_LUCID 10427#ifdef USE_LUCID
10430 { 10428 {