sysheap.inc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Free Pascal development team
  5. This file implements all the base types and limits required
  6. for a minimal POSIX compliant subset required to port the compiler
  7. to a new OS.
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. {****************************************************************************
  15. Heap management releated routines.
  16. ****************************************************************************}
  17. { this function allows to extend the heap by calling
  18. syscall $7f00 resizes the brk area}
  19. function sbrk(size:longint):pointer;
  20. {$IFDEF DUMPGROW}
  21. var
  22. L: longword;
  23. begin
  24. WriteLn ('Trying to grow heap by ', Size);
  25. {$IFDEF CONTHEAP}
  26. WriteLn ('BrkLimit is ', BrkLimit);
  27. {$ENDIF CONTHEAP}
  28. asm
  29. movl size,%edx
  30. movw $0x7f00,%ax
  31. call syscall { result directly in EAX }
  32. inc %eax { Result in EAX, -1 = error (has to be transformed to 0) }
  33. jz .LSbrk_End
  34. dec %eax { No error - back to previous value }
  35. .LSbrk_End:
  36. mov %eax,L
  37. end ['eax', 'edx'];
  38. WriteLn ('New heap at ', L);
  39. Sbrk := pointer (L);
  40. end;
  41. {$ELSE DUMPGROW}
  42. assembler;
  43. asm
  44. {$IFDEF REGCALL}
  45. movl %eax,%edx
  46. {$ELSE REGCALL}
  47. movl size,%edx
  48. {$ENDIF REGCALL}
  49. movw $0x7f00,%ax
  50. call syscall
  51. inc %eax { Result in EAX, -1 = error (has to be transformed to 0) }
  52. jz .LSbrk_End
  53. dec %eax { No error - back to previous value }
  54. .LSbrk_End:
  55. end {['eax', 'edx']};
  56. {$ENDIF DUMPGROW}
  57. function SysOSAlloc (Size: ptrint): pointer;
  58. begin
  59. SysOSAlloc := Sbrk (Size);
  60. end;
  61. {.$define HAS_SYSOSFREE}
  62. procedure SysOSFree (P: pointer; Size: ptrint);
  63. begin
  64. end;
  65. {
  66. $Log$
  67. Revision 1.1 2005-02-06 16:57:18 peter
  68. * threads for go32v2,os,emx,netware
  69. Revision 1.1 2005/02/06 13:06:20 peter
  70. * moved file and dir functions to sysfile/sysdir
  71. * win32 thread in systemunit
  72. }