VirtualBox

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


Ignore:
Timestamp:
Jan 11, 2010 11:15:04 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56449
Message:

iprt: RTSemMutex order validation.

File:
1 edited

Legend:

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

    r25704 r25711  
    7171
    7272
    73 /* Undefine debug mappings. */
    74 #undef RTSemMutexRequest
    75 #undef RTSemMutexRequestNoResume
    76 
    77 
    78 RTDECL(int)  RTSemMutexCreate(PRTSEMMUTEX pMutexSem)
    79 {
     73#undef RTSemMutexCreate
     74RTDECL(int)  RTSemMutexCreate(PRTSEMMUTEX phMutexSem)
     75{
     76    return RTSemMutexCreateEx(phMutexSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, NULL);
     77}
     78
     79
     80RTDECL(int) RTSemMutexCreateEx(PRTSEMMUTEX phMutexSem, uint32_t fFlags,
     81                               RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszNameFmt, ...)
     82{
     83    AssertReturn(!(fFlags & ~RTSEMMUTEX_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
     84
     85    /*
     86     * Allocate semaphore handle.
     87     */
    8088    int rc;
    81 
    82     /*
    83      * Allocate semaphore handle.
    84      */
    8589    struct RTSEMMUTEXINTERNAL *pThis = (struct RTSEMMUTEXINTERNAL *)RTMemAlloc(sizeof(struct RTSEMMUTEXINTERNAL));
    8690    if (pThis)
     
    102106                pThis->u32Magic = RTSEMMUTEX_MAGIC;
    103107#ifdef RTSEMMUTEX_STRICT
    104                 RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, pThis,
    105                                            true /*fEnabled*/, "RTSemMutex");
    106 #endif
    107 
    108                 *pMutexSem = pThis;
     108                va_list va;
     109                va_start(va, pszNameFmt);
     110                RTLockValidatorRecExclInitV(&pThis->ValidatorRec, hClass, uSubClass, pThis,
     111                                            !(fFlags & RTSEMMUTEX_FLAGS_NO_LOCK_VAL), pszNameFmt, va);
     112                va_end(va);
     113#endif
     114
     115                *phMutexSem = pThis;
    109116                return VINF_SUCCESS;
    110117            }
     
    153160
    154161    return VINF_SUCCESS;
     162}
     163
     164
     165RTDECL(uint32_t) RTSemMutexSetSubClass(RTSEMMUTEX hMutexSem, uint32_t uSubClass)
     166{
     167#ifdef RTSEMMUTEX_STRICT
     168    /*
     169     * Validate.
     170     */
     171    RTSEMMUTEXINTERNAL *pThis = hMutexSem;
     172    AssertPtrReturn(pThis, RTLOCKVAL_SUB_CLASS_INVALID);
     173    AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID);
     174
     175    return RTLockValidatorRecExclSetSubClass(&pThis->ValidatorRec, uSubClass);
     176#else
     177    return RTLOCKVAL_SUB_CLASS_INVALID;
     178#endif
    155179}
    156180
     
    256280
    257281
     282#undef RTSemMutexRequest
    258283RTDECL(int) RTSemMutexRequest(RTSEMMUTEX MutexSem, unsigned cMillies)
    259284{
     
    274299
    275300
     301#undef RTSemMutexRequestNoResume
    276302RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
    277303{
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