VirtualBox

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


Ignore:
Timestamp:
Oct 20, 2010 3:42:28 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66829
Message:

IPRT: A quick replacement of the RTMemPage* and RTMemExec* APIs on posix. (Turned out to be a bit more work than expected because of the electric fence heap and init dependencies.)

File:
1 edited

Legend:

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

    r28800 r33269  
    5252                             const char *pszNameFmt, ...)
    5353{
    54     AssertReturn(fFlags <= (RTCRITSECT_FLAGS_NO_NESTING | RTCRITSECT_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
     54    AssertReturn(!(fFlags & ~(RTCRITSECT_FLAGS_NO_NESTING | RTCRITSECT_FLAGS_NO_LOCK_VAL | RTCRITSECT_FLAGS_BOOTSTRAP_HACK)),
     55                 VERR_INVALID_PARAMETER);
    5556
    5657    /*
     
    6566    int rc = VINF_SUCCESS;
    6667#ifdef RTCRITSECT_STRICT
    67     if (!pszNameFmt)
    68     {
    69         static uint32_t volatile s_iCritSectAnon = 0;
    70         rc = RTLockValidatorRecExclCreate(&pCritSect->pValidatorRec, hClass, uSubClass, pCritSect,
    71                                           !(fFlags & RTCRITSECT_FLAGS_NO_LOCK_VAL),
    72                                           "RTCritSect-%u", ASMAtomicIncU32(&s_iCritSectAnon) - 1);
    73     }
    74     else
    75     {
    76         va_list va;
    77         va_start(va, pszNameFmt);
    78         rc = RTLockValidatorRecExclCreateV(&pCritSect->pValidatorRec, hClass, uSubClass, pCritSect,
    79                                            !(fFlags & RTCRITSECT_FLAGS_NO_LOCK_VAL), pszNameFmt, va);
    80         va_end(va);
     68    if (!(fFlags & RTCRITSECT_FLAGS_BOOTSTRAP_HACK))
     69    {
     70        if (!pszNameFmt)
     71        {
     72            static uint32_t volatile s_iCritSectAnon = 0;
     73            rc = RTLockValidatorRecExclCreate(&pCritSect->pValidatorRec, hClass, uSubClass, pCritSect,
     74                                              !(fFlags & RTCRITSECT_FLAGS_NO_LOCK_VAL),
     75                                              "RTCritSect-%u", ASMAtomicIncU32(&s_iCritSectAnon) - 1);
     76        }
     77        else
     78        {
     79            va_list va;
     80            va_start(va, pszNameFmt);
     81            rc = RTLockValidatorRecExclCreateV(&pCritSect->pValidatorRec, hClass, uSubClass, pCritSect,
     82                                               !(fFlags & RTCRITSECT_FLAGS_NO_LOCK_VAL), pszNameFmt, va);
     83            va_end(va);
     84        }
    8185    }
    8286#endif
    8387    if (RT_SUCCESS(rc))
    8488    {
    85         rc = RTSemEventCreate(&pCritSect->EventSem);
     89        rc = RTSemEventCreateEx(&pCritSect->EventSem,
     90                                fFlags & RTCRITSECT_FLAGS_BOOTSTRAP_HACK
     91                                ? RTSEMEVENT_FLAGS_NO_LOCK_VAL | RTSEMEVENT_FLAGS_BOOTSTRAP_HACK
     92                                : RTSEMEVENT_FLAGS_NO_LOCK_VAL,
     93                                NIL_RTLOCKVALCLASS,
     94                                NULL);
    8695        if (RT_SUCCESS(rc))
    8796            return VINF_SUCCESS;
     
    187196
    188197#ifdef RTCRITSECT_STRICT
    189     RTTHREAD        hThreadSelf = RTThreadSelfAutoAdopt();
    190     int rc9 = RTLockValidatorRecExclCheckOrder(pCritSect->pValidatorRec, hThreadSelf, pSrcPos, RT_INDEFINITE_WAIT);
    191     if (RT_FAILURE(rc9))
    192         return rc9;
     198    RTTHREAD hThreadSelf = pCritSect->pValidatorRec
     199                         ? RTThreadSelfAutoAdopt()
     200                         : RTThreadSelf();
     201    int      rc9;
     202    if (pCritSect->pValidatorRec) /* (bootstap) */
     203    {
     204         rc9 = RTLockValidatorRecExclCheckOrder(pCritSect->pValidatorRec, hThreadSelf, pSrcPos, RT_INDEFINITE_WAIT);
     205         if (RT_FAILURE(rc9))
     206             return rc9;
     207    }
    193208#endif
    194209
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