sighnd.inc 1.8 KB

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