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.

51 lines
2.1 KiB

  1. /******************************************************************************
  2. Copyright (C) Microsoft Corporation 1991-1992. All rights reserved.
  3. Title: ntaviprt.h - Definitions for the portable win16/32 version of AVI
  4. *****************************************************************************/
  5. #ifndef WIN32
  6. #define EnterCrit(a)
  7. #define LeaveCrit(a)
  8. #else
  9. /*
  10. * we need to enter critical sections more than once on a thread
  11. * (eg when handling a message that requires sending another message
  12. * to the winproc). This is ok - the same thread can get a critical
  13. * section more than once. BUT - we need to release it the same number
  14. * of times.
  15. *
  16. * Problems occur in mciaviTaskWait when we release the critsec to yield
  17. * - we don't know how many times to release it and enter it again.
  18. *
  19. * Solution: keep a count of how many times we are in the critsec. When
  20. * entering, if the count is already > 0, increment it once more, and leave
  21. * the critsec (ensuring that the count is protected, but the critsec is
  22. * only one level deep). On leaving, only do a leave if the count reaches
  23. * 0.
  24. *
  25. * NB: Critical sections are now defined per device, in the MCIGRAPHIC
  26. * struct. This is needed to avoid critsec deadlocks when running multiple
  27. * 16-bit apps (if a WOW thread yields in any way - and there are a lot
  28. * of ways - while holding the critical section, and another WOW thread
  29. * tries to get the critical section, WOW will hang, since it won't
  30. * reschedule).
  31. */
  32. #define EnterCrit(p) { EnterCriticalSection(&(p)->CritSec); \
  33. if ((p)->lCritRefCount++ > 0) \
  34. LeaveCriticalSection(&(p)->CritSec);\
  35. }
  36. #define LeaveCrit(p) { if (--(p)->lCritRefCount <= 0) { \
  37. LeaveCriticalSection(&(p)->CritSec);\
  38. Sleep(0); \
  39. } \
  40. }
  41. #define IsGDIObject(obj) (GetObjectType((HGDIOBJ)(obj)) != 0)
  42. #endif
  43.