Commit 4a4bbad2 authored by Paul Eggert's avatar Paul Eggert
Browse files

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
parent bd8d6108
2012-09-13 Paul Eggert <eggert@cs.ucla.edu>
Simplify SIGIO usage (Bug#12408).
* 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'.
2012-09-12 Jan Djärv <jan.h.d@swipnet.se> 2012-09-12 Jan Djärv <jan.h.d@swipnet.se>
* configure.ac: No --with-x-toolkit given: Try gtk3 toolkit first * configure.ac: No --with-x-toolkit given: Try gtk3 toolkit first
......
...@@ -91,10 +91,6 @@ BROKEN_GET_CURRENT_DIR_NAME ...@@ -91,10 +91,6 @@ BROKEN_GET_CURRENT_DIR_NAME
BROKEN_NON_BLOCKING_CONNECT BROKEN_NON_BLOCKING_CONNECT
BROKEN_PTY_READ_AFTER_EAGAIN BROKEN_PTY_READ_AFTER_EAGAIN
BROKEN_SA_RESTART BROKEN_SA_RESTART
BROKEN_SIGAIO
BROKEN_SIGIO
BROKEN_SIGPOLL
BROKEN_SIGPTY
CLASH_DETECTION CLASH_DETECTION
DATA_SEG_BITS DATA_SEG_BITS
DATA_START DATA_START
...@@ -423,7 +419,6 @@ MAIL_USE_SYSTEM_LOCK ...@@ -423,7 +419,6 @@ MAIL_USE_SYSTEM_LOCK
MAXPATHLEN MAXPATHLEN
NLIST_STRUCT NLIST_STRUCT
NO_EDITRES NO_EDITRES
NO_TERMIO
NSIG NSIG
NSIG_MINIMUM NSIG_MINIMUM
NULL_DEVICE NULL_DEVICE
......
2012-09-13 Paul Eggert <eggert@cs.ucla.edu>
Simplify SIGIO usage (Bug#12408).
* CPP_DEFINES (BROKEN_SIGAIO, BROKEN_SIGIO, BROKEN_SIGPOLL)
(BROKEN_SIGPTY, NO_TERMIO): Remove.
2012-09-11 Paul Eggert <eggert@cs.ucla.edu> 2012-09-11 Paul Eggert <eggert@cs.ucla.edu>
Simplify, document, and port floating-point (Bug#12381). Simplify, document, and port floating-point (Bug#12381).
......
...@@ -3271,10 +3271,6 @@ esac ...@@ -3271,10 +3271,6 @@ esac
case $opsys in case $opsys in
darwin | gnu | hpux* | *bsd )
AC_DEFINE(NO_TERMIO, 1, [Define if termio.h should not be included.])
;;
irix6-5 | sol2* | unixware ) irix6-5 | sol2* | unixware )
dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments; dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
dnl instead, there's a system variable _sys_nsig. Unfortunately, we dnl instead, there's a system variable _sys_nsig. Unfortunately, we
...@@ -3284,26 +3280,16 @@ case $opsys in ...@@ -3284,26 +3280,16 @@ case $opsys in
;; ;;
esac esac
emacs_broken_SIGIO=no
case $opsys in case $opsys in
dnl SIGIO exists, but the feature doesn't work in the way Emacs needs. dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>. dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>.
hpux* | irix6-5 | openbsd | sol2* | unixware ) hpux* | irix6-5 | openbsd | sol2* | unixware )
AC_DEFINE(BROKEN_SIGIO, 1, [Define if SIGIO should not be used.]) emacs_broken_SIGIO=yes
;; ;;
aix4-2) aix4-2)
dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
AC_DEFINE(BROKEN_FIONREAD, 1, [Define if FIONREAD should not be used.])
dnl As we define BROKEN_FIONREAD, SIGIO will be undefined in systty.h.
dnl But, on AIX, SIGAIO, SIGPTY, and SIGPOLL are defined as SIGIO,
dnl which causes compilation error at init_signals in sysdep.c.
dnl So, we define these macros so that syssignal.h detects them
dnl and undefine SIGAIO, SIGPTY and SIGPOLL.
AC_DEFINE(BROKEN_SIGAIO, 1, [Define if SIGAIO should not be used.])
AC_DEFINE(BROKEN_SIGPOLL,1, [Define if SIGPOLL should not be used.])
AC_DEFINE(BROKEN_SIGPTY, 1, [Define if SIGPTY should not be used.])
dnl On AIX Emacs uses the gmalloc.c malloc implementation. But given dnl On AIX Emacs uses the gmalloc.c malloc implementation. But given
dnl the way this system works, libc functions that return malloced dnl the way this system works, libc functions that return malloced
dnl memory use the libc malloc implementation. Calling xfree or dnl memory use the libc malloc implementation. Calling xfree or
...@@ -3379,7 +3365,7 @@ dnl The choice is controlled by the variable interrupt_input. ...@@ -3379,7 +3365,7 @@ dnl The choice is controlled by the variable interrupt_input.
dnl dnl
dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO) dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
dnl dnl
dnl Emacs uses the presence or absence of the SIGIO and BROKEN_SIGIO macros dnl Emacs uses the presence of the USABLE_SIGIO macro
dnl to indicate whether or not signal-driven I/O is possible. It uses dnl to indicate whether or not signal-driven I/O is possible. It uses
dnl INTERRUPT_INPUT to decide whether to use it by default. dnl INTERRUPT_INPUT to decide whether to use it by default.
dnl dnl
...@@ -3900,6 +3886,46 @@ case $opsys in ...@@ -3900,6 +3886,46 @@ case $opsys in
;; ;;
esac esac
AC_CACHE_CHECK([for usable FIONREAD], [emacs_cv_usable_FIONREAD],
[case $opsys in
aix4-2)
dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
emacs_cv_usable_FIONREAD=no
;;
*)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/ioctl.h>
#ifdef USG5_4
# include <sys/filio.h>
#endif
]],
[[int foo = ioctl (0, FIONREAD, &foo);]])],
[emacs_cv_usable_FIONREAD=yes],
[emacs_cv_usable_FIONREAD=no])
;;
esac])
if test $emacs_cv_usable_FIONREAD = yes; then
AC_DEFINE([USABLE_FIONREAD], [1], [Define to 1 if FIONREAD is usable.])
if test $emacs_broken_SIGIO = no; then
AC_CACHE_CHECK([for usable SIGIO], [emacs_cv_usable_SIGIO],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <fcntl.h>
#include <signal.h>
]],
[[int foo = SIGIO | F_SETFL | FASYNC;]])],
[emacs_cv_usable_SIGIO=yes],
[emacs_cv_usable_SIGIO=no])],
[emacs_cv_usable_SIGIO=yes],
[emacs_cv_usable_SIGIO=no])
if test $emacs_cv_usable_SIGIO = yes; then
AC_DEFINE([USABLE_SIGIO], [1], [Define to 1 if SIGIO is usable.])
fi
fi
fi
case $opsys in case $opsys in
dnl Emacs supplies its own malloc, but glib (part of Gtk+) calls dnl Emacs supplies its own malloc, but glib (part of Gtk+) calls
......
2012-09-13 Paul Eggert <eggert@cs.ucla.edu> 2012-09-13 Paul Eggert <eggert@cs.ucla.edu>
   
