Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. bitset.h
  5. Abstract:
  6. Macro definitions that implement operations on a BITSET type.
  7. Author:
  8. Gor Nishanov Aug-1998
  9. Revision History:
  10. --*/
  11. #ifndef __BITSET_H
  12. #define __BITSET_H
  13. /************************************************************************
  14. * BitsetInit,
  15. * BitsetUnion,
  16. * BitsetIntersection,
  17. * BitsetDifference,
  18. * BitsetCompare,
  19. * BitsetSubsetOf,
  20. * BitsetComplement,
  21. * BitsetMember,
  22. * BitsetInsert,
  23. * BitsetDelete,
  24. * BitsetCopy,
  25. * BitsetEmpty
  26. * =================
  27. *
  28. * Description:
  29. *
  30. * Macro definitions that implement operations on a BITSET type.
  31. * Be very careful with argument order.
  32. *
  33. ************************************************************************/
  34. typedef DWORD BITSET;
  35. #define BITSET_BIT_COUNT (sizeof(BITSET) * 8)
  36. #ifndef BITSET_SKEW
  37. # define BITSET_SKEW ClusterMinNodeId
  38. #endif
  39. /* Operations */
  40. #define BitsetUnion(a,b) ((a)|(b))
  41. #define BitsetIntersection(a,b) ((a)&(b))
  42. #define BitsetDifference(a,b) ((a)&~(b))
  43. #define BitsetEquals(a,b) ((a)==(b))
  44. #define BitsetIsSubsetOf(small,big) BitsetDifference(small,big)
  45. #define BitsetIsEmpty(b) ((b) == 0)
  46. #define BitsetFromUnit(unit) ( (1 << (unit - BITSET_SKEW)) )
  47. #define BitsetIsMember(unit,set) ( BitsetFromUnit(unit) & (set) )
  48. #define BitsetIsNotMember(unit,set) ( !BitsetIsMember(unit,set) )
  49. /* Statements */
  50. #define BitsetInit(set) \
  51. do { (set) = 0; } while(0)
  52. #define BitsetRemove(set, unit) \
  53. do { (set) &= ~BitsetFromUnit(unit); } while(0)
  54. #define BitsetAdd(set, unit) \
  55. do { (set) |= BitsetFromUnit(unit); } while(0)
  56. #define BitsetAssign(dest,src) \
  57. do { (dest) = (src); } while(0)
  58. #define BitsetMergeWith(dest,src) \
  59. do { (dest) |= (src); } while(0)
  60. #define BitsetSubtract(dest,src) \
  61. do { (dest) &= ~(src); } while(0)
  62. #define BitsetIntersectWith(dest,src) \
  63. do { (dest) &= (src); } while(0)
  64. #endif // __BITSET_H
  65.