signal.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. {
  2. $Id: signal.inc,v 1.1.2.2 2002/10/10 19:31:28 pierre Exp $
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Pierre Muller,
  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. { not sure this value is correct for m68k PM }
  65. const
  66. SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
  67. type
  68. { REMARK: floating point regs are defined as arrays of
  69. 3 longints; I don't know if C does align this to
  70. 16 byte boundaries for each element of the array PM }
  71. { If C does we might need to define this as
  72. array from 0 to 3 }
  73. tfpreg = array[0..2] of longint;
  74. pfpstate = ^tfpstate;
  75. tfpstate = record
  76. pcr,psr,fpiaddr : longint;
  77. fpreg : array [0..7] of tfpreg;
  78. end;
  79. Size_T = cardinal;
  80. SigSet = Longint;
  81. PSigSet = ^SigSet;
  82. { as defined in asm_m68k/signal.h }
  83. Stack_T = Record
  84. ss_sp : pointer;
  85. ss_flags : longint;
  86. ss_size : size_t;
  87. end;
  88. { SigContextRec corresponds to the ucontext record
  89. in linux asm-m68k/ucontext.h include file }
  90. PSigContextRec = ^SigContextRec;
  91. SigContextRec = record
  92. uc_flags : cardinal;
  93. uc_link : pSigContextRec;
  94. uc_stack : stack_t; { what's that ?? }
  95. { fields from 'version' to 'pc'
  96. correspond to the mcontext struct in asm-m68k/ucontext.h file }
  97. version : longint; { SigContext version check }
  98. { 18 general registers }
  99. d0,d1,d2,d3,d4,d5,d6,d7 : cardinal;
  100. a0,a1,a2,a3,a4,a5 : cardinal;
  101. fp,sp,ps,pc : cardinal;
  102. { fields from 'pcr' to 'fpreg'
  103. are floating point part }
  104. pcr,psr,fpiaddr : longint;
  105. fpreg : array[0..7] of tfpreg; { how is this aligned ?? }
  106. filler : array[0..79] of cardinal;
  107. sigmask : SigSet;
  108. end;
  109. PSigInfoRec = ^SigInfoRec;
  110. SigInfoRec = record
  111. si_signo: longint;
  112. si_errno: longint;
  113. si_code: longint;
  114. case longint of
  115. 0:
  116. (pad: array[0 .. SI_PAD_SIZE-1] of longint);
  117. 1: { kill }
  118. ( kill: record
  119. pid: longint; { sender's pid }
  120. uid : longint; { sender's uid }
  121. end );
  122. 2: { POSIX.1b timers }
  123. ( timer : record
  124. timer1 : cardinal;
  125. timer2 : cardinal;
  126. end );
  127. 3: { POSIX.1b signals }
  128. ( rt : record
  129. pid : longint; { sender's pid }
  130. uid : longint; { sender's uid }
  131. sigval : longint;
  132. end );
  133. 4: { SIGCHLD }
  134. ( sigchld : record
  135. pid : longint; { which child }
  136. uid : longint; { sender's uid }
  137. status : longint; { exit code }
  138. utime : timeval;
  139. stime : timeval;
  140. end );
  141. 5: { SIGILL, SIGFPE, SIGSEGV, SIGBUS }
  142. ( sigfault : record
  143. addr : pointer;{ faulting insn/memory ref. }
  144. end );
  145. 6:
  146. ( sigpoll : record
  147. band : longint; { POLL_IN, POLL_OUT, POLL_MSG }
  148. fd : longint;
  149. end );
  150. end;
  151. SignalHandler = Procedure(Sig : Longint);cdecl;
  152. PSignalHandler = ^SignalHandler;
  153. SignalRestorer = Procedure;cdecl;
  154. PSignalRestorer = ^SignalRestorer;
  155. { the third argument is only a guess for now,
  156. asm-m68k/signal.h gives only void * arg type PM }
  157. TSigAction = procedure(Sig: Longint; SigInfoPtr : PSigInfoRec; SigContextPtr : PSigContextRec);cdecl;
  158. SigActionRec = packed record
  159. Handler : record
  160. case byte of
  161. 0: (Sh: SignalHandler);
  162. 1: (Sa: TSigAction);
  163. end;
  164. Sa_Mask : SigSet;
  165. Sa_Flags : Longint;
  166. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  167. end;
  168. PSigActionRec = ^SigActionRec;
  169. (*
  170. Procedure SigAction(Signum:Integer;Act,OldAct:PSigActionRec );
  171. {
  172. Change action of process upon receipt of a signal.
  173. Signum specifies the signal (all except SigKill and SigStop).
  174. If Act is non-nil, it is used to specify the new action.
  175. If OldAct is non-nil the previous action is saved there.
  176. }
  177. Var
  178. sr : Syscallregs;
  179. begin
  180. sr.reg2:=Signum;
  181. sr.reg3:=Longint(act);
  182. sr.reg4:=Longint(oldact);
  183. SysCall(Syscall_nr_sigaction,sr);
  184. end; *)
  185. {
  186. $Log: signal.inc,v $
  187. Revision 1.1.2.2 2002/10/10 19:31:28 pierre
  188. * update those files that are unused currently
  189. Revision 1.1.2.1 2001/07/13 15:05:40 pierre
  190. + first signal context tries
  191. }