signal.inc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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_SHIRQ = $04000000;
  28. SA_STACK = $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 = array[0..wordsinsigset-1] of cuLong;
  124. sigset_t= SigSet;
  125. PSigSet = ^SigSet;
  126. psigset_t=psigset;
  127. TSigSet = SigSet;
  128. psiginfo = ^tsiginfo;
  129. tsiginfo = record
  130. si_signo : longint;
  131. si_errno : longint;
  132. si_code : longint;
  133. _sifields : record
  134. case longint of
  135. 0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
  136. 1 : ( _kill : record
  137. _pid : pid_t;
  138. _uid : uid_t;
  139. end );
  140. 2 : ( _timer : record
  141. _timer1 : dword;
  142. _timer2 : dword;
  143. end );
  144. 3 : ( _rt : record
  145. _pid : pid_t;
  146. _uid : uid_t;
  147. _sigval : pointer;
  148. end );
  149. 4 : ( _sigchld : record
  150. _pid : pid_t;
  151. _uid : uid_t;
  152. _status : longint;
  153. _utime : clock_t;
  154. _stime : clock_t;
  155. end );
  156. 5 : ( _sigfault : record
  157. _addr : pointer;
  158. end );
  159. 6 : ( _sigpoll : record
  160. _band : longint;
  161. _fd : longint;
  162. end );
  163. end;
  164. end;
  165. { CPU dependent TSigContext }
  166. {$i sighndh.inc}
  167. type
  168. SignalHandler = Procedure(Sig : Longint);cdecl;
  169. PSignalHandler = ^SignalHandler;
  170. SignalRestorer = Procedure;cdecl;
  171. PSignalRestorer = ^SignalRestorer;
  172. SigActionHandler = procedure(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
  173. {$ifdef CPUARM}
  174. {$define NEWSIGNAL}
  175. {$endif CPUARM}
  176. {$ifdef CPUx86_64}
  177. {$define NEWSIGNAL}
  178. {$endif CPUx86_64}
  179. {$ifdef CPUPOWERPC64}
  180. {$define NEWSIGNAL}
  181. {$endif CPUPOWERPC64}
  182. SigActionRec = packed record // this is temporary for the migration
  183. sa_handler : SigActionHandler;
  184. {$ifdef NEWSIGNAL}
  185. Sa_Flags : culong;
  186. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  187. Sa_Mask : SigSet;
  188. {$else NEWSIGNAL}
  189. Sa_Mask : SigSet;
  190. Sa_Flags : cuLong;
  191. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  192. {$endif NEWSIGNAL}
  193. end;
  194. TSigActionRec = SigActionRec;
  195. PSigActionRec = ^SigActionRec;