sighnd.inc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2006 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. const
  14. REG_PC = 1;
  15. REG_nPC = 2;
  16. REG_O6 = 17;
  17. REG_SP = REG_O6;
  18. const
  19. FPE_INTDIV = 1;
  20. FPE_INTOVF = 2;
  21. FPE_FLTDIV = 3;
  22. FPE_FLTOVF = 4;
  23. FPE_FLTUND = 5;
  24. FPE_FLTRES = 6;
  25. FPE_FLTINV = 7;
  26. FPE_FLTSUB = 8;
  27. procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);public name '_FPC_DEFAULTSIGHANDLER';cdecl;
  28. var
  29. res : word;
  30. addr : pointer;
  31. frame : pointer;
  32. begin
  33. res:=0;
  34. if assigned(sigcontext) then
  35. begin
  36. addr := pointer(sigcontext^.uc_mcontext.gregs[REG_PC]);
  37. frame := pointer(sigcontext^.uc_mcontext.gregs[REG_SP])
  38. end
  39. else
  40. begin
  41. addr := nil;
  42. frame := nil;
  43. end;
  44. case sig of
  45. SIGFPE :
  46. begin
  47. case siginfo^.si_code of
  48. FPE_INTDIV:
  49. res:=200;
  50. FPE_INTOVF:
  51. res:=205;
  52. FPE_FLTDIV:
  53. res:=200;
  54. FPE_FLTOVF:
  55. res:=205;
  56. FPE_FLTUND:
  57. res:=206;
  58. else
  59. res:=207;
  60. end;
  61. end;
  62. SIGILL,
  63. SIGSEGV :
  64. begin
  65. res:=216;
  66. end;
  67. SIGBUS :
  68. begin
  69. res:=214;
  70. end;
  71. SIGINT:
  72. res:=217;
  73. SIGQUIT:
  74. res:=233;
  75. end;
  76. reenable_signal(sig);
  77. { give runtime error at the position where the signal was raised }
  78. if res<>0 then
  79. HandleErrorAddrFrame(res,addr,frame);
  80. end;