sighnd.inc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. (c) 2000-2003 by Marco van de Voort
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. Signalhandler for FreeBSD/i386
  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. procedure SignalToRunerror(Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl;
  14. var
  15. res : word;
  16. begin
  17. res:=0;
  18. case sig of
  19. SIGFPE :
  20. begin
  21. Case Info.si_code Of
  22. FPE_INTDIV : Res:=200; {integer divide fault. Div0?}
  23. FPE_FLTOVF : Res:=205; {Overflow trap}
  24. FPE_FLTUND : Res:=206; {Stack over/underflow}
  25. FPE_FLTRES : Res:=216; {Device not available}
  26. FPE_FLTINV : Res:=216; {Invalid floating point operation}
  27. Else
  28. Res:=208; {coprocessor error}
  29. End;
  30. sysResetFPU;
  31. End;
  32. SIGILL,
  33. SIGBUS,
  34. SIGSEGV :
  35. res:=216;
  36. end;
  37. {$ifdef FPC_USE_SIGPROCMASK}
  38. reenable_signal(sig);
  39. {$endif }
  40. { give runtime error at the position where the signal was raised }
  41. if res<>0 then
  42. begin
  43. {$ifdef cpui386}
  44. HandleErrorAddrFrame(res,Pointer(SigContext.sc_eip),pointer(SigContext.sc_ebp));
  45. {$else}
  46. HandleError(res);
  47. {$endif}
  48. end;
  49. end;
  50. {
  51. procedure SignalToRunerror(signo: cint); cdecl;
  52. var
  53. res : word;
  54. begin
  55. res:=0;
  56. if signo = SIGFPE then
  57. begin
  58. res := 200;
  59. end
  60. else
  61. if (signo = SIGILL) or (signo = SIGBUS) or (signo = SIGSEGV) then
  62. begin
  63. res := 216;
  64. end;
  65. { give runtime error at the position where the signal was raised }
  66. if res<>0 then
  67. begin
  68. HandleError(res);
  69. end;
  70. end;
  71. }
  72. {
  73. $Log$
  74. Revision 1.2 2004-03-04 13:10:26 olle
  75. + added comment to ETXTBSY
  76. * changed i386 -> cpui386, m68k -> cpum68k
  77. Revision 1.1 2004/01/03 12:29:36 marco
  78. * now separately.
  79. }