Changeset 9331 for trunk/src/odincrt/critsect.cpp
- Timestamp:
- Oct 7, 2002, 6:28:15 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/odincrt/critsect.cpp
r8902 r9331 1 /* $Id: critsect.cpp,v 1. 5 2002-07-22 05:58:02 achimhaExp $ */1 /* $Id: critsect.cpp,v 1.6 2002-10-07 16:28:13 sandervl Exp $ */ 2 2 /* 3 3 * Critical sections in the Win32 sense … … 72 72 * DosInitializeCriticalSection 73 73 */ 74 VOIDWIN32API DosInitializeCriticalSection(CRITICAL_SECTION_OS2 *crit, PSZ pszSemName)74 ULONG WIN32API DosInitializeCriticalSection(CRITICAL_SECTION_OS2 *crit, PSZ pszSemName) 75 75 { 76 76 APIRET rc; … … 85 85 DebugInt3(); 86 86 crit->hmtxLock = 0; 87 return rc; 87 88 } 88 89 crit->Reserved = GetCurrentProcessId(); 90 return NO_ERROR; 89 91 } 90 92 … … 93 95 * DosAccessCriticalSection 94 96 */ 95 VOIDWIN32API DosAccessCriticalSection(CRITICAL_SECTION_OS2 *, PSZ pszSemName)97 ULONG WIN32API DosAccessCriticalSection(CRITICAL_SECTION_OS2 *, PSZ pszSemName) 96 98 { 97 99 HMTX hmtxLock = 0; … … 100 102 if(pszSemName == NULL) { 101 103 DebugInt3(); 102 return ;104 return ERROR_INVALID_PARAMETER; 103 105 } 104 106 … … 106 108 if(rc != NO_ERROR) { 107 109 DebugInt3(); 108 } 110 return rc; 111 } 112 return NO_ERROR; 109 113 } 110 114 /*********************************************************************** 111 115 * DosDeleteCriticalSection 112 116 */ 113 voidWIN32API DosDeleteCriticalSection( CRITICAL_SECTION_OS2 *crit )117 ULONG WIN32API DosDeleteCriticalSection( CRITICAL_SECTION_OS2 *crit ) 114 118 { 115 119 if (crit->hmtxLock) … … 126 130 crit->Reserved = (DWORD)-1; 127 131 } 132 return NO_ERROR; 128 133 } 129 134 … … 132 137 * DosEnterCriticalSection 133 138 */ 134 void WIN32API DosEnterCriticalSection( CRITICAL_SECTION_OS2 *crit )139 ULONG WIN32API DosEnterCriticalSection( CRITICAL_SECTION_OS2 *crit, ULONG ulTimeout ) 135 140 { 136 141 DWORD res; … … 151 156 { 152 157 crit->RecursionCount++; 153 return ;158 return NO_ERROR; 154 159 } 155 160 // do an atomic operation where we compare the owning thread id with 0 … … 162 167 163 168 /* Now wait for it */ 164 APIRET rc = DosWaitEventSem(crit->hmtxLock, SEM_INDEFINITE_WAIT);169 APIRET rc = DosWaitEventSem(crit->hmtxLock, ulTimeout); 165 170 if(rc != NO_ERROR) { 166 171 DebugInt3(); 167 return ;172 return rc; 168 173 } 169 174 DosResetEventSem(crit->hmtxLock, &ulnrposts); … … 175 180 crit->OwningThread = GetCurrentThreadId(); 176 181 crit->RecursionCount = 1; 182 return NO_ERROR; 177 183 } 178 184 … … 202 208 * DosLeaveCriticalSection 203 209 */ 204 void WIN32API DosLeaveCriticalSection( CRITICAL_SECTION_OS2 *crit ) 205 { 206 if (crit->OwningThread != GetCurrentThreadId()) return; 210 ULONG WIN32API DosLeaveCriticalSection( CRITICAL_SECTION_OS2 *crit ) 211 { 212 if (crit->OwningThread != GetCurrentThreadId()) { 213 DebugInt3(); 214 return ERROR_INVALID_PARAMETER; 215 } 207 216 208 217 if (--crit->RecursionCount) 209 218 { 210 219 DosInterlockedDecrement( &crit->LockCount ); 211 return ;220 return NO_ERROR; 212 221 } 213 222 crit->OwningThread = 0; … … 217 226 DosPostEventSem(crit->hmtxLock); 218 227 } 219 } 228 return NO_ERROR; 229 }
Note:
See TracChangeset
for help on using the changeset viewer.