signal.inc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 SPARC}
  18. SA_SIGINFO = $200;
  19. SA_NOMASK = $20;
  20. SIG_BLOCK = 1;
  21. SIG_UNBLOCK = 2;
  22. SIG_SETMASK = 4;
  23. {$else SPARC}
  24. SA_NOCLDSTOP = 1;
  25. SA_NOCLDWAIT = 2;
  26. SA_SIGINFO = 4;
  27. SA_RESTORER = $04000000;
  28. SA_ONSTACK = $08000000;
  29. SA_RESTART = $10000000;
  30. SA_INTERRUPT = $20000000;
  31. SA_NODEFER = $40000000;
  32. SA_RESETHAND = $80000000;
  33. SA_NOMASK = SA_NODEFER;
  34. SA_ONESHOT = SA_RESETHAND;
  35. SIG_BLOCK = 0;
  36. SIG_UNBLOCK = 1;
  37. SIG_SETMASK = 2;
  38. {$endif SPARC}
  39. SIG_DFL = 0 ;
  40. SIG_IGN = 1 ;
  41. SIG_ERR = -1 ;
  42. {$ifdef cpusparc}
  43. SIGHUP = 1;
  44. SIGINT = 2;
  45. SIGQUIT = 3;
  46. SIGILL = 4;
  47. SIGTRAP = 5;
  48. SIGABRT = 6;
  49. SIGIOT = 6;
  50. SIGEMT = 7;
  51. SIGFPE = 8;
  52. SIGKILL = 9;
  53. SIGBUS = 10;
  54. SIGSEGV = 11;
  55. SIGSYS = 12;
  56. SIGPIPE = 13;
  57. SIGALRM = 14;
  58. SIGTERM = 15;
  59. SIGURG = 16;
  60. SIGSTOP = 17;
  61. SIGTSTP = 18;
  62. SIGCONT = 19;
  63. SIGCHLD = 20;
  64. SIGTTIN = 21;
  65. SIGTTOU = 22;
  66. SIGIO = 23;
  67. SIGPOLL = SIGIO;
  68. SIGXCPU = 24;
  69. SIGXFSZ = 25;
  70. SIGVTALRM = 26;
  71. SIGPROF = 27;
  72. SIGWINCH = 28;
  73. SIGLOST = 29;
  74. SIGPWR = SIGLOST;
  75. SIGUSR1 = 30;
  76. SIGUSR2 = 31;
  77. {$else cpusparc}
  78. SIGHUP = 1;
  79. SIGINT = 2;
  80. SIGQUIT = 3;
  81. SIGILL = 4;
  82. SIGTRAP = 5;
  83. SIGABRT = 6;
  84. SIGIOT = 6;
  85. SIGBUS = 7;
  86. SIGFPE = 8;
  87. SIGKILL = 9;
  88. SIGUSR1 = 10;
  89. SIGSEGV = 11;
  90. SIGUSR2 = 12;
  91. SIGPIPE = 13;
  92. SIGALRM = 14;
  93. SIGTerm = 15;
  94. SIGSTKFLT = 16;
  95. SIGCHLD = 17;
  96. SIGCONT = 18;
  97. SIGSTOP = 19;
  98. SIGTSTP = 20;
  99. SIGTTIN = 21;
  100. SIGTTOU = 22;
  101. SIGURG = 23;
  102. SIGXCPU = 24;
  103. SIGXFSZ = 25;
  104. SIGVTALRM = 26;
  105. SIGPROF = 27;
  106. SIGWINCH = 28;
  107. SIGIO = 29;
  108. SIGPOLL = SIGIO;
  109. SIGPWR = 30;
  110. SIGUNUSED = 31;
  111. {$endif cpusparc}
  112. { si_code field values for tsiginfo.si_code when si_signo = SIGFPE }
  113. const
  114. FPE_INTDIV = 1; { integer divide by zero }
  115. FPE_INTOVF = 2; { integer overflow }
  116. FPE_FLTDIV = 3; { floating point divide by zero }
  117. FPE_FLTOVF = 4; { floating point overflow }
  118. FPE_FLTUND = 5; { floating point underflow }
  119. FPE_FLTRES = 6; { floating point inexact result }
  120. FPE_FLTINV = 7; { floating point invalid operation }
  121. FPE_FLTSUB = 8; { floating point subscript out of range }
  122. const
  123. SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
  124. type
  125. sigset_t = array[0..wordsinsigset-1] of cuLong;
  126. tsigset = sigset_t;
  127. sigset = sigset_t;
  128. psigset = ^tsigset;
  129. psiginfo = ^tsiginfo;
  130. tsiginfo = record
  131. si_signo : longint;
  132. si_errno : longint;
  133. si_code : longint;
  134. _sifields : record
  135. case longint of
  136. 0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
  137. 1 : ( _kill : record
  138. _pid : pid_t;
  139. _uid : uid_t;
  140. end );
  141. 2 : ( _timer : record
  142. _timer1 : dword;
  143. _timer2 : dword;
  144. end );
  145. 3 : ( _rt : record
  146. _pid : pid_t;
  147. _uid : uid_t;
  148. _sigval : pointer;
  149. end );
  150. 4 : ( _sigchld : record
  151. _pid : pid_t;
  152. _uid : uid_t;
  153. _status : longint;
  154. _utime : clock_t;
  155. _stime : clock_t;
  156. end );
  157. 5 : ( _sigfault : record
  158. _addr : pointer;
  159. end );
  160. 6 : ( _sigpoll : record
  161. _band : longint;
  162. _fd : longint;
  163. end );
  164. end;
  165. end;
  166. { CPU dependent TSigContext }
  167. {$i sighndh.inc}
  168. type
  169. signalhandler_t = procedure(signal: longint); cdecl;
  170. sigactionhandler_t = procedure(signal: longint; info: psiginfo; context: psigcontext); cdecl;
  171. sigrestorerhandler_t = procedure; cdecl;
  172. signalhandler = signalhandler_t;
  173. sigactionhandler = sigactionhandler_t;
  174. sigrestorerhandler = sigrestorerhandler_t;
  175. tsignalhandler = signalhandler_t;
  176. tsigactionhandler = sigactionhandler_t;
  177. tsigrestorerhandler = sigrestorerhandler_t;
  178. psigactionrec = ^sigactionrec;
  179. sigactionrec = record
  180. sa_handler: sigactionhandler_t;
  181. sa_flags: culong;
  182. sa_restorer: sigrestorerhandler_t;
  183. sa_mask: sigset_t;
  184. end;