signal.inc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Jonas Maebe,
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$packrecords C}
  12. {********************
  13. Signal
  14. ********************}
  15. Const
  16. { For sending a signal }
  17. {$ifdef CPUSPARC}
  18. SA_SIGINFO = $200;
  19. SA_NOMASK = $20;
  20. SIG_BLOCK = 1;
  21. SIG_UNBLOCK = 2;
  22. SIG_SETMASK = 4;
  23. {$else CPUSPARC}
  24. {$if defined(cpumips) or defined(cpumipsel)}
  25. SA_NOCLDSTOP = 1;
  26. SA_NOCLDWAIT = $10000;
  27. SA_SIGINFO = 8;
  28. {$else CPUMIPS}
  29. SA_NOCLDSTOP = 1;
  30. SA_NOCLDWAIT = 2;
  31. SA_SIGINFO = 4;
  32. {$endif CPUMIPS}
  33. SA_RESTORER = $04000000;
  34. SA_ONSTACK = $08000000;
  35. SA_RESTART = $10000000;
  36. SA_INTERRUPT = $20000000;
  37. SA_NODEFER = $40000000;
  38. SA_RESETHAND = $80000000;
  39. SA_NOMASK = SA_NODEFER;
  40. SA_ONESHOT = SA_RESETHAND;
  41. SIG_BLOCK = 0;
  42. SIG_UNBLOCK = 1;
  43. SIG_SETMASK = 2;
  44. {$endif CPUSPARC}
  45. SIG_DFL = 0 ;
  46. SIG_IGN = 1 ;
  47. SIG_ERR = -1 ;
  48. {$ifdef cpusparc}
  49. SIGHUP = 1;
  50. SIGINT = 2;
  51. SIGQUIT = 3;
  52. SIGILL = 4;
  53. SIGTRAP = 5;
  54. SIGABRT = 6;
  55. SIGIOT = 6;
  56. SIGEMT = 7;
  57. SIGFPE = 8;
  58. SIGKILL = 9;
  59. SIGBUS = 10;
  60. SIGSEGV = 11;
  61. SIGSYS = 12;
  62. SIGPIPE = 13;
  63. SIGALRM = 14;
  64. SIGTERM = 15;
  65. SIGURG = 16;
  66. SIGSTOP = 17;
  67. SIGTSTP = 18;
  68. SIGCONT = 19;
  69. SIGCHLD = 20;
  70. SIGTTIN = 21;
  71. SIGTTOU = 22;
  72. SIGIO = 23;
  73. SIGPOLL = SIGIO;
  74. SIGXCPU = 24;
  75. SIGXFSZ = 25;
  76. SIGVTALRM = 26;
  77. SIGPROF = 27;
  78. SIGWINCH = 28;
  79. SIGLOST = 29;
  80. SIGPWR = SIGLOST;
  81. SIGUSR1 = 30;
  82. SIGUSR2 = 31;
  83. {$else cpusparc}
  84. SIGHUP = 1;
  85. SIGINT = 2;
  86. SIGQUIT = 3;
  87. SIGILL = 4;
  88. SIGTRAP = 5;
  89. SIGABRT = 6;
  90. SIGIOT = 6;
  91. SIGBUS = 7;
  92. SIGFPE = 8;
  93. SIGKILL = 9;
  94. SIGUSR1 = 10;
  95. SIGSEGV = 11;
  96. SIGUSR2 = 12;
  97. SIGPIPE = 13;
  98. SIGALRM = 14;
  99. SIGTerm = 15;
  100. SIGSTKFLT = 16;
  101. SIGCHLD = 17;
  102. SIGCONT = 18;
  103. SIGSTOP = 19;
  104. SIGTSTP = 20;
  105. SIGTTIN = 21;
  106. SIGTTOU = 22;
  107. SIGURG = 23;
  108. SIGXCPU = 24;
  109. SIGXFSZ = 25;
  110. SIGVTALRM = 26;
  111. SIGPROF = 27;
  112. SIGWINCH = 28;
  113. SIGIO = 29;
  114. SIGPOLL = SIGIO;
  115. SIGPWR = 30;
  116. SIGUNUSED = 31;
  117. {$endif cpusparc}
  118. { si_code field values for tsiginfo.si_code when si_signo = SIGFPE }
  119. const
  120. FPE_INTDIV = 1; { integer divide by zero }
  121. FPE_INTOVF = 2; { integer overflow }
  122. FPE_FLTDIV = 3; { floating point divide by zero }
  123. FPE_FLTOVF = 4; { floating point overflow }
  124. FPE_FLTUND = 5; { floating point underflow }
  125. FPE_FLTRES = 6; { floating point inexact result }
  126. FPE_FLTINV = 7; { floating point invalid operation }
  127. FPE_FLTSUB = 8; { floating point subscript out of range }
  128. const
  129. SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
  130. type
  131. sigset_t = array[0..wordsinsigset-1] of cuLong;
  132. tsigset = sigset_t;
  133. sigset = sigset_t;
  134. psigset = ^tsigset;
  135. psiginfo = ^tsiginfo;
  136. tsiginfo = record
  137. si_signo : longint;
  138. si_errno : longint;
  139. si_code : longint;
  140. _sifields : record
  141. case longint of
  142. 0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
  143. 1 : ( _kill : record
  144. _pid : pid_t;
  145. _uid : uid_t;
  146. end );
  147. 2 : ( _timer : record
  148. _timer1 : dword;
  149. _timer2 : dword;
  150. end );
  151. 3 : ( _rt : record
  152. _pid : pid_t;
  153. _uid : uid_t;
  154. _sigval : pointer;
  155. end );
  156. 4 : ( _sigchld : record
  157. _pid : pid_t;
  158. _uid : uid_t;
  159. _status : longint;
  160. _utime : clock_t;
  161. _stime : clock_t;
  162. end );
  163. 5 : ( _sigfault : record
  164. _addr : pointer;
  165. end );
  166. 6 : ( _sigpoll : record
  167. _band : longint;
  168. _fd : longint;
  169. end );
  170. end;
  171. end;
  172. { CPU dependent TSigContext }
  173. {$i sighndh.inc}
  174. type
  175. signalhandler_t = procedure(signal: longint); cdecl;
  176. sigactionhandler_t = procedure(signal: longint; info: psiginfo; context: psigcontext); cdecl;
  177. sigrestorerhandler_t = procedure; cdecl;
  178. signalhandler = signalhandler_t;
  179. sigactionhandler = sigactionhandler_t;
  180. sigrestorerhandler = sigrestorerhandler_t;
  181. tsignalhandler = signalhandler_t;
  182. tsigactionhandler = sigactionhandler_t;
  183. tsigrestorerhandler = sigrestorerhandler_t;
  184. psigactionrec = ^sigactionrec;
  185. {$ifdef FPC_USE_LIBC} // libc order is different ?
  186. sigactionrec = record
  187. sa_handler: sigactionhandler_t;
  188. sa_mask: sigset_t;
  189. sa_flags: cint;
  190. sa_restorer: sigrestorerhandler_t;
  191. end;
  192. {$else}
  193. sigactionrec = record
  194. sa_handler: sigactionhandler_t;
  195. sa_flags: culong;
  196. sa_restorer: sigrestorerhandler_t;
  197. sa_mask: sigset_t;
  198. end;
  199. {$endif}