sighnd.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt,
  4. member of the Free Pascal development team.
  5. Signal handler is arch dependant due to processor to language
  6. exception conversion.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  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 : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
  14. var
  15. res : word;
  16. { fpustate: longint; }
  17. begin
  18. res:=0;
  19. { exception flags are turned off by kernel }
  20. fpc_enable_ppc_fpu_exceptions;
  21. case sig of
  22. SIGFPE :
  23. begin
  24. {
  25. fpscr is cleared by the kernel -> can't find out cause :(
  26. fpustate := fpc_get_ppc_fpscr;
  27. if (fpustate and ppc_fpu_underflow) <> 0 then
  28. res := 206
  29. else if (fpustate and ppc_fpu_overflow) <> 0 then
  30. res := 205
  31. else if (fpustate and ppc_fpu_divbyzero) <> 0 then
  32. res := 200
  33. else
  34. }
  35. res := 207;
  36. end;
  37. SIGBUS :
  38. res:=214;
  39. SIGILL,
  40. SIGSEGV :
  41. res:=216;
  42. end;
  43. reenable_signal(sig);
  44. { give runtime error at the position where the signal was raised }
  45. if res<>0 then
  46. HandleErrorAddrFrame(res,pointer(SigContext^.pt_regs^.nip),pointer(SigContext^.pt_regs^.gpr[1]));
  47. end;