VirtualBox

Changeset 25717 in vbox for trunk/src/VBox/Runtime/r3/linux


Ignore:
Timestamp:
Jan 11, 2010 1:24:09 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56457
Message:

iprt: Added RTSemEventCreateEx and did some cleanups of the RTSemEventDestroy behavior wrt NIL handles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/linux/semevent-linux.cpp

    r25704 r25717  
    117117
    118118
    119 RTDECL(int)  RTSemEventCreate(PRTSEMEVENT pEventSem)
    120 {
     119RTDECL(int)  RTSemEventCreate(PRTSEMEVENT phEventSem)
     120{
     121    return RTSemEventCreateEx(phEventSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, NULL);
     122}
     123
     124
     125RTDECL(int)  RTSemEventCreateEx(PRTSEMEVENT phEventSem, uint32_t fFlags, RTLOCKVALCLASS hClass, const char *pszNameFmt, ...)
     126{
     127    AssertReturn(!(fFlags & ~RTSEMEVENT_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
     128
    121129    /*
    122130     * Allocate semaphore handle.
     
    129137        pThis->fSignalled = 0;
    130138#ifdef RTSEMEVENT_STRICT
    131         RTLockValidatorRecSharedInit(&pThis->Signallers,
    132                                      NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
    133                                      pThis, true /*fSignaller*/, true /*fEnabled*/, "RTSemEvent");
     139        va_list va;
     140        va_start(va, pszNameFmt);
     141        RTLockValidatorRecSharedInitV(&pThis->Signallers, hClass, RTLOCKVAL_SUB_CLASS_ANY, pThis,
     142                                      true /*fSignaller*/, !(fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL),
     143                                      pszNameFmt, va);
     144        va_end(va);
    134145        pThis->fEverHadSignallers = false;
    135146#endif
    136         *pEventSem = pThis;
     147
     148        *phEventSem = pThis;
    137149        return VINF_SUCCESS;
    138150    }
     
    141153
    142154
    143 RTDECL(int)  RTSemEventDestroy(RTSEMEVENT EventSem)
     155RTDECL(int)  RTSemEventDestroy(RTSEMEVENT hEventSem)
    144156{
    145157    /*
    146158     * Validate input.
    147159     */
    148     if (EventSem == NIL_RTSEMEVENT)     /* don't bitch */
    149         return VERR_INVALID_HANDLE;
    150     struct RTSEMEVENTINTERNAL *pThis = EventSem;
     160    struct RTSEMEVENTINTERNAL *pThis = hEventSem;
     161    if (pThis == NIL_RTSEMEVENT)
     162        return VINF_SUCCESS;
    151163    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    152164    AssertReturn(pThis->iMagic == RTSEMEVENT_MAGIC, VERR_INVALID_HANDLE);
     
    173185
    174186
    175 RTDECL(int)  RTSemEventSignal(RTSEMEVENT EventSem)
     187RTDECL(int)  RTSemEventSignal(RTSEMEVENT hEventSem)
    176188{
    177189    /*
    178190     * Validate input.
    179191     */
    180     struct RTSEMEVENTINTERNAL *pThis = EventSem;
     192    struct RTSEMEVENTINTERNAL *pThis = hEventSem;
    181193    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    182194    AssertReturn(pThis->iMagic == RTSEMEVENT_MAGIC, VERR_INVALID_HANDLE);
     
    207219
    208220
    209 static int rtSemEventWait(RTSEMEVENT EventSem, unsigned cMillies, bool fAutoResume)
     221static int rtSemEventWait(RTSEMEVENT hEventSem, unsigned cMillies, bool fAutoResume)
    210222{
    211223    PCRTLOCKVALSRCPOS pSrcPos = NULL;
     
    214226     * Validate input.
    215227     */
    216     struct RTSEMEVENTINTERNAL *pThis = EventSem;
     228    struct RTSEMEVENTINTERNAL *pThis = hEventSem;
    217229    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    218230    AssertReturn(pThis->iMagic == RTSEMEVENT_MAGIC, VERR_INVALID_HANDLE);
     
    319331
    320332
    321 RTDECL(int)  RTSemEventWait(RTSEMEVENT EventSem, unsigned cMillies)
    322 {
    323     int rc = rtSemEventWait(EventSem, cMillies, true);
     333RTDECL(int)  RTSemEventWait(RTSEMEVENT hEventSem, unsigned cMillies)
     334{
     335    int rc = rtSemEventWait(hEventSem, cMillies, true);
    324336    Assert(rc != VERR_INTERRUPTED);
    325337    Assert(rc != VERR_TIMEOUT || cMillies != RT_INDEFINITE_WAIT);
     
    328340
    329341
    330 RTDECL(int)  RTSemEventWaitNoResume(RTSEMEVENT EventSem, unsigned cMillies)
    331 {
    332     return rtSemEventWait(EventSem, cMillies, false);
     342RTDECL(int)  RTSemEventWaitNoResume(RTSEMEVENT hEventSem, unsigned cMillies)
     343{
     344    return rtSemEventWait(hEventSem, cMillies, false);
    333345}
    334346
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