VirtualBox

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


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/win/semmutex-win.cpp

    r25704 r25711  
    7070
    7171
    72 /* Undefine debug mappings. */
    73 #undef RTSemMutexRequest
    74 #undef RTSemMutexRequestNoResume
    75 
    76 
    77 RTDECL(int)  RTSemMutexCreate(PRTSEMMUTEX pMutexSem)
    78 {
     72
     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     * Create the semaphore.
     87     */
    7988    int rc;
    80 
    81     /*
    82      * Create the semaphore.
    83      */
    8489    HANDLE hMtx = CreateMutex(NULL, FALSE, NULL);
    8590    if (hMtx)
     
    9398            pThis->cRecursions  = 0;
    9499#ifdef RTSEMMUTEX_STRICT
    95             RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, pThis,
    96                                        true /*fEnabled*/, "RTSemMutex");
    97 #endif
    98             *pMutexSem = pThis;
     100            va_list va;
     101            va_start(va, pszNameFmt);
     102            RTLockValidatorRecExclInitV(&pThis->ValidatorRec, hClass, uSubClass, pThis,
     103                                        !(fFlags & RTSEMMUTEX_FLAGS_NO_LOCK_VAL), pszNameFmt, va);
     104            va_end(va);
     105#endif
     106            *phMutexSem = pThis;
    99107            return VINF_SUCCESS;
    100108        }
     
    138146    RTMemFree(pThis);
    139147    return rc;
     148}
     149
     150
     151RTDECL(uint32_t) RTSemMutexSetSubClass(RTSEMMUTEX hMutexSem, uint32_t uSubClass)
     152{
     153#ifdef RTSEMMUTEX_STRICT
     154    /*
     155     * Validate.
     156     */
     157    RTSEMMUTEXINTERNAL *pThis = hMutexSem;
     158    AssertPtrReturn(pThis, RTLOCKVAL_SUB_CLASS_INVALID);
     159    AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID);
     160
     161    return RTLockValidatorRecExclSetSubClass(&pThis->ValidatorRec, uSubClass);
     162#else
     163    return RTLOCKVAL_SUB_CLASS_INVALID;
     164#endif
    140165}
    141166
     
    225250
    226251
     252#undef RTSemMutexRequestNoResume
    227253RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
    228254{
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