sighnd.inc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {
  2. $Id: sighnd.inc,v 1.10 2005/04/24 21:19:22 peter Exp $
  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. const
  15. FPE_INTDIV = 1;
  16. FPE_INTOVF = 2;
  17. FPE_FLTDIV = 3;
  18. FPE_FLTOVF = 4;
  19. FPE_FLTUND = 5;
  20. FPE_FLTRES = 6;
  21. FPE_FLTINV = 7;
  22. FPE_FLTSUB = 8;
  23. procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
  24. var
  25. res : word;
  26. addr : pointer;
  27. begin
  28. res:=0;
  29. addr:=nil;
  30. case sig of
  31. SIGFPE :
  32. begin
  33. addr := siginfo^._sifields._sigfault.si_addr;
  34. res := 207;
  35. case siginfo^.si_code of
  36. FPE_INTDIV:
  37. res:=200;
  38. FPE_INTOVF:
  39. res:=205;
  40. FPE_FLTDIV:
  41. res:=200;
  42. FPE_FLTOVF:
  43. res:=205;
  44. FPE_FLTUND:
  45. res:=206;
  46. FPE_FLTRES,
  47. FPE_FLTINV,
  48. FPE_FLTSUB:
  49. res:=216;
  50. else
  51. res:=207;
  52. end;
  53. end;
  54. SIGILL,
  55. SIGBUS,
  56. SIGSEGV :
  57. begin
  58. addr := siginfo^._sifields._sigfault.si_addr;
  59. res:=216;
  60. end;
  61. end;
  62. reenable_signal(sig);
  63. { give runtime error at the position where the signal was raised }
  64. if res<>0 then
  65. HandleErrorAddrFrame(res,addr,nil);
  66. end;