sysheap.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. {*****************************************************************************
  14. Heap Management
  15. *****************************************************************************}
  16. function SysOSAlloc (size: ptruint): pointer;
  17. var
  18. regs : Registers;
  19. nb_para : longint;
  20. begin
  21. {$ifdef DEBUG_TINY_HEAP}
  22. writeln('SysOSAlloc called size=',size);
  23. {$endif}
  24. {$if defined(FPC_X86_DATA_FAR) or defined(FPC_X86_DATA_HUGE)}
  25. regs.ax:=$4800;
  26. nb_para:=size div 16;
  27. if nb_para > $ffff then
  28. result:=nil
  29. else
  30. begin
  31. regs.bx:=nb_para;
  32. msdos(regs);
  33. if (regs.Flags and fCarry) <> 0 then
  34. begin
  35. {$ifdef DEBUG_TINY_HEAP}
  36. writeln('SysOSAlloc failed, err = ',regs.AX);
  37. {$endif}
  38. GetInOutRes(regs.AX);
  39. Result := nil;
  40. end
  41. else
  42. begin
  43. result:=ptr(regs.ax,0);
  44. {$ifdef DEBUG_TINY_HEAP}
  45. writeln('SysOSAlloc returned= $',hexstr(seg(result),4),':$',hexstr(ofs(result),4));
  46. {$endif}
  47. end;
  48. end;
  49. {$else not DATA_FAR}
  50. Result := nil;
  51. {$endif not DATA_FAR}
  52. end;
  53. procedure SysOSFree(p: pointer; size: ptruint);
  54. begin
  55. end;