signal.inc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. {$PACKRECORDS C}
  2. {
  3. Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  4. @APPLE_LICENSE_HEADER_START@
  5. The contents of this file constitute Original Code as defined in and
  6. are subject to the Apple Public Source License Version 1.1 (the
  7. "License"). You may not use this file except in compliance with the
  8. License. Please obtain a copy of the License at
  9. http://www.apple.com/publicsource and read it before using this file.
  10. This Original Code and all software distributed under the License are
  11. distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  12. EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  13. INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  15. License for the specific language governing rights and limitations
  16. under the License.
  17. @APPLE_LICENSE_HEADER_END@
  18. }
  19. { Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved }
  20. {
  21. Copyright (c) 1982, 1986, 1989, 1991, 1993
  22. The Regents of the University of California. All rights reserved.
  23. (c) UNIX System Laboratories, Inc.
  24. All or some portions of this file are derived from material licensed
  25. to the University of California by American Telephone and Telegraph
  26. Co. or Unix System Laboratories, Inc. and are reproduced herein with
  27. the permission of UNIX System Laboratories, Inc.
  28. Redistribution and use in source and binary forms, with or without
  29. modification, are permitted provided that the following conditions
  30. are met:
  31. 1. Redistributions of source code must retain the above copyright
  32. notice, this list of conditions and the following disclaimer.
  33. 2. Redistributions in binary form must reproduce the above copyright
  34. notice, this list of conditions and the following disclaimer in the
  35. documentation and/or other materials provided with the distribution.
  36. 3. All advertising materials mentioning features or use of this software
  37. must display the following acknowledgement:
  38. This product includes software developed by the University of
  39. California, Berkeley and its contributors.
  40. 4. Neither the name of the University nor the names of its contributors
  41. may be used to endorse or promote products derived from this software
  42. without specific prior written permission.
  43. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  44. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  45. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  46. ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  47. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  48. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  49. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  50. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  51. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  52. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  53. SUCH DAMAGE.
  54. @(#)signal.h 8.2 (Berkeley) 1/21/94
  55. }
  56. const
  57. SA_NOCLDSTOP = 8;
  58. SA_ONSTACK = $001; { take signal on signal stack }
  59. SA_RESTART = $002; { restart system call on signal return }
  60. SA_DISABLE = $004; { disable taking signals on alternate stack }
  61. SA_RESETHAND = $004; { reset to SIG_DFL when taking signal }
  62. SA_NODEFER = $010; { don't mask the signal we're delivering }
  63. SA_NOCLDWAIT = $020; { don't keep zombies around }
  64. SA_SIGINFO = $040; { signal handler with SA_SIGINFO args }
  65. SA_USERTRAMP = $100; { SUNOS compat: Do not bounce off kernel's sigtramp }
  66. SA_64REGSET = $200; { SUNOS compat: Do not bounce off kernel's sigtramp }
  67. { hangup }
  68. SIGHUP = 1;
  69. { interrupt }
  70. SIGINT = 2;
  71. { quit }
  72. SIGQUIT = 3;
  73. { illegal instruction (not reset when caught) }
  74. SIGILL = 4;
  75. { trace trap (not reset when caught) }
  76. SIGTRAP = 5;
  77. { abort() }
  78. SIGABRT = 6;
  79. { compatibility }
  80. SIGIOT = SIGABRT;
  81. { EMT instruction }
  82. SIGEMT = 7;
  83. { floating point exception }
  84. SIGFPE = 8;
  85. { kill (cannot be caught or ignored) }
  86. SIGKILL = 9;
  87. { bus error }
  88. SIGBUS = 10;
  89. { segmentation violation }
  90. SIGSEGV = 11;
  91. { bad argument to system call }
  92. SIGSYS = 12;
  93. { write on a pipe with no one to read it }
  94. SIGPIPE = 13;
  95. { alarm clock }
  96. SIGALRM = 14;
  97. { software termination signal from kill }
  98. SIGTERM = 15;
  99. { urgent condition on IO channel }
  100. SIGURG = 16;
  101. { sendable stop signal not from tty }
  102. SIGSTOP = 17;
  103. { stop signal from tty }
  104. SIGTSTP = 18;
  105. { continue a stopped process }
  106. SIGCONT = 19;
  107. { to parent on child stop or exit }
  108. SIGCHLD = 20;
  109. { to readers pgrp upon background tty read }
  110. SIGTTIN = 21;
  111. { like TTIN for output if (tp->t_local&LTOSTOP) }
  112. SIGTTOU = 22;
  113. { input/output possible signal }
  114. SIGIO = 23;
  115. { exceeded CPU time limit }
  116. SIGXCPU = 24;
  117. { exceeded file size limit }
  118. SIGXFSZ = 25;
  119. { virtual time alarm }
  120. SIGVTALRM = 26;
  121. { profiling time alarm }
  122. SIGPROF = 27;
  123. { window size changes }
  124. SIGWINCH = 28;
  125. { information request }
  126. SIGINFO = 29;
  127. { user defined signal 1 }
  128. SIGUSR1 = 30;
  129. { user defined signal 2 }
  130. SIGUSR2 = 31;
  131. SIG_DFL = 0;
  132. SIG_IGN = 1;
  133. SIG_ERR = -1;
  134. type
  135. sigset_t = array[0..0] of cuint;
  136. Sigval = Record
  137. Case Boolean OF
  138. { Members as suggested by Annex C of POSIX 1003.1b. }
  139. false : (sigval_int : cint);
  140. True : (sigval_ptr : Pointer);
  141. End;
  142. TSigInfo_t = record
  143. si_signo, { signal number }
  144. si_errno, { errno association }
  145. {
  146. * Cause of signal, one of the SI_ macros or signal-specific
  147. * values, i.e. one of the FPE_... values for SIGFPE. This
  148. * value is equivalent to the second argument to an old-style
  149. * FreeBSD signal handler.
  150. }
  151. si_code, { signal code }
  152. si_pid : cint; { sending process }
  153. si_uid : cuint; { sender's ruid }
  154. si_status : cint; { exit value }
  155. si_addr : Pointer; { faulting instruction }
  156. si_value : SigVal; { signal value }
  157. si_band : cuint; { band event for SIGPOLL }
  158. pad : array[0..6] of cint; { Reserved for Future Use }
  159. end;
  160. TSigset=sigset_t;
  161. Sigset=sigset_t;
  162. PSigSet = ^TSigSet;
  163. tdarwin_stack_t = record
  164. ss_sp : pchar; { signal stack base }
  165. ss_size : clong; { signal stack length }
  166. ss_flags : cint; { SA_DISABLE and/or SA_ONSTACK }
  167. end;
  168. {$if defined(cpupowerpc) or defined(cpupowerpc64)}
  169. {$include ppcgen/sig_ppc.inc} { SigContextRec }
  170. {$else cpupowerpc or cpupowerpc64}
  171. {$ifdef cpui386}
  172. {$include i386/sig_cpu.inc} { SigContextRec }
  173. {$else cpui386}
  174. {$ifdef cpux86_64}
  175. {$include x86_64/sig_cpu.inc} { SigContextRec }
  176. {$else cpux86_64}
  177. {$ifdef cpuarm}
  178. {$include arm/sig_cpu.inc}
  179. {$else cpuarm}
  180. {$error Unsupported cpu type!}
  181. {$endif cpuarm}
  182. {$endif cpux86_64}
  183. {$endif cpui386}
  184. {$endif cpupowerpc or cpupowerpc64}
  185. psigcontext = ^sigcontextrec;
  186. psigcontextrec = ^sigcontextrec;
  187. sigcontextrec = record
  188. uc_onstack : cint;
  189. uc_sigmask : sigset_t; { signal mask used by this context }
  190. uc_stack : tdarwin_stack_t; { stack used by this context }
  191. uc_link : psigcontextrec; { pointer to resuming context }
  192. uc_mcsize : size_t; { size of the machine context passed in }
  193. uc_mcontext: ^mcontext_t; { machine specific context }
  194. end;
  195. SignalHandler = Procedure(Sig : Longint);cdecl;
  196. PSignalHandler = ^SignalHandler;
  197. SignalRestorer = Procedure;cdecl;
  198. PSignalRestorer = ^SignalRestorer;
  199. PSigInfo = ^TSigInfo_t;
  200. SigActionHandler = procedure (Sig: cint; info : psiginfo; SigContext:PSigContext); cdecl;
  201. SigActionRec = packed record
  202. {
  203. case byte of
  204. 0: (Sh: SignalHandler; Sa_Flags: longint; Sa_Mask: SigSet);
  205. 1: (sa_handler: TSigAction);
  206. }
  207. Sa_Handler: SigActionHandler;
  208. Sa_Mask: sigset_t;
  209. Sa_Flags: cint;
  210. end;
  211. PSigActionRec = ^SigActionRec;
  212. {
  213. Flags for sigprocmask:
  214. }
  215. const
  216. { block specified signal set }
  217. SIG_BLOCK = 1;
  218. { unblock specified signal set }
  219. SIG_UNBLOCK = 2;
  220. { set specified signal set }
  221. SIG_SETMASK = 3;
  222. { type of signal function }
  223. {
  224. Structure used in sigaltstack call.
  225. }
  226. type
  227. sigaltstack = record
  228. { signal stack base }
  229. ss_sp : pchar;
  230. { signal stack length }
  231. ss_size : clong;
  232. { SA_DISABLE and/or SA_ONSTACK }
  233. ss_flags : cint;
  234. end;
  235. { minimum allowable stack }
  236. const
  237. MINSIGSTKSZ = 8192;
  238. { recommended stack size }
  239. { already defined in another BSD include file }
  240. // SIGSTKSZ = MINSIGSTKSZ + 32768;
  241. {
  242. 4.3 compatibility:
  243. Signal vector "template" used in sigvec call.
  244. }
  245. type
  246. sigvec = record
  247. { signal handler }
  248. sv_handler : procedure(para: cint);
  249. { signal mask to apply }
  250. sv_mask : cint;
  251. { see signal options below }
  252. sv_flags : cint;
  253. end;
  254. const
  255. SV_ONSTACK = SA_ONSTACK;
  256. { same bit, opposite sense }
  257. SV_INTERRUPT = SA_RESTART;
  258. { Codes for SIGFPE }
  259. FPE_NOOP = 0; { if only I knew... }
  260. FPE_FLTDIV = 1; { floating point divide by zero }
  261. FPE_FLTOVF = 2; { floating point overflow }
  262. FPE_FLTUND = 3; { floating point underflow }
  263. FPE_FLTRES = 4; { floating point inexact result }
  264. FPE_FLTINV = 5; { invalid floating point operation }
  265. FPE_FLTSUB = 6; { subscript out of range -NOTIMP on Mac OS X 10.4.7 }
  266. FPE_INTDIV = 7; { integer divide by zero -NOTIMP on Mac OS X 10.4.7 }
  267. FPE_INTOVF = 8; { integer overflow -NOTIMP on Mac OS X 10.4.7 }