home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / e20313sr.zip / emacs / 20.3.1 / src / syssignal.h < prev    next >
C/C++ Source or Header  |  1999-07-31  |  5KB  |  159 lines

  1. /* syssignal.h - System-dependent definitions for signals.
  2.    Copyright (C) 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21. /* Modified for emx by Jeremy Bowen, May 1999 based on patches
  22.    to v19.33 by Eberhard Mattes */
  23.  
  24. #ifdef POSIX_SIGNALS
  25.  
  26. /* Don't #include <signal.h>.  That header should always be #included
  27.    before "config.h", because some configuration files (like s/hpux.h)
  28.    indicate that SIGIO doesn't work by #undef-ing SIGIO.  If this file
  29.    #includes <signal.h>, then that will re-#define SIGIO and confuse
  30.    things.  */
  31.  
  32. #define SIGMASKTYPE sigset_t
  33.  
  34. #define SIGEMPTYMASK (empty_mask)
  35. #define SIGFULLMASK (full_mask)
  36. extern sigset_t empty_mask, full_mask;
  37. extern void init_signals P_ ((void));
  38.  
  39. /* POSIX pretty much destroys any possibility of writing sigmask as a
  40.    macro in standard C.  We always define our own version because the
  41.    predefined macro in Glibc 2.1 is only provided for compatility for old
  42.    programs that use int as signal mask type.  */
  43. #undef sigmask
  44. #ifdef __GNUC__
  45. #define sigmask(SIG)                 \
  46.   ({                        \
  47.     sigset_t _mask;                \
  48.     sigemptyset (&_mask);            \
  49.     sigaddset (&_mask, SIG);            \
  50.     _mask;                    \
  51.   })
  52. #else /* ! defined (__GNUC__) */
  53. extern sigset_t sys_sigmask ();
  54. #define sigmask(SIG) (sys_sigmask (SIG))
  55. #endif /* ! defined (__GNUC__) */
  56.  
  57. #undef sigpause
  58. #define sigpause(MASK)    sigsuspend (&(MASK))
  59.  
  60. #define sigblock(SIG)    sys_sigblock (SIG)
  61. #define sigunblock(SIG)  sys_sigunblock (SIG)
  62. #ifndef sigsetmask
  63. #define sigsetmask(SIG)  sys_sigsetmask (SIG)
  64. #endif
  65. #define sighold(SIG)     ONLY_USED_IN_BSD_4_1
  66. #define sigrelse(SIG)    ONLY_USED_IN_BSD_4_1
  67. #undef signal
  68. #define signal(SIG,ACT)      sys_signal(SIG,ACT)
  69.  
  70. /* Whether this is what all systems want or not, this is what
  71.    appears to be assumed in the source, for example data.c:arith_error.  */
  72. typedef RETSIGTYPE (*signal_handler_t) (/*int*/);
  73.  
  74. signal_handler_t sys_signal P_ ((int signal_number, signal_handler_t action));
  75. sigset_t sys_sigblock   P_ ((sigset_t new_mask));
  76. sigset_t sys_sigunblock P_ ((sigset_t new_mask));
  77. sigset_t sys_sigsetmask P_ ((sigset_t new_mask));
  78.  
  79. #define sys_sigdel(MASK,SIG) sigdelset (&MASK,SIG)
  80.  
  81. #else /* ! defined (POSIX_SIGNALS) */
  82. #ifdef USG5_4
  83.  
  84. #ifndef sigblock
  85. #define sigblock(sig) (sigprocmask (SIG_BLOCK, SIGEMPTYMASK | sig, NULL))
  86. #endif
  87.  
  88. #define sigunblock(sig) (sigprocmask (SIG_SETMASK, SIGFULLMASK & ~(sig), NULL))
  89.  
  90. #else
  91. #ifdef USG
  92.  
  93. #define sigunblock(sig) 
  94.  
  95. #else
  96.  
  97. #define sigunblock(SIG) \
  98. { SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
  99.  
  100. #endif /* ! defined (USG) */
  101. #endif /* ! defined (USG5_4) */
  102. #endif /* ! defined (POSIX_SIGNALS) */
  103.  
  104. #ifndef SIGMASKTYPE
  105. #define SIGMASKTYPE int
  106. #endif
  107.  
  108. #ifndef SIGEMPTYMASK
  109. #define SIGEMPTYMASK (0)
  110. #endif
  111.  
  112. #ifndef SIGFULLMASK
  113. #define SIGFULLMASK (0xffffffff)
  114. #endif
  115.  
  116. #ifndef sigmask
  117. #define sigmask(no) (1L << ((no) - 1))
  118. #endif
  119.  
  120. #ifndef sigunblock
  121. #define sigunblock(SIG) \
  122. { SIGMASKTYPE omask = sigblock (SIGFULLMASK); sigsetmask (omask & ~SIG); }
  123. #endif
  124.  
  125. #ifndef BSD4_1
  126. #define sigfree() sigsetmask (SIGEMPTYMASK)
  127. #endif /* not BSD4_1 */
  128.  
  129. #ifdef BSD4_1
  130. #define SIGIO SIGTINT
  131. /* sigfree is in sysdep.c */
  132. #endif /* BSD4_1 */
  133.  
  134. /* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
  135.    Must do that using the killpg call.  */
  136. #ifdef BSD_SYSTEM
  137. #define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
  138. #else
  139. #ifdef WINDOWSNT
  140. #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
  141. #else
  142. #ifdef EMX
  143. #define EMACS_KILLPG(gid, signo) emx_killpg ((gid), (signo))
  144. #else /* not EMX */
  145. #define EMACS_KILLPG(gid, signo) (kill   (-(gid), (signo)))
  146. #endif /* not EMX */
  147. #endif
  148. #endif
  149.  
  150. /* Define SIGCHLD as an alias for SIGCLD.  There are many conditionals
  151.    testing SIGCHLD.  */
  152. #ifndef VMS
  153. #ifdef SIGCLD
  154. #ifndef SIGCHLD
  155. #define SIGCHLD SIGCLD
  156. #endif /* SIGCHLD */
  157. #endif /* ! defined (SIGCLD) */
  158. #endif /* VMS */
  159.