VirtualBox

Changeset 25478 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
Dec 18, 2009 12:58:10 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56147
Message:

IPRT,PDMCritSect: More lock validator refactoring.

Location:
trunk/src/VBox/Runtime/r3/posix
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/semmutex-posix.cpp

    r25467 r25478  
    155155
    156156
    157 DECL_FORCE_INLINE(int) rtSemMutexRequest(RTSEMMUTEX MutexSem, unsigned cMillies, RTSEMMUTEX_STRICT_POS_DECL)
     157DECL_FORCE_INLINE(int) rtSemMutexRequest(RTSEMMUTEX MutexSem, unsigned cMillies, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    158158{
    159159    /*
     
    166166#ifdef RTSEMMUTEX_STRICT
    167167    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    168     RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, RTSEMMUTEX_STRICT_POS_ARGS);
     168    RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    169169#endif
    170170
     
    190190#ifdef RTSEMMUTEX_STRICT
    191191        int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf,
    192                                                RTTHREADSTATE_MUTEX, true, uId, RT_SRC_POS_ARGS);
     192                                               RTTHREADSTATE_MUTEX, true, pSrcPos);
    193193        if (RT_FAILURE(rc9))
    194194            return rc9;
    195 #else
     195#endif
    196196        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_MUTEX);
    197 #endif
    198197    }
    199198
     
    248247    ASMAtomicWriteU32(&pThis->cNesting, 1);
    249248#ifdef RTSEMMUTEX_STRICT
    250     RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, RTSEMMUTEX_STRICT_POS_ARGS);
     249    RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    251250#endif
    252251
     
    258257{
    259258#ifndef RTSEMMUTEX_STRICT
    260     return rtSemMutexRequest(MutexSem, cMillies, RTSEMMUTEX_STRICT_POS_ARGS);
     259    return rtSemMutexRequest(MutexSem, cMillies, NULL);
    261260#else
    262     return RTSemMutexRequestDebug(MutexSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     261    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     262    return rtSemMutexRequest(MutexSem, cMillies, &SrcPos);
    263263#endif
    264264}
     
    267267RTDECL(int) RTSemMutexRequestDebug(RTSEMMUTEX MutexSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    268268{
    269 #ifdef RTSEMMUTEX_STRICT
    270     return rtSemMutexRequest(MutexSem, cMillies, RTSEMMUTEX_STRICT_POS_ARGS);
     269    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     270    return rtSemMutexRequest(MutexSem, cMillies, &SrcPos);
     271}
     272
     273
     274RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
     275{
     276    /* (EINTR isn't returned by the wait functions we're using.) */
     277#ifndef RTSEMMUTEX_STRICT
     278    return rtSemMutexRequest(MutexSem, cMillies, NULL);
    271279#else
    272     return RTSemMutexRequest(MutexSem, cMillies);
    273 #endif
    274 }
    275 
    276 
    277 RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
    278 {
    279     /* EINTR isn't returned by the wait functions we're using. */
    280 #ifndef RTSEMMUTEX_STRICT
    281     return RTSemMutexRequest(MutexSem, cMillies);
    282 #else
    283     return RTSemMutexRequestDebug(MutexSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     280    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     281    return rtSemMutexRequest(MutexSem, cMillies, &SrcPos);
    284282#endif
    285283}
     
    288286RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX MutexSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    289287{
    290     /* EINTR isn't returned by the wait functions we're using. */
    291 #ifdef RTSEMMUTEX_STRICT
    292     return RTSemMutexRequestDebug(MutexSem, cMillies, RTSEMMUTEX_STRICT_POS_ARGS);
    293 #else
    294     return RTSemMutexRequest(MutexSem, cMillies);
    295 #endif
     288    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     289    return rtSemMutexRequest(MutexSem, cMillies, &SrcPos);
    296290}
    297291
  • trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp

    r25467 r25478  
    315315
    316316
    317 DECL_FORCE_INLINE(int) rtSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies, RTSEMRW_STRICT_POS_DECL)
     317DECL_FORCE_INLINE(int) rtSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies, PCRTLOCKVALIDATORSRCPOS pSrcPos)
    318318{
    319319    /*
     
    327327#ifdef RTSEMRW_STRICT
    328328    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    329     RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, RTSEMRW_STRICT_POS_ARGS);
     329    RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    330330#endif
    331331
     
    339339    {
    340340#ifdef RTSEMRW_STRICT
    341         int rc9 = RTLockValidatorRecordRecursion(&pThis->ValidatorRec, RTSEMRW_STRICT_POS_ARGS);
     341        int rc9 = RTLockValidatorRecordRecursion(&pThis->ValidatorRec, pSrcPos);
    342342        if (RT_FAILURE(rc9))
    343343            return rc9;
     
    357357    {
    358358#ifdef RTSEMRW_STRICT
    359         int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf, RTTHREADSTATE_RW_WRITE, true, uId, RT_SRC_POS_ARGS);
     359        int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf, RTTHREADSTATE_RW_WRITE, true, pSrcPos);
    360360        if (RT_FAILURE(rc9))
    361361            return rc9;
    362 #else
     362#endif
    363363        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_WRITE);
    364 #endif
    365364    }
    366365
     
    412411    pThis->cWrites = 1;
    413412#ifdef RTSEMRW_STRICT
    414     RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, RTSEMRW_STRICT_POS_ARGS);
     413    RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    415414#endif
    416415    return VINF_SUCCESS;
     
    421420{
    422421#ifndef RTSEMRW_STRICT
    423     return rtSemRWRequestWrite(RWSem, cMillies, RTSEMRW_STRICT_POS_ARGS);
     422    return rtSemRWRequestWrite(RWSem, cMillies, NULL);
    424423#else
    425     return RTSemRWRequestWriteDebug(RWSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     424    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     425    return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    426426#endif
    427427}
     
    430430RTDECL(int) RTSemRWRequestWriteDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    431431{
    432 #ifdef RTSEMRW_STRICT
    433     return rtSemRWRequestWrite(RWSem, cMillies, RTSEMRW_STRICT_POS_ARGS);
    434 #else
    435     return RTSemRWRequestWrite(RWSem, cMillies);
    436 #endif
     432    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     433    return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    437434}
    438435
     
    442439    /* EINTR isn't returned by the wait functions we're using. */
    443440#ifndef RTSEMRW_STRICT
    444     return RTSemRWRequestWrite(RWSem, cMillies);
     441    return rtSemRWRequestWrite(RWSem, cMillies, NULL);
    445442#else
    446     return RTSemRWRequestWriteDebug(RWSem, cMillies, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);
     443    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API();
     444    return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    447445#endif
    448446}
     
    452450{
    453451    /* EINTR isn't returned by the wait functions we're using. */
    454 #ifdef RTSEMRW_STRICT
    455     return RTSemRWRequestWriteDebug(RWSem, cMillies, RTSEMRW_STRICT_POS_ARGS);
    456 #else
    457     return RTSemRWRequestWrite(RWSem, cMillies);
    458 #endif
     452    RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API();
     453    return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    459454}
    460455
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette