VirtualBox

Ignore:
Timestamp:
Jun 9, 2010 12:14:59 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
62505
Message:

iprt/asm.h,*: Revised the ASMAtomic*Ptr functions and macros. The new saves lots of unsafe (void * volatile *) casts as well as adding some type safety when using GCC (typeof rulez).

File:
1 edited

Legend:

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

    r29477 r30111  
    198198        for (unsigned iSlot = 0; iSlot < RT_ELEMENTS(pCtxInt->apReqsNewHead); iSlot++)
    199199        {
    200             PRTFILEAIOREQINTERNAL pReqHead = (PRTFILEAIOREQINTERNAL)ASMAtomicXchgPtr((void* volatile*)&pCtxInt->apReqsNewHead[iSlot],
    201                                                                                      NULL);
     200            PRTFILEAIOREQINTERNAL pReqHead = ASMAtomicXchgPtrT(&pCtxInt->apReqsNewHead[iSlot], NULL, PRTFILEAIOREQINTERNAL);
    202201
    203202            while (  (pCtxInt->iFirstFree < pCtxInt->cReqsWaitMax)
     
    249248
    250249        /* Check if a request needs to be canceled. */
    251         PRTFILEAIOREQINTERNAL pReqToCancel = (PRTFILEAIOREQINTERNAL)ASMAtomicReadPtr((void* volatile*)&pCtxInt->pReqToCancel);
     250        PRTFILEAIOREQINTERNAL pReqToCancel = ASMAtomicReadPtrT(&pCtxInt->pReqToCancel, PRTFILEAIOREQINTERNAL);
    252251        if (pReqToCancel)
    253252        {
     
    487486
    488487        Assert(!pCtxInt->pReqToCancel);
    489         ASMAtomicWritePtr((void* volatile*)&pCtxInt->pReqToCancel, pReqInt);
     488        ASMAtomicWritePtr(&pCtxInt->pReqToCancel, pReqInt);
    490489        rtFileAioCtxWakeup(pCtxInt);
    491490
     
    494493        AssertRC(rc);
    495494
    496         ASMAtomicWritePtr((void* volatile*)&pCtxInt->pReqToCancel, NULL);
     495        ASMAtomicWritePtr(&pCtxInt->pReqToCancel, NULL);
    497496        pReqInt->Rc = VERR_FILE_AIO_CANCELED;
    498497        RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED);
     
    819818        unsigned iSlot = 0;
    820819        while (  (iSlot < RT_ELEMENTS(pCtxInt->apReqsNewHead))
    821                && !ASMAtomicCmpXchgPtr((void * volatile *)&pCtxInt->apReqsNewHead[iSlot], pHead, NULL))
     820               && !ASMAtomicCmpXchgPtr(&pCtxInt->apReqsNewHead[iSlot], pHead, NULL))
    822821            iSlot++;
    823822
     
    825824        {
    826825            /* Nothing found. */
    827             PRTFILEAIOREQINTERNAL pOldHead = (PRTFILEAIOREQINTERNAL)ASMAtomicXchgPtr((void * volatile *)&pCtxInt->apReqsNewHead[0],
    828                                                                                       NULL);
     826            PRTFILEAIOREQINTERNAL pOldHead = ASMAtomicXchgPtrT(&pCtxInt->apReqsNewHead[0], NULL, PRTFILEAIOREQINTERNAL);
    829827
    830828            /* Find the end of the current head and link the old list to the current. */
     
    835833            pTail->pNext = pOldHead;
    836834
    837             ASMAtomicXchgPtr((void * volatile *)&pCtxInt->apReqsNewHead[0], pHead);
     835            ASMAtomicWritePtr(&pCtxInt->apReqsNewHead[0], pHead);
    838836        }
    839837
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