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