sighnd.inc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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; info : psiginfo; SigContext:PSigContext); public name '_FPC_DEFAULTSIGHANDLER'; 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. if sse_check then
  33. begin
  34. os_supports_sse:=false;
  35. res:=0;
  36. inc(sigcontext^.sc_eip,3);
  37. end
  38. else
  39. res:=216;
  40. SIGBUS:
  41. res:=214;
  42. SIGSEGV :
  43. res:=216;
  44. SIGINT:
  45. res:=217;
  46. SIGQUIT:
  47. res:=233;
  48. end;
  49. {$ifdef FPC_USE_SIGPROCMASK}
  50. reenable_signal(sig);
  51. {$endif }
  52. { give runtime error at the position where the signal was raised }
  53. if res<>0 then
  54. begin
  55. {$ifdef cpui386}
  56. HandleErrorAddrFrame(res,Pointer(SigContext^.sc_eip),pointer(SigContext^.sc_ebp));
  57. {$else}
  58. HandleError(res);
  59. {$endif}
  60. end;
  61. end;