home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / SOURCE / STARTUP / HEAP.IN_ / HEAP.IN
Encoding:
Text File  |  1993-02-08  |  3.5 KB  |  138 lines

  1. ;***
  2. ;heap.inc - definitions and structures for C library heap
  3. ;
  4. ;    Copyright (c) 1987-1992, Microsoft Corporation.  All rights reserved.
  5. ;
  6. ;Purpose:
  7. ;    This file contains definitions and structures used by
  8. ;    the C library heap routines.
  9. ;
  10. ;*******************************************************************************
  11.  
  12. ;
  13. ; --- Heap segment descriptor ---
  14. ;
  15. ; [***NOTE*** Some heap routines make assumptions about the layout of the
  16. ; heap descriptor.  If this descriptor changes, some routines may break.]
  17. ;
  18.  
  19. _heap_seg_desc    struc
  20.     checksum    dw    ?    ; checksum area
  21.     flags        dw    ?    ; flags word
  22.     segsize     dw    ?    ; size of segment
  23. ifdef _WINDOWS
  24.     handle        dw    ?    ; handle for this segment
  25. endif
  26.     start        dw    ?    ; offset of first heap entry
  27.     rover        dw    ?    ; rover offset
  28.     last        dw    ?    ; offset to end-of-heap marker
  29.     nextseg     dd    ?    ; far pointer to next _heap_seg_desc
  30.     prevseg     dd    ?    ; far pointer to previous _heap_seg_desc
  31. _heap_seg_desc    ends
  32.  
  33. ;
  34. ; _heap_seg_desc.flags bit offsets
  35. ;
  36.  
  37. _HEAP_MODIFY    equ    01h        ; heap segment size can be modified
  38. _HEAP_FREE    equ    02h        ; heap segment may be freed up to OS
  39. _HEAP_NEAR    equ    04h        ; heap segment is part of the near heap
  40. _HEAP_BASED    equ    08h        ; heap segment is part of the based heap
  41.  
  42. ;
  43. ; --- Heap Linked List Descriptor ---
  44. ;
  45. ; [***NOTE*** Some heap routines make assumptions about the layout of the
  46. ; heap list descriptor.  If this descriptor changes, some routines may break.]
  47. ;
  48.  
  49. _heap_list_desc struc
  50.     startseg    dd    0    ; pointer to first heap descriptor
  51.     roverseg    dd    0    ; rover pointer
  52.     lastseg     dd    0    ; pointer to last heap descriptor
  53.     segflags    dw    0    ; flags word for init'ing new segs
  54. _heap_list_desc ends
  55.  
  56. ;
  57. ; --- General Use Heap Constants ---
  58. ;
  59.  
  60. _HEAP_END    equ    0FFFEh        ; End-of-heap flag
  61. _HEAP_COALESCE    equ    0FFFEh        ; Coalesce segment value
  62. ifdef _WINDOWS
  63. ; Note:  Increment must be a multiple of 4K for SMK support
  64. _HEAP_GROWSEG    equ    1 shl 12    ; Default heap seg growth increment (4K)
  65. _HEAP_GROWSTART equ    1 shl 12    ; Startup heap seg growth size (4K)
  66. else
  67. _HEAP_GROWSEG    equ    1 shl 13    ; Default heap seg growth increment (8K)
  68. _HEAP_GROWSTART equ    1 shl 10    ; Startup heap seg growth size (1K)
  69. endif
  70. _HEAP_MAXREQ    equ    0FFFCh - (size _heap_seg_desc)    ; Max heap request size
  71. _HEAP_MINSEG    equ    ((size _heap_seg_desc) + 4) ; Min size heap segment
  72.  
  73. ;
  74. ; --- Heap Check/Set/Walk Definitions ---
  75. ;
  76.  
  77. ; Heap info structure used by heapwalk
  78.  
  79. _heapinfo    struc
  80.     _pentry_off    dw    ?    ; far pointer to heap entry (offset)
  81.     _pentry_seg    dw    ?    ; far pointer to heap entry (segment)
  82.     _size        dw    ?    ; size of entry
  83.     _useflag    dw    ?    ; in use flag
  84. _heapinfo    ends
  85.  
  86. ;
  87. ; Heap Check/Set/Walk Constants
  88. ; [NOTE: These definitions must match malloc.h]
  89. ;
  90.  
  91. _HEAPEMPTY    equ    -1
  92. _HEAPOK     equ    -2
  93. _HEAPBADBEGIN    equ    -3
  94. _HEAPBADNODE    equ    -4
  95. _HEAPEND    equ    -5
  96. _HEAPBADPTR    equ    -6
  97.  
  98. _HEAPSET_NOFILL equ    07FFFh
  99.  
  100. _FREEENTRY    equ    0
  101. _USEDENTRY    equ    1
  102.  
  103. ;
  104. ; Return value denoting failure for based heap functions of based pointer
  105. ; return type. The name and definition must correspond to the one given
  106. ; in MALLOC.H.
  107. ;
  108.  
  109. _NULLOFF    equ    -1
  110.  
  111.  
  112. IFDEF    _WINDOWS
  113. ;
  114. ; --- WINDOWS Support ---
  115. ;
  116.  
  117. ifdef _WINDLL
  118. _HEAP_REAL    equ 2020h    ; GMEM_FIXED | GMEM_NODISCARD | GMEM_DDESHARE
  119. _HEAP_PROTECT    equ 2002h    ; GMEM_MOVEABLE | GMEM_DDESHARE
  120. else
  121. _HEAP_REAL    equ 0020h    ; GMEM_FIXED | GMEM_NODISCARD
  122. _HEAP_PROTECT    equ 0002h    ; GMEM_MOVEABLE
  123. endif
  124.  
  125. ENDIF
  126.  
  127. IFDEF    M_XENIX
  128. ;
  129. ; --- XENIX Heap Support ---
  130. ;
  131.  
  132. BR_ARGSEG    equ 1            ; specified segment
  133. BR_NEWSEG    equ 2            ; new segment
  134. BR_IMPSEG    equ 3            ; last or new segment
  135. BR_FREESEG    equ 4            ; free segment
  136.  
  137. ENDIF
  138.