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.

63 lines
1.2 KiB

  1. #ifndef __MS_UTIL_H__
  2. #define __MS_UTIL_H__
  3. //
  4. // GUI message boxes kill us when we hit an assert or error, because they
  5. // have a message pump that causes messages to get dispatched, making it
  6. // very difficult for us to debug problems when they occur. Therefore
  7. // we redefine ERROR_OUT and ASSERT
  8. //
  9. #ifdef _DEBUG
  10. __inline void MyDebugBreak(void) { DebugBreak(); }
  11. #endif // _DEBUG
  12. // the following create a dword that will look like "abcd" in debugger
  13. #ifdef SHIP_BUILD
  14. #define MAKE_STAMP_ID(a,b,c,d)
  15. #else
  16. #define MAKE_STAMP_ID(a,b,c,d) MAKELONG(MAKEWORD(a,b),MAKEWORD(c,d))
  17. #endif // SHIP_BUILD
  18. class CRefCount
  19. {
  20. public:
  21. #ifdef SHIP_BUILD
  22. CRefCount(void);
  23. #else
  24. CRefCount(DWORD dwStampID);
  25. #endif
  26. virtual ~CRefCount(void) = 0;
  27. LONG AddRef(void);
  28. LONG Release(void);
  29. protected:
  30. LONG GetRefCount(void) { return m_cRefs; }
  31. BOOL IsRefCountZero(void) { return (0 == m_cRefs); }
  32. private:
  33. #ifndef SHIP_BUILD
  34. DWORD m_dwStampID;// to remove before we ship it
  35. #endif
  36. LONG m_cRefs; // reference count
  37. };
  38. __inline void My_CloseHandle(HANDLE hdl)
  39. {
  40. if (NULL != hdl)
  41. {
  42. CloseHandle(hdl);
  43. }
  44. }
  45. #endif // __MS_UTIL_H__