Subversion Repositories Kolibri OS

Rev

Rev 6099 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* sys/signal.h */
  2.  
  3. #ifndef _SYS_SIGNAL_H
  4. #define _SYS_SIGNAL_H
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8.  
  9. #include "_ansi.h"
  10. #include <sys/cdefs.h>
  11. #include <sys/features.h>
  12. #include <sys/types.h>
  13. #include <sys/_sigset.h>
  14. #include <sys/_timespec.h>
  15.  
  16. #if !defined(_SIGSET_T_DECLARED)
  17. #define _SIGSET_T_DECLARED
  18. typedef __sigset_t      sigset_t;
  19. #endif
  20.  
  21. #if defined(__rtems__)
  22.  
  23. #if defined(_POSIX_REALTIME_SIGNALS)
  24.  
  25. /* sigev_notify values
  26.    NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD.  */
  27.  
  28. #define SIGEV_NONE   1  /* No asynchronous notification shall be delivered */
  29.                         /*   when the event of interest occurs. */
  30. #define SIGEV_SIGNAL 2  /* A queued signal, with an application defined */
  31.                         /*  value, shall be delivered when the event of */
  32.                         /*  interest occurs. */
  33. #define SIGEV_THREAD 3  /* A notification function shall be called to */
  34.                         /*   perform notification. */
  35.  
  36. /*  Signal Generation and Delivery, P1003.1b-1993, p. 63
  37.     NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
  38.           sigev_notify_attributes to the sigevent structure.  */
  39.  
  40. union sigval {
  41.   int    sival_int;    /* Integer signal value */
  42.   void  *sival_ptr;    /* Pointer signal value */
  43. };
  44.  
  45. struct sigevent {
  46.   int              sigev_notify;               /* Notification type */
  47.   int              sigev_signo;                /* Signal number */
  48.   union sigval     sigev_value;                /* Signal value */
  49.  
  50. #if defined(_POSIX_THREADS)
  51.   void           (*sigev_notify_function)( union sigval );
  52.                                                /* Notification function */
  53.   pthread_attr_t  *sigev_notify_attributes;    /* Notification Attributes */
  54. #endif
  55. };
  56.  
  57. /* Signal Actions, P1003.1b-1993, p. 64 */
  58. /* si_code values, p. 66 */
  59.  
  60. #define SI_USER    1    /* Sent by a user. kill(), abort(), etc */
  61. #define SI_QUEUE   2    /* Sent by sigqueue() */
  62. #define SI_TIMER   3    /* Sent by expiration of a timer_settime() timer */
  63. #define SI_ASYNCIO 4    /* Indicates completion of asycnhronous IO */
  64. #define SI_MESGQ   5    /* Indicates arrival of a message at an empty queue */
  65.  
  66. typedef struct {
  67.   int          si_signo;    /* Signal number */
  68.   int          si_code;     /* Cause of the signal */
  69.   union sigval si_value;    /* Signal value */
  70. } siginfo_t;
  71. #endif
  72.  
  73. /*  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
  74.  
  75. #define SA_NOCLDSTOP 0x1   /* Do not generate SIGCHLD when children stop */
  76. #define SA_SIGINFO   0x2   /* Invoke the signal catching function with */
  77.                            /*   three arguments instead of one. */
  78. #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
  79. #define SA_ONSTACK   0x4   /* Signal delivery will be on a separate stack. */
  80. #endif
  81.  
  82. /* struct sigaction notes from POSIX:
  83.  *
  84.  *  (1) Routines stored in sa_handler should take a single int as
  85.  *      their argument although the POSIX standard does not require this.
  86.  *      This is not longer true since at least POSIX.1-2008
  87.  *  (2) The fields sa_handler and sa_sigaction may overlap, and a conforming
  88.  *      application should not use both simultaneously.
  89.  */
  90.  
  91. typedef void (*_sig_func_ptr)(int);
  92.  
  93. struct sigaction {
  94.   int         sa_flags;       /* Special flags to affect behavior of signal */
  95.   sigset_t    sa_mask;        /* Additional set of signals to be blocked */
  96.                               /*   during execution of signal-catching */
  97.                               /*   function. */
  98.   union {
  99.     _sig_func_ptr _handler;  /* SIG_DFL, SIG_IGN, or pointer to a function */
  100. #if defined(_POSIX_REALTIME_SIGNALS)
  101.     void      (*_sigaction)( int, siginfo_t *, void * );
  102. #endif
  103.   } _signal_handlers;
  104. };
  105.  
  106. #define sa_handler    _signal_handlers._handler
  107. #if defined(_POSIX_REALTIME_SIGNALS)
  108. #define sa_sigaction  _signal_handlers._sigaction
  109. #endif
  110.  
  111. #elif defined(__CYGWIN__)
  112. #include <cygwin/signal.h>
  113. #else
  114. #define SA_NOCLDSTOP 1  /* only value supported now for sa_flags */
  115.  
  116. typedef void (*_sig_func_ptr)(int);
  117.  
  118. struct sigaction
  119. {
  120.         _sig_func_ptr sa_handler;
  121.         sigset_t sa_mask;
  122.         int sa_flags;
  123. };
  124. #endif /* defined(__rtems__) */
  125.  
  126. #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
  127. /*
  128.  * Minimum and default signal stack constants. Allow for target overrides
  129.  * from <sys/features.h>.
  130.  */
  131. #ifndef MINSIGSTKSZ
  132. #define MINSIGSTKSZ     2048
  133. #endif
  134. #ifndef SIGSTKSZ
  135. #define SIGSTKSZ        8192
  136. #endif
  137.  
  138. /*
  139.  * Possible values for ss_flags in stack_t below.
  140.  */
  141. #define SS_ONSTACK      0x1
  142. #define SS_DISABLE      0x2
  143.  
  144. #endif
  145.  
  146. /*
  147.  * Structure used in sigaltstack call.
  148.  */
  149. typedef struct sigaltstack {
  150.   void     *ss_sp;    /* Stack base or pointer.  */
  151.   int       ss_flags; /* Flags.  */
  152.   size_t    ss_size;  /* Stack size.  */
  153. } stack_t;
  154.  
  155. #define SIG_SETMASK 0   /* set mask with sigprocmask() */
  156. #define SIG_BLOCK 1     /* set of signals to block */
  157. #define SIG_UNBLOCK 2   /* set of signals to, well, unblock */
  158.  
  159. int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset));
  160.  
  161. #if defined(_POSIX_THREADS)
  162. int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
  163. #endif
  164.  
  165. #if defined(__CYGWIN__) || defined(__rtems__)
  166. #ifdef _COMPILING_NEWLIB
  167. int _EXFUN(_kill, (pid_t, int));
  168. #endif /* _COMPILING_NEWLIB */
  169. #endif /* __CYGWIN__ || __rtems__ */
  170.  
  171. int _EXFUN(kill, (pid_t, int));
  172.  
  173. #if __BSD_VISIBLE || __XSI_VISIBLE >= 4
  174. int _EXFUN(killpg, (pid_t, int));
  175. int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
  176. int _EXFUN(sigaddset, (sigset_t *, const int));
  177. int _EXFUN(sigdelset, (sigset_t *, const int));
  178. int _EXFUN(sigismember, (const sigset_t *, int));
  179. int _EXFUN(sigfillset, (sigset_t *));
  180. int _EXFUN(sigemptyset, (sigset_t *));
  181. int _EXFUN(sigpending, (sigset_t *));
  182. int _EXFUN(sigsuspend, (const sigset_t *));
  183. int _EXFUN(sigpause, (int));
  184.  
  185. #if !defined(__CYGWIN__) && !defined(__rtems__)
  186. /* These depend upon the type of sigset_t, which right now
  187.    is always a long.. They're in the POSIX namespace, but
  188.    are not ANSI. */
  189. #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
  190. #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
  191. #define sigemptyset(what)   (*(what) = 0, 0)
  192. #define sigfillset(what)    (*(what) = ~(0), 0)
  193. #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
  194. #endif /* !__CYGWIN__ && !__rtems__ */
  195. #endif /* __BSD_VISIBLE || __XSI_VISIBLE >= 4 */
  196.  
  197. #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
  198. int _EXFUN(sigaltstack, (const stack_t *__restrict, stack_t *__restrict));
  199. #endif
  200.  
  201. #if defined(_POSIX_THREADS)
  202. #ifdef __CYGWIN__
  203. #  ifndef _CYGWIN_TYPES_H
  204. #    error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib.
  205. #  endif
  206. #endif
  207. int _EXFUN(pthread_kill, (pthread_t thread, int sig));
  208. #endif
  209.  
  210. #if defined(_POSIX_REALTIME_SIGNALS)
  211.  
  212. /*  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
  213.     NOTE: P1003.1c/D10, p. 39 adds sigwait().  */
  214.  
  215. int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info));
  216. int _EXFUN(sigtimedwait,
  217.   (const sigset_t *set, siginfo_t *info, const struct timespec  *timeout)
  218. );
  219. int _EXFUN(sigwait, (const sigset_t *set, int *sig));
  220.  
  221. /*  3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
  222. int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
  223.  
  224. #endif /* defined(_POSIX_REALTIME_SIGNALS) */
  225.  
  226. #if defined(___AM29K__)
  227. /* These all need to be defined for ANSI C, but I don't think they are
  228.    meaningful.  */
  229. #define SIGABRT 1
  230. #define SIGFPE 1
  231. #define SIGILL 1
  232. #define SIGINT 1
  233. #define SIGSEGV 1
  234. #define SIGTERM 1
  235. /* These need to be defined for POSIX, and some others do too.  */
  236. #define SIGHUP 1
  237. #define SIGQUIT 1
  238. #define NSIG 2
  239. #elif defined(__GO32__)
  240. #define SIGINT  1
  241. #define SIGKILL 2
  242. #define SIGPIPE 3
  243. #define SIGFPE  4
  244. #define SIGHUP  5
  245. #define SIGTERM 6
  246. #define SIGSEGV 7
  247. #define SIGTSTP 8
  248. #define SIGQUIT 9
  249. #define SIGTRAP 10
  250. #define SIGILL  11
  251. #define SIGEMT  12
  252. #define SIGALRM 13
  253. #define SIGBUS  14
  254. #define SIGLOST 15
  255. #define SIGSTOP 16
  256. #define SIGABRT 17
  257. #define SIGUSR1 18
  258. #define SIGUSR2 19
  259. #define NSIG    20
  260. #elif !defined(SIGTRAP)
  261. #define SIGHUP  1       /* hangup */
  262. #define SIGINT  2       /* interrupt */
  263. #define SIGQUIT 3       /* quit */
  264. #define SIGILL  4       /* illegal instruction (not reset when caught) */
  265. #define SIGTRAP 5       /* trace trap (not reset when caught) */
  266. #define SIGIOT  6       /* IOT instruction */
  267. #define SIGABRT 6       /* used by abort, replace SIGIOT in the future */
  268. #define SIGEMT  7       /* EMT instruction */
  269. #define SIGFPE  8       /* floating point exception */
  270. #define SIGKILL 9       /* kill (cannot be caught or ignored) */
  271. #define SIGBUS  10      /* bus error */
  272. #define SIGSEGV 11      /* segmentation violation */
  273. #define SIGSYS  12      /* bad argument to system call */
  274. #define SIGPIPE 13      /* write on a pipe with no one to read it */
  275. #define SIGALRM 14      /* alarm clock */
  276. #define SIGTERM 15      /* software termination signal from kill */
  277.  
  278. #if defined(__rtems__)
  279. #define SIGURG  16      /* urgent condition on IO channel */
  280. #define SIGSTOP 17      /* sendable stop signal not from tty */
  281. #define SIGTSTP 18      /* stop signal from tty */
  282. #define SIGCONT 19      /* continue a stopped process */
  283. #define SIGCHLD 20      /* to parent on child stop or exit */
  284. #define SIGCLD  20      /* System V name for SIGCHLD */
  285. #define SIGTTIN 21      /* to readers pgrp upon background tty read */
  286. #define SIGTTOU 22      /* like TTIN for output if (tp->t_local&LTOSTOP) */
  287. #define SIGIO   23      /* input/output possible signal */
  288. #define SIGPOLL SIGIO   /* System V name for SIGIO */
  289. #define SIGWINCH 24     /* window changed */
  290. #define SIGUSR1 25      /* user defined signal 1 */
  291. #define SIGUSR2 26      /* user defined signal 2 */
  292.  
  293. /* Real-Time Signals Range, P1003.1b-1993, p. 61
  294.    NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX
  295.          (which is a minimum of 8) signals.
  296.  */
  297. #define SIGRTMIN 27
  298. #define SIGRTMAX 31
  299. #define __SIGFIRSTNOTRT SIGHUP
  300. #define __SIGLASTNOTRT  SIGUSR2
  301.  
  302. #define NSIG    32      /* signal 0 implied */
  303.  
  304. #elif defined(__svr4__)
  305. /* svr4 specifics. different signals above 15, and sigaction. */
  306. #define SIGUSR1 16
  307. #define SIGUSR2 17
  308. #define SIGCLD  18
  309. #define SIGPWR  19
  310. #define SIGWINCH 20
  311. #define SIGPOLL 22      /* 20 for x.out binaries!!!! */
  312. #define SIGSTOP 23      /* sendable stop signal not from tty */
  313. #define SIGTSTP 24      /* stop signal from tty */
  314. #define SIGCONT 25      /* continue a stopped process */
  315. #define SIGTTIN 26      /* to readers pgrp upon background tty read */
  316. #define SIGTTOU 27      /* like TTIN for output if (tp->t_local&LTOSTOP) */
  317. #define NSIG    28     
  318. #else
  319. #define SIGURG  16      /* urgent condition on IO channel */
  320. #define SIGSTOP 17      /* sendable stop signal not from tty */
  321. #define SIGTSTP 18      /* stop signal from tty */
  322. #define SIGCONT 19      /* continue a stopped process */
  323. #define SIGCHLD 20      /* to parent on child stop or exit */
  324. #define SIGCLD  20      /* System V name for SIGCHLD */
  325. #define SIGTTIN 21      /* to readers pgrp upon background tty read */
  326. #define SIGTTOU 22      /* like TTIN for output if (tp->t_local&LTOSTOP) */
  327. #define SIGIO   23      /* input/output possible signal */
  328. #define SIGPOLL SIGIO   /* System V name for SIGIO */
  329. #define SIGXCPU 24      /* exceeded CPU time limit */
  330. #define SIGXFSZ 25      /* exceeded file size limit */
  331. #define SIGVTALRM 26    /* virtual time alarm */
  332. #define SIGPROF 27      /* profiling time alarm */
  333. #define SIGWINCH 28     /* window changed */
  334. #define SIGLOST 29      /* resource lost (eg, record-lock lost) */
  335. #define SIGUSR1 30      /* user defined signal 1 */
  336. #define SIGUSR2 31      /* user defined signal 2 */
  337. #define NSIG    32      /* signal 0 implied */
  338. #endif
  339. #endif
  340.  
  341. #ifdef __cplusplus
  342. }
  343. #endif
  344.  
  345. #if defined(__CYGWIN__)
  346. #if __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
  347. #include <sys/ucontext.h>
  348. #endif
  349. #endif
  350.  
  351. #ifndef _SIGNAL_H_
  352. /* Some applications take advantage of the fact that <sys/signal.h>
  353.  * and <signal.h> are equivalent in glibc.  Allow for that here.  */
  354. #include <signal.h>
  355. #endif
  356. #endif /* _SYS_SIGNAL_H */
  357.