home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / ixemul-39.47-env-bin.lha / include / signal.h < prev    next >
C/C++ Source or Header  |  1993-09-05  |  8KB  |  246 lines

  1. /*
  2.  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution is only permitted until one year after the first shipment
  6.  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
  7.  * binary forms are permitted provided that: (1) source distributions retain
  8.  * this entire copyright notice and comment, and (2) distributions including
  9.  * binaries display the following acknowledgement:  This product includes
  10.  * software developed by the University of California, Berkeley and its
  11.  * contributors'' in the documentation or other materials provided with the
  12.  * distribution and in all advertising materials mentioning features or use
  13.  * of this software.  Neither the name of the University nor the names of
  14.  * its contributors may be used to endorse or promote products derived from
  15.  * this software without specific prior written permission.
  16.  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  17.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  18.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19.  *
  20.  *    @(#)signal.h    7.11 (Berkeley) 7/1/90
  21.  */
  22.  
  23. #ifndef _SIGNAL_H
  24. #define _SIGNAL_H
  25.  
  26. #include <sys/types.h>
  27.  
  28. #define NSIG    33        /* counting 0; max = 33 (mask is 1-32) */
  29.  
  30. #ifndef _POSIX_SOURCE
  31. #include <sys/signal.h>    /* codes for SIGILL, SIGFPE */
  32. #endif /* _POSIX_SOURCE */
  33.  
  34. #define    SIGHUP    1    /* hangup */
  35. #define    SIGINT    2    /* interrupt */
  36. #define    SIGQUIT    3    /* quit */
  37. #define    SIGILL    4    /* illegal instruction (not reset when caught) */
  38. #ifndef _POSIX_SOURCE
  39. #define    SIGTRAP    5    /* trace trap (not reset when caught) */
  40. #endif
  41. #define    SIGABRT    6    /* abort() */
  42. #ifndef _POSIX_SOURCE
  43. #define    SIGIOT    SIGABRT    /* compatibility */
  44. #define    SIGEMT    7    /* EMT instruction */
  45. #endif
  46. #define    SIGFPE    8    /* floating point exception */
  47. #define    SIGKILL    9    /* kill (cannot be caught or ignored) */
  48. #ifndef _POSIX_SOURCE
  49. #define    SIGBUS    10    /* bus error */
  50. #endif
  51. #define    SIGSEGV    11    /* segmentation violation */
  52. #ifndef _POSIX_SOURCE
  53. #define    SIGSYS    12    /* bad argument to system call */
  54. #endif
  55. #define    SIGPIPE    13    /* write on a pipe with no one to read it */
  56. #define    SIGALRM    14    /* alarm clock */
  57. #define    SIGTERM    15    /* software termination signal from kill */
  58. #ifndef _POSIX_SOURCE
  59. #define    SIGURG    16    /* urgent condition on IO channel */
  60. #endif
  61. #define    SIGSTOP    17    /* sendable stop signal not from tty */
  62. #define    SIGTSTP    18    /* stop signal from tty */
  63. #define    SIGCONT    19    /* continue a stopped process */
  64. #define    SIGCHLD    20    /* to parent on child stop or exit */
  65. #define    SIGTTIN    21    /* to readers pgrp upon background tty read */
  66. #define    SIGTTOU    22    /* like TTIN for output if (tp->t_local<OSTOP) */
  67. #ifndef _POSIX_SOURCE
  68. #define    SIGIO    23    /* input/output possible signal */
  69. #define    SIGXCPU    24    /* exceeded CPU time limit */
  70. #define    SIGXFSZ    25    /* exceeded file size limit */
  71. #define    SIGVTALRM 26    /* virtual time alarm */
  72. #define    SIGPROF    27    /* profiling time alarm */
  73. #define SIGWINCH 28    /* window size changes */
  74. #define SIGINFO    29    /* information request */
  75. #endif
  76. #define SIGUSR1 30    /* user defined signal 1 */
  77. #define SIGUSR2 31    /* user defined signal 2 */
  78. #define SIGMSG    32    /* an AmigaDOS signal has been set. SIGMSG is normally ignored.
  79.                (code is the mask of new signals) */
  80. #include <sys/cdefs.h>
  81.  
  82. #ifndef _POSIX_SOURCE
  83. typedef    void (*sig_t)();
  84. #endif
  85.  
  86. #if 0
  87. #ifndef KERNEL
  88. void    (*signal())();
  89. #endif
  90. #endif
  91.  
  92. typedef unsigned int sigset_t;
  93.  
  94. __BEGIN_DECLS
  95. int    sigaddset __P((sigset_t *, int));
  96. int    sigdelset __P((sigset_t *, int));
  97. int    sigemptyset __P((sigset_t *));
  98. int    sigfillset __P((sigset_t *));
  99. int    sigismember __P((const sigset_t *, int));
  100. __END_DECLS
  101.  
  102. #define sigemptyset(set)    ( *(set) = 0 )
  103. #define sigfillset(set)        ( *(set) = ~(sigset_t)0, 0 )
  104. #define sigaddset(set, signo)    ( *(set) |= 1 << ((signo) - 1), 0)
  105. #define sigdelset(set, signo)    ( *(set) &= ~(1 << ((signo) - 1)), 0)
  106. #define sigismember(set, signo)    ( (*(set) & (1 << ((signo) - 1))) != 0)
  107.  
  108. /*
  109.  * Signal vector "template" used in sigaction call.
  110.  */
  111. struct    sigaction {
  112.     void    (*sa_handler)();    /* signal handler */
  113.     sigset_t sa_mask;        /* signal mask to apply */
  114.     int    sa_flags;        /* see signal options below */
  115. };
  116. #ifndef _POSIX_SOURCE
  117. #define SA_ONSTACK    0x0001    /* take signal on signal stack */
  118. #define SA_RESTART    0x0002    /* do not restart system on signal return */
  119. #endif
  120. #define SA_NOCLDSTOP    0x0004    /* do not generate SIGCHLD on child stop */
  121.  
  122. /*
  123.  * Flags for sigprocmask:
  124.  */
  125. #define    SIG_BLOCK    1    /* block specified signal set */
  126. #define    SIG_UNBLOCK    2    /* unblock specified signal set */
  127. #define    SIG_SETMASK    3    /* set specified signal set */
  128.  
  129. #ifndef _POSIX_SOURCE
  130. /*
  131.  * 4.3 compatibility:
  132.  * Signal vector "template" used in sigvec call.
  133.  */
  134. struct    sigvec {
  135.     void    (*sv_handler)();    /* signal handler */
  136.     int    sv_mask;        /* signal mask to apply */
  137.     int    sv_flags;        /* see signal options below */
  138. };
  139. #define SV_ONSTACK    SA_ONSTACK
  140. #define SV_INTERRUPT    SA_RESTART    /* same bit, opposite sense */
  141. #define sv_onstack sv_flags    /* isn't compatibility wonderful! */
  142.  
  143. /*
  144.  * Structure used in sigaltstack call.
  145.  */
  146. struct    sigaltstack {
  147.     char    *ss_base;        /* signal stack base */
  148.     int    ss_len;            /* signal stack length */
  149.     int    ss_onstack;        /* current status */
  150. };
  151.  
  152. /*
  153.  * Structure used in sigstack call.
  154.  */
  155. struct    sigstack {
  156.     char    *ss_sp;            /* signal stack pointer */
  157.     int    ss_onstack;        /* current status */
  158. };
  159.  
  160. /*
  161.  * Information pushed on stack when a signal is delivered.
  162.  * This is used by the kernel to restore state following
  163.  * execution of the signal handler.  It is also made available
  164.  * to the handler to allow it to restore state properly if
  165.  * a non-standard exit is performed.
  166.  */
  167. struct    sigcontext {
  168.     int    sc_onstack;        /* sigstack state to restore */
  169.     int    sc_mask;        /* signal mask to restore */
  170.     int    sc_sp;            /* sp to restore */
  171.     int    sc_fp;            /* fp to restore */
  172.     int    sc_ap;            /* ap to restore */
  173.     int    sc_pc;            /* pc to restore */
  174.     int    sc_ps;            /* psl to restore */
  175. };
  176.  
  177. /*
  178.  * Macro for converting signal number to a mask suitable for
  179.  * sigblock().
  180.  */
  181. #define sigmask(m)    (1 << ((m)-1))
  182.  
  183. #define    BADSIG        (void (*)())-1
  184. #endif    /* _POSIX_SOURCE */
  185.  
  186. #ifdef KERNEL
  187. #define    SIG_CATCH    (void (*)())2
  188. #define    SIG_HOLD    (void (*)())3
  189.  
  190. #define    sigcantmask    (sigmask(SIGKILL)|sigmask(SIGSTOP))
  191. /*
  192.  * get signal action for process and signal; currently only for current process
  193.  */
  194. #define SIGACTION(p, sig)    (u.u_signal[(sig)])
  195.  
  196. /*
  197.  * Determine signal that should be delivered to process p, the current process,
  198.  * 0 if none.  If there is a pending stop signal with default action,
  199.  * the process stops in issig().
  200.  */
  201. #define    CURSIG(p) \
  202.     (((p)->p_sig == 0 || \
  203.         ((p)->p_flag&STRC) == 0 && ((p)->p_sig &~ (p)->p_sigmask) == 0) ? \
  204.         0 : issig(p))
  205.  
  206. /*
  207.  * Clear a pending signal from a process.
  208.  */
  209. #define    CLRSIG(p, sig)    { (p)->p_sig &= ~sigmask(sig); }
  210. #endif
  211.  
  212.  
  213. #define    SIG_ERR        (void (*)(int))-1
  214. #define    SIG_DFL        (void (*)(int))0
  215. #define    SIG_IGN        (void (*)(int))1
  216.  
  217. #ifndef KERNEL
  218. #include <sys/types.h>
  219.  
  220. __BEGIN_DECLS
  221. void    (*signal __P((int, void (*) __P((int))))) __P((int));
  222. int    raise __P((int));
  223. #ifndef    _ANSI_SOURCE
  224. int    kill __P((pid_t, int));
  225. int    sigaction __P((int, const struct sigaction *, struct sigaction *));
  226. int    sigpending __P((sigset_t *));
  227. int    sigprocmask __P((int, const sigset_t *, sigset_t *));
  228. int    sigsuspend __P((const sigset_t *));
  229. #endif    /* !_ANSI_SOURCE */
  230. #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  231. int    killpg __P((pid_t, int));
  232. void    psignal __P((unsigned, const char *));
  233. int    sigblock __P((int));
  234. int    siginterrupt __P((int, int));
  235. int    sigpause __P((int));
  236. int    sigreturn __P((struct sigcontext *));
  237. int    sigsetmask __P((int));
  238. int    sigstack __P((const struct sigstack *, struct sigstack *));
  239. int    sigvec __P((int, struct sigvec *, struct sigvec *));
  240. #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
  241. __END_DECLS
  242.  
  243. #endif    /* !KERNEL */
  244.  
  245. #endif /* _SIGNAL_H */
  246.