static void MXUserCondDestroyRecLock(MXUserRecLock *lock) // IN: { ASSERT(lock); MXUserValidateHeader(&lock->header, MXUSER_TYPE_REC); ASSERT(Atomic_Read(&lock->refCount) > 0); if (Atomic_ReadDec32(&lock->refCount) == 1) { if (lock->vmmLock == NULL) { if (MXRecLockCount(&lock->recursiveLock) > 0) { MXUserDumpAndPanic(&lock->header, "%s: Destroy of an acquired recursive lock\n", __FUNCTION__); } MXRecLockDestroy(&lock->recursiveLock); MXUserRemoveFromList(&lock->header); if (vmx86_stats) { MXUserDisableStats(&lock->acquireStatsMem, &lock->heldStatsMem); } } lock->header.signature = 0; // just in case... free(lock->header.name); lock->header.name = NULL; free(lock); } }
void MXUser_DestroyRWLock(MXUserRWLock *lock) // IN: { if (LIKELY(lock != NULL)) { MXUserValidateHeader(&lock->header, MXUSER_TYPE_RW); if (Atomic_Read(&lock->holderCount) != 0) { MXUserDumpAndPanic(&lock->header, "%s: Destroy on an acquired read-write lock\n", __FUNCTION__); } if (LIKELY(lock->useNative)) { int err = MXUserNativeRWDestroy(&lock->nativeLock); if (UNLIKELY(err != 0)) { MXUserDumpAndPanic(&lock->header, "%s: Internal error (%d)\n", __FUNCTION__, err); } } lock->header.signature = 0; // just in case... MXRecLockDestroy(&lock->recursiveLock); MXUserRemoveFromList(&lock->header); if (vmx86_stats) { MXUserStats *stats = Atomic_ReadPtr(&lock->statsMem); if (LIKELY(stats != NULL)) { MXUserAcquisitionStatsTearDown(&stats->acquisitionStats); MXUserHistoTearDown(Atomic_ReadPtr(&stats->acquisitionHisto)); MXUserBasicStatsTearDown(&stats->heldStats); MXUserHistoTearDown(Atomic_ReadPtr(&stats->heldHisto)); free(stats); } } HashTable_FreeUnsafe(lock->holderTable); free(lock->header.name); lock->header.name = NULL; free(lock); } }
void MXUser_DestroySemaphore(MXUserSemaphore *sema) // IN: { if (LIKELY(sema != NULL)) { int err; MXUserValidateHeader(&sema->header, MXUSER_TYPE_SEMA); if (Atomic_Read(&sema->activeUserCount) != 0) { MXUserDumpAndPanic(&sema->header, "%s: Attempted destroy on semaphore while in use\n", __FUNCTION__); } sema->header.signature = 0; // just in case... err = MXUserDestroy(&sema->nativeSemaphore); if (UNLIKELY(err != 0)) { MXUserDumpAndPanic(&sema->header, "%s: Internal error (%d)\n", __FUNCTION__, err); } MXUserRemoveFromList(&sema->header); if (vmx86_stats) { MXUserAcquireStats *acquireStats; acquireStats = Atomic_ReadPtr(&sema->acquireStatsMem); if (LIKELY(acquireStats != NULL)) { MXUserAcquisitionStatsTearDown(&acquireStats->data); MXUserHistoTearDown(Atomic_ReadPtr(&acquireStats->histo)); free(acquireStats); } } free(sema->header.name); sema->header.name = NULL; free(sema); } }
void MXUser_DestroyExclLock(MXUserExclLock *lock) // IN: { if (lock != NULL) { MXUserValidateHeader(&lock->header, MXUSER_TYPE_EXCL); if (MXRecLockCount(&lock->recursiveLock) > 0) { MXUserDumpAndPanic(&lock->header, "%s: Destroy of an acquired exclusive lock\n", __FUNCTION__); } lock->header.signature = 0; // just in case... MXRecLockDestroy(&lock->recursiveLock); MXUserRemoveFromList(&lock->header); if (vmx86_stats) { MXUserStats *stats = Atomic_ReadPtr(&lock->statsMem); if (LIKELY(stats != NULL)) { MXUserAcquisitionStatsTearDown(&stats->acquisitionStats); MXUserHistoTearDown(Atomic_ReadPtr(&stats->acquisitionHisto)); MXUserBasicStatsTearDown(&stats->heldStats); MXUserHistoTearDown(Atomic_ReadPtr(&stats->heldHisto)); free(stats); } } free(lock->header.name); lock->header.name = NULL; free(lock); } }