sighnd.inc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. (c) 2000-2003 by Marco van de Voort
  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. Signalhandler for FreeBSD/i386
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY;without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. }
  13. procedure SignalToRunerror(Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl;
  14. var
  15. res : word;
  16. begin
  17. res:=0;
  18. case sig of
  19. SIGFPE :
  20. begin
  21. Case Info.si_code Of
  22. FPE_INTDIV : Res:=200; {integer divide fault. Div0?}
  23. FPE_FLTOVF : Res:=205; {Overflow trap}
  24. FPE_FLTUND : Res:=206; {Stack over/underflow}
  25. FPE_FLTRES : Res:=208; {Device not available}
  26. FPE_FLTINV : Res:=207; {Invalid floating point operation}
  27. Else
  28. Res:=208; {coprocessor error}
  29. end;
  30. { FPU exceptions are completely disabled by the kernel if one occurred, it }
  31. { seems this is necessary to be able to return to user mode. They can be }
  32. { enabled by executing a sigreturn, however then the exception is triggered }
  33. { triggered again immediately if we don't turn off the "exception occurred" }
  34. { flags in fpscr }
  35. SigContext.uc_mcontext^.fs.fpscr := SigContext.uc_mcontext^.fs.fpscr and not($fffe0700);
  36. end;
  37. SIGILL,
  38. SIGBUS,
  39. SIGSEGV :
  40. res:=216;
  41. end;
  42. {$ifdef FPC_USE_SIGPROCMASK}
  43. reenable_signal(sig);
  44. {$endif }
  45. { return to trampoline }
  46. if res <> 0 then
  47. begin
  48. SigContext.uc_mcontext^.ss.r3 := res;
  49. SigContext.uc_mcontext^.ss.r4 := SigContext.uc_mcontext^.ss.srr0;
  50. SigContext.uc_mcontext^.ss.r5 := SigContext.uc_mcontext^.ss.r1;
  51. pointer(SigContext.uc_mcontext^.ss.srr0) := @HandleErrorAddrFrame;
  52. end;
  53. end;
  54. {
  55. $Log$
  56. Revision 1.3 2004-01-10 00:16:21 jonas
  57. * fixed mtfsb0 instruction for assembler reader/writer
  58. * fixed initialisation of fpscr register to avoid spurious SIGPFE's
  59. (uses mtfsb0 instruction, so added extra define in options.pas to avoid
  60. requiring to start with a cross compiler)
  61. Revision 1.2 2004/01/08 21:52:34 jonas
  62. * fixed signal handling under 10.3.2, still have to verify whether it's
  63. backwards compatible
  64. Revision 1.1 2004/01/04 20:05:38 jonas
  65. * first working version of the Darwin/Mac OS X (for PowerPC) RTL
  66. Several non-essential units are still missing, but make cycle works
  67. Revision 1.1 2004/01/03 12:29:36 marco
  68. * now separately.
  69. }