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.

82 lines
2.1 KiB

  1. /*****************************************************************************\
  2. * MODULE: sem.h
  3. *
  4. * Header file for the semaphore/crit-sect handling.
  5. *
  6. *
  7. * Copyright (C) 1996-1997 Microsoft Corporation
  8. * Copyright (C) 1996-1997 Hewlett Packard
  9. *
  10. * History:
  11. * 24-Aug-1997 HWP-Guys Created.
  12. *
  13. \*****************************************************************************/
  14. #ifndef _INETPPSEM_H
  15. #define _INETPPSEM_H
  16. #ifdef DEBUG
  17. /*****************************************************************************\
  18. * _sem_dbg_EnterCrit
  19. *
  20. \*****************************************************************************/
  21. _inline VOID _sem_dbg_EnterCrit(VOID)
  22. {
  23. EnterCriticalSection(&g_csMonitorSection);
  24. g_dwCritOwner = GetCurrentThreadId();
  25. }
  26. /*****************************************************************************\
  27. * _sem_dbg_LeaveCrit
  28. *
  29. \*****************************************************************************/
  30. _inline VOID _sem_dbg_LeaveCrit(VOID)
  31. {
  32. g_dwCritOwner = 0;
  33. LeaveCriticalSection(&g_csMonitorSection);
  34. }
  35. /*****************************************************************************\
  36. * _sem_dbg_CheckCrit
  37. *
  38. \*****************************************************************************/
  39. _inline VOID _sem_dbg_CheckCrit(VOID)
  40. {
  41. DWORD dwCurrent = GetCurrentThreadId();
  42. DBG_ASSERT((dwCurrent == g_dwCritOwner), (TEXT("Assert: _sem_dbg_CheckCrit: Thread(%d), Owner(%d)"), dwCurrent, g_dwCritOwner));
  43. }
  44. #define semEnterCrit() _sem_dbg_EnterCrit()
  45. #define semLeaveCrit() _sem_dbg_LeaveCrit()
  46. #define semCheckCrit() _sem_dbg_CheckCrit()
  47. #else
  48. #define semEnterCrit() EnterCriticalSection(&g_csMonitorSection)
  49. #define semLeaveCrit() LeaveCriticalSection(&g_csMonitorSection)
  50. #define semCheckCrit() {}
  51. #endif
  52. #define semInitCrit() InitializeCriticalSection(&g_csMonitorSection)
  53. #define semFreeCrit() DeleteCriticalSection(&g_csMonitorSection)
  54. _inline VOID semSafeLeaveCrit(PCINETMONPORT pIniPort)
  55. {
  56. pIniPort->IncRef ();
  57. semLeaveCrit();
  58. }
  59. _inline VOID semSafeEnterCrit(PCINETMONPORT pIniPort)
  60. {
  61. pIniPort->DecRef ();
  62. semEnterCrit();
  63. }
  64. #endif