signal.inc 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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.23 2005-01-30 18:01:15 peter
  187. * signal cleanup for linux
  188. * sigactionhandler instead of tsigaction for bsds
  189. * sigcontext moved to cpu dir
  190. Revision 1.22 2004/08/04 19:27:10 florian
  191. * fixed floating point and integer exception handling on sparc/linux
  192. Revision 1.21 2004/05/31 09:08:14 peter
  193. * added siginfo const
  194. Revision 1.20 2004/05/27 23:15:43 peter
  195. * sparc signals added between $ifdef cpusparc
  196. Revision 1.19 2004/05/01 15:59:17 florian
  197. * x86_64 exception handling fixed
  198. Revision 1.18 2004/04/27 20:47:00 florian
  199. * tried to fix x86-64 signal handling
  200. Revision 1.17 2004/03/27 14:35:13 florian
  201. * structs for arm adapted
  202. Revision 1.16 2004/02/05 01:16:12 florian
  203. + completed x86-64/linux system unit
  204. Revision 1.15 2004/01/01 16:28:16 jonas
  205. * fixed signal handling
  206. Revision 1.14 2003/11/21 00:40:06 florian
  207. * some arm issues fixed
  208. Revision 1.13 2003/11/02 14:53:06 jonas
  209. + sighand and associated record definitions for ppc. Untested.
  210. Revision 1.12 2003/09/14 20:15:01 marco
  211. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  212. Revision 1.11 2003/09/03 14:09:37 florian
  213. * arm fixes to the common rtl code
  214. * some generic math code fixed
  215. * ...
  216. Revision 1.10 2003/08/21 22:24:52 olle
  217. - removed parameter from fpc_iocheck
  218. Revision 1.9 2002/12/24 21:30:20 mazen
  219. - some writeln(s) removed in compiler
  220. + many files added to RTL
  221. * some errors fixed in RTL
  222. Revision 1.8 2002/12/18 16:43:26 marco
  223. * new unix rtl, linux part.....
  224. Revision 1.7 2002/11/12 14:51:44 marco
  225. * signal.
  226. Revision 1.6 2002/09/07 16:01:19 peter
  227. * old logs removed and tabs fixed
  228. Revision 1.5 2002/07/28 20:43:48 florian
  229. * several fixes for linux/powerpc
  230. * several fixes to MT
  231. }