ppchnd.inc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_FLTDIV : Res:=208; { floating point divide by zero }
  22. FPE_INTDIV : Res:=200; { integer divide by zero }
  23. FPE_FLTOVF : Res:=205; { floating point overflow }
  24. FPE_FLTUND : Res:=206; { floating point underflow }
  25. FPE_FLTRES, { floating point inexact result }
  26. FPE_FLTINV : Res:=207; { invalid floating point operation }
  27. Else
  28. Res:=207; {coprocessor error}
  29. end;
  30. { FPU exceptions are completely disabled by the kernel if one occurred, it }
  31. { seems this is necessary to be able to return to user mode. They can be }
  32. { enabled by executing a sigreturn, however then the exception is triggered }
  33. { again immediately if we don't turn off the "exception occurred" flags }
  34. { in fpscr }
  35. SigContext^.uc_mcontext^.fs.fpscr := SigContext^.uc_mcontext^.fs.fpscr and not($fffe0700);
  36. end;
  37. SIGILL,
  38. SIGBUS,
  39. SIGSEGV :
  40. res:=216;
  41. SIGINT:
  42. res:=217;
  43. SIGQUIT:
  44. res:=233;
  45. end;
  46. {$ifdef FPC_USE_SIGPROCMASK}
  47. reenable_signal(sig);
  48. {$endif }
  49. { return to trampoline }
  50. if res <> 0 then
  51. begin
  52. SigContext^.uc_mcontext^.ss.r3 := res;
  53. SigContext^.uc_mcontext^.ss.r4 := SigContext^.uc_mcontext^.ss.srr0;
  54. SigContext^.uc_mcontext^.ss.r5 := SigContext^.uc_mcontext^.ss.r1;
  55. pointer(SigContext^.uc_mcontext^.ss.srr0) := @HandleErrorAddrFrame;
  56. end;
  57. end;