VirtualBox

Changeset 25723 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Jan 11, 2010 2:28:57 PM (15 years ago)
Author:
vboxsync
Message:

iprt/RTSemRW: A little cleanup.

File:
1 edited

Legend:

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

    r25710 r25723  
    155155
    156156
    157 RTDECL(int) RTSemRWDestroy(RTSEMRW RWSem)
     157RTDECL(int) RTSemRWDestroy(RTSEMRW hRWSem)
    158158{
    159159    /*
    160160     * Validate input, nil handle is fine.
    161161     */
    162     struct RTSEMRWINTERNAL *pThis = RWSem;
     162    struct RTSEMRWINTERNAL *pThis = hRWSem;
    163163    if (pThis == NIL_RTSEMRW)
    164164        return VINF_SUCCESS;
     
    189189    {
    190190        ASMAtomicWriteU32(&pThis->u32Magic, RTSEMRW_MAGIC);
    191         AssertMsgFailed(("Failed to destroy read-write sem %p, rc=%d.\n", RWSem, rc));
     191        AssertMsgFailed(("Failed to destroy read-write sem %p, rc=%d.\n", hRWSem, rc));
    192192        rc = RTErrConvertFromErrno(rc);
    193193    }
     
    215215
    216216
    217 DECL_FORCE_INLINE(int) rtSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies, PCRTLOCKVALSRCPOS pSrcPos)
    218 {
    219     /*
    220      * Validate input.
    221      */
    222     struct RTSEMRWINTERNAL *pThis = RWSem;
     217DECL_FORCE_INLINE(int) rtSemRWRequestRead(RTSEMRW hRWSem, RTMSINTERVAL cMillies, PCRTLOCKVALSRCPOS pSrcPos)
     218{
     219    /*
     220     * Validate input.
     221     */
     222    struct RTSEMRWINTERNAL *pThis = hRWSem;
    223223    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    224224    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     
    269269        if (rc)
    270270        {
    271             AssertMsgFailed(("Failed read lock read-write sem %p, rc=%d.\n", RWSem, rc));
     271            AssertMsgFailed(("Failed read lock read-write sem %p, rc=%d.\n", hRWSem, rc));
    272272            return RTErrConvertFromErrno(rc);
    273273        }
     
    301301        if (rc)
    302302        {
    303             AssertMsg(rc == ETIMEDOUT, ("Failed read lock read-write sem %p, rc=%d.\n", RWSem, rc));
     303            AssertMsg(rc == ETIMEDOUT, ("Failed read lock read-write sem %p, rc=%d.\n", hRWSem, rc));
    304304            return RTErrConvertFromErrno(rc);
    305305        }
     
    316316
    317317#undef RTSemRWRequestRead
    318 RTDECL(int) RTSemRWRequestRead(RTSEMRW RWSem, unsigned cMillies)
     318RTDECL(int) RTSemRWRequestRead(RTSEMRW hRWSem, RTMSINTERVAL cMillies)
    319319{
    320320#ifndef RTSEMRW_STRICT
    321     return rtSemRWRequestRead(RWSem, cMillies, NULL);
     321    return rtSemRWRequestRead(hRWSem, cMillies, NULL);
    322322#else
    323323    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
    324     return rtSemRWRequestRead(RWSem, cMillies, &SrcPos);
    325 #endif
    326 }
    327 
    328 
    329 RTDECL(int) RTSemRWRequestReadDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     324    return rtSemRWRequestRead(hRWSem, cMillies, &SrcPos);
     325#endif
     326}
     327
     328
     329RTDECL(int) RTSemRWRequestReadDebug(RTSEMRW hRWSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    330330{
    331331    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
    332     return rtSemRWRequestRead(RWSem, cMillies, &SrcPos);
     332    return rtSemRWRequestRead(hRWSem, cMillies, &SrcPos);
    333333}
    334334
    335335
    336336#undef RTSemRWRequestReadNoResume
    337 RTDECL(int) RTSemRWRequestReadNoResume(RTSEMRW RWSem, unsigned cMillies)
     337RTDECL(int) RTSemRWRequestReadNoResume(RTSEMRW hRWSem, RTMSINTERVAL cMillies)
    338338{
    339339    /* EINTR isn't returned by the wait functions we're using. */
    340340#ifndef RTSEMRW_STRICT
    341     return rtSemRWRequestRead(RWSem, cMillies, NULL);
     341    return rtSemRWRequestRead(hRWSem, cMillies, NULL);
    342342#else
    343343    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
    344     return rtSemRWRequestRead(RWSem, cMillies, &SrcPos);
    345 #endif
    346 }
    347 
    348 
    349 RTDECL(int) RTSemRWRequestReadNoResumeDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     344    return rtSemRWRequestRead(hRWSem, cMillies, &SrcPos);
     345#endif
     346}
     347
     348
     349RTDECL(int) RTSemRWRequestReadNoResumeDebug(RTSEMRW hRWSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    350350{
    351351    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
    352     return rtSemRWRequestRead(RWSem, cMillies, &SrcPos);
    353 }
    354 
    355 
    356 RTDECL(int) RTSemRWReleaseRead(RTSEMRW RWSem)
    357 {
    358     /*
    359      * Validate input.
    360      */
    361     struct RTSEMRWINTERNAL *pThis = RWSem;
     352    return rtSemRWRequestRead(hRWSem, cMillies, &SrcPos);
     353}
     354
     355
     356RTDECL(int) RTSemRWReleaseRead(RTSEMRW hRWSem)
     357{
     358    /*
     359     * Validate input.
     360     */
     361    struct RTSEMRWINTERNAL *pThis = hRWSem;
    362362    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    363363    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     
    403403    {
    404404        ASMAtomicIncU32(&pThis->cReaders);
    405         AssertMsgFailed(("Failed read unlock read-write sem %p, rc=%d.\n", RWSem, rc));
     405        AssertMsgFailed(("Failed read unlock read-write sem %p, rc=%d.\n", hRWSem, rc));
    406406        return RTErrConvertFromErrno(rc);
    407407    }
     
    410410
    411411
    412 DECL_FORCE_INLINE(int) rtSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies, PCRTLOCKVALSRCPOS pSrcPos)
    413 {
    414     /*
    415      * Validate input.
    416      */
    417     struct RTSEMRWINTERNAL *pThis = RWSem;
     412DECL_FORCE_INLINE(int) rtSemRWRequestWrite(RTSEMRW hRWSem, RTMSINTERVAL cMillies, PCRTLOCKVALSRCPOS pSrcPos)
     413{
     414    /*
     415     * Validate input.
     416     */
     417    struct RTSEMRWINTERNAL *pThis = hRWSem;
    418418    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    419419    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     
    464464        if (rc)
    465465        {
    466             AssertMsgFailed(("Failed write lock read-write sem %p, rc=%d.\n", RWSem, rc));
     466            AssertMsgFailed(("Failed write lock read-write sem %p, rc=%d.\n", hRWSem, rc));
    467467            return RTErrConvertFromErrno(rc);
    468468        }
     
    495495        if (rc)
    496496        {
    497             AssertMsg(rc == ETIMEDOUT, ("Failed read lock read-write sem %p, rc=%d.\n", RWSem, rc));
     497            AssertMsg(rc == ETIMEDOUT, ("Failed read lock read-write sem %p, rc=%d.\n", hRWSem, rc));
    498498            return RTErrConvertFromErrno(rc);
    499499        }
     
    512512
    513513#undef RTSemRWRequestWrite
    514 RTDECL(int) RTSemRWRequestWrite(RTSEMRW RWSem, unsigned cMillies)
     514RTDECL(int) RTSemRWRequestWrite(RTSEMRW hRWSem, RTMSINTERVAL cMillies)
    515515{
    516516#ifndef RTSEMRW_STRICT
    517     return rtSemRWRequestWrite(RWSem, cMillies, NULL);
     517    return rtSemRWRequestWrite(hRWSem, cMillies, NULL);
    518518#else
    519519    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
    520     return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    521 #endif
    522 }
    523 
    524 
    525 RTDECL(int) RTSemRWRequestWriteDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     520    return rtSemRWRequestWrite(hRWSem, cMillies, &SrcPos);
     521#endif
     522}
     523
     524
     525RTDECL(int) RTSemRWRequestWriteDebug(RTSEMRW hRWSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    526526{
    527527    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
    528     return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
     528    return rtSemRWRequestWrite(hRWSem, cMillies, &SrcPos);
    529529}
    530530
    531531
    532532#undef RTSemRWRequestWriteNoResume
    533 RTDECL(int) RTSemRWRequestWriteNoResume(RTSEMRW RWSem, unsigned cMillies)
     533RTDECL(int) RTSemRWRequestWriteNoResume(RTSEMRW hRWSem, RTMSINTERVAL cMillies)
    534534{
    535535    /* EINTR isn't returned by the wait functions we're using. */
    536536#ifndef RTSEMRW_STRICT
    537     return rtSemRWRequestWrite(RWSem, cMillies, NULL);
     537    return rtSemRWRequestWrite(hRWSem, cMillies, NULL);
    538538#else
    539539    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
    540     return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    541 #endif
    542 }
    543 
    544 
    545 RTDECL(int) RTSemRWRequestWriteNoResumeDebug(RTSEMRW RWSem, unsigned cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
     540    return rtSemRWRequestWrite(hRWSem, cMillies, &SrcPos);
     541#endif
     542}
     543
     544
     545RTDECL(int) RTSemRWRequestWriteNoResumeDebug(RTSEMRW hRWSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
    546546{
    547547    /* EINTR isn't returned by the wait functions we're using. */
    548548    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
    549     return rtSemRWRequestWrite(RWSem, cMillies, &SrcPos);
    550 }
    551 
    552 
    553 RTDECL(int) RTSemRWReleaseWrite(RTSEMRW RWSem)
    554 {
    555     /*
    556      * Validate input.
    557      */
    558     struct RTSEMRWINTERNAL *pThis = RWSem;
     549    return rtSemRWRequestWrite(hRWSem, cMillies, &SrcPos);
     550}
     551
     552
     553RTDECL(int) RTSemRWReleaseWrite(RTSEMRW hRWSem)
     554{
     555    /*
     556     * Validate input.
     557     */
     558    struct RTSEMRWINTERNAL *pThis = hRWSem;
    559559    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    560560    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     
    596596    if (rc)
    597597    {
    598         AssertMsgFailed(("Failed write unlock read-write sem %p, rc=%d.\n", RWSem, rc));
     598        AssertMsgFailed(("Failed write unlock read-write sem %p, rc=%d.\n", hRWSem, rc));
    599599        return RTErrConvertFromErrno(rc);
    600600    }
     
    604604
    605605
    606 RTDECL(bool) RTSemRWIsWriteOwner(RTSEMRW RWSem)
    607 {
    608     /*
    609      * Validate input.
    610      */
    611     struct RTSEMRWINTERNAL *pThis = RWSem;
     606RTDECL(bool) RTSemRWIsWriteOwner(RTSEMRW hRWSem)
     607{
     608    /*
     609     * Validate input.
     610     */
     611    struct RTSEMRWINTERNAL *pThis = hRWSem;
    612612    AssertPtrReturn(pThis, false);
    613613    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     
    625625
    626626
    627 RTDECL(uint32_t) RTSemRWGetWriteRecursion(RTSEMRW RWSem)
    628 {
    629     /*
    630      * Validate input.
    631      */
    632     struct RTSEMRWINTERNAL *pThis = RWSem;
     627RTDECL(uint32_t) RTSemRWGetWriteRecursion(RTSEMRW hRWSem)
     628{
     629    /*
     630     * Validate input.
     631     */
     632    struct RTSEMRWINTERNAL *pThis = hRWSem;
    633633    AssertPtrReturn(pThis, 0);
    634634    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     
    643643
    644644
    645 RTDECL(uint32_t) RTSemRWGetWriterReadRecursion(RTSEMRW RWSem)
    646 {
    647     /*
    648      * Validate input.
    649      */
    650     struct RTSEMRWINTERNAL *pThis = RWSem;
     645RTDECL(uint32_t) RTSemRWGetWriterReadRecursion(RTSEMRW hRWSem)
     646{
     647    /*
     648     * Validate input.
     649     */
     650    struct RTSEMRWINTERNAL *pThis = hRWSem;
    651651    AssertPtrReturn(pThis, 0);
    652652    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     
    661661
    662662
    663 RTDECL(uint32_t) RTSemRWGetReadCount(RTSEMRW RWSem)
    664 {
    665     /*
    666      * Validate input.
    667      */
    668     struct RTSEMRWINTERNAL *pThis = RWSem;
     663RTDECL(uint32_t) RTSemRWGetReadCount(RTSEMRW hRWSem)
     664{
     665    /*
     666     * Validate input.
     667     */
     668    struct RTSEMRWINTERNAL *pThis = hRWSem;
    669669    AssertPtrReturn(pThis, 0);
    670670    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
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