home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / mslang / vm / h / vmbm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-15  |  2.7 KB  |  85 lines

  1. /***
  2. * vmbm.h -
  3. *
  4. *       Copyright (c) 1989-1992, Microsoft Corporation.  All rights reserved.
  5. *
  6. *******************************************************************************/
  7.  
  8. // These are the VMBM internal data structures ONLY, not public to the
  9. // user of the VMBM!
  10.  
  11. #pragma pack(1)
  12. typedef union {
  13.     struct {
  14.     unsigned short  fAdjacent   :1;
  15.     unsigned short  fVoid       :15;
  16.     };
  17.     unsigned short  cbSize;
  18.     unsigned short  cPage;
  19.     } SZBK;                             //* SiZe of allocated BlocK
  20.  
  21. typedef struct {
  22.     SZBK;
  23.     struct {
  24.     unsigned short  cLock       :8;
  25.     unsigned short  fFree       :1;
  26.     unsigned short  fByPage     :1;
  27.     };
  28.     } HDP;                              //* HeaDer info for a Page
  29. typedef HDP far *   PHDP;
  30.  
  31. typedef struct {
  32.     HDP;
  33.     SZBK        szbkBack;
  34.     } HDB;                              //* HeaDer info for a Block
  35. typedef HDB far *   PHDB;
  36.  
  37. typedef struct {
  38.     HDB;
  39.     HBK         hbkBackHdf;
  40.     HBK         hbkNextHdf;
  41.     } HDF;                              //* Free HeaDer, at the start of
  42. typedef HDF far *   PHDF;
  43.  
  44. #pragma pack()
  45.  
  46. #define bitShift    4                   // used to calculate cbClose and cbBig
  47.  
  48. #define cbClose (cbVmPage >> bitShift)    // This says that cbClose bytes is
  49.                     // close enough to a page boundary
  50.                     // to go ahead an go to the next page
  51.                     // this must be greater that
  52.                     // sizeof(FHD)
  53.  
  54. #define cbBig                   (cbVmPage - sizeof(HDB))
  55.  
  56. #define cbMaxAlloc  (0xFFFFFFFF - cbVmPage)
  57. #define cbEndPage(a) (cbVmPage - ((a) % cbVmPage))  // nbr bytes from vp to end
  58.                         // of the page
  59.  
  60. #define CbGetSize(a)    (((unsigned short) (a)) & 0xFFFE)
  61. #define CbMakeSize(a,b) ((((unsigned short) (a)) & 0xFFFE) | (((unsigned short) (b)) & 0x0001))
  62. #define cbMaxFreeSize   0xFFFE
  63. #define AddHbk(a,b)     ((HBK) (((unsigned long) (a)) + (b)))
  64.  
  65. #define cMaxLock 255U
  66.  
  67. // the VMBM global variable structure.
  68. typedef struct {
  69.     unsigned        cbMaxFree;          // how many bytes free in last block, must be first item in struct for initialization
  70.     unsigned long   cFree;              // nbr of free blocks known
  71.     HBK             hbkFreeStart;       // the first free block
  72.     HBK             hbkFreeLast;        // the last free block
  73.     HBK             hbkLastBlock;       // the last block in the list
  74.     } GVMBM;
  75.  
  76. extern GVMBM    _gvmbm;
  77.  
  78. extern void VMFUNC __VmFreeLink(HBK, HBK);
  79. extern void VMFUNC __VmFreeLinkIn(HBK, unsigned, HBK, HBK);
  80. extern void VMFUNC __VmFreeLinkEnd(HBK, unsigned);
  81.  
  82. extern unsigned _near _fVmInit; /* TRUE when VM is initialized */
  83. extern const VPVOID _hbkMin; /* lowest legal handle address */
  84. extern const VPVOID _hbkMax; /* highest legal handle address */
  85.