sighnd.inc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {
  2. This file is part of the Free Pascal run time library.
  3. (c) 2000-2003 by Marco van de Voort
  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. Signalhandler for FreeBSD/i386
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY;without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. }
  12. procedure SignalToRunerror(Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl;
  13. var
  14. res : word;
  15. begin
  16. res:=0;
  17. case sig of
  18. SIGFPE :
  19. begin
  20. Case Info.si_code Of
  21. FPE_INTDIV : Res:=200; {integer divide fault. Div0?}
  22. FPE_FLTOVF : Res:=205; {Overflow trap}
  23. FPE_FLTUND : Res:=206; {Stack over/underflow}
  24. FPE_FLTRES : Res:=208; {Device not available}
  25. FPE_FLTINV : Res:=207; {Invalid floating point operation}
  26. Else
  27. Res:=208; {coprocessor error}
  28. end;
  29. { FPU exceptions are completely disabled by the kernel if one occurred, it }
  30. { seems this is necessary to be able to return to user mode. They can be }
  31. { enabled by executing a sigreturn, however then the exception is triggered }
  32. { triggered again immediately if we don't turn off the "exception occurred" }
  33. { flags in fpscr }
  34. SigContext.uc_mcontext^.fs.fpscr := SigContext.uc_mcontext^.fs.fpscr and not($fffe0700);
  35. end;
  36. SIGILL,
  37. SIGBUS,
  38. SIGSEGV :
  39. res:=216;
  40. end;
  41. {$ifdef FPC_USE_SIGPROCMASK}
  42. reenable_signal(sig);
  43. {$endif }
  44. { return to trampoline }
  45. if res <> 0 then
  46. begin
  47. SigContext.uc_mcontext^.ss.r3 := res;
  48. SigContext.uc_mcontext^.ss.r4 := SigContext.uc_mcontext^.ss.srr0;
  49. SigContext.uc_mcontext^.ss.r5 := SigContext.uc_mcontext^.ss.r1;
  50. pointer(SigContext.uc_mcontext^.ss.srr0) := @HandleErrorAddrFrame;
  51. end;
  52. end;