sighnd.inc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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);public name '_FPC_DEFAULTSIGHANDLER';cdecl;
  14. var
  15. res,fpustate : word;
  16. begin
  17. res:=0;
  18. case sig of
  19. SIGFPE :
  20. begin
  21. res:=200;
  22. (*
  23. fpustate:=GetFPUState(SigContext^);
  24. if (FpuState and FPU_All) <> 0 then
  25. begin
  26. { first check the more precise options }
  27. if (FpuState and FPU_DivisionByZero)<>0 then
  28. res:=200
  29. else if (FpuState and FPU_Overflow)<>0 then
  30. res:=205
  31. else if (FpuState and FPU_Underflow)<>0 then
  32. res:=206
  33. else if (FpuState and FPU_Denormal)<>0 then
  34. res:=216
  35. else if (FpuState and (FPU_StackOverflow or FPU_StackUnderflow or FPU_Invalid))<>0 Then
  36. res:=207
  37. else
  38. res:=207; {'Coprocessor Error'}
  39. end;
  40. *)
  41. sysResetFPU;
  42. end;
  43. SIGILL,
  44. SIGBUS,
  45. SIGSEGV :
  46. res:=216;
  47. SIGINT:
  48. res:=217;
  49. SIGKILL :
  50. res:=233;
  51. end;
  52. { give runtime error at the position where the signal was raised }
  53. if res<>0 then
  54. HandleErrorAddrFrame(res,pointer(SigContext^.eip),pointer(SigContext^.ebp));
  55. end;