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.

110 lines
2.8 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: w95csect.c
  6. * Content: code for managing critical sections on Win95
  7. * We trade a performance hit when 2 threads try to use a surface
  8. * for only using 4 bytes (pointer) instead of 24 bytes for a
  9. * critical section object PER SURFACE.
  10. *
  11. *@@BEGIN_MSINTERNAL
  12. * History:
  13. * Date By Reason
  14. * ==== == ======
  15. * 22-feb-95 craige initial implementation
  16. *@@END_MSINTERNAL
  17. *
  18. ***************************************************************************/
  19. #include "ddrawpr.h"
  20. #if 0
  21. #ifdef USE_CRITSECTS
  22. /*
  23. * MyReinitializeCriticalSection
  24. */
  25. BOOL MyReinitializeCriticalSection( LPVOID *lplpCriticalSection )
  26. {
  27. *lplpCriticalSection = NULL;
  28. return TRUE;
  29. } /* MyReinitializeCriticalSection */
  30. /*
  31. * MyEnterCriticalSection
  32. */
  33. BOOL MyEnterCriticalSection( LPVOID *lplpCriticalSection )
  34. {
  35. LPCRITICAL_SECTION pcs;
  36. if( *lplpCriticalSection != hDLLMutex )
  37. {
  38. EnterCriticalSection( hDLLMutex );
  39. }
  40. if( *lplpCriticalSection == NULL )
  41. {
  42. OutputDebugString( "DOING MALLOC" );
  43. pcs = MemAlloc( sizeof( CRITICAL_SECTION ) );
  44. if( pcs == NULL )
  45. {
  46. DPF( 0, "OUT OF MEMORY CREATING CRITICAL SECTION" );
  47. LeaveCriticalSection( hDLLMutex );
  48. return FALSE;
  49. }
  50. ReinitializeCriticalSection( pcs );
  51. *lplpCriticalSection = pcs;
  52. }
  53. // ACKACK: ALWAYS WANT TO SEE THIS MESSAGE
  54. if( *lplpCriticalSection != hDLLMutex )
  55. {
  56. // OutputDebugString( "DCIENG32: EnterCriticalSection\r\n" );
  57. }
  58. EnterCriticalSection( *lplpCriticalSection );
  59. if( *lplpCriticalSection != hDLLMutex )
  60. {
  61. LeaveCriticalSection( hDLLMutex );
  62. }
  63. return TRUE;
  64. } /* MyEnterCriticalSection */
  65. /*
  66. * MyLeaveCriticalSection
  67. */
  68. void MyLeaveCriticalSection( LPVOID *lplpCriticalSection )
  69. {
  70. if( *lplpCriticalSection == NULL )
  71. {
  72. DPF( 0, "TRYING TO LEAVE NULL CRITICAL SECTION" );
  73. LeaveCriticalSection( hDLLMutex );
  74. return;
  75. }
  76. // ALWAYS WANT TO SEE THIS MESSAGE
  77. if( *lplpCriticalSection != hDLLMutex )
  78. {
  79. // OutputDebugString( "DCIENG32: LeaveCriticalSection\r\n" );
  80. }
  81. LeaveCriticalSection( *lplpCriticalSection );
  82. } /* MyLeaveCriticalSection */
  83. /*
  84. * MyDeleteCriticalSection
  85. */
  86. void MyDeleteCriticalSection( LPVOID *lplpCriticalSection )
  87. {
  88. EnterCriticalSection( hDLLMutex );
  89. if( *lplpCriticalSection == NULL )
  90. {
  91. LeaveCriticalSection( hDLLMutex );
  92. return;
  93. }
  94. DeleteCriticalSection( *lplpCriticalSection );
  95. MemFree( *lplpCriticalSection );
  96. *lplpCriticalSection = NULL;
  97. LeaveCriticalSection( hDLLMutex );
  98. } /* MyDeleteCriticalSection */
  99. #endif
  100. #endif