libc_signal.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. */
  10. #ifndef LIBC_SIGNAL_H__
  11. #define LIBC_SIGNAL_H__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <stdint.h>
  16. #ifdef HAVE_CCONFIG_H
  17. #include <cconfig.h>
  18. #endif
  19. #ifndef HAVE_SIGVAL
  20. /* Signal Generation and Delivery, P1003.1b-1993, p. 63
  21. NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
  22. sigev_notify_attributes to the sigevent structure. */
  23. union sigval
  24. {
  25. int sival_int; /* Integer signal value */
  26. void *sival_ptr; /* Pointer signal value */
  27. };
  28. #endif
  29. #ifndef HAVE_SIGEVENT
  30. struct sigevent
  31. {
  32. int sigev_notify; /* Notification type */
  33. int sigev_signo; /* Signal number */
  34. union sigval sigev_value; /* Signal value */
  35. void (*sigev_notify_function)( union sigval );
  36. /* Notification function */
  37. void *sigev_notify_attributes; /* Notification Attributes, really pthread_attr_t */
  38. };
  39. #endif
  40. #ifndef HAVE_SIGINFO
  41. struct siginfo
  42. {
  43. uint16_t si_signo;
  44. uint16_t si_code;
  45. union sigval si_value;
  46. };
  47. typedef struct siginfo siginfo_t;
  48. #endif
  49. #define SI_USER 0x01 /* Signal sent by kill(). */
  50. #define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */
  51. #define SI_TIMER 0x03 /* Signal generated by expiration of a
  52. timer set by timer_settime(). */
  53. #define SI_ASYNCIO 0x04 /* Signal generated by completion of an
  54. asynchronous I/O request. */
  55. #define SI_MESGQ 0x05 /* Signal generated by arrival of a
  56. message on an empty message queue. */
  57. #if !defined(RT_USING_NEWLIB)
  58. typedef void (*_sig_func_ptr)(int);
  59. typedef unsigned long sigset_t;
  60. #endif
  61. #include <signal.h>
  62. #if defined(__CC_ARM) || defined(__CLANG_ARM)
  63. #define SIGHUP 1
  64. /* #define SIGINT 2 */
  65. #define SIGQUIT 3
  66. /* #define SIGILL 4 */
  67. #define SIGTRAP 5
  68. /* #define SIGABRT 6 */
  69. #define SIGEMT 7
  70. /* #define SIGFPE 8 */
  71. #define SIGKILL 9
  72. #define SIGBUS 10
  73. /* #define SIGSEGV 11 */
  74. #define SIGSYS 12
  75. #define SIGPIPE 13
  76. #define SIGALRM 14
  77. /* #define SIGTERM 15 */
  78. #define SIGURG 16
  79. #define SIGSTOP 17
  80. #define SIGTSTP 18
  81. #define SIGCONT 19
  82. #define SIGCHLD 20
  83. #define SIGTTIN 21
  84. #define SIGTTOU 22
  85. #define SIGPOLL 23
  86. #define SIGWINCH 24
  87. /* #define SIGUSR1 25 */
  88. /* #define SIGUSR2 26 */
  89. #define SIGRTMIN 27
  90. #define SIGRTMAX 31
  91. #define NSIG 32
  92. #define SIG_SETMASK 0 /* set mask with sigprocmask() */
  93. #define SIG_BLOCK 1 /* set of signals to block */
  94. #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
  95. struct sigaction
  96. {
  97. _sig_func_ptr sa_handler;
  98. sigset_t sa_mask;
  99. int sa_flags;
  100. };
  101. #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
  102. #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
  103. #define sigemptyset(what) (*(what) = 0, 0)
  104. #define sigfillset(what) (*(what) = ~(0), 0)
  105. #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
  106. int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
  107. int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
  108. #elif defined(__IAR_SYSTEMS_ICC__)
  109. #define SIGHUP 1
  110. #define SIGINT 2
  111. #define SIGQUIT 3
  112. #define SIGILL 4
  113. #define SIGTRAP 5
  114. /* #define SIGABRT 6 */
  115. #define SIGEMT 7
  116. #define SIGFPE 8
  117. #define SIGKILL 9
  118. #define SIGBUS 10
  119. #define SIGSEGV 11
  120. #define SIGSYS 12
  121. #define SIGPIPE 13
  122. #define SIGALRM 14
  123. #define SIGTERM 15
  124. #define SIGURG 16
  125. #define SIGSTOP 17
  126. #define SIGTSTP 18
  127. #define SIGCONT 19
  128. #define SIGCHLD 20
  129. #define SIGTTIN 21
  130. #define SIGTTOU 22
  131. #define SIGPOLL 23
  132. #define SIGWINCH 24
  133. #define SIGUSR1 25
  134. #define SIGUSR2 26
  135. #define SIGRTMIN 27
  136. #define SIGRTMAX 31
  137. #define NSIG 32
  138. #define SIG_SETMASK 0 /* set mask with sigprocmask() */
  139. #define SIG_BLOCK 1 /* set of signals to block */
  140. #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
  141. struct sigaction
  142. {
  143. _sig_func_ptr sa_handler;
  144. sigset_t sa_mask;
  145. int sa_flags;
  146. };
  147. #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
  148. #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
  149. #define sigemptyset(what) (*(what) = 0, 0)
  150. #define sigfillset(what) (*(what) = ~(0), 0)
  151. #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
  152. int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
  153. int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
  154. #endif
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif