aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
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/sysdep.c
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/sysdep.c')
-rw-r--r--src/sysdep.c98
1 files changed, 18 insertions, 80 deletions
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. */