signal.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2017-09-12 Bernard The first version
  9. * 2021-07-21 Meco Man move to libc/common
  10. */
  11. #ifndef __SYS_SIGNAL_H__
  12. #define __SYS_SIGNAL_H__
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #include <stdint.h>
  17. /* Signal Generation and Delivery, P1003.1b-1993, p. 63
  18. NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
  19. sigev_notify_attributes to the sigevent structure. */
  20. union sigval
  21. {
  22. int sival_int; /* Integer signal value */
  23. void *sival_ptr; /* Pointer signal value */
  24. };
  25. struct sigevent
  26. {
  27. int sigev_notify; /* Notification type */
  28. int sigev_signo; /* Signal number */
  29. union sigval sigev_value; /* Signal value */
  30. void (*sigev_notify_function)( union sigval );
  31. /* Notification function */
  32. void *sigev_notify_attributes; /* Notification Attributes, really pthread_attr_t */
  33. };
  34. struct siginfo
  35. {
  36. uint16_t si_signo;
  37. uint16_t si_code;
  38. union sigval si_value;
  39. };
  40. typedef struct siginfo siginfo_t;
  41. #define SI_USER 0x01 /* Signal sent by kill(). */
  42. #define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */
  43. #define SI_TIMER 0x03 /* Signal generated by expiration of a timer set by timer_settime(). */
  44. #define SI_ASYNCIO 0x04 /* Signal generated by completion of an asynchronous I/O request. */
  45. #define SI_MESGQ 0x05 /* Signal generated by arrival of a message on an empty message queue. */
  46. typedef void (*_sig_func_ptr)(int);
  47. typedef unsigned long sigset_t;
  48. struct sigaction
  49. {
  50. _sig_func_ptr sa_handler;
  51. sigset_t sa_mask;
  52. int sa_flags;
  53. };
  54. #define SIG_SETMASK 0 /* set mask with sigprocmask() */
  55. #define SIG_BLOCK 1 /* set of signals to block */
  56. #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
  57. #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
  58. #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
  59. #define sigemptyset(what) (*(what) = 0, 0)
  60. #define sigfillset(what) (*(what) = ~(0), 0)
  61. #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
  62. int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
  63. int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
  64. #ifdef __ARMCC_VERSION
  65. #define SIGHUP 1
  66. /* #define SIGINT 2 */
  67. #define SIGQUIT 3
  68. /* #define SIGILL 4 */
  69. #define SIGTRAP 5
  70. /* #define SIGABRT 6 */
  71. #define SIGEMT 7
  72. /* #define SIGFPE 8 */
  73. #define SIGKILL 9
  74. #define SIGBUS 10
  75. /* #define SIGSEGV 11 */
  76. #define SIGSYS 12
  77. #define SIGPIPE 13
  78. #define SIGALRM 14
  79. /* #define SIGTERM 15 */
  80. #define SIGURG 16
  81. #define SIGSTOP 17
  82. #define SIGTSTP 18
  83. #define SIGCONT 19
  84. #define SIGCHLD 20
  85. #define SIGTTIN 21
  86. #define SIGTTOU 22
  87. #define SIGPOLL 23
  88. #define SIGWINCH 24
  89. /* #define SIGUSR1 25 */
  90. /* #define SIGUSR2 26 */
  91. #define SIGRTMIN 27
  92. #define SIGRTMAX 31
  93. #define NSIG 32
  94. #include <signal.h>
  95. #elif defined(__IAR_SYSTEMS_ICC__)
  96. #define SIGHUP 1
  97. #define SIGINT 2
  98. #define SIGQUIT 3
  99. #define SIGILL 4
  100. #define SIGTRAP 5
  101. /* #define SIGABRT 6 */
  102. #define SIGEMT 7
  103. #define SIGFPE 8
  104. #define SIGKILL 9
  105. #define SIGBUS 10
  106. #define SIGSEGV 11
  107. #define SIGSYS 12
  108. #define SIGPIPE 13
  109. #define SIGALRM 14
  110. #define SIGTERM 15
  111. #define SIGURG 16
  112. #define SIGSTOP 17
  113. #define SIGTSTP 18
  114. #define SIGCONT 19
  115. #define SIGCHLD 20
  116. #define SIGTTIN 21
  117. #define SIGTTOU 22
  118. #define SIGPOLL 23
  119. #define SIGWINCH 24
  120. #define SIGUSR1 25
  121. #define SIGUSR2 26
  122. #define SIGRTMIN 27
  123. #define SIGRTMAX 31
  124. #define NSIG 32
  125. #include <signal.h>
  126. #elif defined(__GNUC__)
  127. #define SIGHUP 1 /* hangup */
  128. #define SIGINT 2 /* interrupt */
  129. #define SIGQUIT 3 /* quit */
  130. #define SIGILL 4 /* illegal instruction (not reset when caught) */
  131. #define SIGTRAP 5 /* trace trap (not reset when caught) */
  132. #define SIGIOT 6 /* IOT instruction */
  133. #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
  134. #define SIGEMT 7 /* EMT instruction */
  135. #define SIGFPE 8 /* floating point exception */
  136. #define SIGKILL 9 /* kill (cannot be caught or ignored) */
  137. #define SIGBUS 10 /* bus error */
  138. #define SIGSEGV 11 /* segmentation violation */
  139. #define SIGSYS 12 /* bad argument to system call */
  140. #define SIGPIPE 13 /* write on a pipe with no one to read it */
  141. #define SIGALRM 14 /* alarm clock */
  142. #define SIGTERM 15 /* software termination signal from kill */
  143. #define SIGURG 16 /* urgent condition on IO channel */
  144. #define SIGSTOP 17 /* sendable stop signal not from tty */
  145. #define SIGTSTP 18 /* stop signal from tty */
  146. #define SIGCONT 19 /* continue a stopped process */
  147. #define SIGCHLD 20 /* to parent on child stop or exit */
  148. #define SIGCLD 20 /* System V name for SIGCHLD */
  149. #define SIGTTIN 21 /* to readers pgrp upon background tty read */
  150. #define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
  151. #define SIGIO 23 /* input/output possible signal */
  152. #define SIGPOLL SIGIO /* System V name for SIGIO */
  153. #define SIGXCPU 24 /* exceeded CPU time limit */
  154. #define SIGXFSZ 25 /* exceeded file size limit */
  155. #define SIGVTALRM 26 /* virtual time alarm */
  156. #define SIGPROF 27 /* profiling time alarm */
  157. #define SIGWINCH 28 /* window changed */
  158. #define SIGLOST 29 /* resource lost (eg, record-lock lost) */
  159. #define SIGUSR1 30 /* user defined signal 1 */
  160. #define SIGUSR2 31 /* user defined signal 2 */
  161. #define NSIG 32 /* signal 0 implied */
  162. #ifndef _SIGNAL_H_
  163. /* Some applications take advantage of the fact that <sys/signal.h>
  164. * and <signal.h> are equivalent in glibc. Allow for that here. */
  165. #include <signal.h>
  166. #endif
  167. #endif
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif