sysos.inc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2001 by Free Pascal development team
  4. This file implements all the base types and limits required
  5. for a minimal POSIX compliant subset required to port the compiler
  6. to a new OS.
  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. {$include xbios.inc}
  14. {$include gemdos.inc}
  15. procedure Error2InOutRes(errno: longint);
  16. begin
  17. if (errno <= -2) and (errno >= -11) then
  18. InOutRes:=150-errno
  19. else
  20. begin
  21. case errno of
  22. -32 : InOutRes:=1;
  23. -33 : InOutRes:=2;
  24. -34 : InOutRes:=3;
  25. -35 : InOutRes:=4;
  26. -36 : InOutRes:=5;
  27. -37 : InOutRes:=8;
  28. -39 : InOutRes:=8;
  29. -40 : InOutRes:=9;
  30. -46 : InOutRes:=15;
  31. -67..-64 : InOutRes:=153;
  32. -15 : InOutRes:=151;
  33. -13 : InOutRes:=150;
  34. else
  35. InOutRes := word(errno);
  36. end;
  37. end;
  38. end;
  39. var
  40. stackpointer_on_entry: pointer; external name '__stktop';
  41. function StackTop: Pointer;
  42. begin
  43. StackTop:=stackpointer_on_entry;
  44. end;
  45. var
  46. basepage: PPD; external name '__base';
  47. function SysBackTraceStr (Addr: CodePointer): ShortString;
  48. begin
  49. if (addr<basepage^.p_tbase) or (addr>pointer(basepage^.p_tbase+basepage^.p_tlen)) then
  50. SysBackTraceStr:=' Addr $'+hexstr(addr)
  51. else
  52. SysBackTraceStr:=' Offs $'+hexstr(pointer(addr-basepage^.p_tbase));
  53. end;