From 4a4bbad21472cc0ede4691cbdbf8117b655b574f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 12 Sep 2012 19:21:28 -0700 Subject: [PATCH] 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 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 , for FIONREAD. (FIONREAD, SIGIO): Do not #undef. (tty_read_avail_input): Use #error rather than a syntax error. * src/process.c [USG5_4]: Include and , 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 ; 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 --- ChangeLog | 10 +++++ admin/CPP-DEFINES | 5 --- admin/ChangeLog | 6 +++ configure.ac | 60 +++++++++++++++++++++-------- src/ChangeLog | 36 +++++++++++++++++ src/blockinput.h | 13 ++----- src/conf_post.h | 16 -------- src/dispextern.h | 1 + src/dispnew.c | 2 +- src/emacs.c | 4 +- src/keyboard.c | 71 +++++++++++++--------------------- src/process.c | 29 +++++++------- src/sound.c | 12 +++--- src/sysdep.c | 98 +++++++++-------------------------------------- src/syssignal.h | 21 ---------- src/systty.h | 13 +------ src/term.c | 3 +- src/xterm.c | 4 +- 18 files changed, 171 insertions(+), 233 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8a7fdc2966..96cb4b2b89c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2012-09-13 Paul Eggert + + 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 * configure.ac: No --with-x-toolkit given: Try gtk3 toolkit first diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index cf6ffee2c63..834695d6c78 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -91,10 +91,6 @@ BROKEN_GET_CURRENT_DIR_NAME BROKEN_NON_BLOCKING_CONNECT BROKEN_PTY_READ_AFTER_EAGAIN BROKEN_SA_RESTART -BROKEN_SIGAIO -BROKEN_SIGIO -BROKEN_SIGPOLL -BROKEN_SIGPTY CLASH_DETECTION DATA_SEG_BITS DATA_START @@ -423,7 +419,6 @@ MAIL_USE_SYSTEM_LOCK MAXPATHLEN NLIST_STRUCT NO_EDITRES -NO_TERMIO NSIG NSIG_MINIMUM NULL_DEVICE diff --git a/admin/ChangeLog b/admin/ChangeLog index b70067d7465..25eed8af5e3 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog @@ -1,3 +1,9 @@ +2012-09-13 Paul Eggert + + Simplify SIGIO usage (Bug#12408). + * CPP_DEFINES (BROKEN_SIGAIO, BROKEN_SIGIO, BROKEN_SIGPOLL) + (BROKEN_SIGPTY, NO_TERMIO): Remove. + 2012-09-11 Paul Eggert Simplify, document, and port floating-point (Bug#12381). diff --git a/configure.ac b/configure.ac index ed1849514c1..3761d814364 100644 --- a/configure.ac +++ b/configure.ac @@ -3271,10 +3271,6 @@ esac case $opsys in - darwin | gnu | hpux* | *bsd ) - AC_DEFINE(NO_TERMIO, 1, [Define if termio.h should not be included.]) - ;; - irix6-5 | sol2* | unixware ) 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 @@ -3284,26 +3280,16 @@ case $opsys in ;; esac +emacs_broken_SIGIO=no case $opsys in dnl SIGIO exists, but the feature doesn't work in the way Emacs needs. dnl See eg . hpux* | irix6-5 | openbsd | sol2* | unixware ) - AC_DEFINE(BROKEN_SIGIO, 1, [Define if SIGIO should not be used.]) + emacs_broken_SIGIO=yes ;; 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 the way this system works, libc functions that return malloced dnl memory use the libc malloc implementation. Calling xfree or @@ -3379,7 +3365,7 @@ dnl The choice is controlled by the variable interrupt_input. dnl dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO) 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 INTERRUPT_INPUT to decide whether to use it by default. dnl @@ -3900,6 +3886,46 @@ case $opsys in ;; 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 + #include + #ifdef USG5_4 + # include + #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 + #include + ]], + [[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 dnl Emacs supplies its own malloc, but glib (part of Gtk+) calls diff --git a/src/ChangeLog b/src/ChangeLog index 29e8ea4232e..c8588b973f8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,41 @@ 2012-09-13 Paul Eggert + 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 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 , + for FIONREAD. + (FIONREAD, SIGIO): Do not #undef. + (tty_read_avail_input): Use #error rather than a syntax error. + * process.c [USG5_4]: Include and , + 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 ; 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. * emacsgtkfixed.c (G_STATIC_ASSERT): Redefine to use 'verify', 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; If doing signal-driven input, and a signal came in when input was blocked, reinvoke the signal handler now to deal with it. - We used to have two possible definitions of this macro - one for - when SIGIO was #defined, and one for when it wasn't; when SIGIO - wasn't #defined, we wouldn't bother to check if we should re-invoke - the signal handler. But that doesn't work very well; some of the - 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. */ + Always test interrupt_input_pending; that's not too expensive, and + it'll never get set if we don't need to resignal. This is simpler + than dealing here with every configuration option that might affect + whether interrupt_input_pending can be nonzero. */ #define UNBLOCK_INPUT \ 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 */ #endif #endif /* MSDOS */ -#ifdef USG5_4 -/* Get FIONREAD from . Get to get struct tchars. - But get first to make sure ttold.h doesn't interfere. */ -#include - -#ifdef emacs -#include -#include -#include -#include -#include -#include -#include -#endif -#endif /* USG5_4 */ - /* 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. */ #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); int tabs_safe_p (int); void init_baud_rate (int); void init_sigio (int); +void ignore_sigio (void); /* Defined in xfaces.c */ 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) wrong_type_argument (Qnumberp, timeout); -#ifdef SIGIO +#ifdef USABLE_SIGIO gobble_input (0); #endif 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) unlock_all_files (); #endif -#ifdef SIGIO /* There is a tendency for a SIGIO signal to arrive within exit, and cause a SIGHUP because the input descriptor is already closed. */ unrequest_sigio (); - signal (SIGIO, SIG_IGN); -#endif + ignore_sigio (); #ifdef WINDOWSNT 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 . */ #include #endif /* not MSDOS */ +#if defined USABLE_FIONREAD && defined USG5_4 +# include +#endif + #include "syssignal.h" #include @@ -385,19 +389,6 @@ int interrupt_input; /* Nonzero while interrupts are temporarily deferred during redisplay. */ 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 to detect C-g. It isn't actually used when doing interrupt input. */ #if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS) @@ -448,7 +439,7 @@ static void restore_getcjmp (jmp_buf); static Lisp_Object apply_modifiers (int, Lisp_Object); static void clear_event (struct input_event *); static Lisp_Object restore_kboard_configuration (Lisp_Object); -#ifdef SIGIO +#ifdef USABLE_SIGIO static void deliver_input_available_signal (int signo); #endif static void handle_interrupt (void); @@ -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. This happens when pasting text longer than KBD_BUFFER_SIZE/2. */ hold_keyboard_input (); -#ifdef SIGIO if (!noninteractive) - signal (SIGIO, SIG_IGN); -#endif + ignore_sigio (); stop_polling (); } #endif /* subprocesses */ @@ -3818,14 +3807,14 @@ kbd_buffer_get_event (KBOARD **kbp, /* Start reading input again, we have processed enough so we can accept new events again. */ unhold_keyboard_input (); -#ifdef SIGIO +#ifdef USABLE_SIGIO if (!noninteractive) { struct sigaction action; emacs_sigaction_init (&action, deliver_input_available_signal); sigaction (SIGIO, &action, 0); } -#endif /* SIGIO */ +#endif start_polling (); } #endif /* subprocesses */ @@ -3867,10 +3856,9 @@ kbd_buffer_get_event (KBOARD **kbp, /* One way or another, wait until input is available; then, if interrupt handlers have not read it, read it now. */ -/* Note SIGIO has been undef'd if FIONREAD is missing. */ -#ifdef SIGIO +#ifdef USABLE_SIGIO gobble_input (0); -#endif /* SIGIO */ +#endif if (kbd_fetch_ptr != kbd_store_ptr) break; #if defined (HAVE_MOUSE) || defined (HAVE_GPM) @@ -6769,7 +6757,7 @@ get_input_pending (int *addr, int flags) void gobble_input (int expected) { -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) { sigset_t blocked, procmask; @@ -6824,7 +6812,7 @@ record_asynch_buffer_change (void) return; /* Make sure no interrupt happens while storing the event. */ -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) { sigset_t blocked, procmask; @@ -7050,7 +7038,7 @@ tty_read_avail_input (struct terminal *terminal, #endif /* HAVE_GPM */ /* Determine how many characters we should *try* to read. */ -#ifdef FIONREAD +#ifdef USABLE_FIONREAD /* Find out how much input is available. */ if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) { @@ -7063,14 +7051,12 @@ tty_read_avail_input (struct terminal *terminal, return 0; if (n_to_read > sizeof cbuf) n_to_read = sizeof cbuf; -#else /* no FIONREAD */ -#if defined (USG) || defined (CYGWIN) +#elif defined USG || defined CYGWIN /* Read some input if available, but don't wait. */ n_to_read = sizeof cbuf; fcntl (fileno (tty->input), F_SETFL, O_NDELAY); #else - you lose; -#endif +# error "Cannot read without possibly delaying" #endif #ifdef subprocesses @@ -7119,7 +7105,7 @@ tty_read_avail_input (struct terminal *terminal, #endif ); -#ifndef FIONREAD +#ifndef USABLE_FIONREAD #if defined (USG) || defined (CYGWIN) fcntl (fileno (tty->input), F_SETFL, 0); #endif /* USG or CYGWIN */ @@ -7190,7 +7176,7 @@ tty_read_avail_input (struct terminal *terminal, return nread; } -#if defined SYNC_INPUT || defined SIGIO +#if defined SYNC_INPUT || defined USABLE_SIGIO static void handle_async_input (void) { @@ -7217,7 +7203,7 @@ handle_async_input (void) --handling_signal; #endif } -#endif /* SYNC_INPUT || SIGIO */ +#endif /* SYNC_INPUT || USABLE_SIGIO */ #ifdef SYNC_INPUT void @@ -7229,8 +7215,7 @@ process_pending_signals (void) } #endif -#ifdef SIGIO /* for entire page */ -/* Note SIGIO has been undef'd if FIONREAD is missing. */ +#ifdef USABLE_SIGIO static void handle_input_available_signal (int sig) @@ -7253,7 +7238,7 @@ deliver_input_available_signal (int sig) { handle_on_main_thread (sig, handle_input_available_signal); } -#endif /* SIGIO */ +#endif /* USABLE_SIGIO */ /* Send ourselves a SIGIO. @@ -7264,7 +7249,7 @@ deliver_input_available_signal (int sig) void reinvoke_input_signal (void) { -#ifdef SIGIO +#ifdef USABLE_SIGIO handle_async_input (); #endif } @@ -7338,7 +7323,7 @@ handle_user_signal (int sig) } p->npending++; -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) kill (getpid (), SIGIO); else @@ -11007,8 +10992,7 @@ See also `current-input-mode'. */) (Lisp_Object interrupt) { int new_interrupt_input; -#ifdef SIGIO -/* Note SIGIO has been undef'd if FIONREAD is missing. */ +#ifdef USABLE_SIGIO #ifdef HAVE_X_WINDOWS if (x_display_list != NULL) { @@ -11019,9 +11003,9 @@ See also `current-input-mode'. */) else #endif /* HAVE_X_WINDOWS */ new_interrupt_input = !NILP (interrupt); -#else /* not SIGIO */ +#else /* not USABLE_SIGIO */ new_interrupt_input = 0; -#endif /* not SIGIO */ +#endif /* not USABLE_SIGIO */ if (new_interrupt_input != interrupt_input) { @@ -11415,15 +11399,14 @@ init_keyboard (void) sigaction (SIGQUIT, &action, 0); #endif /* not DOS_NT */ } -/* Note SIGIO has been undef'd if FIONREAD is missing. */ -#ifdef SIGIO +#ifdef USABLE_SIGIO if (!noninteractive) { struct sigaction action; emacs_sigaction_init (&action, deliver_input_available_signal); sigaction (SIGIO, &action, 0); } -#endif /* SIGIO */ +#endif /* Use interrupt input by default, if it works and noninterrupt input 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 . */ #include #endif +#ifdef USG5_4 +# include +# include +#endif + #ifdef HAVE_RES_INIT #include #include @@ -212,17 +217,13 @@ static EMACS_INT update_tick; "non-destructive" select. So we require either native select, or emulation of select using FIONREAD. */ -#ifdef BROKEN_DATAGRAM_SOCKETS -#undef DATAGRAM_SOCKETS -#else -#ifndef DATAGRAM_SOCKETS -#if defined (HAVE_SELECT) || defined (FIONREAD) -#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE) -#define DATAGRAM_SOCKETS -#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */ -#endif /* HAVE_SELECT || FIONREAD */ -#endif /* DATAGRAM_SOCKETS */ -#endif /* BROKEN_DATAGRAM_SOCKETS */ +#ifndef BROKEN_DATAGRAM_SOCKETS +# if defined HAVE_SELECT || defined USABLE_FIONREAD +# if defined HAVE_SENDTO && defined HAVE_RECVFROM && defined EMSGSIZE +# define DATAGRAM_SOCKETS +# endif +# endif +#endif #if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS # define HAVE_SEQPACKET @@ -251,7 +252,7 @@ static int process_output_skip; #endif static void create_process (Lisp_Object, char **, Lisp_Object); -#ifdef SIGIO +#ifdef USABLE_SIGIO static int keyboard_bit_set (SELECT_TYPE *); #endif static void deactivate_process (Lisp_Object); @@ -4836,7 +4837,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) break; -#ifdef SIGIO +#ifdef USABLE_SIGIO /* If we think we have keyboard input waiting, but didn't get SIGIO, go read it. This can happen with X on BSD after logging out. In that case, there really is no input and no SIGIO, @@ -6853,7 +6854,7 @@ delete_gpm_wait_descriptor (int desc) # endif -# ifdef SIGIO +# ifdef USABLE_SIGIO /* Return nonzero if *MASK has a bit set 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) int saved_errno = errno; turn_on_atimers (1); -#ifdef SIGIO +#ifdef USABLE_SIGIO { sigset_t unblocked; sigemptyset (&unblocked); @@ -732,7 +732,7 @@ static void vox_configure (struct sound_device *sd) { int val; -#ifdef SIGIO +#ifdef USABLE_SIGIO sigset_t blocked; #endif @@ -742,7 +742,7 @@ vox_configure (struct sound_device *sd) interrupted by a signal. Block the ones we know to cause troubles. */ turn_on_atimers (0); -#ifdef SIGIO +#ifdef USABLE_SIGIO sigemptyset (&blocked); sigaddset (&blocked, SIGIO); pthread_sigmask (SIG_BLOCK, &blocked, 0); @@ -778,7 +778,7 @@ vox_configure (struct sound_device *sd) } turn_on_atimers (1); -#ifdef SIGIO +#ifdef USABLE_SIGIO pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #endif } @@ -794,7 +794,7 @@ vox_close (struct sound_device *sd) /* On GNU/Linux, it seems that the device driver doesn't like to be interrupted by a signal. Block the ones we know to cause troubles. */ -#ifdef SIGIO +#ifdef USABLE_SIGIO sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGIO); @@ -806,7 +806,7 @@ vox_close (struct sound_device *sd) ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); turn_on_atimers (1); -#ifdef SIGIO +#ifdef USABLE_SIGIO pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #endif 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 *); static int emacs_get_tty (int, struct emacs_tty *); static int emacs_set_tty (int, struct emacs_tty *, int); -#if defined TIOCNOTTY || defined USG5 || defined CYGWIN -static _Noreturn void croak (char *); -#endif /* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781. */ #ifndef ULLONG_MAX @@ -513,7 +510,7 @@ sys_subshell (void) saved_handlers[0].code = SIGINT; saved_handlers[1].code = SIGQUIT; saved_handlers[2].code = SIGTERM; -#ifdef SIGIO +#ifdef USABLE_SIGIO saved_handlers[3].code = SIGIO; saved_handlers[4].code = 0; #else @@ -642,121 +639,75 @@ restore_signal_handlers (struct save_signal *saved_handlers) } } -#ifndef SIGIO -/* If SIGIO is broken, don't do anything. */ -void -init_sigio (int fd) -{ -} - -static void -reset_sigio (int fd) -{ -} - -void -request_sigio (void) -{ -} - -void -unrequest_sigio (void) -{ -} - -#else -#ifdef F_SETFL - +#ifdef USABLE_SIGIO static int old_fcntl_flags[MAXDESC]; +#endif void init_sigio (int fd) { -#ifdef FASYNC +#ifdef USABLE_SIGIO old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); -#endif interrupts_deferred = 0; +#endif } static void reset_sigio (int fd) { -#ifdef FASYNC +#ifdef USABLE_SIGIO fcntl (fd, F_SETFL, old_fcntl_flags[fd]); #endif } -#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ -/* XXX Uhm, FASYNC is not used anymore here. */ -/* XXX Yeah, but you need it for SIGIO, don't you? */ - void request_sigio (void) { +#ifdef USABLE_SIGIO sigset_t unblocked; if (noninteractive) return; sigemptyset (&unblocked); -#ifdef SIGWINCH +# ifdef SIGWINCH sigaddset (&unblocked, SIGWINCH); -#endif +# endif sigaddset (&unblocked, SIGIO); pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); interrupts_deferred = 0; +#endif } void unrequest_sigio (void) { +#ifdef USABLE_SIGIO sigset_t blocked; if (noninteractive) return; -#if 0 /* XXX What's wrong with blocking SIGIO under X? */ - if (x_display_list) - return; -#endif - sigemptyset (&blocked); -#ifdef SIGWINCH +# ifdef SIGWINCH sigaddset (&blocked, SIGWINCH); -#endif +# endif sigaddset (&blocked, SIGIO); pthread_sigmask (SIG_BLOCK, &blocked, 0); interrupts_deferred = 1; -} - -#else /* no FASYNC */ -#ifndef MSDOS - -void -request_sigio (void) -{ - if (noninteractive || read_socket_hook) - return; - - croak ("request_sigio"); +#endif } void -unrequest_sigio (void) +ignore_sigio (void) { - if (noninteractive || read_socket_hook) - return; - - croak ("unrequest_sigio"); +#ifdef USABLE_SIGIO + signal (SIGIO, SIG_IGN); +#endif } -#endif /* MSDOS */ -#endif /* FASYNC */ -#endif /* F_SETFL */ -#endif /* SIGIO */ - /* Getting and setting emacs_tty structures. */ @@ -2051,19 +2002,6 @@ getwd (char *pathname) } #endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */ - -/* - * This function will go away as soon as all the stubs fixed. (fnf) - */ - -void -croak (char *badfunc) -{ - printf ("%s not yet implemented\r\n", badfunc); - reset_all_sys_modes (); - exit (1); -} - #endif /* USG */ /* 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); extern void emacs_sigaction_init (struct sigaction *, signal_handler_t); -#if ! (defined TIOCNOTTY || defined USG5 || defined CYGWIN) -_Noreturn void croak (char *); -#endif - -/* Interrupt input is not used if there is no FIONREAD. */ -#include -#if defined BROKEN_SIGIO || ! defined FIONREAD || defined BROKEN_FIONREAD -# undef SIGIO -#endif - -/* These are only used by AIX */ -#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) -#undef SIGPOLL -#endif -#if defined (SIGAIO) && defined (BROKEN_SIGAIO) -#undef SIGAIO -#endif -#if defined (SIGPTY) && defined (BROKEN_SIGPTY) -#undef SIGPTY -#endif - #if NSIG < NSIG_MINIMUM # undef NSIG # 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 along with GNU Emacs. If not, see . */ /* Include the proper files. */ + #ifndef DOS_NT -#ifndef NO_TERMIO -#include -#endif /* not NO_TERMIO */ #include #include #endif /* not DOS_NT */ @@ -38,15 +36,6 @@ along with GNU Emacs. If not, see . */ #include - -/* Special cases - inhibiting the use of certain features. */ - -/* Allow configure to inhibit use of FIONREAD. */ -#ifdef BROKEN_FIONREAD -#undef FIONREAD -#undef ASYNC -#endif - /* Try to establish the correct character to disable terminal functions in a system-independent manner. Note that USG (at least) define 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) emacs_close (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #else - /* Unknown system. */ - croak (); +# error "Unknown system." #endif /* ! TIOCNOTTY */ #endif /* ! USG */ } 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", { sigset_t unblocked; sigemptyset (&unblocked); -#ifdef SIGIO +#ifdef USABLE_SIGIO sigaddset (&unblocked, SIGIO); #endif sigaddset (&unblocked, SIGALRM); @@ -10421,10 +10421,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) fcntl (connection, F_SETOWN, getpid ()); #endif /* ! defined (F_SETOWN) */ -#ifdef SIGIO if (interrupt_input) init_sigio (connection); -#endif /* ! defined (SIGIO) */ #ifdef USE_LUCID { -- 2.39.2