VirtualBox

Ignore:
Timestamp:
Jan 11, 2010 1:24:09 PM (15 years ago)
Author:
vboxsync
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/os2/sems-os2.cpp

    r25711 r25717  
    4747
    4848
    49 /* Undefine debug mappings. */
    50 #undef RTSemMutexRequest
    51 #undef RTSemMutexRequestNoResume
    52 
    53 
    54 RTDECL(int)   RTSemEventCreate(PRTSEMEVENT pEventSem)
    55 {
     49
     50RTDECL(int)  RTSemEventCreate(PRTSEMEVENT phEventSem)
     51{
     52    return RTSemEventCreateEx(phEventSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, NULL);
     53}
     54
     55
     56RTDECL(int)  RTSemEventCreateEx(PRTSEMEVENT phEventSem, uint32_t fFlags, RTLOCKVALCLASS hClass, const char *pszNameFmt, ...)
     57{
     58    AssertReturn(!(fFlags & ~RTSEMEVENT_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
     59
    5660    /*
    5761     * Create the semaphore.
     
    6266    if (!rc)
    6367    {
    64         *pEventSem = (RTSEMEVENT)(void *)hev;
    65         return VINF_SUCCESS;
    66     }
    67     return RTErrConvertFromOS2(rc);
    68 }
    69 
    70 
    71 RTDECL(int)   RTSemEventDestroy(RTSEMEVENT EventSem)
    72 {
    73     if (EventSem == NIL_RTSEMEVENT)     /* don't bitch */
    74         return VERR_INVALID_HANDLE;
     68        *phEventSem = (RTSEMEVENT)(void *)hev;
     69        return VINF_SUCCESS;
     70    }
     71    return RTErrConvertFromOS2(rc);
     72}
     73
     74
     75RTDECL(int)   RTSemEventDestroy(RTSEMEVENT hEventSem)
     76{
     77    if (hEventSem == NIL_RTSEMEVENT)
     78        return VINF_SUCCESS;
    7579
    7680    /*
    7781     * Close semaphore handle.
    7882     */
    79     int rc = DosCloseEventSem(SEM2HND(EventSem));
    80     if (!rc)
    81         return VINF_SUCCESS;
    82     AssertMsgFailed(("Destroy EventSem %p failed, rc=%d\n", EventSem, rc));
    83     return RTErrConvertFromOS2(rc);
    84 }
    85 
    86 
    87 RTDECL(int)   RTSemEventWaitNoResume(RTSEMEVENT EventSem, unsigned cMillies)
     83    int rc = DosCloseEventSem(SEM2HND(hEventSem));
     84    if (!rc)
     85        return VINF_SUCCESS;
     86    AssertMsgFailed(("Destroy hEventSem %p failed, rc=%d\n", hEventSem, rc));
     87    return RTErrConvertFromOS2(rc);
     88}
     89
     90
     91RTDECL(int)   RTSemEventWaitNoResume(RTSEMEVENT hEventSem, unsigned cMillies)
    8892{
    8993    /*
    9094     * Wait for condition.
    9195     */
    92     int rc = DosWaitEventSem(SEM2HND(EventSem), cMillies == RT_INDEFINITE_WAIT ? SEM_INDEFINITE_WAIT : cMillies);
     96    int rc = DosWaitEventSem(SEM2HND(hEventSem), cMillies == RT_INDEFINITE_WAIT ? SEM_INDEFINITE_WAIT : cMillies);
    9397    switch (rc)
    9498    {
     
    99103        default:
    100104        {
    101             AssertMsgFailed(("Wait on EventSem %p failed, rc=%d\n", EventSem, rc));
     105            AssertMsgFailed(("Wait on hEventSem %p failed, rc=%d\n", hEventSem, rc));
    102106            return RTErrConvertFromOS2(rc);
    103107        }
     
    106110
    107111
    108 RTDECL(int)  RTSemEventSignal(RTSEMEVENT EventSem)
     112RTDECL(int)  RTSemEventSignal(RTSEMEVENT hEventSem)
    109113{
    110114    /*
    111115     * Signal the object.
    112116     */
    113     int rc = DosPostEventSem(SEM2HND(EventSem));
     117    int rc = DosPostEventSem(SEM2HND(hEventSem));
    114118    switch (rc)
    115119    {
     
    292296
    293297
     298#undef RTSemMutexRequestNoResume
    294299RTDECL(int)  RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
    295300{
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