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/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r29662 r30111  
    236236    if (!ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost))
    237237    {
    238         pIfNet = (ifnet_t)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pIfNet);
     238        pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
    239239        if (pIfNet)
    240240            ifnet_reference(pIfNet);
     
    666666    RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    667667
    668     pIfNet = (ifnet_t)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pIfNet);
     668    pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
    669669    int cPromisc = VALID_PTR(pIfNet) ? VBOX_GET_PCOUNT(pIfNet) : - 1;
    670670
    671     ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pIfNet, NULL);
    672     ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pIfFilter, NULL);
     671    ASMAtomicUoWritePtr(&pThis->u.s.pIfNet, NULL);
     672    ASMAtomicUoWritePtr(&pThis->u.s.pIfFilter, NULL);
    673673    ASMAtomicWriteBool(&pThis->u.s.fNeedSetPromiscuous, false);
    674674    pThis->u.s.fSetPromiscuous = false;
     
    914914    RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    915915    RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    916     ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pIfNet, pIfNet);
     916    ASMAtomicUoWritePtr(&pThis->u.s.pIfNet, pIfNet);
    917917    RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
    918918
     
    940940
    941941        RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    942         pIfNet = (ifnet_t)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pIfNet);
     942        pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
    943943        if (pIfNet && !err)
    944944        {
    945945            ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false);
    946             ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pIfFilter, pIfFilter);
     946            ASMAtomicUoWritePtr(&pThis->u.s.pIfFilter, pIfFilter);
    947947            pIfNet = NULL; /* don't dereference it */
    948948        }
     
    11621162     */
    11631163    RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
    1164     pIfFilter = (interface_filter_t)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pIfFilter);
     1164    pIfFilter = ASMAtomicUoReadPtrT(&pThis->u.s.pIfFilter, interface_filter_t);
    11651165    if (pIfFilter)
    1166         ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pIfFilter, NULL);
     1166        ASMAtomicUoWritePtr(&pThis->u.s.pIfFilter, NULL);
    11671167    RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
    11681168
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