VirtualBox

Changeset 25620 in vbox for trunk/src/VBox/Runtime/generic


Ignore:
Timestamp:
Jan 2, 2010 10:18:07 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56311
Message:

iprt/semaphore.h: Added Debug wrappers for all the RW semaphores.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/semrw-generic.cpp

    r25618 r25620  
    9191
    9292
     93/* No debug wrapping here. */
     94#undef RTSemRWRequestRead
     95#undef RTSemRWRequestReadNoResume
     96#undef RTSemRWRequestWrite
     97#undef RTSemRWRequestWriteNoResume
     98
    9399
    94100RTDECL(int) RTSemRWCreate(PRTSEMRW pRWSem)
     
    217223
    218224
    219 RTDECL(int) RTSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies)
    220 {
    221     PRTLOCKVALSRCPOS        pSrcPos = NULL;
    222 
     225DECL_FORCE_INLINE(int) rtSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies, bool fInterruptible, PCRTLOCKVALSRCPOS pSrcPos)
     226{
    223227    /*
    224228     * Validate handle.
     
    326330        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_READ);
    327331#endif
    328         int rcWait = rc = RTSemEventMultiWait(pThis->ReadEvent, cMillies);
     332        int rcWait;
     333        if (fInterruptible)
     334            rcWait = rc = RTSemEventMultiWaitNoResume(pThis->ReadEvent, cMillies);
     335        else
     336            rcWait = rc = RTSemEventMultiWait(pThis->ReadEvent, cMillies);
    329337        RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_RW_READ);
    330338        if (RT_FAILURE(rc) && rc != VERR_TIMEOUT) /* handle timeout below */
     
    382390    return rc;
    383391}
     392
     393
     394RTDECL(int) RTSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies)
     395{
     396#ifndef RTSEMRW_STRICT
     397    return rtSemRWRequestRead(RWSem, cMillies, false, NULL);
     398#else
     399    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
     400    return rtSemRWRequestRead(RWSem, cMillies, false, &SrcPos);
     401#endif
     402}
    384403RT_EXPORT_SYMBOL(RTSemRWRequestRead);
    385404
    386405
     406RTDECL(int) RTSemRWRequestReadDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     407{
     408    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
     409    return rtSemRWRequestRead(RWSem, cMillies, false, &SrcPos);
     410}
     411RT_EXPORT_SYMBOL(RTSemRWRequestReadDebug);
     412
     413
    387414RTDECL(int) RTSemRWRequestReadNoResume(RTSEMRW RWSem, unsigned cMillies)
    388415{
    389     return RTSemRWRequestRead(RWSem, cMillies);
     416#ifndef RTSEMRW_STRICT
     417    return rtSemRWRequestRead(RWSem, cMillies, true, NULL);
     418#else
     419    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
     420    return rtSemRWRequestRead(RWSem, cMillies, true, &SrcPos);
     421#endif
    390422}
    391423RT_EXPORT_SYMBOL(RTSemRWRequestReadNoResume);
     424
     425
     426RTDECL(int) RTSemRWRequestReadNoResumeDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     427{
     428    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
     429    return rtSemRWRequestRead(RWSem, cMillies, true, &SrcPos);
     430}
     431RT_EXPORT_SYMBOL(RTSemRWRequestReadNoResumeDebug);
    392432
    393433
     
    472512
    473513
    474 RTDECL(int) RTSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies)
    475 {
    476     PRTLOCKVALSRCPOS        pSrcPos = NULL;
    477 
     514DECL_FORCE_INLINE(int) rtSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies, bool fInterruptible, PCRTLOCKVALSRCPOS pSrcPos)
     515{
    478516    /*
    479517     * Validate handle.
     
    580618        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_WRITE);
    581619#endif
    582         int rcWait = rc = RTSemEventWait(pThis->WriteEvent, cMillies);
     620        int rcWait;
     621        if (fInterruptible)
     622            rcWait = rc = RTSemEventWaitNoResume(pThis->WriteEvent, cMillies);
     623        else
     624            rcWait = rc = RTSemEventWait(pThis->WriteEvent, cMillies);
    583625        RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_RW_WRITE);
    584626        if (RT_UNLIKELY(RT_FAILURE_NP(rc) && rc != VERR_TIMEOUT)) /* timeouts are handled below */
     
    651693    return rc;
    652694}
     695
     696
     697RTDECL(int) RTSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies)
     698{
     699#ifndef RTSEMRW_STRICT
     700    return rtSemRWRequestWrite(RWSem, cMillies, false, NULL);
     701#else
     702    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
     703    return rtSemRWRequestWrite(RWSem, cMillies, false, &SrcPos);
     704#endif
     705}
    653706RT_EXPORT_SYMBOL(RTSemRWRequestWrite);
    654707
    655708
     709RTDECL(int) RTSemRWRequestWriteDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     710{
     711    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
     712    return rtSemRWRequestWrite(RWSem, cMillies, false, &SrcPos);
     713}
     714RT_EXPORT_SYMBOL(RTSemRWRequestWriteDebug);
     715
     716
    656717RTDECL(int) RTSemRWRequestWriteNoResume(RTSEMRW RWSem, unsigned cMillies)
    657718{
    658     return RTSemRWRequestWrite(RWSem, cMillies);
     719#ifndef RTSEMRW_STRICT
     720    return rtSemRWRequestWrite(RWSem, cMillies, true, NULL);
     721#else
     722    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
     723    return rtSemRWRequestWrite(RWSem, cMillies, true, &SrcPos);
     724#endif
    659725}
    660726RT_EXPORT_SYMBOL(RTSemRWRequestWriteNoResume);
     727
     728
     729RTDECL(int) RTSemRWRequestWriteNoResumeDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     730{
     731    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
     732    return rtSemRWRequestWrite(RWSem, cMillies, true, &SrcPos);
     733}
     734RT_EXPORT_SYMBOL(RTSemRWRequestWriteNoResumeDebug);
    661735
    662736
Note: See TracChangeset for help on using the changeset viewer.

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