sighnd.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt,
  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. { fpustate: longint; }
  17. begin
  18. res:=0;
  19. {$ifndef FPUNONE}
  20. { exception flags are turned off by kernel }
  21. fpc_enable_ppc_fpu_exceptions;
  22. {$endif}
  23. case sig of
  24. SIGFPE :
  25. case (SigInfo^.si_code) of
  26. FPE_FLTDIV : res := 200;
  27. FPE_FLTOVF : res := 205;
  28. FPE_FLTUND : res := 206;
  29. else
  30. res := 207;
  31. end;
  32. SIGBUS :
  33. res:=214;
  34. SIGILL,
  35. SIGSEGV :
  36. res:=216;
  37. SIGINT:
  38. res:=217;
  39. SIGQUIT:
  40. res:=233;
  41. end;
  42. reenable_signal(sig);
  43. { give runtime error at the position where the signal was raised }
  44. if res<>0 then
  45. HandleErrorAddrFrame(res, pointer(context^.uc_mcontext.pt_regs^.nip),
  46. pointer(context^.uc_mcontext.pt_regs^.gpr[1]));
  47. end;