sighnd.inc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. {
  2. This file is part of the Free Pascal run time library.
  3. (c) 2008 by Jonas Maebe
  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 Darwin/arm
  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,
  22. FPE_INTDIV : Res:=200; { floating point 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. { clear "exception happened" flags }
  31. SigContext^.uc_mcontext^.__fs.__fpscr := SigContext^.uc_mcontext^.__fs.__fpscr and not($df);
  32. end;
  33. SIGBUS:
  34. res:=214;
  35. SIGILL,
  36. SIGSEGV :
  37. res:=216;
  38. SIGINT:
  39. res:=217;
  40. SIGQUIT:
  41. res:=233;
  42. end;
  43. {$ifdef FPC_USE_SIGPROCMASK}
  44. reenable_signal(sig);
  45. {$endif }
  46. { return to trampoline }
  47. if res <> 0 then
  48. begin
  49. SigContext^.uc_mcontext^.__ss.__r[0] := res;
  50. SigContext^.uc_mcontext^.__ss.__r[1] := SigContext^.uc_mcontext^.__ss.__pc;
  51. SigContext^.uc_mcontext^.__ss.__r[2] := SigContext^.uc_mcontext^.__ss.__sp;
  52. pointer(SigContext^.uc_mcontext^.__ss.__pc) := @HandleErrorAddrFrame;
  53. end;
  54. end;