2
0

signal.inc 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Jonas Maebe,
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Const { For sending a signal }
  12. SA_NOCLDSTOP = 1;
  13. // does not exist under BeOS i think !
  14. SA_ONSTACK = $001; { take signal on signal stack }
  15. SA_RESTART = $002; { restart system call on signal return }
  16. SA_RESETHAND = $004; { reset to SIG_DFL when taking signal }
  17. SA_NODEFER = $010; { don't mask the signal we're delivering }
  18. SA_NOCLDWAIT = $020; { don't keep zombies around }
  19. SA_SIGINFO = $040; { signal handler with SA_SIGINFO args }
  20. SA_USERTRAMP = $100; { SUNOS compat: Do not bounce off kernel's sigtramp }
  21. SIG_BLOCK = 1;
  22. SIG_UNBLOCK = 2;
  23. SIG_SETMASK = 3;
  24. {BeOS Checked}
  25. {
  26. The numbering of signals for BeOS attempts to maintain
  27. some consistency with UN*X conventions so that things
  28. like "kill -9" do what you expect.
  29. }
  30. SIG_DFL = 0 ;
  31. SIG_IGN = 1 ;
  32. SIG_ERR = -1 ;
  33. SIGHUP = 1;
  34. SIGINT = 2;
  35. SIGQUIT = 3;
  36. SIGILL = 4;
  37. SIGCHLD = 5;
  38. SIGABRT = 6;
  39. SIGPIPE = 7;
  40. SIGFPE = 8;
  41. SIGKILL = 9;
  42. SIGSTOP = 10;
  43. SIGSEGV = 11;
  44. SIGCONT = 12;
  45. SIGTSTP = 13;
  46. SIGALRM = 14;
  47. SIGTERM = 15;
  48. SIGTTIN = 16;
  49. SIGTTOU = 17;
  50. SIGUSR1 = 18;
  51. SIGUSR2 = 19;
  52. SIGWINCH = 20;
  53. SIGKILLTHR = 21;
  54. SIGTRAP = 22;
  55. SIGBUS = SIGSEGV;
  56. {
  57. Signal numbers 23-32 are currently free but may be used in future
  58. releases. Use them at your own peril (if you do use them, at least
  59. be smart and use them backwards from signal 32).
  60. }
  61. {$packrecords C}
  62. const
  63. SI_PAD_SIZE = ((128/sizeof(longint)) - 3);
  64. {
  65. * The sequence of the fields/registers in struct sigcontext should match
  66. * those in mcontext_t.
  67. }
  68. type
  69. packed_fp_stack = packed record
  70. st0 : array[0..9] of byte;
  71. st1 : array[0..9] of byte;
  72. st2 : array[0..9] of byte;
  73. st3 : array[0..9] of byte;
  74. st4 : array[0..9] of byte;
  75. st5 : array[0..9] of byte;
  76. st6 : array[0..9] of byte;
  77. st7 : array[0..9] of byte;
  78. end;
  79. packed_mmx_regs = packed record
  80. mm0 : array[0..9] of byte;
  81. mm1 : array[0..9] of byte;
  82. mm2 : array[0..9] of byte;
  83. mm3 : array[0..9] of byte;
  84. mm4 : array[0..9] of byte;
  85. mm5 : array[0..9] of byte;
  86. mm6 : array[0..9] of byte;
  87. mm7 : array[0..9] of byte;
  88. end;
  89. old_extended_regs = packed record
  90. fp_control : word;
  91. _reserved1 : word;
  92. fp_status : word;
  93. _reserved2 : word;
  94. fp_tag : word;
  95. _reserved3 : word;
  96. fp_eip : cardinal;
  97. fp_cs : word;
  98. fp_opcode : word;
  99. fp_datap : word;
  100. fp_ds : word;
  101. _reserved4 : word;
  102. fp_mmx : record
  103. case fp_mmx : byte of
  104. 0 : (fp : packed_fp_stack);
  105. 1 : (mmx : packed_mmx_regs);
  106. end;
  107. end;
  108. fp_stack = record
  109. st0 : array[0..9] of byte;
  110. _reserved_42_47 : array[0..5] of byte;
  111. st1 : array[0..9] of byte;
  112. _reserved_58_63 : array[0..5] of byte;
  113. st2 : array[0..9] of byte;
  114. _reserved_74_79 : array[0..5] of byte;
  115. st3 : array[0..9] of byte;
  116. _reserved_90_95 : array[0..5] of byte;
  117. st4 : array[0..9] of byte;
  118. _reserved_106_111 : array[0..5] of byte;
  119. st5 : array[0..9] of byte;
  120. _reserved_122_127 : array[0..5] of byte;
  121. st6 : array[0..9] of byte;
  122. _reserved_138_143 : array[0..5] of byte;
  123. st7 : array[0..9] of byte;
  124. _reserved_154_159 : array[0..5] of byte;
  125. end;
  126. mmx_regs = record
  127. mm0 : array[0..9] of byte;
  128. _reserved_42_47 : array[0..5] of byte;
  129. mm1 : array[0..9] of byte;
  130. _reserved_58_63 : array[0..5] of byte;
  131. mm2 : array[0..9] of byte;
  132. _reserved_74_79 : array[0..5] of byte;
  133. mm3 : array[0..9] of byte;
  134. _reserved_90_95 : array[0..5] of byte;
  135. mm4 : array[0..9] of byte;
  136. _reserved_106_111 : array[0..5] of byte;
  137. mm5 : array[0..9] of byte;
  138. _reserved_122_127 : array[0..5] of byte;
  139. mm6 : array[0..9] of byte;
  140. _reserved_138_143 : array[0..5] of byte;
  141. mm7 : array[0..9] of byte;
  142. _reserved_154_159 : array[0..5] of byte;
  143. end;
  144. xmmx_regs = record
  145. xmm0 : array [0..15] of byte;
  146. xmm1 : array [0..15] of byte;
  147. xmm2 : array [0..15] of byte;
  148. xmm3 : array [0..15] of byte;
  149. xmm4 : array [0..15] of byte;
  150. xmm5 : array [0..15] of byte;
  151. xmm6 : array [0..15] of byte;
  152. xmm7 : array [0..15] of byte;
  153. end;
  154. new_extended_regs = record
  155. fp_control : word;
  156. fp_status : word;
  157. fp_tag : word;
  158. fp_opcode : word;
  159. fp_eip : Cardinal;
  160. fp_cs : word;
  161. res_14_15 : word;
  162. fp_datap : Cardinal;
  163. fp_ds : word;
  164. _reserved_22_23 : word;
  165. mxcsr : Cardinal;
  166. _reserved_28_31 : Cardinal;
  167. fp_mmx : record
  168. case byte of
  169. 0 : (fp : fp_stack);
  170. 1 : (mmx : mmx_regs);
  171. end;
  172. xmmx : xmmx_regs;
  173. _reserved_288_511 : array[0..223] of byte;
  174. end;
  175. extended_regs = record
  176. state : record
  177. case byte of
  178. 0 : (old_format : old_extended_regs);
  179. 1 : (new_format : new_extended_regs);
  180. end;
  181. format : Cardinal;
  182. end;
  183. vregs = record
  184. eip : Cardinal;
  185. eflags : cardinal;
  186. eax : Cardinal;
  187. ecx : Cardinal;
  188. edx : Cardinal;
  189. esp : Cardinal;
  190. ebp : Cardinal;
  191. _reserved_1 : Cardinal;
  192. xregs : extended_regs;
  193. _reserved_2 : array[0..2] of Cardinal;
  194. end;
  195. Pvregs = ^vregs;
  196. sigset_t = array[0..3] of Longint;
  197. PSigContextRec = ^SigContextRec;
  198. SigContextRec = record
  199. sc_mask : sigset_t; { signal mask to restore }
  200. sc_onstack : longint; { sigstack state to restore }
  201. sc_gs : longint; { machine state (struct trapframe): }
  202. sc_fs : longint;
  203. sc_es : longint;
  204. sc_ds : longint;
  205. sc_edi : longint;
  206. sc_esi : longint;
  207. sc_ebp : longint;
  208. sc_isp : longint;
  209. sc_ebx : longint;
  210. sc_edx : longint;
  211. sc_ecx : longint;
  212. sc_eax : longint;
  213. sc_trapno : longint;
  214. sc_err : longint;
  215. sc_eip : longint;
  216. sc_cs : longint;
  217. sc_efl : longint;
  218. sc_esp : longint;
  219. sc_ss : longint;
  220. {
  221. * XXX FPU state is 27 * 4 bytes h/w, 1 * 4 bytes s/w (probably not
  222. * needed here), or that + 16 * 4 bytes for emulators (probably all
  223. * needed here). The "spare" bytes are mostly not spare.
  224. }
  225. en_cw : cardinal; { control word (16bits used) }
  226. en_sw : cardinal; { status word (16bits) }
  227. en_tw : cardinal; { tag word (16bits) }
  228. en_fip : cardinal; { floating point instruction pointer }
  229. en_fcs : word; { floating code segment selector }
  230. en_opcode : word; { opcode last executed (11 bits ) }
  231. en_foo : cardinal; { floating operand offset }
  232. en_fos : cardinal; { floating operand segment selector }
  233. fpr_acc : array[0..79] of char;
  234. fpr_ex_sw : cardinal;
  235. fpr_pad : array[0..63] of char;
  236. end;
  237. SignalHandler = Procedure(Sig : Longint);cdecl;
  238. PSignalHandler = ^SignalHandler;
  239. SignalRestorer = Procedure;cdecl;
  240. PSignalRestorer = ^SignalRestorer;
  241. {$WARNING TODO : check with signal.h}
  242. sigActionHandler = procedure(Sig: Longint; SigContext: PSigContextRec; uContext : Pvregs);cdecl;
  243. Sigset=sigset_t;
  244. TSigset=sigset_t;
  245. PSigSet = ^SigSet;
  246. psigset_t=psigset;
  247. SigActionRec = packed record
  248. // Handler : record
  249. sa_handler : sigActionHandler;
  250. // case byte of
  251. // 0: (Sh: SignalHandler);
  252. // 1: (Sa: TSigAction);
  253. // end;
  254. sa_Mask : SigSet;
  255. sa_Flags : Longint;
  256. sa_userdaa : pointer
  257. end;
  258. PSigActionRec = ^SigActionRec;
  259. {
  260. Change action of process upon receipt of a signal.
  261. Signum specifies the signal (all except SigKill and SigStop).
  262. If Act is non-nil, it is used to specify the new action.
  263. If OldAct is non-nil the previous action is saved there.
  264. }