From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#12408: Simplify SIGIO usage Date: Mon, 10 Sep 2012 22:14:25 -0700 Organization: UCLA Computer Science Department Message-ID: <504EC8B1.1010203@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1347340536 10908 80.91.229.3 (11 Sep 2012 05:15:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Sep 2012 05:15:36 +0000 (UTC) To: 12408@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 11 07:15:37 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TBIoy-0008Lc-QR for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Sep 2012 07:15:37 +0200 Original-Received: from localhost ([::1]:35439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBIov-0006nR-A5 for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Sep 2012 01:15:33 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBIop-0006mg-FH for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 01:15:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBIom-0002Qs-Fn for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 01:15:27 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBIom-0002Qm-Aw for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 01:15:24 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TBIpO-0007Qz-Ah for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 01:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Sep 2012 05:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12408 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.134734052328528 (code B ref -1); Tue, 11 Sep 2012 05:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Sep 2012 05:15:23 +0000 Original-Received: from localhost ([127.0.0.1]:53381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBIoj-0007Q4-GX for submit@debbugs.gnu.org; Tue, 11 Sep 2012 01:15:23 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50362) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBIod-0007Pr-Vc for submit@debbugs.gnu.org; Tue, 11 Sep 2012 01:15:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBIny-0001ik-Hf for submit@debbugs.gnu.org; Tue, 11 Sep 2012 01:14:37 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:44436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBIny-0001if-E8 for submit@debbugs.gnu.org; Tue, 11 Sep 2012 01:14:34 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBInv-0006AT-FO for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 01:14:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBInr-0001hr-S7 for bug-gnu-emacs@gnu.org; Tue, 11 Sep 2012 01:14:31 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:42228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBInr-0001hb-EM; Tue, 11 Sep 2012 01:14:27 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id AC67D39E800A; Mon, 10 Sep 2012 22:14:26 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sY-s3ZxUwFfO; Mon, 10 Sep 2012 22:14:24 -0700 (PDT) Original-Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 39B6D39E8008; Mon, 10 Sep 2012 22:14:24 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:64086 Archived-At: Here's my next signal-handling cleanup patch, which I plan to install after a bit more testing. This one is mostly just a cleanup and shouldn't break the Windows port, but it does affect low-level code of interest to Windows so I'll CC: it to Eli. === modified file 'ChangeLog' --- ChangeLog 2012-09-11 02:28:27 +0000 +++ ChangeLog 2012-09-11 04:34:42 +0000 @@ -1,5 +1,13 @@ 2012-09-11 Paul Eggert + Simplify SIGIO usage. + * 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'. + Simplify, document, and port floating-point (Bug#12381). * configure.ac (logb, cbrt): Do not check for these functions, as they are not being used. === modified file 'admin/CPP-DEFINES' --- admin/CPP-DEFINES 2012-09-11 02:28:27 +0000 +++ admin/CPP-DEFINES 2012-09-11 04:34:42 +0000 @@ -91,10 +91,6 @@ 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 @@ MAXPATHLEN NLIST_STRUCT NO_EDITRES -NO_TERMIO NSIG NSIG_MINIMUM NULL_DEVICE === modified file 'admin/ChangeLog' --- admin/ChangeLog 2012-09-11 02:28:27 +0000 +++ admin/ChangeLog 2012-09-11 04:34:42 +0000 @@ -1,5 +1,9 @@ 2012-09-11 Paul Eggert + Simplify SIGIO usage. + * CPP_DEFINES (BROKEN_SIGAIO, BROKEN_SIGIO, BROKEN_SIGPOLL) + (BROKEN_SIGPTY, NO_TERMIO): Remove. + Simplify, document, and port floating-point (Bug#12381). * CPP-DEFINES (HAVE_CBRT, HAVE_LOGB, logb): Remove. === modified file 'configure.ac' --- configure.ac 2012-09-11 02:28:27 +0000 +++ configure.ac 2012-09-11 04:34:42 +0000 @@ -3260,10 +3260,6 @@ 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 @@ -3273,26 +3269,16 @@ ;; 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 @@ -3368,7 +3354,7 @@ 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 @@ -3889,6 +3875,46 @@ ;; 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 === modified file 'src/ChangeLog' --- src/ChangeLog 2012-09-11 03:32:41 +0000 +++ src/ChangeLog 2012-09-11 04:34:42 +0000 @@ -1,3 +1,41 @@ +2012-09-11 Paul Eggert + + 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 mess with). + * 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. + 2012-09-11 YAMAMOTO Mitsuharu * xdisp.c (right_overwritten, right_overwriting): Also handle gstring === modified file 'src/blockinput.h' --- src/blockinput.h 2012-09-04 17:34:54 +0000 +++ src/blockinput.h 2012-09-11 04:34:42 +0000 @@ -67,15 +67,10 @@ 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 \ === modified file 'src/conf_post.h' --- src/conf_post.h 2012-09-07 01:27:44 +0000 +++ src/conf_post.h 2012-09-11 04:34:42 +0000 @@ -133,22 +133,6 @@ #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 === modified file 'src/dispextern.h' --- src/dispextern.h 2012-09-02 17:10:35 +0000 +++ src/dispextern.h 2012-09-11 04:34:42 +0000 @@ -3193,6 +3193,7 @@ int tabs_safe_p (int); void init_baud_rate (int); void init_sigio (int); +void ignore_sigio (void); /* Defined in xfaces.c */ === modified file 'src/dispnew.c' --- src/dispnew.c 2012-09-09 17:59:50 +0000 +++ src/dispnew.c 2012-09-11 04:34:42 +0000 @@ -5971,7 +5971,7 @@ wrong_type_argument (Qnumberp, timeout); -#ifdef SIGIO +#ifdef USABLE_SIGIO gobble_input (0); #endif === modified file 'src/emacs.c' --- src/emacs.c 2012-09-09 16:06:33 +0000 +++ src/emacs.c 2012-09-11 04:34:42 +0000 @@ -2035,12 +2035,10 @@ 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 (); === modified file 'src/keyboard.c' --- src/keyboard.c 2012-09-07 01:27:44 +0000 +++ src/keyboard.c 2012-09-11 04:34:42 +0000 @@ -56,6 +56,10 @@ #include #endif /* not MSDOS */ +#if defined USABLE_FIONREAD && defined USG5_4 +# include +#endif + #include "syssignal.h" #include @@ -385,19 +389,6 @@ /* 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 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); @@ -3657,10 +3648,8 @@ /* 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 */ @@ -3829,14 +3818,14 @@ /* 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 */ @@ -3878,10 +3867,9 @@ /* 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) @@ -6780,7 +6768,7 @@ void gobble_input (int expected) { -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) { sigset_t blocked, procmask; @@ -6835,7 +6823,7 @@ return; /* Make sure no interrupt happens while storing the event. */ -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) { sigset_t blocked, procmask; @@ -7061,7 +7049,7 @@ #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) { @@ -7074,14 +7062,12 @@ 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 @@ -7130,7 +7116,7 @@ #endif ); -#ifndef FIONREAD +#ifndef USABLE_FIONREAD #if defined (USG) || defined (CYGWIN) fcntl (fileno (tty->input), F_SETFL, 0); #endif /* USG or CYGWIN */ @@ -7201,7 +7187,7 @@ return nread; } -#if defined SYNC_INPUT || defined SIGIO +#if defined SYNC_INPUT || defined USABLE_SIGIO static void handle_async_input (void) { @@ -7228,7 +7214,7 @@ --handling_signal; #endif } -#endif /* SYNC_INPUT || SIGIO */ +#endif /* SYNC_INPUT || USABLE_SIGIO */ #ifdef SYNC_INPUT void @@ -7240,8 +7226,7 @@ } #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) @@ -7264,7 +7249,7 @@ { handle_on_main_thread (sig, handle_input_available_signal); } -#endif /* SIGIO */ +#endif /* USABLE_SIGIO */ /* Send ourselves a SIGIO. @@ -7275,7 +7260,7 @@ void reinvoke_input_signal (void) { -#ifdef SIGIO +#ifdef USABLE_SIGIO handle_async_input (); #endif } @@ -7349,7 +7334,7 @@ } p->npending++; -#ifdef SIGIO +#ifdef USABLE_SIGIO if (interrupt_input) kill (getpid (), SIGIO); else @@ -11020,8 +11005,7 @@ (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) { @@ -11032,9 +11016,9 @@ 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) { @@ -11429,15 +11413,14 @@ 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. */ === modified file 'src/process.c' --- src/process.c 2012-09-07 01:27:44 +0000 +++ src/process.c 2012-09-11 04:34:42 +0000 @@ -75,6 +75,11 @@ #include #endif +#ifdef USG5_4 +# include +# include +#endif + #ifdef HAVE_RES_INIT #include #include @@ -212,17 +217,13 @@ "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 @@ #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 @@ 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, @@ -6854,7 +6855,7 @@ # endif -# ifdef SIGIO +# ifdef USABLE_SIGIO /* Return nonzero if *MASK has a bit set that corresponds to one of the keyboard input descriptors. */ === modified file 'src/sound.c' --- src/sound.c 2012-09-07 01:27:44 +0000 +++ src/sound.c 2012-09-11 04:34:42 +0000 @@ -314,7 +314,7 @@ int saved_errno = errno; turn_on_atimers (1); -#ifdef SIGIO +#ifdef USABLE_SIGIO { sigset_t unblocked; sigemptyset (&unblocked); @@ -732,7 +732,7 @@ vox_configure (struct sound_device *sd) { int val; -#ifdef SIGIO +#ifdef USABLE_SIGIO sigset_t blocked; #endif @@ -742,7 +742,7 @@ 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 @@ } turn_on_atimers (1); -#ifdef SIGIO +#ifdef USABLE_SIGIO pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #endif } @@ -794,7 +794,7 @@ /* 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 @@ ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); turn_on_atimers (1); -#ifdef SIGIO +#ifdef USABLE_SIGIO pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #endif === modified file 'src/sysdep.c' --- src/sysdep.c 2012-09-07 01:27:44 +0000 +++ src/sysdep.c 2012-09-11 04:34:42 +0000 @@ -107,9 +107,6 @@ 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 @@ 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,120 +639,74 @@ } } -#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); + interrupts_deferred = 0; #endif - interrupts_deferred = 0; } 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"); -} - -void -unrequest_sigio (void) -{ - if (noninteractive || read_socket_hook) - return; - - croak ("unrequest_sigio"); -} - -#endif /* MSDOS */ -#endif /* FASYNC */ -#endif /* F_SETFL */ -#endif /* SIGIO */ +#endif +} + +void +ignore_sigio (void) +{ +#ifdef USABLE_SIGIO + signal (SIGIO, SIG_IGN); +#endif +} /* Getting and setting emacs_tty structures. */ @@ -2051,19 +2002,6 @@ } #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. */ === modified file 'src/syssignal.h' --- src/syssignal.h 2012-09-07 08:46:44 +0000 +++ src/syssignal.h 2012-09-11 04:34:42 +0000 @@ -34,27 +34,6 @@ 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 === modified file 'src/systty.h' --- src/systty.h 2012-09-07 08:46:44 +0000 +++ src/systty.h 2012-09-11 04:34:42 +0000 @@ -17,10 +17,8 @@ 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 */ @@ -39,15 +37,6 @@ #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 _POSIX_VDISABLE as 0! */ === modified file 'src/term.c' --- src/term.c 2012-09-07 01:27:44 +0000 +++ src/term.c 2012-09-11 04:34:42 +0000 @@ -2944,8 +2944,7 @@ emacs_close (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); #else - /* Unknown system. */ - croak (); +# error "Unknown system." #endif /* ! TIOCNOTTY */ #endif /* ! USG */ } === modified file 'src/xterm.c' --- src/xterm.c 2012-09-11 03:32:41 +0000 +++ src/xterm.c 2012-09-11 04:34:42 +0000 @@ -7878,7 +7878,7 @@ { sigset_t unblocked; sigemptyset (&unblocked); -#ifdef SIGIO +#ifdef USABLE_SIGIO sigaddset (&unblocked, SIGIO); #endif sigaddset (&unblocked, SIGALRM); @@ -10421,10 +10421,8 @@ fcntl (connection, F_SETOWN, getpid ()); #endif /* ! defined (F_SETOWN) */ -#ifdef SIGIO if (interrupt_input) init_sigio (connection); -#endif /* ! defined (SIGIO) */ #ifdef USE_LUCID {