Source code of Windows XP (NT5)
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.

109 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. refcnt.h
  5. Abstract:
  6. Author:
  7. Edward Buchwalter (v-edbuc) 15-Aug-1996
  8. Revision History:
  9. Shreedhar Madhavapeddi (ShreeM) 16-April-1999
  10. Adapted for GPC.
  11. --*/
  12. #ifndef REFCNT_H
  13. #define REFCNT_H
  14. //
  15. // Reference Count Control Block
  16. //
  17. // Elements:
  18. //
  19. // - Count: number of outstanding references
  20. // - Instance: user supplied context
  21. // - UserDeleteFunc: user supplied delete function
  22. //
  23. #define TAG_CNT 16
  24. #define REF_SIG 0x7841eeee
  25. typedef struct
  26. {
  27. ULONG Tag;
  28. LONG Count;
  29. } REF_TAG;
  30. typedef struct reference_count_control
  31. {
  32. INT Count;
  33. PVOID Instance;
  34. VOID (*DeleteHandler)( PVOID );
  35. #if DBG
  36. int Sig;
  37. REF_TAG Tags[TAG_CNT];
  38. CTELock Lock;
  39. #endif
  40. }
  41. REF_CNT, *PREF_CNT;
  42. VOID
  43. ReferenceInit
  44. (
  45. IN PREF_CNT pRefCnt,
  46. PVOID InstanceHandle,
  47. VOID (*DeleteHandler)( PVOID )
  48. );
  49. VOID
  50. ReferenceAdd
  51. (
  52. IN PREF_CNT pRefCnt
  53. );
  54. VOID
  55. ReferenceAddCount
  56. (
  57. IN PREF_CNT pRefCnt,
  58. IN UINT Count
  59. );
  60. PVOID
  61. ReferenceRemove
  62. (
  63. IN PREF_CNT pRefCnt
  64. );
  65. VOID
  66. ReferenceApiTest
  67. (
  68. VOID
  69. );
  70. #if DBG
  71. VOID ReferenceAddDbg(PREF_CNT pRefCnt, ULONG Tag);
  72. VOID ReferenceRemoveDbg(PREF_CNT pRefCnt, ULONG Tag);
  73. VOID ReferenceCheckForZeroRef(PREF_CNT pRefCnt, ULONG Tag);
  74. #define REFADD(Rc, Tag) ReferenceAddDbg(Rc, Tag)
  75. #define REFDEL(Rc, Tag) ReferenceRemoveDbg(Rc, Tag)
  76. #define REFZEROCHECK(Rc, Tag) ReferenceCheckForZeroRef(Rc, Tag)
  77. #else
  78. #define REFADD(Rc, Tag) ReferenceAdd(Rc);
  79. #define REFDEL(Rc, Tag) ReferenceRemove(Rc);
  80. #define REFZEROCHECK(Rc, Tag)
  81. #endif
  82. #endif