signal.inc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. SA_NOCLDSTOP = 1;
  19. SA_SHIRQ = $04000000;
  20. SA_STACK = $08000000;
  21. SA_RESTART = $10000000;
  22. SA_INTERRUPT = $20000000;
  23. SA_NOMASK = $40000000;
  24. SA_ONESHOT = $80000000;
  25. SIG_BLOCK = 0;
  26. SIG_UNBLOCK = 1;
  27. SIG_SETMASK = 2;
  28. SIG_DFL = 0 ;
  29. SIG_IGN = 1 ;
  30. SIG_ERR = -1 ;
  31. SIGHUP = 1;
  32. SIGINT = 2;
  33. SIGQUIT = 3;
  34. SIGILL = 4;
  35. SIGTRAP = 5;
  36. SIGABRT = 6;
  37. SIGIOT = 6;
  38. SIGBUS = 7;
  39. SIGFPE = 8;
  40. SIGKILL = 9;
  41. SIGUSR1 = 10;
  42. SIGSEGV = 11;
  43. SIGUSR2 = 12;
  44. SIGPIPE = 13;
  45. SIGALRM = 14;
  46. SIGTerm = 15;
  47. SIGSTKFLT = 16;
  48. SIGCHLD = 17;
  49. SIGCONT = 18;
  50. SIGSTOP = 19;
  51. SIGTSTP = 20;
  52. SIGTTIN = 21;
  53. SIGTTOU = 22;
  54. SIGURG = 23;
  55. SIGXCPU = 24;
  56. SIGXFSZ = 25;
  57. SIGVTALRM = 26;
  58. SIGPROF = 27;
  59. SIGWINCH = 28;
  60. SIGIO = 29;
  61. SIGPOLL = SIGIO;
  62. SIGPWR = 30;
  63. SIGUNUSED = 31;
  64. const
  65. SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
  66. type
  67. tfpreg = record
  68. significand: array[0..3] of word;
  69. exponent: word;
  70. end;
  71. pfpstate = ^tfpstate;
  72. tfpstate = record
  73. cw, sw, tag, ipoff, cssel, dataoff, datasel: cardinal;
  74. st: array[0..7] of tfpreg;
  75. status: cardinal;
  76. end;
  77. {$ifdef cpui386}
  78. PSigContextRec = ^SigContextRec;
  79. SigContextRec = record
  80. gs, __gsh: word;
  81. fs, __fsh: word;
  82. es, __esh: word;
  83. ds, __dsh: word;
  84. edi: cardinal;
  85. esi: cardinal;
  86. ebp: cardinal;
  87. esp: cardinal;
  88. ebx: cardinal;
  89. edx: cardinal;
  90. ecx: cardinal;
  91. eax: cardinal;
  92. trapno: cardinal;
  93. err: cardinal;
  94. eip: cardinal;
  95. cs, __csh: word;
  96. eflags: cardinal;
  97. esp_at_signal: cardinal;
  98. ss, __ssh: word;
  99. fpstate: pfpstate;
  100. oldmask: cardinal;
  101. cr2: cardinal;
  102. end;
  103. {$endif cpui386}
  104. {$Ifdef cpum68k}
  105. PSigContextRec = ^SigContextRec;
  106. SigContextRec = record
  107. { dummy for now PM }
  108. end;
  109. {$endif cpum68k}
  110. {$ifdef cpupowerpc}
  111. PSigContextRec = ^SigContextRec;
  112. SigContextRec = record
  113. { dummy for now PM }
  114. end;
  115. {$endif cpupowerpc}
  116. {$ifdef cpusparc}
  117. PSigContextRec = ^SigContextRec;
  118. SigContextRec = record
  119. { dummy for now PM }
  120. end;
  121. {$endif cpusparc}
  122. {$ifdef cpuarm}
  123. PSigContextRec = ^SigContextRec;
  124. SigContextRec = record
  125. { dummy for now PM }
  126. end;
  127. {$endif cpuarm}
  128. (*
  129. PSigInfoRec = ^SigInfoRec;
  130. SigInfoRec = record
  131. si_signo: longint;
  132. si_errno: longint;
  133. si_code: longint;
  134. case longint of
  135. 0:
  136. (pad: array[SI_PAD_SIZE] of longint);
  137. 1: { kill }
  138. ( kill: record
  139. pid: longint; { sender's pid }
  140. uid : longint; { sender's uid }
  141. end );
  142. 2: { POSIX.1b timers }
  143. ( timer : record
  144. timer1 : cardinal;
  145. timer2 : cardinal;
  146. end );
  147. 3: { POSIX.1b signals }
  148. ( rt : record
  149. pid : longint; { sender's pid }
  150. uid : longint; { sender's uid }
  151. sigval : longint;
  152. end );
  153. 4: { SIGCHLD }
  154. ( sigchld : record
  155. pid : longint; { which child }
  156. uid : longint; { sender's uid }
  157. status : longint; { exit code }
  158. utime : timeval;
  159. stime : timeval;
  160. end );
  161. 5: { SIGILL, SIGFPE, SIGSEGV, SIGBUS }
  162. ( sigfault : record
  163. addr : pointer;{ faulting insn/memory ref. }
  164. end );
  165. 6:
  166. ( sigpoll : record
  167. band : longint; { POLL_IN, POLL_OUT, POLL_MSG }
  168. fd : longint;
  169. end );
  170. end;
  171. *)
  172. SignalHandler = Procedure(Sig : Longint);cdecl;
  173. PSignalHandler = ^SignalHandler;
  174. SignalRestorer = Procedure;cdecl;
  175. PSignalRestorer = ^SignalRestorer;
  176. TSigAction = procedure(Sig: Longint; SigContext: SigContextRec);cdecl;
  177. SigSet = array[0..wordsinsigset-1] of Longint;
  178. sigset_t= SigSet;
  179. PSigSet = ^SigSet;
  180. psigset_t=psigset;
  181. TSigSet = SigSet;
  182. SigActionRec = packed record // this is temporary for the migration
  183. {$ifdef posixworkaround}
  184. sa_handler : signalhandler;
  185. {$else}
  186. Handler : record
  187. case byte of
  188. 0: (Sh: SignalHandler);
  189. 1: (Sa: TSigAction);
  190. end;
  191. {$endif}
  192. Sa_Mask : SigSet;
  193. Sa_Flags : Longint;
  194. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  195. end;
  196. TSigActionRec = SigActionRec;
  197. PSigActionRec = ^SigActionRec;
  198. {
  199. $Log$
  200. Revision 1.12 2003-09-14 20:15:01 marco
  201. * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
  202. Revision 1.11 2003/09/03 14:09:37 florian
  203. * arm fixes to the common rtl code
  204. * some generic math code fixed
  205. * ...
  206. Revision 1.10 2003/08/21 22:24:52 olle
  207. - removed parameter from fpc_iocheck
  208. Revision 1.9 2002/12/24 21:30:20 mazen
  209. - some writeln(s) removed in compiler
  210. + many files added to RTL
  211. * some errors fixed in RTL
  212. Revision 1.8 2002/12/18 16:43:26 marco
  213. * new unix rtl, linux part.....
  214. Revision 1.7 2002/11/12 14:51:44 marco
  215. * signal.
  216. Revision 1.6 2002/09/07 16:01:19 peter
  217. * old logs removed and tabs fixed
  218. Revision 1.5 2002/07/28 20:43:48 florian
  219. * several fixes for linux/powerpc
  220. * several fixes to MT
  221. }