signal.inc 5.8 KB

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