signal.inc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. {$packrecords C}
  12. {********************
  13. Signal
  14. ********************}
  15. Const
  16. { For sending a signal }
  17. {$if defined(CPUSPARC) or defined(CPUSPARC64)}
  18. SA_SIGINFO = $200;
  19. SA_NOMASK = $20;
  20. SIG_BLOCK = 1;
  21. SIG_UNBLOCK = 2;
  22. SIG_SETMASK = 4;
  23. {$else : not (CPUSPARC or CPUSPARC64)}
  24. {$ifdef CPUMIPS}
  25. SA_NOCLDSTOP = 1;
  26. SA_NOCLDWAIT = $10000;
  27. SA_SIGINFO = 8;
  28. SIG_BLOCK = 1;
  29. SIG_UNBLOCK = 2;
  30. SIG_SETMASK = 3;
  31. {$else CPUMIPS}
  32. SA_NOCLDSTOP = 1;
  33. SA_NOCLDWAIT = 2;
  34. SA_SIGINFO = 4;
  35. SIG_BLOCK = 0;
  36. SIG_UNBLOCK = 1;
  37. SIG_SETMASK = 2;
  38. {$endif CPUMIPS}
  39. SA_RESTORER = $04000000;
  40. SA_ONSTACK = $08000000;
  41. SA_RESTART = $10000000;
  42. SA_INTERRUPT = $20000000;
  43. SA_NODEFER = $40000000;
  44. SA_RESETHAND = $80000000;
  45. SA_NOMASK = SA_NODEFER;
  46. SA_ONESHOT = SA_RESETHAND;
  47. {$endif not (CPUSPARC or CPUSPARC64) }
  48. SIG_DFL = 0 ;
  49. SIG_IGN = 1 ;
  50. SIG_ERR = -1 ;
  51. {$if defined(CPUSPARC) or defined(CPUSPARC64)}
  52. SIGHUP = 1;
  53. SIGINT = 2;
  54. SIGQUIT = 3;
  55. SIGILL = 4;
  56. SIGTRAP = 5;
  57. SIGABRT = 6;
  58. SIGIOT = 6;
  59. SIGEMT = 7;
  60. SIGFPE = 8;
  61. SIGKILL = 9;
  62. SIGBUS = 10;
  63. SIGSEGV = 11;
  64. SIGSYS = 12;
  65. SIGPIPE = 13;
  66. SIGALRM = 14;
  67. SIGTERM = 15;
  68. SIGURG = 16;
  69. SIGSTOP = 17;
  70. SIGTSTP = 18;
  71. SIGCONT = 19;
  72. SIGCHLD = 20;
  73. SIGTTIN = 21;
  74. SIGTTOU = 22;
  75. SIGIO = 23;
  76. SIGPOLL = SIGIO;
  77. SIGXCPU = 24;
  78. SIGXFSZ = 25;
  79. SIGVTALRM = 26;
  80. SIGPROF = 27;
  81. SIGWINCH = 28;
  82. SIGLOST = 29;
  83. SIGPWR = SIGLOST;
  84. SIGUSR1 = 30;
  85. SIGUSR2 = 31;
  86. {$else defined(CPUSPARC) or defined(CPUSPARC64)}
  87. SIGHUP = 1;
  88. SIGINT = 2;
  89. SIGQUIT = 3;
  90. SIGILL = 4;
  91. SIGTRAP = 5;
  92. SIGABRT = 6;
  93. SIGIOT = 6;
  94. SIGFPE = 8;
  95. SIGKILL = 9;
  96. SIGSEGV = 11;
  97. SIGPIPE = 13;
  98. SIGALRM = 14;
  99. SIGTERM = 15;
  100. {$ifdef CPUMIPS}
  101. SIGEMT = 7;
  102. SIGBUS = 10;
  103. SIGSYS = 12;
  104. SIGUSR1 = 16;
  105. SIGUSR2 = 17;
  106. SIGCHLD = 18;
  107. SIGPWR = 19;
  108. SIGWINCH = 20;
  109. SIGURG = 21;
  110. SIGIO = 22;
  111. SIGPOLL = 22;
  112. SIGSTOP = 23;
  113. SIGTSTP = 24;
  114. SIGCONT = 25;
  115. SIGTTIN = 26;
  116. SIGTTOU = 27;
  117. SIGVTALRM = 28;
  118. SIGPROF = 29;
  119. SIGXCPU = 30;
  120. SIGXFSZ = 31;
  121. {$else not CPUMIPS}
  122. SIGBUS = 7;
  123. SIGUSR1 = 10;
  124. SIGUSR2 = 12;
  125. SIGSTKFLT = 16;
  126. SIGCHLD = 17;
  127. SIGCONT = 18;
  128. SIGSTOP = 19;
  129. SIGTSTP = 20;
  130. SIGTTIN = 21;
  131. SIGTTOU = 22;
  132. SIGURG = 23;
  133. SIGXCPU = 24;
  134. SIGXFSZ = 25;
  135. SIGVTALRM = 26;
  136. SIGPROF = 27;
  137. SIGWINCH = 28;
  138. SIGIO = 29;
  139. SIGPOLL = SIGIO;
  140. SIGPWR = 30;
  141. SIGUNUSED = 31;
  142. {$endif not CPUMIPS}
  143. {$endif defined(CPUSPARC) or defined(CPUSPARC64)}
  144. { si_code field values for tsiginfo.si_code when si_signo = SIGFPE }
  145. const
  146. FPE_INTDIV = 1; { integer divide by zero }
  147. FPE_INTOVF = 2; { integer overflow }
  148. FPE_FLTDIV = 3; { floating point divide by zero }
  149. FPE_FLTOVF = 4; { floating point overflow }
  150. FPE_FLTUND = 5; { floating point underflow }
  151. FPE_FLTRES = 6; { floating point inexact result }
  152. FPE_FLTINV = 7; { floating point invalid operation }
  153. FPE_FLTSUB = 8; { floating point subscript out of range }
  154. const
  155. SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
  156. type
  157. sigset_t = array[0..wordsinsigset-1] of cuLong;
  158. tsigset = sigset_t;
  159. sigset = sigset_t;
  160. psigset = ^tsigset;
  161. psiginfo = ^tsiginfo;
  162. tsiginfo = record
  163. si_signo : longint;
  164. {$ifdef CPUMIPS}
  165. si_code : longint;
  166. si_errno : longint;
  167. {$else not CPUMIPS}
  168. si_errno : longint;
  169. si_code : longint;
  170. {$endif not CPUMIPS}
  171. _sifields : record
  172. case longint of
  173. 0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
  174. 1 : ( _kill : record
  175. _pid : pid_t;
  176. _uid : uid_t;
  177. end );
  178. 2 : ( _timer : record
  179. _timer1 : dword;
  180. _timer2 : dword;
  181. end );
  182. 3 : ( _rt : record
  183. _pid : pid_t;
  184. _uid : uid_t;
  185. _sigval : pointer;
  186. end );
  187. 4 : ( _sigchld : record
  188. _pid : pid_t;
  189. _uid : uid_t;
  190. _status : longint;
  191. _utime : clock_t;
  192. _stime : clock_t;
  193. end );
  194. 5 : ( _sigfault : record
  195. _addr : pointer;
  196. end );
  197. 6 : ( _sigpoll : record
  198. _band : longint;
  199. _fd : longint;
  200. end );
  201. end;
  202. end;
  203. { CPU dependent TSigContext }
  204. {$i sighndh.inc}
  205. type
  206. signalhandler_t = procedure(signal: longint); cdecl;
  207. sigactionhandler_t = procedure(signal: longint; info: psiginfo; context: psigcontext); cdecl;
  208. sigrestorerhandler_t = procedure; cdecl;
  209. signalhandler = signalhandler_t;
  210. sigactionhandler = sigactionhandler_t;
  211. sigrestorerhandler = sigrestorerhandler_t;
  212. tsignalhandler = signalhandler_t;
  213. tsigactionhandler = sigactionhandler_t;
  214. tsigrestorerhandler = sigrestorerhandler_t;
  215. psigactionrec = ^sigactionrec;
  216. {$ifdef FPC_USE_LIBC} // libc order is different ?
  217. sigactionrec = record
  218. sa_handler: sigactionhandler_t;
  219. sa_mask: sigset_t;
  220. sa_flags: cint;
  221. sa_restorer: sigrestorerhandler_t;
  222. end;
  223. {$else}
  224. {$ifdef cpumips}
  225. sigactionrec = record
  226. sa_flags: cuint;
  227. sa_handler: sigactionhandler_t;
  228. sa_mask: sigset_t;
  229. sa_restorer: sigrestorerhandler_t; { Doesn't seem to exist on MIPS }
  230. sa_resv : array [0..0] of cint;
  231. end;
  232. {$else not mips}
  233. sigactionrec = record
  234. sa_handler: sigactionhandler_t;
  235. sa_flags: culong;
  236. sa_restorer: sigrestorerhandler_t;
  237. sa_mask: sigset_t;
  238. end;
  239. {$endif not mips}
  240. {$endif}