sighnd.inc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. 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._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._addr;
  59. res:=216;
  60. end;
  61. end;
  62. { give runtime error at the position where the signal was raised }
  63. if res<>0 then
  64. HandleErrorAddrFrame(res,addr,nil);
  65. end;
  66. {
  67. $Log$
  68. Revision 1.2 2005-02-14 17:13:31 peter
  69. * truncate log
  70. Revision 1.1 2005/02/13 22:13:20 peter
  71. * get solaris back in shape
  72. Revision 1.8 2005/02/05 23:46:12 peter
  73. * set addr:=nil for other signals
  74. Revision 1.7 2005/02/05 23:45:38 peter
  75. * sigcontext is invalid, use siginfo only
  76. Revision 1.6 2005/01/30 18:01:15 peter
  77. * signal cleanup for linux
  78. * sigactionhandler instead of tsigaction for bsds
  79. * sigcontext moved to cpu dir
  80. }