sighnd.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.4 2005-02-14 17:13:22 peter
  57. * truncate log
  58. }