2
0

signal.inc 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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 = $01;
  13. SA_NOCLDWAIT = $02;
  14. SA_RESETHAND = $03;
  15. SA_NODEFER = $08;
  16. SA_RESTART = $10;
  17. SA_ONSTACK = $20;
  18. SA_SIGINFO = $40;
  19. SA_NOMASK = SA_NODEFER;
  20. SA_STACK = SA_ONSTACK;
  21. SA_ONESHOT = SA_RESETHAND;
  22. SIG_BLOCK = 1;
  23. SIG_UNBLOCK = 2;
  24. SIG_SETMASK = 3;
  25. { values for ss_flags }
  26. SS_ONSTACK = $1;
  27. SS_DISABLE = $2;
  28. MINSIGSTKSZ = 4096;
  29. SIGSTKSZ = 16384;
  30. {Haiku Checked}
  31. {
  32. The numbering of signals for BeOS attempts to maintain
  33. some consistency with UN*X conventions so that things
  34. like "kill -9" do what you expect.
  35. }
  36. SIG_DFL = 0;
  37. SIG_IGN = 1;
  38. SIG_ERR = -1;
  39. SIG_HOLD = 3;
  40. SIGHUP = 1;
  41. SIGINT = 2;
  42. SIGQUIT = 3;
  43. SIGILL = 4;
  44. SIGCHLD = 5;
  45. SIGABRT = 6;
  46. SIGPIPE = 7;
  47. SIGFPE = 8;
  48. SIGKILL = 9;
  49. SIGSTOP = 10;
  50. SIGSEGV = 11;
  51. SIGCONT = 12;
  52. SIGTSTP = 13;
  53. SIGALRM = 14;
  54. SIGTERM = 15;
  55. SIGTTIN = 16;
  56. SIGTTOU = 17;
  57. SIGUSR1 = 18;
  58. SIGUSR2 = 19;
  59. SIGWINCH = 20;
  60. SIGKILLTHR = 21;
  61. SIGTRAP = 22;
  62. SIGPOLL = 23;
  63. SIGPROF = 24;
  64. SIGSYS = 25;
  65. SIGURG = 26;
  66. SIGVTALRM = 27;
  67. SIGXCPU = 28;
  68. SIGXFSZ = 29;
  69. SIGBUS = SIGSEGV;
  70. {
  71. Signal numbers 23-32 are currently free but may be used in future
  72. releases. Use them at your own peril (if you do use them, at least
  73. be smart and use them backwards from signal 32).
  74. }
  75. {$packrecords C}
  76. const
  77. SI_PAD_SIZE = ((128/sizeof(longint)) - 3);
  78. {
  79. * The sequence of the fields/registers in struct sigcontext should match
  80. * those in mcontext_t.
  81. }
  82. type
  83. packed_fp_stack = packed record
  84. st0 : array[0..9] of byte;
  85. st1 : array[0..9] of byte;
  86. st2 : array[0..9] of byte;
  87. st3 : array[0..9] of byte;
  88. st4 : array[0..9] of byte;
  89. st5 : array[0..9] of byte;
  90. st6 : array[0..9] of byte;
  91. st7 : array[0..9] of byte;
  92. end;
  93. packed_mmx_regs = packed record
  94. mm0 : array[0..9] of byte;
  95. mm1 : array[0..9] of byte;
  96. mm2 : array[0..9] of byte;
  97. mm3 : array[0..9] of byte;
  98. mm4 : array[0..9] of byte;
  99. mm5 : array[0..9] of byte;
  100. mm6 : array[0..9] of byte;
  101. mm7 : array[0..9] of byte;
  102. end;
  103. old_extended_regs = packed record
  104. fp_control : word;
  105. _reserved1 : word;
  106. fp_status : word;
  107. _reserved2 : word;
  108. fp_tag : word;
  109. _reserved3 : word;
  110. fp_eip : cardinal;
  111. fp_cs : word;
  112. fp_opcode : word;
  113. fp_datap : word;
  114. fp_ds : word;
  115. _reserved4 : word;
  116. fp_mmx : record
  117. case fp_mmx : byte of
  118. 0 : (fp : packed_fp_stack);
  119. 1 : (mmx : packed_mmx_regs);
  120. end;
  121. end;
  122. fp_stack = record
  123. st0 : array[0..9] of byte;
  124. _reserved_42_47 : array[0..5] of byte;
  125. st1 : array[0..9] of byte;
  126. _reserved_58_63 : array[0..5] of byte;
  127. st2 : array[0..9] of byte;
  128. _reserved_74_79 : array[0..5] of byte;
  129. st3 : array[0..9] of byte;
  130. _reserved_90_95 : array[0..5] of byte;
  131. st4 : array[0..9] of byte;
  132. _reserved_106_111 : array[0..5] of byte;
  133. st5 : array[0..9] of byte;
  134. _reserved_122_127 : array[0..5] of byte;
  135. st6 : array[0..9] of byte;
  136. _reserved_138_143 : array[0..5] of byte;
  137. st7 : array[0..9] of byte;
  138. _reserved_154_159 : array[0..5] of byte;
  139. end;
  140. mmx_regs = record
  141. mm0 : array[0..9] of byte;
  142. _reserved_42_47 : array[0..5] of byte;
  143. mm1 : array[0..9] of byte;
  144. _reserved_58_63 : array[0..5] of byte;
  145. mm2 : array[0..9] of byte;
  146. _reserved_74_79 : array[0..5] of byte;
  147. mm3 : array[0..9] of byte;
  148. _reserved_90_95 : array[0..5] of byte;
  149. mm4 : array[0..9] of byte;
  150. _reserved_106_111 : array[0..5] of byte;
  151. mm5 : array[0..9] of byte;
  152. _reserved_122_127 : array[0..5] of byte;
  153. mm6 : array[0..9] of byte;
  154. _reserved_138_143 : array[0..5] of byte;
  155. mm7 : array[0..9] of byte;
  156. _reserved_154_159 : array[0..5] of byte;
  157. end;
  158. xmmx_regs = record
  159. xmm0 : array [0..15] of byte;
  160. xmm1 : array [0..15] of byte;
  161. xmm2 : array [0..15] of byte;
  162. xmm3 : array [0..15] of byte;
  163. xmm4 : array [0..15] of byte;
  164. xmm5 : array [0..15] of byte;
  165. xmm6 : array [0..15] of byte;
  166. xmm7 : array [0..15] of byte;
  167. end;
  168. new_extended_regs = record
  169. fp_control : word;
  170. fp_status : word;
  171. fp_tag : word;
  172. fp_opcode : word;
  173. fp_eip : Cardinal;
  174. fp_cs : word;
  175. res_14_15 : word;
  176. fp_datap : Cardinal;
  177. fp_ds : word;
  178. _reserved_22_23 : word;
  179. mxcsr : Cardinal;
  180. _reserved_28_31 : Cardinal;
  181. fp_mmx : record
  182. case byte of
  183. 0 : (fp : fp_stack);
  184. 1 : (mmx : mmx_regs);
  185. end;
  186. xmmx : xmmx_regs;
  187. _reserved_288_511 : array[0..223] of byte;
  188. end;
  189. extended_regs = record
  190. state : record
  191. case byte of
  192. 0 : (old_format : old_extended_regs);
  193. 1 : (new_format : new_extended_regs);
  194. end;
  195. format : Cardinal;
  196. end;
  197. vregs = record
  198. eip : Cardinal;
  199. eflags : cardinal;
  200. eax : Cardinal;
  201. ecx : Cardinal;
  202. edx : Cardinal;
  203. esp : Cardinal;
  204. ebp : Cardinal;
  205. _reserved_1 : Cardinal;
  206. xregs : extended_regs;
  207. _reserved_2 : array[0..2] of Cardinal;
  208. end;
  209. Pvregs = ^vregs;
  210. sigset_t = array[0..0] of Longint;
  211. PSigContextRec = ^SigContextRec;
  212. SigContextRec = record
  213. sc_mask : sigset_t; { signal mask to restore }
  214. sc_onstack : longint; { sigstack state to restore }
  215. sc_gs : longint; { machine state (struct trapframe): }
  216. sc_fs : longint;
  217. sc_es : longint;
  218. sc_ds : longint;
  219. sc_edi : longint;
  220. sc_esi : longint;
  221. sc_ebp : longint;
  222. sc_isp : longint;
  223. sc_ebx : longint;
  224. sc_edx : longint;
  225. sc_ecx : longint;
  226. sc_eax : longint;
  227. sc_trapno : longint;
  228. sc_err : longint;
  229. sc_eip : longint;
  230. sc_cs : longint;
  231. sc_efl : longint;
  232. sc_esp : longint;
  233. sc_ss : longint;
  234. {
  235. * XXX FPU state is 27 * 4 bytes h/w, 1 * 4 bytes s/w (probably not
  236. * needed here), or that + 16 * 4 bytes for emulators (probably all
  237. * needed here). The "spare" bytes are mostly not spare.
  238. }
  239. en_cw : cardinal; { control word (16bits used) }
  240. en_sw : cardinal; { status word (16bits) }
  241. en_tw : cardinal; { tag word (16bits) }
  242. en_fip : cardinal; { floating point instruction pointer }
  243. en_fcs : word; { floating code segment selector }
  244. en_opcode : word; { opcode last executed (11 bits ) }
  245. en_foo : cardinal; { floating operand offset }
  246. en_fos : cardinal; { floating operand segment selector }
  247. fpr_acc : array[0..79] of char;
  248. fpr_ex_sw : cardinal;
  249. fpr_pad : array[0..63] of char;
  250. end;
  251. SignalHandler = Procedure(Sig : Longint);cdecl;
  252. PSignalHandler = ^SignalHandler;
  253. SignalRestorer = Procedure;cdecl;
  254. PSignalRestorer = ^SignalRestorer;
  255. {$WARNING TODO : check with signal.h}
  256. { Note: As of R1alpha3, sa_handler still was of SignalHandler type, with one parameter,
  257. but the Signal stack has a second parameter that is set to zero
  258. and a third that is of type pvregs }
  259. sigActionHandler = procedure(Sig: Longint; SigContext: PSigContextRec; uContext : Pvregs);cdecl;
  260. { Add those type definition to obtain same declaration as for other unix targets
  261. but do not forget the PSigInfo field is currently nil for Haiku as of R1alpha3. }
  262. PSigInfo = PSigContextRec;
  263. PSigContext = Pvregs;
  264. Sigset=sigset_t;
  265. TSigset=sigset_t;
  266. PSigSet = ^SigSet;
  267. psigset_t=psigset;
  268. SigActionRec = packed record
  269. // Handler : record
  270. sa_handler : sigActionHandler;
  271. // case byte of
  272. // 0: (Sh: SignalHandler);
  273. // 1: (Sa: TSigAction);
  274. // end;
  275. sa_Mask : SigSet;
  276. sa_Flags : Longint;
  277. sa_userdata : pointer
  278. end;
  279. PSigActionRec = ^SigActionRec;
  280. {$PACKRECORDS C}
  281. pstack_t = ^stack_t;
  282. stack_t = record
  283. ss_sp: pChar; {* signal stack base *}
  284. ss_size: size_t; {* signal stack length *}
  285. ss_flags: cInt; {* SS_DISABLE and/or SS_ONSTACK *}
  286. end;
  287. TStack = stack_t;
  288. PStack = pstack_t;
  289. {
  290. Change action of process upon receipt of a signal.
  291. Signum specifies the signal (all except SigKill and SigStop).
  292. If Act is non-nil, it is used to specify the new action.
  293. If OldAct is non-nil the previous action is saved there.
  294. }