Lines Matching defs:pRec
105 PRTLOCKVALRECUNION pRec;
106 /** The current entry number if pRec is a shared one. */
577 DECL_FORCE_INLINE(void) rtLockValComplainAboutLockHlp(const char *pszPrefix, PRTLOCKVALRECUNION pRec, const char *pszSuffix,
587 pRec->Excl.hLock, pRec->Excl.pszName, pRec,
588 rtLockValidatorNameThreadHandle(&pRec->Excl.hThread), cRecursion,
589 rtLockValComplainGetClassName(pRec->Excl.hClass),
590 rtLockValComplainGetSubClassName(pRec->Excl.uSubClass, szBuf),
595 pRec->Excl.hLock, pRec->Excl.szName,
596 rtLockValidatorNameThreadHandle(&pRec->Excl.hThread), cRecursion,
597 rtLockValComplainGetClassName(pRec->Excl.hClass),
598 rtLockValComplainGetSubClassName(pRec->Excl.uSubClass, szBuf),
606 pRec->Shared.hLock, pRec->Shared.szName, pRec,
607 rtLockValComplainGetClassName(pRec->Shared.hClass),
608 rtLockValComplainGetSubClassName(pRec->Shared.uSubClass, szBuf),
614 PRTLOCKVALRECSHRD pShared = pRec->ShrdOwner.pSharedRec;
620 pRec, rtLockValidatorNameThreadHandle(&pRec->ShrdOwner.hThread), cRecursion,
628 rtLockValidatorNameThreadHandle(&pRec->ShrdOwner.hThread), cRecursion,
637 pRec, rtLockValidatorNameThreadHandle(&pRec->ShrdOwner.hThread), cRecursion,
653 * @param pRec The lock record we're working on.
656 static void rtLockValComplainAboutLock(const char *pszPrefix, PRTLOCKVALRECUNION pRec, const char *pszSuffix)
663 if ( VALID_PTR(pRec)
666 switch (pRec->Core.u32Magic)
669 rtLockValComplainAboutLockHlp(pszPrefix, pRec, pszSuffix, RTLOCKVALRECEXCL_MAGIC,
670 &pRec->Excl.SrcPos, FIX_REC(pRec->Excl.cRecursion), "");
674 rtLockValComplainAboutLockHlp(pszPrefix, pRec, pszSuffix, RTLOCKVALRECSHRD_MAGIC, NULL, 0, "");
678 rtLockValComplainAboutLockHlp(pszPrefix, pRec, pszSuffix, RTLOCKVALRECSHRDOWN_MAGIC,
679 &pRec->ShrdOwner.SrcPos, FIX_REC(pRec->ShrdOwner.cRecursion), "");
684 PRTLOCKVALRECUNION pRealRec = pRec->Nest.pRec;
692 &pRec->Nest.SrcPos, pRec->Nest.cRecursion, "/r");
695 pRealRec, pRec, pRec->Nest.cRecursion,
696 pRec->Nest.SrcPos.pszFile, pRec->Nest.SrcPos.uLine, pRec->Nest.SrcPos.pszFunction, pRec->Nest.SrcPos.uId,
702 RTAssertMsg2AddWeak("%spRec=%p u32Magic=%#x (bad)%s", pszPrefix, pRec, pRec->Core.u32Magic, pszSuffix);
762 * @param pRec The main lock involved. Can be NULL.
767 PRTLOCKVALRECUNION pRec, bool fDumpStack)
777 rtLockValComplainAboutLock("Lock: ", pRec, "\n");
779 rtLockValComplainAboutLockStack(pThreadSelf, 0, 1, pRec);
967 Assert(pPerThread->pRec == NULL);
1577 * @param pRec The lock record.
1579 DECL_FORCE_INLINE(const char *) rtLockValidatorRecName(PRTLOCKVALRECUNION pRec)
1581 switch (pRec->Core.u32Magic)
1584 return pRec->Excl.szName;
1586 return pRec->Shared.szName;
1588 return pRec->ShrdOwner.pSharedRec ? pRec->ShrdOwner.pSharedRec->szName : "orphaned";
1590 pRec = rtLockValidatorReadRecUnionPtr(&pRec->Nest.pRec);
1591 if (VALID_PTR(pRec))
1593 switch (pRec->Core.u32Magic)
1596 return pRec->Excl.szName;
1598 return pRec->Shared.szName;
1600 return pRec->ShrdOwner.pSharedRec ? pRec->ShrdOwner.pSharedRec->szName : "orphaned";
1616 * @param pRec The lock validator record.
1618 DECLINLINE(RTLOCKVALCLASSINT *) rtLockValidatorRecGetClass(PRTLOCKVALRECUNION pRec)
1620 switch (pRec->Core.u32Magic)
1623 return pRec->Excl.hClass;
1626 return pRec->Shared.hClass;
1630 PRTLOCKVALRECSHRD pSharedRec = pRec->ShrdOwner.pSharedRec;
1639 PRTLOCKVALRECUNION pRealRec = pRec->Nest.pRec;
1657 AssertMsgFailed(("%p %p %#x\n", pRec, pRealRec, pRealRec->Core.u32Magic));
1665 AssertMsgFailed(("%#x\n", pRec->Core.u32Magic));
1676 * @param pRec The lock validator record.
1681 rtLockValidatorRecGetClassesAndDown(PRTLOCKVALRECUNION pRec, uint32_t *puSubClass, PRTLOCKVALRECUNION *ppDown)
1683 switch (pRec->Core.u32Magic)
1686 *ppDown = pRec->Excl.pDown;
1687 *puSubClass = pRec->Excl.uSubClass;
1688 return pRec->Excl.hClass;
1692 *puSubClass = pRec->Shared.uSubClass;
1693 return pRec->Shared.hClass;
1697 *ppDown = pRec->ShrdOwner.pDown;
1699 PRTLOCKVALRECSHRD pSharedRec = pRec->ShrdOwner.pSharedRec;
1712 *ppDown = pRec->Nest.pDown;
1714 PRTLOCKVALRECUNION pRealRec = pRec->Nest.pRec;
1736 AssertMsgFailed(("%p %p %#x\n", pRec, pRealRec, pRealRec->Core.u32Magic));
1745 AssertMsgFailed(("%#x\n", pRec->Core.u32Magic));
1757 * @param pRec The lock validator record.
1759 DECLINLINE(uint32_t) rtLockValidatorRecGetSubClass(PRTLOCKVALRECUNION pRec)
1761 switch (pRec->Core.u32Magic)
1764 return pRec->Excl.uSubClass;
1767 return pRec->Shared.uSubClass;
1771 PRTLOCKVALRECSHRD pSharedRec = pRec->ShrdOwner.pSharedRec;
1780 PRTLOCKVALRECUNION pRealRec = pRec->Nest.pRec;
1786 return pRec->Excl.uSubClass;
1798 AssertMsgFailed(("%p %p %#x\n", pRec, pRealRec, pRealRec->Core.u32Magic));
1806 AssertMsgFailed(("%#x\n", pRec->Core.u32Magic));
1851 * Checks if the stack contains @a pRec.
1855 * @param pRec The lock record.
1857 static bool rtLockValidatorStackContainsRec(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
1863 if (pCur == pRec)
1895 * @param pRec The lock record.
1897 static void rtLockValidatorStackPush(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
1900 Assert(!rtLockValidatorStackContainsRec(pThreadSelf, pRec));
1902 switch (pRec->Core.u32Magic)
1905 Assert(pRec->Excl.cRecursion == 1);
1906 Assert(pRec->Excl.pDown == NULL);
1907 rtLockValidatorWriteRecUnionPtr(&pRec->Excl.pDown, pThreadSelf->LockValidator.pStackTop);
1911 Assert(pRec->ShrdOwner.cRecursion == 1);
1912 Assert(pRec->ShrdOwner.pDown == NULL);
1913 rtLockValidatorWriteRecUnionPtr(&pRec->ShrdOwner.pDown, pThreadSelf->LockValidator.pStackTop);
1917 AssertMsgFailedReturnVoid(("%#x\n", pRec->Core.u32Magic));
1919 rtLockValidatorWriteRecUnionPtr(&pThreadSelf->LockValidator.pStackTop, pRec);
1927 * @param pRec The lock.
1929 static void rtLockValidatorStackPop(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
1934 switch (pRec->Core.u32Magic)
1937 Assert(pRec->Excl.cRecursion == 0);
1938 pDown = pRec->Excl.pDown;
1939 rtLockValidatorWriteRecUnionPtr(&pRec->Excl.pDown, NULL); /* lazy bird */
1943 Assert(pRec->ShrdOwner.cRecursion == 0);
1944 pDown = pRec->ShrdOwner.pDown;
1945 rtLockValidatorWriteRecUnionPtr(&pRec->ShrdOwner.pDown, NULL);
1949 AssertMsgFailedReturnVoid(("%#x\n", pRec->Core.u32Magic));
1951 if (pThreadSelf->LockValidator.pStackTop == pRec)
1981 if (pCur == pRec)
1987 AssertMsgFailed(("%p %p\n", pRec, pThreadSelf));
1996 * @param pRec The lock record.
1999 static void rtLockValidatorStackPushRecursion(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec, PCRTLOCKVALSRCPOS pSrcPos)
2002 Assert(rtLockValidatorStackContainsRec(pThreadSelf, pRec));
2021 switch (pRec->Core.u32Magic)
2024 pRecursionRec->cRecursion = pRec->Excl.cRecursion;
2028 pRecursionRec->cRecursion = pRec->ShrdOwner.cRecursion;
2032 AssertMsgFailed(("%#x\n", pRec->Core.u32Magic));
2039 pRecursionRec->pRec = pRec;
2058 * @param pRec The lock record.
2060 static void rtLockValidatorStackPopRecursion(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
2063 Assert(rtLockValidatorStackContainsRec(pThreadSelf, pRec));
2066 switch (pRec->Core.u32Magic)
2068 case RTLOCKVALRECEXCL_MAGIC: cRecursion = pRec->Excl.cRecursion; break;
2069 case RTLOCKVALRECSHRDOWN_MAGIC: cRecursion = pRec->ShrdOwner.cRecursion; break;
2070 default: AssertMsgFailedReturnVoid(("%#x\n", pRec->Core.u32Magic));
2081 && pNest->Nest.pRec == pRec
2093 AssertMsgReturnVoid(pNest, ("%p %p\n", pRec, pThreadSelf));
2105 if (pNest->Nest.pRec == pRec)
2124 rtLockValidatorWriteRecUnionPtr(&pNest->Nest.pRec, NULL);
2207 * @param pRec The lock record.
2211 PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION const pRec,
2223 pRec, pFirstBadRec, pClass, pFirstBadClass);
2226 pRec, pFirstBadRec, pClass, pFirstBadClass);
2254 pRec, pCur, pClass, pPriorClass);
2271 pRec, pFirstBadRec, pClass, pFirstBadClass);
2307 pRec, pCur, pClass, pPriorClass);
2361 * @param pRec The lock record.
2365 PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION const pRec,
2375 AssertPtr(pRec);
2401 return rtLockValidatorStackCheckLockingOrder2(pClass, uSubClass, pThreadSelf, pRec, pSrcPos,
2419 * @param pRec The record.
2421 static int rtLockValidatorStackCheckReleaseOrder(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
2427 if (RT_LIKELY( pTop == pRec
2430 && pTop->Nest.pRec == pRec) ))
2439 if (pTop->Nest.pRec == pRec)
2441 pRec = pTop;
2455 rtLockValComplainFirst("Wrong release order!", NULL, pThreadSelf, pRec, true);
2465 * @param pRec The record.
2468 DECL_FORCE_INLINE(bool) rtLockValidatorDdAreAllThreadsBlocked(PRTLOCKVALRECSHRD pRec, PRTTHREADINT pThreadSelf)
2470 PRTLOCKVALRECSHRDOWN volatile *papOwners = pRec->papOwners;
2471 uint32_t cAllocated = pRec->cAllocated;
2472 uint32_t cEntries = ASMAtomicUoReadU32(&pRec->cEntries);
2523 if (rtLockValidatorReadRecUnionPtr(&pThread->LockValidator.pRec) != pStack->a[i].pFirstSibling)
2526 PRTLOCKVALRECUNION pRec = pStack->a[i].pRec;
2527 if ( pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC
2528 && pRec->Shared.fSignaller
2529 && !rtLockValidatorDdAreAllThreadsBlocked(&pRec->Shared, pThreadSelf))
2589 PRTLOCKVALRECUNION pRec = pOriginalRec;
2599 RTLOCKVAL_ASSERT_PTR_ALIGN(pRec);
2605 switch (pRec->Core.u32Magic)
2611 pNextThread = rtLockValidatorReadThreadHandle(&pRec->Excl.hThread);
2619 pNextRec = rtLockValidatorReadRecUnionPtr(&pNextThread->LockValidator.pRec);
2627 pRec = pRec->Excl.pSibling;
2628 if ( pRec
2629 && pRec != pFirstSibling)
2636 if (!pRec->Shared.fSignaller)
2651 if ( pRec == pFirstSibling
2652 && pRec->Shared.pSibling != NULL
2653 && pRec->Shared.pSibling != pFirstSibling)
2655 pRec = pRec->Shared.pSibling;
2662 if ( ASMAtomicUoReadU32(&pRec->Shared.cEntries) > 0
2663 && ( !pRec->Shared.fSignaller
2665 || rtLockValidatorDdAreAllThreadsBlocked(&pRec->Shared, pThreadSelf)
2669 uint32_t cAllocated = pRec->Shared.cAllocated;
2670 PRTLOCKVALRECSHRDOWN volatile *papOwners = pRec->Shared.papOwners;
2688 pNextRec = rtLockValidatorReadRecUnionPtr(&pNextThread->LockValidator.pRec);
2706 pRec = pRec->Shared.pSibling;
2707 if ( pRec != NULL
2708 && pRec != pFirstSibling)
2722 AssertMsgFailed(("%p: %#x\n", pRec, pRec->Core));
2736 pStack->a[i].pRec = pRec;
2744 || pRec->Core.u32Magic != RTLOCKVALRECSHRD_MAGIC
2745 || !pRec->Shared.fSignaller) /* ASSUMES signaller records have no siblings. */
2750 pRec = pNextRec;
2769 pRec = pStack->a[i].pRec;
2773 uint32_t u32Magic = pRec->Core.u32Magic;
2775 pRec = pRec->Excl.pSibling;
2778 if (iEntry + 1 < pRec->Shared.cAllocated)
2780 pRec = pRec->Shared.pSibling;
2790 if ( !pRec
2791 || pRec == pStack->a[i].pFirstSibling)
2837 * @param pRec The record relating to the current thread's lock
2843 static void rcLockValidatorDoDeadlockComplaining(PRTLOCKVALDDSTACK pStack, PRTLOCKVALRECUNION pRec,
2856 rtLockValComplainFirst(pszWhat, pSrcPos, pThreadSelf, pStack->a[0].pRec != pRec ? pRec : NULL, true);
2863 if (pStack->a[i].pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC)
2864 pShrdOwner = (PRTLOCKVALRECUNION)pStack->a[i].pRec->Shared.papOwners[pStack->a[i].iEntry];
2872 rtLockValComplainAboutLock(szPrefix, pStack->a[i].pRec, "\n");
2873 if (pStack->a[i].pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC)
2874 rtLockValComplainAboutLockStack(pStack->a[i].pRec->Excl.hThread, 5, 2, pStack->a[i].pRec);
2892 * @param pRec The record relating to the current thread's lock
2897 static int rtLockValidatorDeadlockDetection(PRTLOCKVALRECUNION pRec, PRTTHREADINT pThreadSelf, PCRTLOCKVALSRCPOS pSrcPos)
2900 int rc = rtLockValidatorDdDoDetection(&Stack, pRec, pThreadSelf);
2908 rc = rtLockValidatorDdDoDetection(&Stack, pRec, pThreadSelf);
2919 rcLockValidatorDoDeadlockComplaining(&Stack, pRec, pThreadSelf, pSrcPos, rc);
2924 RTDECL(void) RTLockValidatorRecExclInitV(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
2927 RTLOCKVAL_ASSERT_PTR_ALIGN(pRec);
2933 pRec->Core.u32Magic = RTLOCKVALRECEXCL_MAGIC;
2934 pRec->fEnabled = fEnabled && RTLockValidatorIsEnabled();
2935 pRec->afReserved[0] = 0;
2936 pRec->afReserved[1] = 0;
2937 pRec->afReserved[2] = 0;
2938 rtLockValidatorSrcPosInit(&pRec->SrcPos);
2939 pRec->hThread = NIL_RTTHREAD;
2940 pRec->pDown = NULL;
2941 pRec->hClass = rtLockValidatorClassValidateAndRetain(hClass);
2942 pRec->uSubClass = uSubClass;
2943 pRec->cRecursion = 0;
2944 pRec->hLock = hLock;
2945 pRec->pSibling = NULL;
2947 RTStrPrintfV(pRec->szName, sizeof(pRec->szName), pszNameFmt, va);
2952 RTStrPrintf(pRec->szName, sizeof(pRec->szName), "anon-excl-%u", i);
2961 RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
2966 RTLockValidatorRecExclInitV(pRec, hClass, uSubClass, hLock, fEnabled, pszNameFmt, va);
2975 PRTLOCKVALRECEXCL pRec;
2976 *ppRec = pRec = (PRTLOCKVALRECEXCL)RTMemAlloc(sizeof(*pRec));
2977 if (!pRec)
2979 RTLockValidatorRecExclInitV(pRec, hClass, uSubClass, pvLock, fEnabled, pszNameFmt, va);
2996 RTDECL(void) RTLockValidatorRecExclDelete(PRTLOCKVALRECEXCL pRec)
2998 Assert(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
3002 ASMAtomicWriteU32(&pRec->Core.u32Magic, RTLOCKVALRECEXCL_MAGIC_DEAD);
3003 ASMAtomicWriteHandle(&pRec->hThread, NIL_RTTHREAD);
3005 ASMAtomicXchgHandle(&pRec->hClass, NIL_RTLOCKVALCLASS, &hClass);
3006 if (pRec->pSibling)
3007 rtLockValidatorUnlinkAllSiblings(&pRec->Core);
3016 PRTLOCKVALRECEXCL pRec = *ppRec;
3018 if (pRec)
3020 RTLockValidatorRecExclDelete(pRec);
3021 RTMemFree(pRec);
3026 RTDECL(uint32_t) RTLockValidatorRecExclSetSubClass(PRTLOCKVALRECEXCL pRec, uint32_t uSubClass)
3028 AssertPtrReturn(pRec, RTLOCKVAL_SUB_CLASS_INVALID);
3029 AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID);
3034 return ASMAtomicXchgU32(&pRec->uSubClass, uSubClass);
3038 RTDECL(void) RTLockValidatorRecExclSetOwner(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
3041 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3080 static void rtLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECUNION pRec, bool fFinalRecursion)
3082 RTTHREADINT *pThread = pRec->Excl.hThread;
3087 uint32_t c = ASMAtomicDecU32(&pRec->Excl.cRecursion);
3090 rtLockValidatorStackPop(pThread, pRec);
3091 ASMAtomicWriteHandle(&pRec->Excl.hThread, NIL_RTTHREAD);
3097 rtLockValidatorStackPopRecursion(pThread, pRec);
3101 RTDECL(int) RTLockValidatorRecExclReleaseOwner(PRTLOCKVALRECEXCL pRec, bool fFinalRecursion)
3103 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3131 RTDECL(void) RTLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECEXCL pRec)
3133 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3140 RTDECL(int) RTLockValidatorRecExclRecursion(PRTLOCKVALRECEXCL pRec, PCRTLOCKVALSRCPOS pSrcPos)
3142 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3155 pSrcPos, pRecU->Excl.hThread, (PRTLOCKVALRECUNION)pRec, true);
3167 RTDECL(int) RTLockValidatorRecExclUnwind(PRTLOCKVALRECEXCL pRec)
3169 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3199 RTDECL(int) RTLockValidatorRecExclRecursionMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed, PCRTLOCKVALSRCPOS pSrcPos)
3201 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3217 pSrcPos, pRecU->Excl.hThread, (PRTLOCKVALRECUNION)pRec, true);
3230 RTDECL(int) RTLockValidatorRecExclUnwindMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed)
3232 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3266 RTDECL(int) RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
3272 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3293 if (pRec->hThread == hThreadSelf)
3300 RTDECL(int) RTLockValidatorRecExclCheckBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
3307 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3312 if (!pRec->fEnabled)
3334 rtLockValidatorWriteRecUnionPtr(&pThreadSelf->LockValidator.pRec, pRecU);
3373 rtLockValidatorWriteRecUnionPtr(&pThreadSelf->LockValidator.pRec, NULL);
3381 RTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
3385 int rc = RTLockValidatorRecExclCheckOrder(pRec, hThreadSelf, pSrcPos, cMillies);
3387 rc = RTLockValidatorRecExclCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, cMillies,
3394 RTDECL(void) RTLockValidatorRecSharedInitV(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
3397 RTLOCKVAL_ASSERT_PTR_ALIGN(pRec);
3403 pRec->Core.u32Magic = RTLOCKVALRECSHRD_MAGIC;
3404 pRec->uSubClass = uSubClass;
3405 pRec->hClass = rtLockValidatorClassValidateAndRetain(hClass);
3406 pRec->hLock = hLock;
3407 pRec->fEnabled = fEnabled && RTLockValidatorIsEnabled();
3408 pRec->fSignaller = fSignaller;
3409 pRec->pSibling = NULL;
3412 pRec->cEntries = 0;
3413 pRec->iLastEntry = 0;
3414 pRec->cAllocated = 0;
3415 pRec->fReallocating = false;
3416 pRec->fPadding = false;
3417 pRec->papOwners = NULL;
3421 RTStrPrintfV(pRec->szName, sizeof(pRec->szName), pszNameFmt, va);
3426 RTStrPrintf(pRec->szName, sizeof(pRec->szName), "anon-shrd-%u", i);
3431 RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
3436 RTLockValidatorRecSharedInitV(pRec, hClass, uSubClass, hLock, fSignaller, fEnabled, pszNameFmt, va);
3445 PRTLOCKVALRECSHRD pRec;
3446 *ppRec = pRec = (PRTLOCKVALRECSHRD)RTMemAlloc(sizeof(*pRec));
3447 if (!pRec)
3449 RTLockValidatorRecSharedInitV(pRec, hClass, uSubClass, pvLock, fSignaller, fEnabled, pszNameFmt, va);
3466 RTDECL(void) RTLockValidatorRecSharedDelete(PRTLOCKVALRECSHRD pRec)
3468 Assert(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC);
3474 while (!ASMAtomicCmpXchgBool(&pRec->fReallocating, true, false))
3484 ASMAtomicWriteU32(&pRec->Core.u32Magic, RTLOCKVALRECSHRD_MAGIC_DEAD);
3486 ASMAtomicXchgHandle(&pRec->hClass, NIL_RTLOCKVALCLASS, &hClass);
3487 if (pRec->papOwners)
3489 PRTLOCKVALRECSHRDOWN volatile *papOwners = pRec->papOwners;
3490 ASMAtomicUoWriteNullPtr(&pRec->papOwners);
3491 ASMAtomicUoWriteU32(&pRec->cAllocated, 0);
3495 if (pRec->pSibling)
3496 rtLockValidatorUnlinkAllSiblings(&pRec->Core);
3497 ASMAtomicWriteBool(&pRec->fReallocating, false);
3508 PRTLOCKVALRECSHRD pRec = *ppRec;
3510 if (pRec)
3512 RTLockValidatorRecSharedDelete(pRec);
3513 RTMemFree(pRec);
3518 RTDECL(uint32_t) RTLockValidatorRecSharedSetSubClass(PRTLOCKVALRECSHRD pRec, uint32_t uSubClass)
3520 AssertPtrReturn(pRec, RTLOCKVAL_SUB_CLASS_INVALID);
3521 AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID);
3526 return ASMAtomicXchgU32(&pRec->uSubClass, uSubClass);
3566 RTDECL(int) RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
3572 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3600 RTDECL(int) RTLockValidatorRecSharedCheckBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
3607 PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
3632 rtLockValidatorWriteRecUnionPtr(&pThreadSelf->LockValidator.pRec, pRecU);
3648 || ( pRec->hClass
3649 && !pRec->hClass->fRecursionOk)
3660 else if ( pRec->hClass
3661 && ( pRec->hClass->cMsMinDeadlock == RT_INDEFINITE_WAIT
3662 || pRec->hClass->cMsMinDeadlock > cMillies))
3672 rtLockValidatorWriteRecUnionPtr(&pThreadSelf->LockValidator.pRec, NULL);
3680 RTDECL(int) RTLockValidatorRecSharedCheckOrderAndBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
3684 int rc = RTLockValidatorRecSharedCheckOrder(pRec, hThreadSelf, pSrcPos, cMillies);
3686 rc = RTLockValidatorRecSharedCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, cMillies,
3697 * @param pRec The shared lock record.
3703 rtLockValidatorRecSharedAllocOwner(PRTLOCKVALRECSHRD pRec, PRTTHREADINT pThreadSelf, PCRTLOCKVALSRCPOS pSrcPos)
3733 pEntry->ShrdOwner.pSharedRec = pRec;
3941 RTDECL(void) RTLockValidatorRecSharedResetOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread, PCRTLOCKVALSRCPOS pSrcPos)
3943 AssertReturnVoid(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC);
3944 if (!pRec->fEnabled)
3947 AssertReturnVoid(pRec->fSignaller);
3953 while (ASMAtomicUoReadU32(&pRec->cEntries) > 0)
3955 AssertReturnVoidStmt(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, rtLockValidatorSerializeDetectionLeave());
3957 uint32_t cEntries = pRec->cAllocated;
3958 PRTLOCKVALRECSHRDOWN volatile *papEntries = pRec->papOwners;
3964 ASMAtomicDecU32(&pRec->cEntries);
3970 if (ASMAtomicUoReadU32(&pRec->cEntries) == 0)
3972 cEntries = pRec->cAllocated;
3973 papEntries = pRec->papOwners;
3985 PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedAllocOwner(pRec, hThread, pSrcPos);
3987 && !rtLockValidatorRecSharedAddOwner(pRec, &pEntry->ShrdOwner))
3994 RTDECL(void) RTLockValidatorRecSharedAddOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread, PCRTLOCKVALSRCPOS pSrcPos)
3996 AssertReturnVoid(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC);
3997 if (!pRec->fEnabled)
4013 PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, NULL);
4016 Assert(!pRec->fSignaller);
4025 pEntry = rtLockValidatorRecSharedAllocOwner(pRec, hThread, pSrcPos);
4028 if (rtLockValidatorRecSharedAddOwner(pRec, &pEntry->ShrdOwner))
4030 if (!pRec->fSignaller)
4040 RTDECL(void) RTLockValidatorRecSharedRemoveOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread)
4042 AssertReturnVoid(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC);
4043 if (!pRec->fEnabled)
4056 PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, &iEntry);
4063 if (!pRec->fSignaller)
4065 rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, &pEntry->ShrdOwner, iEntry);
4069 Assert(!pRec->fSignaller);
4076 RTDECL(bool) RTLockValidatorRecSharedIsOwner(PRTLOCKVALRECSHRD pRec, RTTHREAD hThread)
4079 AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, false);
4080 if (!pRec->fEnabled)
4090 PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, NULL);
4096 RTDECL(int) RTLockValidatorRecSharedCheckAndRelease(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf)
4098 AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
4099 if (!pRec->fEnabled)
4113 PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
4116 rtLockValComplainFirst("Not owner (shared)!", NULL, hThreadSelf, (PRTLOCKVALRECUNION)pRec, true);
4124 if ( pRec->hClass != NIL_RTLOCKVALCLASS
4125 && pRec->hClass->fStrictReleaseOrder
4126 && pRec->hClass->cMsMinOrder != RT_INDEFINITE_WAIT
4142 rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, &pEntry->ShrdOwner, iEntry);
4151 RTDECL(int) RTLockValidatorRecSharedCheckSignaller(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf)
4153 AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
4154 if (!pRec->fEnabled)
4168 PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
4171 rtLockValComplainFirst("Invalid signaller!", NULL, hThreadSelf, (PRTLOCKVALRECUNION)pRec, true);
4263 PRTLOCKVALRECUNION pRec = rtLockValidatorReadRecUnionPtr(&pThread->LockValidator.pRec);
4264 if (pRec)
4266 switch (pRec->Core.u32Magic)
4269 pvLock = pRec->Excl.hLock;
4273 pRec = (PRTLOCKVALRECUNION)pRec->ShrdOwner.pSharedRec;
4274 if (!pRec || pRec->Core.u32Magic != RTLOCKVALRECSHRD_MAGIC)
4277 pvLock = pRec->Shared.hLock;
4335 switch (pCur->Nest.pRec->Core.u32Magic)
4338 fRet = pCur->Nest.pRec->Excl.hClass == hClass;
4342 && pCur->Nest.pRec->ShrdOwner.pSharedRec->hClass == hClass;
4390 switch (pCur->Nest.pRec->Core.u32Magic)
4393 fRet = pCur->Nest.pRec->Excl.hClass == hClass
4394 && pCur->Nest.pRec->Excl.uSubClass == uSubClass;
4398 && pCur->Nest.pRec->ShrdOwner.pSharedRec->hClass == hClass
4399 && pCur->Nest.pRec->ShrdOwner.pSharedRec->uSubClass == uSubClass;