sysheap.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. {$ifndef HAS_SYSOSALLOC}
  14. {$define HAS_SYSOSALLOC}
  15. function SysOSAlloc(size: ptruint): pointer;
  16. begin
  17. result:=Fpmmap(nil,Size,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0);
  18. if result=pointer(-1) then
  19. result:=nil
  20. else
  21. seterrno(0);
  22. end;
  23. {$endif HAS_SYSOSALLOC}
  24. {$ifndef HAS_SYSOSFREE}
  25. {$define HAS_SYSOSFREE}
  26. procedure SysOSFree(p: pointer; size: ptruint);
  27. begin
  28. fpmunmap(p, size);
  29. end;
  30. {$endif HAS_SYSOSFREE}
  31. {$ifdef FPC_SYSTEM_HAS_MREMAP}
  32. const
  33. MREMAP_MAYMOVE = 1;
  34. {$define FPC_SYSTEM_HAS_SYSOSREALLOC}
  35. function SysOSRealloc(p: pointer;oldsize,newsize: ptruint): pointer;
  36. begin
  37. result:=Fpmremap(p,oldsize,newsize,MREMAP_MAYMOVE,nil);
  38. if result=pointer(-1) then
  39. result:=nil
  40. else
  41. seterrno(0);
  42. end;
  43. {$endif FPC_SYSTEM_HAS_MREMAP}