changeset 637:639afe138172

entered into RCS
author Jim Blandy <jimb@redhat.com>
date Sun, 10 May 1992 18:13:22 +0000
parents dce8cdbac0ea
children 40b255f55df3
files src/syssignal.h
diffstat 1 files changed, 46 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/src/syssignal.h	Fri May 08 21:45:00 1992 +0000
+++ b/src/syssignal.h	Sun May 10 18:13:22 1992 +0000
@@ -17,7 +17,6 @@
 along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
-
 #ifdef POSIX_SIGNALS
 #define SIGMASKTYPE sigset_t
 
@@ -25,22 +24,24 @@
 #define SIGFULLMASK (full_mask)
 extern sigset_t empty_mask, full_mask, temp_mask;
 
-#define sigmask(SIG) \
-(sigemptyset (&temp_mask), sigaddset (&temp_mask, SIG), temp_mask)
-
-/* The below routines may need a local mask.  There could be problems
-   if code using any of the 3 macros below could be reentered due to a
-   signal occurring.  This can't happen in Emacs 18.57, so we don't
-   worry. - DJB */
+/* POSIX pretty much destroys any possibility of writing sigmask as a
+   macro in standard C.  */
+#ifdef __GNUC__
+#define sigmask(SIG) 				\
+  ({						\
+    sigset_t _mask;				\
+    sigemptyset (&_mask);			\
+    sigaddset (&_mask, SIG);			\
+    _mask;					\
+  })
+#else
+#define sigmask(SIG) (sys_sigmask (SIG))
+#endif
 
-#define EMACS_SIGPAUSE(sigset) \
-  do { sigset_t _mask; sys_sigpause (sigset); } while (0)
-#define EMACS_SIGBLOCK(new_sig, old_sig) \
-  do { sigset_t _mask; (old_sig) = sys_sigblock (new_sig); } while (0)
-#define EMACS_SIGUNBLOCK(new_sig, old_sig) \
-  do { sigset_t _mask; (old_sig) = sys_sigunblock (new_sig); } while (0)
-#define EMACS_SIGSETMASK(new_sig, old_sig) \
-  do { sigset_t _mask; (old_sig) = sys_sigsetmask (new_sig); } while (0)
+#define sigpause(SIG)    sys_sigpause(SIG)
+#define sigblock(SIG)    sys_sigblock(SIG)
+#define sigunblock(SIG)  sys_sigunblock(SIG)
+#define sigsetmask(SIG)  sys_sigsetmask(SIG)
 #define sighold(SIG)     ONLY_USED_IN_BSD_4_1
 #define sigrelse(SIG)    ONLY_USED_IN_BSD_4_1
 
@@ -52,57 +53,51 @@
 
 #define sys_sigdel(MASK,SIG) sigdelset(&MASK,SIG)
 
-#else /* ! defined (POSIX_SIGNALS) */
+#else /* not POSIX_SIGNALS */
 
 #define sigunblock(SIG) \
 { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
 
-#endif /* ! defined (POSIX_SIGNALS) */
+#endif /* not POSIX_SIGNALS */
 
 #ifndef SIGMASKTYPE
 #define SIGMASKTYPE int
 #endif
 
 #ifndef SIGEMPTYMASK
-#define SIGEMPTYMASK 0
+#define SIGEMPTYMASK (0)
+#endif
+
+#ifndef SIGFULLMASK
+#define SIGFULLMASK (0xffffffff)
 #endif
 
 #ifndef sigmask
 #define sigmask(no) (1L << ((no) - 1))
 #endif
 
+#ifndef sigunblock
+#define sigunblock(SIG) \
+{ SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
+#endif
+
+/* It would be very nice if we could somehow clean up all this trash.  */
+
+#ifndef BSD4_1
+#define sigfree() sigsetmask (SIGEMPTYMASK)
+#define sigholdx(sig) sigsetmask (sigmask (sig))
+#define sigblockx(sig) sigblock (sigmask (sig))
+#define sigunblockx(sig) sigblock (SIGEMPTYMASK)
+#define sigpausex(sig) sigpause (0)
+#endif /* not BSD4_1 */
+
 #ifdef BSD4_1
 #define SIGIO SIGTINT
 /* sigfree and sigholdx are in sysdep.c */
-#define EMACS_SIGFREE () sigfree ()
-
-/* We define the following macros to expand into statements rather
-   than expressions, because the POSIX macros above do the same, and
-   we don't want people on BSD4_1 systems accidentally using the
-   macros in a way that will break the other systems.  */
-#define EMACS_SIGHOLDX(new_sig, old_sig) \
-  do { (old_sig) = sigholdx (new_sig); } while (0)
-#define EMACS_SIGBLOCKX(new_sig, old_sig) \
-  do { (old_sig) = sighold (new_sig); } while (0)
-#define EMACS_SIGUNBLOCKX(new_sig, old_sig) \
-  do { (old_sig) = sigrelse (new_sig); } while (0)
-#define EMACS_SIGPAUSEX(sig) \
-  EMACS_SIGPAUSE (new_sig);
-
-#else /* ! defined (BSD4_1) */
-
-#define EMACS_SIGFREE() \
-  do { SIGMASKTYPE _dummy; EMACS_SIGSETMASK (SIGEMPTYMASK, _dummy); } while (0)
-#define EMACS_SIGHOLDX(new_sig, old_sig) \
-  EMACS_SIGSETMASK (sigmask (new_sig), old_sig)
-#define EMACS_SIGBLOCKX(new_sig, old_sig) \
-  EMACS_SIGBLOCK (sigmask (new_sig), old_sig)
-#define EMACS_SIGUNBLOCKX(new_sig, old_sig) \
-  EMACS_SIGUNBLOCK (sigmask (new_sig), old_sig)
-#define EMACS_SIGPAUSEX(sig) \
-  EMACS_SIGPAUSE (0)
-
-#endif /* ! defined (BSD4_1) */
+#define sigblockx(sig) sighold (sig)
+#define sigunblockx(sig) sigrelse (sig)
+#define sigpausex(sig) sigpause (sig)
+#endif /* BSD4_1 */
 
 /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
    Must do that using the killpg call.  */
@@ -114,11 +109,10 @@
 
 /* Define SIGCHLD as an alias for SIGCLD.  There are many conditionals
    testing SIGCHLD.  */
-
 #ifndef VMS
 #ifdef SIGCLD
 #ifndef SIGCHLD
 #define SIGCHLD SIGCLD
-#endif /* SIGCHLD */
-#endif /* ! defined (SIGCLD) */
-#endif /* VMS */
+#endif /* not SIGCHLD */
+#endif /* SIGCLD */
+#endif /* not VMS */