VirtualBox

Changeset 8653 in vbox for trunk/src


Ignore:
Timestamp:
May 7, 2008 12:31:30 PM (17 years ago)
Author:
vboxsync
Message:

Added RTSemRWIsWriteOwner, RTSemRWGetWriteRecursion and RTSemRWGetWriterReadRecursion.

File:
1 edited

Legend:

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

    r8652 r8653  
    430430}
    431431
     432
     433RTDECL(bool) RTSemRWIsWriteOwner(RTSEMRW RWSem)
     434{
     435    /*
     436     * Validate input.
     437     */
     438    struct RTSEMRWINTERNAL *pThis = RWSem;
     439    AssertPtrReturn(pThis, false);
     440    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     441                    ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic),
     442                    false);
     443
     444    /*
     445     * Check ownership.
     446     */
     447    pthread_t Self = pthread_self();
     448    pthread_t Writer;
     449    ATOMIC_GET_PTHREAD_T(&pThis->Writer, &Writer);
     450    return Writer == Self;
     451}
     452
     453
     454RTDECL(uint32_t) RTSemRWGetWriteRecursion(RTSEMRW RWSem)
     455{
     456    /*
     457     * Validate input.
     458     */
     459    struct RTSEMRWINTERNAL *pThis = RWSem;
     460    AssertPtrReturn(pThis, 0);
     461    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     462                    ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic),
     463                    0);
     464
     465    /*
     466     * Return the requested data.
     467     */
     468    return pThis->cWrites;
     469}
     470
     471
     472RTDECL(uint32_t) RTSemRWGetWriterReadRecursion(RTSEMRW RWSem)
     473{
     474    /*
     475     * Validate input.
     476     */
     477    struct RTSEMRWINTERNAL *pThis = RWSem;
     478    AssertPtrReturn(pThis, 0);
     479    AssertMsgReturn(pThis->u32Magic == RTSEMRW_MAGIC,
     480                    ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic),
     481                    0);
     482
     483    /*
     484     * Return the requested data.
     485     */
     486    return pThis->cWriterReads;
     487}
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