sighnd.inc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt,
  5. member of the Free Pascal development team.
  6. Signal handler is arch dependant due to processor to language
  7. exception conversion.
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
  15. var
  16. res : word;
  17. { fpustate: longint; }
  18. begin
  19. res:=0;
  20. { exception flags are turned off by kernel }
  21. fpc_enable_ppc_fpu_exceptions;
  22. case sig of
  23. SIGFPE :
  24. begin
  25. {
  26. fpscr is cleared by the kernel -> can't find out cause :(
  27. fpustate := fpc_get_ppc_fpscr;
  28. if (fpustate and ppc_fpu_underflow) <> 0 then
  29. res := 206
  30. else if (fpustate and ppc_fpu_overflow) <> 0 then
  31. res := 205
  32. else if (fpustate and ppc_fpu_divbyzero) <> 0 then
  33. res := 200
  34. else
  35. }
  36. res := 207;
  37. end;
  38. SIGILL,
  39. SIGBUS,
  40. SIGSEGV :
  41. res:=216;
  42. end;
  43. { give runtime error at the position where the signal was raised }
  44. if res<>0 then
  45. HandleErrorAddrFrame(res,pointer(SigContext^.pt_regs^.nip),pointer(SigContext^.pt_regs^.gpr[1]));
  46. end;
  47. {
  48. $Log$
  49. Revision 1.6 2005-02-14 17:13:30 peter
  50. * truncate log
  51. Revision 1.5 2005/01/30 18:01:15 peter
  52. * signal cleanup for linux
  53. * sigactionhandler instead of tsigaction for bsds
  54. * sigcontext moved to cpu dir
  55. }