signal.inc 4.8 KB

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