VirtualBox

Ignore:
Timestamp:
Apr 6, 2012 9:05:19 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77321
Message:

RTSpinlock: Redid the interface, eliminating NoInts and Tmp. Whether a spinlock is interrupt safe or not is now defined at creation time, preventing stupid bugs arrising from calling the wrong acquire and/or release methods somewhere. The saved flags are stored in the spinlock strucutre, eliminating the annoying Tmp variable. Needs testing on each platform before fixing the build burn.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/darwin/VBoxNetFlt-darwin.cpp

    r38485 r40806  
    227227DECLINLINE(ifnet_t) vboxNetFltDarwinRetainIfNet(PVBOXNETFLTINS pThis)
    228228{
    229     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    230229    ifnet_t pIfNet = NULL;
    231230
     
    233232     * Be careful here to avoid problems racing the detached callback.
    234233     */
    235     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     234    RTSpinlockAcquire(pThis->hSpinlock);
    236235    if (!ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost))
    237236    {
     
    240239            ifnet_reference(pIfNet);
    241240    }
    242     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     241    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    243242
    244243    return pIfNet;
     
    639638{
    640639    PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)pvThis;
    641     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    642640    uint64_t NanoTS = RTTimeSystemNanoTS();
    643641    LogFlow(("vboxNetFltDarwinIffDetached: pThis=%p NanoTS=%RU64 (%d)\n",
     
    658656     * behind it in order to avoid problematic races with the detached callback.
    659657     */
    660     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     658    RTSpinlockAcquire(pThis->hSpinlock);
    661659
    662660    pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
     
    671669    ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true);
    672670
    673     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     671    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    674672
    675673    if (pIfNet)
     
    916914    }
    917915
    918     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    919     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     916    RTSpinlockAcquire(pThis->hSpinlock);
    920917    ASMAtomicUoWritePtr(&pThis->u.s.pIfNet, pIfNet);
    921     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     918    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    922919
    923920    /*
     
    943940        Assert(err || pIfFilter);
    944941
    945         RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     942        RTSpinlockAcquire(pThis->hSpinlock);
    946943        pIfNet = ASMAtomicUoReadPtrT(&pThis->u.s.pIfNet, ifnet_t);
    947944        if (pIfNet && !err)
     
    951948            pIfNet = NULL; /* don't dereference it */
    952949        }
    953         RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     950        RTSpinlockReleaseNoInts(pThis->hSpinlock);
    954951
    955952        /* Report capabilities. */
     
    11631160void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
    11641161{
    1165     RTSPINLOCKTMP Tmp = RTSPINLOCKTMP_INITIALIZER;
    11661162    interface_filter_t pIfFilter;
    11671163
     
    11691165     * Carefully obtain the interface filter reference and detach it.
    11701166     */
    1171     RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp);
     1167    RTSpinlockAcquire(pThis->hSpinlock);
    11721168    pIfFilter = ASMAtomicUoReadPtrT(&pThis->u.s.pIfFilter, interface_filter_t);
    11731169    if (pIfFilter)
    11741170        ASMAtomicUoWriteNullPtr(&pThis->u.s.pIfFilter);
    1175     RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
     1171    RTSpinlockReleaseNoInts(pThis->hSpinlock);
    11761172
    11771173    if (pIfFilter)
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