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.

40 lines
921 B

  1. #include "stock.h"
  2. #pragma hdrstop
  3. #include "dbutil.h"
  4. ///////
  5. // Critical section helper stuff
  6. //
  7. #ifdef DEBUG
  8. UINT g_CriticalSectionCount = 0;
  9. DWORD g_CriticalSectionOwner = 0;
  10. #ifdef STACKBACKTRACE
  11. DBstkback g_CriticalSectionLastCall[4] = { 0 };
  12. #endif
  13. void Dll_EnterCriticalSection(CRITICAL_SECTION * pcsDll)
  14. {
  15. #ifdef STACKBACKTRACE
  16. int var0; // *must* be 1st on frame
  17. #endif
  18. EnterCriticalSection(pcsDll);
  19. if (g_CriticalSectionCount++ == 0)
  20. {
  21. g_CriticalSectionOwner = GetCurrentThreadId();
  22. #ifdef STACKBACKTRACE
  23. int fp = (int) (1 + (int *)&var0);
  24. DBGetStackBack(&fp, g_CriticalSectionLastCall, ARRAYSIZE(g_CriticalSectionLastCall));
  25. #endif
  26. }
  27. }
  28. void Dll_LeaveCriticalSection(CRITICAL_SECTION * pcsDll)
  29. {
  30. if (--g_CriticalSectionCount == 0)
  31. g_CriticalSectionOwner = 0;
  32. LeaveCriticalSection(pcsDll);
  33. }
  34. #endif