sighnd.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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,fpustate : word;
  17. begin
  18. res:=0;
  19. case sig of
  20. SIGFPE :
  21. begin
  22. res:=200;
  23. (*
  24. fpustate:=GetFPUState(SigContext^);
  25. if (FpuState and FPU_All) <> 0 then
  26. begin
  27. { first check the more precise options }
  28. if (FpuState and FPU_DivisionByZero)<>0 then
  29. res:=200
  30. else if (FpuState and FPU_Overflow)<>0 then
  31. res:=205
  32. else if (FpuState and FPU_Underflow)<>0 then
  33. res:=206
  34. else if (FpuState and FPU_Denormal)<>0 then
  35. res:=216
  36. else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow or FPU_Invalid))<>0 Then
  37. res:=207
  38. else
  39. res:=207; {'Coprocessor Error'}
  40. end;
  41. *)
  42. sysResetFPU;
  43. end;
  44. SIGILL,
  45. SIGBUS,
  46. SIGSEGV :
  47. res:=216;
  48. end;
  49. { give runtime error at the position where the signal was raised }
  50. if res<>0 then
  51. HandleErrorAddrFrame(res,pointer(SigContext^.eip),pointer(SigContext^.ebp));
  52. end;
  53. {
  54. $Log$
  55. Revision 1.2 2005-02-14 17:13:31 peter
  56. * truncate log
  57. Revision 1.1 2005/02/13 22:13:20 peter
  58. * get solaris back in shape
  59. Revision 1.5 2005/01/30 18:01:15 peter
  60. * signal cleanup for linux
  61. * sigactionhandler instead of tsigaction for bsds
  62. * sigcontext moved to cpu dir
  63. }