sysheap.inc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 releated routines.
  15. ****************************************************************************}
  16. { this function allows to extend the heap by calling
  17. syscall $7f00 resizes the brk area}
  18. function sbrk(size:longint):pointer;
  19. {$IFDEF DUMPGROW}
  20. var
  21. L: longword;
  22. begin
  23. WriteLn ('Trying to grow heap by ', Size);
  24. {$IFDEF CONTHEAP}
  25. WriteLn ('BrkLimit is ', BrkLimit);
  26. {$ENDIF CONTHEAP}
  27. asm
  28. movl size,%edx
  29. movw $0x7f00,%ax
  30. call syscall { result directly in EAX }
  31. inc %eax { Result in EAX, -1 = error (has to be transformed to 0) }
  32. jz .LSbrk_End
  33. dec %eax { No error - back to previous value }
  34. .LSbrk_End:
  35. mov %eax,L
  36. end ['eax', 'edx'];
  37. WriteLn ('New heap at ', L);
  38. Sbrk := pointer (L);
  39. end;
  40. {$ELSE DUMPGROW}
  41. assembler;
  42. asm
  43. {$IFDEF REGCALL}
  44. movl %eax,%edx
  45. {$ELSE REGCALL}
  46. movl size,%edx
  47. {$ENDIF REGCALL}
  48. movw $0x7f00,%ax
  49. call syscall
  50. inc %eax { Result in EAX, -1 = error (has to be transformed to 0) }
  51. jz .LSbrk_End
  52. dec %eax { No error - back to previous value }
  53. .LSbrk_End:
  54. end {['eax', 'edx']};
  55. {$ENDIF DUMPGROW}
  56. function SysOSAlloc (Size: ptruint): pointer;
  57. begin
  58. SysOSAlloc := Sbrk (Size);
  59. end;
  60. {.$define HAS_SYSOSFREE}
  61. procedure SysOSFree (P: pointer; Size: ptruint);
  62. begin
  63. end;