signal.inc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Jonas Maebe,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$packrecords C}
  13. {********************
  14. Signal
  15. ********************}
  16. Const
  17. { For sending a signal }
  18. {$ifdef SPARC}
  19. SA_SIGINFO = $200;
  20. SA_NOMASK = $20;
  21. SIG_BLOCK = 1;
  22. SIG_UNBLOCK = 2;
  23. SIG_SETMASK = 4;
  24. {$else SPARC}
  25. SA_NOCLDSTOP = 1;
  26. SA_NOCLDWAIT = 2;
  27. SA_SIGINFO = 4;
  28. SA_SHIRQ = $04000000;
  29. SA_STACK = $08000000;
  30. SA_RESTART = $10000000;
  31. SA_INTERRUPT = $20000000;
  32. SA_NOMASK = $40000000;
  33. SA_ONESHOT = $80000000;
  34. SIG_BLOCK = 0;
  35. SIG_UNBLOCK = 1;
  36. SIG_SETMASK = 2;
  37. {$endif SPARC}
  38. SIG_DFL = 0 ;
  39. SIG_IGN = 1 ;
  40. SIG_ERR = -1 ;
  41. {$ifdef cpusparc}
  42. SIGHUP = 1;
  43. SIGINT = 2;
  44. SIGQUIT = 3;
  45. SIGILL = 4;
  46. SIGTRAP = 5;
  47. SIGABRT = 6;
  48. SIGIOT = 6;
  49. SIGEMT = 7;
  50. SIGFPE = 8;
  51. SIGKILL = 9;
  52. SIGBUS = 10;
  53. SIGSEGV = 11;
  54. SIGSYS = 12;
  55. SIGPIPE = 13;
  56. SIGALRM = 14;
  57. SIGTERM = 15;
  58. SIGURG = 16;
  59. SIGSTOP = 17;
  60. SIGTSTP = 18;
  61. SIGCONT = 19;
  62. SIGCHLD = 20;
  63. SIGTTIN = 21;
  64. SIGTTOU = 22;
  65. SIGIO = 23;
  66. SIGPOLL = SIGIO;
  67. SIGXCPU = 24;
  68. SIGXFSZ = 25;
  69. SIGVTALRM = 26;
  70. SIGPROF = 27;
  71. SIGWINCH = 28;
  72. SIGLOST = 29;
  73. SIGPWR = SIGLOST;
  74. SIGUSR1 = 30;
  75. SIGUSR2 = 31;
  76. {$else cpusparc}
  77. SIGHUP = 1;
  78. SIGINT = 2;
  79. SIGQUIT = 3;
  80. SIGILL = 4;
  81. SIGTRAP = 5;
  82. SIGABRT = 6;
  83. SIGIOT = 6;
  84. SIGBUS = 7;
  85. SIGFPE = 8;
  86. SIGKILL = 9;
  87. SIGUSR1 = 10;
  88. SIGSEGV = 11;
  89. SIGUSR2 = 12;
  90. SIGPIPE = 13;
  91. SIGALRM = 14;
  92. SIGTerm = 15;
  93. SIGSTKFLT = 16;
  94. SIGCHLD = 17;
  95. SIGCONT = 18;
  96. SIGSTOP = 19;
  97. SIGTSTP = 20;
  98. SIGTTIN = 21;
  99. SIGTTOU = 22;
  100. SIGURG = 23;
  101. SIGXCPU = 24;
  102. SIGXFSZ = 25;
  103. SIGVTALRM = 26;
  104. SIGPROF = 27;
  105. SIGWINCH = 28;
  106. SIGIO = 29;
  107. SIGPOLL = SIGIO;
  108. SIGPWR = 30;
  109. SIGUNUSED = 31;
  110. {$endif cpusparc}
  111. const
  112. SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
  113. type
  114. SigSet = array[0..wordsinsigset-1] of cint;
  115. sigset_t= SigSet;
  116. PSigSet = ^SigSet;
  117. psigset_t=psigset;
  118. TSigSet = SigSet;
  119. psiginfo = ^tsiginfo;
  120. tsiginfo = record
  121. si_signo : longint;
  122. si_errno : longint;
  123. si_code : longint;
  124. _sifields : record
  125. case longint of
  126. 0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
  127. 1 : ( _kill : record
  128. _pid : pid_t;
  129. _uid : uid_t;
  130. end );
  131. 2 : ( _timer : record
  132. _timer1 : dword;
  133. _timer2 : dword;
  134. end );
  135. 3 : ( _rt : record
  136. _pid : pid_t;
  137. _uid : uid_t;
  138. _sigval : pointer;
  139. end );
  140. 4 : ( _sigchld : record
  141. _pid : pid_t;
  142. _uid : uid_t;
  143. _status : longint;
  144. _utime : clock_t;
  145. _stime : clock_t;
  146. end );
  147. 5 : ( _sigfault : record
  148. _addr : pointer;
  149. end );
  150. 6 : ( _sigpoll : record
  151. _band : longint;
  152. _fd : longint;
  153. end );
  154. end;
  155. end;
  156. { CPU dependent TSigContext }
  157. {$i sighndh.inc}
  158. type
  159. SignalHandler = Procedure(Sig : Longint);cdecl;
  160. PSignalHandler = ^SignalHandler;
  161. SignalRestorer = Procedure;cdecl;
  162. PSignalRestorer = ^SignalRestorer;
  163. SigActionHandler = procedure(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
  164. {$ifdef CPUARM}
  165. {$define NEWSIGNAL}
  166. {$endif CPUARM}
  167. {$ifdef CPUx86_64}
  168. {$define NEWSIGNAL}
  169. {$endif CPUx86_64}
  170. SigActionRec = packed record // this is temporary for the migration
  171. sa_handler : SigActionHandler;
  172. {$ifdef NEWSIGNAL}
  173. Sa_Flags : cuint;
  174. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  175. Sa_Mask : SigSet;
  176. {$else NEWSIGNAL}
  177. Sa_Mask : SigSet;
  178. Sa_Flags : Longint;
  179. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  180. {$endif NEWSIGNAL}
  181. end;
  182. TSigActionRec = SigActionRec;
  183. PSigActionRec = ^SigActionRec;
  184. {
  185. $Log$
  186. Revision 1.26 2005-02-14 17:13:30 peter
  187. * truncate log
  188. Revision 1.25 2005/02/05 22:53:43 peter
  189. * use typecasted sigactionhandler, needed for arm
  190. Revision 1.24 2005/02/05 22:45:54 peter
  191. * sigactionhandler fixed for arm
  192. Revision 1.23 2005/01/30 18:01:15 peter
  193. * signal cleanup for linux
  194. * sigactionhandler instead of tsigaction for bsds
  195. * sigcontext moved to cpu dir
  196. }