Changeset 25491 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Dec 18, 2009 3:20:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
r25478 r25491 140 140 141 141 142 RTDECL(void) RTLockValidator Init(PRTLOCKVALIDATORREC pRec, RTLOCKVALIDATORCLASS hClass,143 uint32_t uSubClass, const char *pszName, void *hLock)142 RTDECL(void) RTLockValidatorRecInit(PRTLOCKVALIDATORREC pRec, RTLOCKVALIDATORCLASS hClass, 143 uint32_t uSubClass, const char *pszName, void *hLock) 144 144 { 145 145 pRec->u32Magic = RTLOCKVALIDATORREC_MAGIC; … … 167 167 168 168 169 RTDECL(int) RTLockValidator Create(PRTLOCKVALIDATORREC *ppRec, RTLOCKVALIDATORCLASS hClass,170 uint32_t uSubClass, const char *pszName, void *pvLock)169 RTDECL(int) RTLockValidatorRecCreate(PRTLOCKVALIDATORREC *ppRec, RTLOCKVALIDATORCLASS hClass, 170 uint32_t uSubClass, const char *pszName, void *pvLock) 171 171 { 172 172 PRTLOCKVALIDATORREC pRec; … … 175 175 return VERR_NO_MEMORY; 176 176 177 RTLockValidator Init(pRec, hClass, uSubClass, pszName, pvLock);177 RTLockValidatorRecInit(pRec, hClass, uSubClass, pszName, pvLock); 178 178 179 179 return VINF_SUCCESS; … … 181 181 182 182 183 RTDECL(void) RTLockValidator Delete(PRTLOCKVALIDATORREC pRec)183 RTDECL(void) RTLockValidatorRecDelete(PRTLOCKVALIDATORREC pRec) 184 184 { 185 185 Assert(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC); … … 195 195 196 196 197 RTDECL(void) RTLockValidator Destroy(PRTLOCKVALIDATORREC *ppRec)197 RTDECL(void) RTLockValidatorRecDestroy(PRTLOCKVALIDATORREC *ppRec) 198 198 { 199 199 PRTLOCKVALIDATORREC pRec = *ppRec; … … 201 201 if (pRec) 202 202 { 203 RTLockValidator Delete(pRec);203 RTLockValidatorRecDelete(pRec); 204 204 RTMemFree(pRec); 205 205 } 206 } 207 208 209 RTDECL(void) RTLockValidatorSharedRecInit(PRTLOCKVALIDATORSHARED pRec, RTLOCKVALIDATORCLASS hClass, 210 uint32_t uSubClass, const char *pszName, void *hLock) 211 { 212 pRec->u32Magic = RTLOCKVALIDATORSHARED_MAGIC; 213 pRec->uSubClass = uSubClass; 214 pRec->hClass = hClass; 215 pRec->hLock = hLock; 216 pRec->pszName = pszName; 217 218 /* the table */ 219 pRec->cEntries = 0; 220 pRec->iLastEntry = 0; 221 pRec->cAllocated = 0; 222 pRec->fReallocating = false; 223 pRec->afPadding[0] = false; 224 pRec->afPadding[1] = false; 225 pRec->afPadding[2] = false; 226 pRec->papOwners = NULL; 227 pRec->u64Alignment = UINT64_MAX; 228 } 229 230 231 RTDECL(void) RTLockValidatorSharedRecDelete(PRTLOCKVALIDATORSHARED pRec) 232 { 233 Assert(pRec->u32Magic == RTLOCKVALIDATORSHARED_MAGIC); 234 235 /* 236 * Flip it into table realloc mode and take the destruction lock. 237 */ 238 rtLockValidatorSerializeDestructEnter(); 239 240 if (!ASMAtomicCmpXchgBool(&pRec->fReallocating, true, false)) 241 { 242 for (;;) 243 { 244 rtLockValidatorSerializeDestructEnter(); 245 rtLockValidatorSerializeDetectionEnter(); 246 rtLockValidatorSerializeDetectionLeave(); 247 rtLockValidatorSerializeDestructEnter(); 248 if (ASMAtomicCmpXchgBool(&pRec->fReallocating, true, false)) 249 break; 250 } 251 } 252 253 ASMAtomicWriteU32(&pRec->u32Magic, RTLOCKVALIDATORSHARED_MAGIC_DEAD); 254 ASMAtomicUoWriteHandle(&pRec->hClass, NIL_RTLOCKVALIDATORCLASS); 255 if (pRec->papOwners) 256 { 257 PRTLOCKVALIDATORSHAREDONE volatile *papOwners = pRec->papOwners; 258 ASMAtomicUoWritePtr((void * volatile *)&pRec->papOwners, NULL); 259 ASMAtomicUoWriteU32(&pRec->cAllocated, 0); 260 261 RTMemFree((void *)pRec->papOwners); 262 } 263 ASMAtomicWriteBool(&pRec->fReallocating, false); 264 265 rtLockValidatorSerializeDestructLeave(); 206 266 } 207 267
Note:
See TracChangeset
for help on using the changeset viewer.