aboutsummaryrefslogtreecommitdiffstats
path: root/src/sound.c
diff options
context:
space:
mode:
authorPaul Eggert2012-09-06 18:27:44 -0700
committerPaul Eggert2012-09-06 18:27:44 -0700
commit2fe282993cf9c84f5be424dc93d03f9705a7edd8 (patch)
tree229edb6fe29e66984b2992f3f9fa081cd7fe8920 /src/sound.c
parent845ce106c0ab157e25416964330875ad6c24b699 (diff)
downloademacs-2fe282993cf9c84f5be424dc93d03f9705a7edd8.tar.gz
emacs-2fe282993cf9c84f5be424dc93d03f9705a7edd8.zip
Signal-handler cleanup.
Emacs's signal handlers were written in the old 4.2BSD style with sigblock and sigmask and so forth, and this led to some inefficiencies and confusion. Rewrite these to use pthread_sigmask etc. without copying signal sets around. Also, get rid of the confusing macros 'SIGNAL_THREAD_CHECK' and 'signal', and instead use functions that do not attempt to take over the system name space. This patch causes Emacs's text segment to shrink by 0.7% on my platform, Fedora 17 x86-64. * configure.ac (PTY_OPEN, PTY_TTY_NAME_SPRINTF): Adjust to syssignal.h changes. (SIGNAL_H_AB): Remove; no longer needed. * src/alloc.c, src/emacsgtkfixed.c, src/nsfns.m, src/widget.c, src/xmenu.c: Do not include <signal.h> or "syssignal.h", as these modules do not use signals. * src/atimer.c, src/callproc.c, src/data.c, src/dispnew.c, src/emacs.c: * src/floatfns.c, src/gtkutil.c, src/keyboard.c, src/process.c, src/sound.c: * src/sysdep.c, src/term.c, src/xterm.c: Do not include <signal.h>, as "syssignal.h" does that for us now. * src/atimer.c (sigmask_atimers): New function. (block_atimers, unblock_atimers): New functions, replacing the old macros BLOCK_ATIMERS and UNBLOCK_ATIMERS. All uses replaced. * src/conf_post.h [SIGNAL_H_AHB]: Do not include <signal.h>; no longer needed here. * src/emacs.c (main): Inspect existing signal handler with sigaction, so that there's no need to block and unblock SIGHUP. * src/sysdep.c (struct save_signal): New member 'action', replacing old member 'handler'. (save_signal_handlers, restore_signal_handlers): Use sigaction instead of 'signal' to save and restore. (get_set_sighandler, set_sighandler) [!WINDOWSNT]: New function. All users of 'signal' modified to use set_sighandler if they're writeonly, and to use sys_signal if they're read+write. (emacs_sigaction_init, forwarded_signal): New functions. (sys_signal): Remove. All uses replaced by calls to sigaction and emacs_sigaction_init, or by direct calls to 'signal'. (sys_sigmask) [!__GNUC__]: Remove; no longer needed. (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove; all uses replaced by pthread_sigmask etc. calls. * src/syssignal.h: Include <signal.h>. (emacs_sigaction_init, forwarded_signal): New decls. (SIGMASKTYPE): Remove. All uses replaced by its definiens, sigset_t. (SIGEMPTYMASK): Remove; all uses replaced by its definiens, empty_mask. (sigmask, sys_sigmask): Remove; no longer needed. (sigpause): Remove. All uses replaced by its definiens, sigsuspend. (sigblock, sigunblock, sigfree): (sigsetmask) [!defined sigsetmask]: Remove. All uses replaced by pthread_sigmask. (signal): Remove. Its remaining uses (with SIG_DFL and SIG_IGN) no longer need to be replaced, and its typical old uses are now done via emacs_sigaction_init and sigaction. (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove decls. (sys_sigdel): Remove; unused. (NSIG): Remove a FIXME; the code's fine. Remove an unnecessary ifdef. Fixes: debbugs:12327
Diffstat (limited to 'src/sound.c')
-rw-r--r--src/sound.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/sound.c b/src/sound.c
index d20fa5ee8eb..5729d704b6a 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -48,7 +48,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
48#include "lisp.h" 48#include "lisp.h"
49#include "dispextern.h" 49#include "dispextern.h"
50#include "atimer.h" 50#include "atimer.h"
51#include <signal.h>
52#include "syssignal.h" 51#include "syssignal.h"
53/* END: Common Includes */ 52/* END: Common Includes */
54 53
@@ -316,7 +315,12 @@ sound_perror (const char *msg)
316 315
317 turn_on_atimers (1); 316 turn_on_atimers (1);
318#ifdef SIGIO 317#ifdef SIGIO
319 sigunblock (sigmask (SIGIO)); 318 {
319 sigset_t unblocked;
320 sigemptyset (&unblocked);
321 sigaddset (&unblocked, SIGIO);
322 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
323 }
320#endif 324#endif
321 if (saved_errno != 0) 325 if (saved_errno != 0)
322 error ("%s: %s", msg, strerror (saved_errno)); 326 error ("%s: %s", msg, strerror (saved_errno));
@@ -728,6 +732,9 @@ static void
728vox_configure (struct sound_device *sd) 732vox_configure (struct sound_device *sd)
729{ 733{
730 int val; 734 int val;
735#ifdef SIGIO
736 sigset_t blocked;
737#endif
731 738
732 eassert (sd->fd >= 0); 739 eassert (sd->fd >= 0);
733 740
@@ -736,7 +743,9 @@ vox_configure (struct sound_device *sd)
736 troubles. */ 743 troubles. */
737 turn_on_atimers (0); 744 turn_on_atimers (0);
738#ifdef SIGIO 745#ifdef SIGIO
739 sigblock (sigmask (SIGIO)); 746 sigemptyset (&blocked);
747 sigaddset (&blocked, SIGIO);
748 pthread_sigmask (SIG_BLOCK, &blocked, 0);
740#endif 749#endif
741 750
742 val = sd->format; 751 val = sd->format;
@@ -770,7 +779,7 @@ vox_configure (struct sound_device *sd)
770 779
771 turn_on_atimers (1); 780 turn_on_atimers (1);
772#ifdef SIGIO 781#ifdef SIGIO
773 sigunblock (sigmask (SIGIO)); 782 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
774#endif 783#endif
775} 784}
776 785
@@ -786,7 +795,10 @@ vox_close (struct sound_device *sd)
786 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
787 troubles. */ 796 troubles. */
788#ifdef SIGIO 797#ifdef SIGIO
789 sigblock (sigmask (SIGIO)); 798 sigset_t blocked;
799 sigemptyset (&blocked);
800 sigaddset (&blocked, SIGIO);
801 pthread_sigmask (SIG_BLOCK, &blocked, 0);
790#endif 802#endif
791 turn_on_atimers (0); 803 turn_on_atimers (0);
792 804
@@ -795,7 +807,7 @@ vox_close (struct sound_device *sd)
795 807
796 turn_on_atimers (1); 808 turn_on_atimers (1);
797#ifdef SIGIO 809#ifdef SIGIO
798 sigunblock (sigmask (SIGIO)); 810 pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
799#endif 811#endif
800 812
801 /* Close the device. */ 813 /* Close the device. */