plex.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 4k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. /*
  2.  *      plex.h
  3.  *
  4.  *      Structures and definitions for using plexs.
  5.  */
  6. #ifndef __plex__
  7. #define __plex__
  8. #define WAlign(w) (((w)+1)&~1)
  9. /*      comparison return values
  10.  */
  11. #define sgnGT   1
  12. #define sgnEQ   0
  13. #define sgnLT   (-1)
  14. #define sgnNE  2
  15. /*----------------------------------------------------------------------------
  16. |       PL structure
  17. |
  18. |       The PL (pronounced "plex") structure is used to efficiently
  19. |       manipulate variable sized arrays.
  20. |
  21. |       Fields:
  22. |               iMax            number of allocated items
  23. |               fUseCount use count plex (not all plex API's work w/ UseCount plexes)
  24. |               iMac            last used allocated item
  25. |               cbItem          sizeof item
  26. |               dAlloc          number of items to allocate at a time
  27. |               dgShift         data group to the plex should be
  28. |                               allocated in
  29. |               rg              the array of items
  30. |
  31. | WARNING: this structure also in winpmexcel.inc & macexcel.i
  32. |
  33. ----------------------------------------------------------------------------*/
  34. typedef struct _pl
  35.                 {
  36.                 WORD    iMax : 15,
  37.                                 fUseCount : 1;
  38.                 SHORT   iMac;
  39.                 WORD    cbItem;
  40.                 WORD    dAlloc:5,
  41.                                 unused:11;
  42.                 BYTE    rg[1];
  43.                 }
  44.         PL;
  45. /*----------------------------------------------------------------------------
  46. |       DEFPL macro
  47. |
  48. |       Used to define a specific plex.
  49. |
  50. |       Arguments:
  51. |               PLTYP           name of the plex type
  52. |               TYP             type of item stored in the plex
  53. |               iMax            name to use for the iMax field
  54. |               iMac            name to use for the iMac field
  55. |               rg              name to use for the rg field
  56. ----------------------------------------------------------------------------*/
  57. #define DEFPL(PLTYP,TYP,iMax,iMac,rg) 
  58.         typedef struct PLTYP
  59.                 { 
  60.                 WORD iMax : 15, 
  61.                         fUseCount : 1; 
  62.                 SHORT iMac; 
  63.                 WORD cbItem; 
  64.                 WORD dAlloc:5, 
  65.                         unused:11; 
  66.                 TYP rg[1]; 
  67.                 } 
  68.             PLTYP;
  69. /*----------------------------------------------------------------------------
  70. |       DEFPL2 macro
  71. |
  72. |       Used to define a specific plex.
  73. |
  74. |       Arguments:
  75. |               PLST            name of the plex struct
  76. |               PLTYP           name of the plex type
  77. |               TYP             type of item stored in the plex
  78. |               iMax            name to use for the iMax field
  79. |               iMac            name to use for the iMac field
  80. |               rg              name to use for the rg field
  81. ----------------------------------------------------------------------------*/
  82. #define DEFPL2(PLST,PLTYP,TYP,iMax,iMac,rg) 
  83.         typedef struct PLST
  84.                 { 
  85.                 WORD iMax : 15, 
  86.                         fUseCount : 1; 
  87.                 SHORT iMac; 
  88.                 WORD cbItem; 
  89.                 WORD dAlloc:5, 
  90.                         dgShift:3, 
  91.                         unused:8; 
  92.                 TYP rg[1]; 
  93.                 } 
  94.             PLTYP;
  95. // a FORPLEX was expanded by hand in bar.c:FHptbFromBarId for speed --
  96. // if you change this then you may need to change that
  97. #define FORPLEX(hp, hpMac, hppl) 
  98.                         for ((hpMac) = ((hp) = (VOID HUGE *)((PL HUGE *)(hppl))->rg) + 
  99.                                                  ((PL HUGE *)(hppl))->iMac; 
  100.                                  LOWORD(hp) < LOWORD(hpMac); (hp)++)
  101. #define cbPL ((int)&((PL *)0)->rg)
  102. #ifdef __cplusplus
  103. extern "C" {
  104. #endif // __cplusplus
  105. VOID *PplAlloc(unsigned, int, unsigned);
  106. int IAddPl(VOID **, VOID *);
  107. VOID FreePpl(VOID *);
  108. BOOL RemovePl(VOID *, int);
  109. int IAddPlSort(VOID **, VOID *, int (*pfnSgn)());
  110. BOOL FLookupSortedPl(VOID *, VOID *, int *, int (*pfnSgn)());
  111. int ILookupPl(VOID *, VOID *, int (*pfnSgn)());
  112. VOID *PLookupPl(VOID *, VOID *, int (*pfnSgn)());
  113. int CbPlAlloc(VOID *);
  114. int IAddNewPlPos(VOID **, VOID *, int, int);
  115. #ifdef __cplusplus
  116. }; // extern "C"
  117. #endif // __cplusplus
  118. #endif /* __plex__ */