sighnd.inc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.8 2005-02-05 23:46:12 peter
  69. * set addr:=nil for other signals
  70. Revision 1.7 2005/02/05 23:45:38 peter
  71. * sigcontext is invalid, use siginfo only
  72. Revision 1.6 2005/01/30 18:01:15 peter
  73. * signal cleanup for linux
  74. * sigactionhandler instead of tsigaction for bsds
  75. * sigcontext moved to cpu dir
  76. Revision 1.5 2004/11/06 22:48:16 florian
  77. * fixed errno setting in mt sparc/linux mt programs
  78. Revision 1.4 2004/08/04 19:27:10 florian
  79. * fixed floating point and integer exception handling on sparc/linux
  80. Revision 1.3 2004/05/31 20:25:04 peter
  81. * removed warnings
  82. Revision 1.2 2003/11/06 16:28:52 peter
  83. * compile fix
  84. Revision 1.1 2003/11/06 16:22:01 peter
  85. * sparc
  86. Revision 1.1 2003/11/02 14:53:06 jonas
  87. + sighand and associated record definitions for ppc. Untested.
  88. Revision 1.2 2003/11/01 01:58:11 marco
  89. * more small fixes.
  90. Revision 1.1 2003/11/01 01:27:20 marco
  91. * initial version from 1.0.x branch
  92. }