sighnd.inc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.5 2005-01-30 18:01:15 peter
  50. * signal cleanup for linux
  51. * sigactionhandler instead of tsigaction for bsds
  52. * sigcontext moved to cpu dir
  53. Revision 1.4 2004/01/02 17:57:16 jonas
  54. * re-enable fpu exceptions in signal handler, they're turned off by the
  55. kernel
  56. Revision 1.3 2004/01/01 16:28:16 jonas
  57. * fixed signal handling
  58. Revision 1.2 2003/11/21 00:40:06 florian
  59. * some arm issues fixed
  60. Revision 1.1 2003/11/02 14:53:06 jonas
  61. + sighand and associated record definitions for ppc. Untested.
  62. }