signal.inc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. (*
  128. PSigInfoRec = ^SigInfoRec;
  129. SigInfoRec = record
  130. si_signo: longint;
  131. si_errno: longint;
  132. si_code: longint;
  133. case longint of
  134. 0:
  135. (pad: array[SI_PAD_SIZE] of longint);
  136. 1: { kill }
  137. ( kill: record
  138. pid: longint; { sender's pid }
  139. uid : longint; { sender's uid }
  140. end );
  141. 2: { POSIX.1b timers }
  142. ( timer : record
  143. timer1 : cardinal;
  144. timer2 : cardinal;
  145. end );
  146. 3: { POSIX.1b signals }
  147. ( rt : record
  148. pid : longint; { sender's pid }
  149. uid : longint; { sender's uid }
  150. sigval : longint;
  151. end );
  152. 4: { SIGCHLD }
  153. ( sigchld : record
  154. pid : longint; { which child }
  155. uid : longint; { sender's uid }
  156. status : longint; { exit code }
  157. utime : timeval;
  158. stime : timeval;
  159. end );
  160. 5: { SIGILL, SIGFPE, SIGSEGV, SIGBUS }
  161. ( sigfault : record
  162. addr : pointer;{ faulting insn/memory ref. }
  163. end );
  164. 6:
  165. ( sigpoll : record
  166. band : longint; { POLL_IN, POLL_OUT, POLL_MSG }
  167. fd : longint;
  168. end );
  169. end;
  170. *)
  171. SignalHandler = Procedure(Sig : Longint);cdecl;
  172. PSignalHandler = ^SignalHandler;
  173. SignalRestorer = Procedure;cdecl;
  174. PSignalRestorer = ^SignalRestorer;
  175. TSigAction = procedure(Sig: Longint; SigContext: SigContextRec);cdecl;
  176. SigSet = array[0..wordsinsigset-1] of Longint;
  177. sigset_t= SigSet;
  178. PSigSet = ^SigSet;
  179. psigset_t=psigset;
  180. TSigSet = SigSet;
  181. SigActionRec = packed record // this is temporary for the migration
  182. {$ifdef posixworkaround}
  183. sa_handler : signalhandler;
  184. {$else}
  185. Handler : record
  186. case byte of
  187. 0: (Sh: SignalHandler);
  188. 1: (Sa: TSigAction);
  189. end;
  190. {$endif}
  191. Sa_Mask : SigSet;
  192. Sa_Flags : Longint;
  193. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  194. end;
  195. TSigActionRec = SigActionRec;
  196. PSigActionRec = ^SigActionRec;
  197. {
  198. $Log$
  199. Revision 1.10 2003-08-21 22:24:52 olle
  200. - removed parameter from fpc_iocheck
  201. Revision 1.9 2002/12/24 21:30:20 mazen
  202. - some writeln(s) removed in compiler
  203. + many files added to RTL
  204. * some errors fixed in RTL
  205. Revision 1.8 2002/12/18 16:43:26 marco
  206. * new unix rtl, linux part.....
  207. Revision 1.7 2002/11/12 14:51:44 marco
  208. * signal.
  209. Revision 1.6 2002/09/07 16:01:19 peter
  210. * old logs removed and tabs fixed
  211. Revision 1.5 2002/07/28 20:43:48 florian
  212. * several fixes for linux/powerpc
  213. * several fixes to MT
  214. }