sighnd.inc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2005 by Thomas Schatzl,
  4. member of the Free Pascal development team.
  5. Signal handler is arch dependant due to processor to language
  6. exception conversion.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  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 : longint; SigInfo: PSigInfo; context: PUContext); public name '_FPC_DEFAULTSIGHANDLER'; cdecl;
  14. var
  15. res : word;
  16. begin
  17. res:=0;
  18. { exception flags are turned off by kernel }
  19. fpc_enable_ppc_fpu_exceptions;
  20. case sig of
  21. SIGFPE :
  22. { distuingish between different FPU exceptions }
  23. case (SigInfo^.si_code) of
  24. FPE_FLTDIV : res := 200;
  25. FPE_FLTOVF : res := 205;
  26. FPE_FLTUND : res := 206;
  27. else
  28. res := 207;
  29. end;
  30. SIGBUS :
  31. res:=214;
  32. SIGILL,
  33. SIGSEGV :
  34. res:=216;
  35. SIGINT:
  36. res:=217;
  37. SIGQUIT:
  38. res:=233;
  39. end;
  40. { reenable signal }
  41. reenable_signal(sig);
  42. { handle error }
  43. if res<>0 then
  44. HandleErrorAddrFrame(res,
  45. Pointer(context^.uc_mcontext.gp_regs[PT_NIP]),
  46. Pointer(context^.uc_mcontext.gp_regs[PT_R1]));
  47. end;