Simplify SIGIO usage (Bug#12408).
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).
* 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.
* dispextern.h (ignore_sigio): New decl.
* emacs.c (shut_down_emacs): Invoke unrequest_sigio
unconditionally, since it's now a no-op if !USABLE_SIGIO.
* emacs.c (shut_down_emacs):
* keyboard.c (kbd_buffer_store_event_hold):
Use ignore_sigio rather than invoking 'signal' directly.
* 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.
* 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.
* 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.
* syssignal.h (croak): Remove decl.
(SIGIO, SIGPOO, SIGAIO, SIGPTY): Do not #undef; that's too fragile.
* 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.
* term.c (dissociate_if_controlling_tty): Use #error rather than
a run-time error.
Work around GCC and GNOME bugs when --enable-gcc-warnings. Work around GCC and GNOME bugs when --enable-gcc-warnings.
* emacsgtkfixed.c (G_STATIC_ASSERT): Redefine to use 'verify', * emacsgtkfixed.c (G_STATIC_ASSERT): Redefine to use 'verify',
to work around GNOME bug 683906. to work around GNOME bug 683906.
......
...@@ -67,15 +67,10 @@ extern int pending_atimers; ...@@ -67,15 +67,10 @@ extern int pending_atimers;
If doing signal-driven input, and a signal came in when input was If doing signal-driven input, and a signal came in when input was
blocked, reinvoke the signal handler now to deal with it. blocked, reinvoke the signal handler now to deal with it.
We used to have two possible definitions of this macro - one for Always test interrupt_input_pending; that's not too expensive, and
when SIGIO was #defined, and one for when it wasn't; when SIGIO it'll never get set if we don't need to resignal. This is simpler
wasn't #defined, we wouldn't bother to check if we should re-invoke than dealing here with every configuration option that might affect
the signal handler. But that doesn't work very well; some of the whether interrupt_input_pending can be nonzero. */
files which use this macro don't #include the right files to get
SIGIO.
So, we always test interrupt_input_pending now; that's not too
expensive, and it'll never get set if we don't need to resignal. */
#define UNBLOCK_INPUT \ #define UNBLOCK_INPUT \
do \ do \
......
...@@ -133,22 +133,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ ...@@ -133,22 +133,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
#endif #endif
#endif /* MSDOS */ #endif /* MSDOS */
#ifdef USG5_4
/* Get FIONREAD from <sys/filio.h>. Get <sys/ttold.h> to get struct tchars.
But get <termio.h> first to make sure ttold.h doesn't interfere. */
#include <sys/wait.h>
#ifdef emacs
#include <sys/filio.h>
#include <termio.h>
#include <sys/ttold.h>
#include <signal.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/termios.h>
#endif
#endif /* USG5_4 */
/* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs, /* Mac OS X / GNUstep need a bit more pure memory. Of the existing knobs,
SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */ SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */
#ifdef HAVE_NS #ifdef HAVE_NS
......
...@@ -3193,6 +3193,7 @@ void unrequest_sigio (void); ...@@ -3193,6 +3193,7 @@ void unrequest_sigio (void);
int tabs_safe_p (int); int tabs_safe_p (int);
void init_baud_rate (int); void init_baud_rate (int);
void init_sigio (int); void init_sigio (int);
void ignore_sigio (void);
/* Defined in xfaces.c */ /* Defined in xfaces.c */
......
...@@ -5971,7 +5971,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display) ...@@ -5971,7 +5971,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display)
wrong_type_argument (Qnumberp, timeout); wrong_type_argument (Qnumberp, timeout);
#ifdef SIGIO #ifdef USABLE_SIGIO
gobble_input (0); gobble_input (0);
#endif #endif
......
...@@ -2035,12 +2035,10 @@ shut_down_emacs (int sig, Lisp_Object stuff) ...@@ -2035,12 +2035,10 @@ shut_down_emacs (int sig, Lisp_Object stuff)
unlock_all_files (); unlock_all_files ();
#endif #endif
#ifdef SIGIO
/* There is a tendency for a SIGIO signal to arrive within exit, /* There is a tendency for a SIGIO signal to arrive within exit,
and cause a SIGHUP because the input descriptor is already closed. */ and cause a SIGHUP because the input descriptor is already closed. */
unrequest_sigio (); unrequest_sigio ();
signal (SIGIO, SIG_IGN); ignore_sigio ();
#endif
#ifdef WINDOWSNT #ifdef WINDOWSNT
term_ntproc (); term_ntproc ();
......
...@@ -56,6 +56,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -56,6 +56,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif /* not MSDOS */ #endif /* not MSDOS */
#if defined USABLE_FIONREAD && defined USG5_4
# include <sys/filio.h>
#endif
#include "syssignal.h" #include "syssignal.h"
#include <sys/types.h> #include <sys/types.h>
...@@ -385,19 +389,6 @@ int interrupt_input; ...@@ -385,19 +389,6 @@ int interrupt_input;
/* Nonzero while interrupts are temporarily deferred during redisplay. */ /* Nonzero while interrupts are temporarily deferred during redisplay. */
int interrupts_deferred; int interrupts_deferred;
/* Allow configure to inhibit use of FIONREAD. */
#ifdef BROKEN_FIONREAD
#undef FIONREAD
#endif
/* We are unable to use interrupts if FIONREAD is not available,
so flush SIGIO so we won't try. */
#if !defined (FIONREAD)
#ifdef SIGIO
#undef SIGIO
#endif
#endif
/* If we support a window system, turn on the code to poll periodically /* If we support a window system, turn on the code to poll periodically
to detect C-g. It isn't actually used when doing interrupt input. */ to detect C-g. It isn't actually used when doing interrupt input. */
#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) #if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS)
...@@ -448,7 +439,7 @@ static void restore_getcjmp (jmp_buf); ...@@ -448,7 +439,7 @@ static void restore_getcjmp (jmp_buf);
static Lisp_Object apply_modifiers (int, Lisp_Object); static Lisp_Object apply_modifiers (int, Lisp_Object);
static void clear_event (struct input_event *); static void clear_event (struct input_event *);
static Lisp_Object restore_kboard_configuration (Lisp_Object); static Lisp_Object restore_kboard_configuration (Lisp_Object);
#ifdef SIGIO #ifdef USABLE_SIGIO
static void deliver_input_available_signal (int signo); static void deliver_input_available_signal (int signo);
#endif #endif
static void handle_interrupt (void); static void handle_interrupt (void);
...@@ -3646,10 +3637,8 @@ kbd_buffer_store_event_hold (register struct input_event *event, ...@@ -3646,10 +3637,8 @@ kbd_buffer_store_event_hold (register struct input_event *event,
/* Don't read keyboard input until we have processed kbd_buffer. /* Don't read keyboard input until we have processed kbd_buffer.
This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ This happens when pasting text longer than KBD_BUFFER_SIZE/2. */
hold_keyboard_input (); hold_keyboard_input ();
#ifdef SIGIO
if (!noninteractive) if (!noninteractive)
signal (SIGIO, SIG_IGN); ignore_sigio ();
#endif
stop_polling (); stop_polling ();
} }
#endif /* subprocesses */ #endif /* subprocesses */
...@@ -3818,14 +3807,14 @@ kbd_buffer_get_event (KBOARD **kbp, ...@@ -3818,14 +3807,14 @@ kbd_buffer_get_event (KBOARD **kbp,
/* Start reading input again, we have processed enough so we can /* Start reading input again, we have processed enough so we can
accept new events again. */ accept new events again. */
unhold_keyboard_input (); unhold_keyboard_input ();
#ifdef SIGIO #ifdef USABLE_SIGIO
if (!noninteractive) if (!noninteractive)
{ {
struct sigaction action; struct sigaction action;
emacs_sigaction_init (&action, deliver_input_available_signal); emacs_sigaction_init (&action, deliver_input_available_signal);
sigaction (SIGIO, &action, 0); sigaction (SIGIO, &action, 0);
} }
#endif /* SIGIO */ #endif
start_polling (); start_polling ();
} }
#endif /* subprocesses */ #endif /* subprocesses */
...@@ -3867,10 +3856,9 @@ kbd_buffer_get_event (KBOARD **kbp, ...@@ -3867,10 +3856,9 @@ kbd_buffer_get_event (KBOARD **kbp,
/* One way or another, wait until input is available; then, if /* One way or another, wait until input is available; then, if
interrupt handlers have not read it, read it now. */ interrupt handlers have not read it, read it now. */
/* Note SIGIO has been undef'd if FIONREAD is missing. */ #ifdef USABLE_SIGIO
#ifdef SIGIO
gobble_input (0); gobble_input (0);
#endif /* SIGIO */ #endif
if (kbd_fetch_ptr != kbd_store_ptr) if (kbd_fetch_ptr != kbd_store_ptr)
break; break;
#if defined (HAVE_MOUSE) || defined (HAVE_GPM) #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
...@@ -6769,7 +6757,7 @@ get_input_pending (int *addr, int flags) ...@@ -6769,7 +6757,7 @@ get_input_pending (int *addr, int flags)
void void
gobble_input (int expected) gobble_input (int expected)
{ {
#ifdef SIGIO #ifdef USABLE_SIGIO
if (interrupt_input) if (interrupt_input)
{ {
sigset_t blocked, procmask; sigset_t blocked, procmask;
...@@ -6824,7 +6812,7 @@ record_asynch_buffer_change (void) ...@@ -6824,7 +6812,7 @@ record_asynch_buffer_change (void)
return; return;
/* Make sure no interrupt happens while storing the event. */ /* Make sure no interrupt happens while storing the event. */
#ifdef SIGIO #ifdef USABLE_SIGIO
if (interrupt_input) if (interrupt_input)
{ {
sigset_t blocked, procmask; sigset_t blocked, procmask;
...@@ -7050,7 +7038,7 @@ tty_read_avail_input (struct terminal *terminal, ...@@ -7050,7 +7038,7 @@ tty_read_avail_input (struct terminal *terminal,
#endif /* HAVE_GPM */ #endif /* HAVE_GPM */
/* Determine how many characters we should *try* to read. */ /* Determine how many characters we should *try* to read. */
#ifdef FIONREAD #ifdef USABLE_FIONREAD
/* Find out how much input is available. */ /* Find out how much input is available. */
if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
{ {
...@@ -7063,14 +7051,12 @@ tty_read_avail_input (struct terminal *terminal, ...@@ -7063,14 +7051,12 @@ tty_read_avail_input (struct terminal *terminal,
return 0; return 0;
if (n_to_read > sizeof cbuf) if (n_to_read > sizeof cbuf)
n_to_read = sizeof cbuf; n_to_read = sizeof cbuf;
#else /* no FIONREAD */ #elif defined USG || defined CYGWIN
#if defined (USG) || defined (CYGWIN)
/* Read some input if available, but don't wait. */ /* Read some input if available, but don't wait. */
n_to_read = sizeof cbuf; n_to_read = sizeof cbuf;
fcntl (fileno (tty->input), F_SETFL, O_NDELAY); fcntl (fileno (tty->input), F_SETFL, O_NDELAY);
#else #else
you lose; # error "Cannot read without possibly delaying"
#endif
#endif #endif
#ifdef subprocesses #ifdef subprocesses
...@@ -7119,7 +7105,7 @@ tty_read_avail_input (struct terminal *terminal, ...@@ -7119,7 +7105,7 @@ tty_read_avail_input (struct terminal *terminal,
#endif #endif
); );
#ifndef FIONREAD #ifndef USABLE_FIONREAD
#if defined (USG) || defined (CYGWIN) #if defined (USG) || defined (CYGWIN)
fcntl (fileno (tty->input), F_SETFL, 0); fcntl (fileno (tty->input), F_SETFL, 0);
#endif /* USG or CYGWIN */ #endif /* USG or CYGWIN */
...@@ -7190,7 +7176,7 @@ tty_read_avail_input (struct terminal *terminal, ...@@ -7190,7 +7176,7 @@ tty_read_avail_input (struct terminal *terminal,
return nread; return nread;
} }
#if defined SYNC_INPUT || defined SIGIO #if defined SYNC_INPUT || defined USABLE_SIGIO
static void static void
handle_async_input (void) handle_async_input (void)
{ {
...@@ -7217,7 +7203,7 @@ handle_async_input (void) ...@@ -7217,7 +7203,7 @@ handle_async_input (void)
--handling_signal; --handling_signal;
#endif #endif
} }
#endif /* SYNC_INPUT || SIGIO */ #endif /* SYNC_INPUT || USABLE_SIGIO */
#ifdef SYNC_INPUT #ifdef SYNC_INPUT
void void
...@@ -7229,8 +7215,7 @@ process_pending_signals (void) ...@@ -7229,8 +7215,7 @@ process_pending_signals (void)
} }
#endif #endif
#ifdef SIGIO /* for entire page */ #ifdef USABLE_SIGIO
/* Note SIGIO has been undef'd if FIONREAD is missing. */
static void static void
handle_input_available_signal (int sig) handle_input_available_signal (int sig)
...@@ -7253,7 +7238,7 @@ deliver_input_available_signal (int sig) ...@@ -7253,7 +7238,7 @@ deliver_input_available_signal (int sig)
{ {
handle_on_main_thread (sig, handle_input_available_signal); handle_on_main_thread (sig, handle_input_available_signal);
} }
#endif /* SIGIO */ #endif /* USABLE_SIGIO */
/* Send ourselves a SIGIO. /* Send ourselves a SIGIO.
...@@ -7264,7 +7249,7 @@ deliver_input_available_signal (int sig) ...@@ -7264,7 +7249,7 @@ deliver_input_available_signal (int sig)
void void
reinvoke_input_signal (void) reinvoke_input_signal (void)
{ {
#ifdef SIGIO #ifdef USABLE_SIGIO
handle_async_input (); handle_async_input ();
#endif #endif
} }
...@@ -7338,7 +7323,7 @@ handle_user_signal (int sig) ...@@ -7338,7 +7323,7 @@ handle_user_signal (int sig)
} }
p->npending++; p->npending++;
#ifdef SIGIO #ifdef USABLE_SIGIO
if (interrupt_input) if (interrupt_input)
kill (getpid (), SIGIO); kill (getpid (), SIGIO);
else else
...@@ -11007,8 +10992,7 @@ See also `current-input-mode'. */) ...@@ -11007,8 +10992,7 @@ See also `current-input-mode'. */)
(Lisp_Object interrupt) (Lisp_Object interrupt)
{ {
int new_interrupt_input; int new_interrupt_input;
#ifdef SIGIO #ifdef USABLE_SIGIO
/* Note SIGIO has been undef'd if FIONREAD is missing. */
#ifdef HAVE_X_WINDOWS #ifdef HAVE_X_WINDOWS
if (x_display_list != NULL) if (x_display_list != NULL)
{ {
...@@ -11019,9 +11003,9 @@ See also `current-input-mode'. */) ...@@ -11019,9 +11003,9 @@ See also `current-input-mode'. */)
else else
#endif /* HAVE_X_WINDOWS */ #endif /* HAVE_X_WINDOWS */
new_interrupt_input = !NILP (interrupt); new_interrupt_input = !NILP (interrupt);
#else /* not SIGIO */ #else /* not USABLE_SIGIO */
new_interrupt_input = 0; new_interrupt_input = 0;
#endif /* not SIGIO */ #endif /* not USABLE_SIGIO */
if (new_interrupt_input != interrupt_input) if (new_interrupt_input != interrupt_input)
{ {
...@@ -11415,15 +11399,14 @@ init_keyboard (void) ...@@ -11415,15 +11399,14 @@ init_keyboard (void)
sigaction (SIGQUIT, &action, 0); sigaction (SIGQUIT, &action, 0);
#endif /* not DOS_NT */ #endif /* not DOS_NT */
} }
/* Note SIGIO has been undef'd if FIONREAD is missing. */ #ifdef USABLE_SIGIO
#ifdef SIGIO
if (!noninteractive) if (!noninteractive)
{ {
struct sigaction action; struct sigaction action;
emacs_sigaction_init (&action, deliver_input_available_signal); emacs_sigaction_init (&action, deliver_input_available_signal);
sigaction (SIGIO, &action, 0); sigaction (SIGIO, &action, 0);
} }
#endif /* SIGIO */ #endif
/* Use interrupt input by default, if it works and noninterrupt input /* Use interrupt input by default, if it works and noninterrupt input
has deficiencies. */ has deficiencies. */
......
...@@ -75,6 +75,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ ...@@ -75,6 +75,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <bsdtty.h> #include <bsdtty.h>