sighnd.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {
  2. This file is part of the Free Pascal run time library.
  3. (c) 2000-2003 by Marco van de Voort
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. Signalhandler for FreeBSD/i386
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY;without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. }
  12. procedure SignalToRunerror(Sig: cint; var info : tsiginfo_t;Var SigContext:SigContextRec); cdecl;
  13. var
  14. res : word;
  15. begin
  16. res:=0;
  17. case sig of
  18. SIGFPE :
  19. begin
  20. Case Info.si_code Of
  21. FPE_INTDIV : Res:=200; {integer divide fault. Div0?}
  22. FPE_FLTOVF : Res:=205; {Overflow trap}
  23. FPE_FLTUND : Res:=206; {Stack over/underflow}
  24. FPE_FLTRES : Res:=216; {Device not available}
  25. FPE_FLTINV : Res:=216; {Invalid floating point operation}
  26. Else
  27. Res:=208; {coprocessor error}
  28. End;
  29. sysResetFPU;
  30. End;
  31. SIGILL,
  32. SIGBUS,
  33. SIGSEGV :
  34. res:=216;
  35. end;
  36. {$ifdef FPC_USE_SIGPROCMASK}
  37. reenable_signal(sig);
  38. {$endif }
  39. { give runtime error at the position where the signal was raised }
  40. if res<>0 then
  41. begin
  42. {$ifdef cpui386}
  43. HandleErrorAddrFrame(res,Pointer(SigContext.sc_eip),pointer(SigContext.sc_ebp));
  44. {$else}
  45. HandleError(res);
  46. {$endif}
  47. end;
  48. end;
  49. {
  50. procedure SignalToRunerror(signo: cint); cdecl;
  51. var
  52. res : word;
  53. begin
  54. res:=0;
  55. if signo = SIGFPE then
  56. begin
  57. res := 200;
  58. end
  59. else
  60. if (signo = SIGILL) or (signo = SIGBUS) or (signo = SIGSEGV) then
  61. begin
  62. res := 216;
  63. end;
  64. { give runtime error at the position where the signal was raised }
  65. if res<>0 then
  66. begin
  67. HandleError(res);
  68. end;
  69. end;
  70. }