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.

113 lines
1.9 KiB

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