VirtualBox

Changeset 54613 in vbox for trunk/src


Ignore:
Timestamp:
Mar 3, 2015 11:00:35 PM (10 years ago)
Author:
vboxsync
Message:

VBoxGuest: Optimized vbgdBitUsageTrackerChange and got rid of some unnecessary member type prefixes.

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r54612 r54613  
    10061006    pDevExt->fMouseStatusHost = UINT32_MAX;  /* forces a report */
    10071007
    1008     pDevExt->u32AcquireModeGuestCaps = 0;
    1009     pDevExt->u32SetModeGuestCaps = 0;
    1010     pDevExt->u32GuestCapsAcquired = 0;
     1008    pDevExt->fAcquireModeGuestCaps = 0;
     1009    pDevExt->fSetModeGuestCaps = 0;
     1010    pDevExt->fAcquiredGuestCaps = 0;
    10111011    vbgdBitUsageTrackerClear(&pDevExt->SetGuestCapsTracker);
    10121012    pDevExt->fGuestCapsHost = UINT32_MAX; /* forces a report */
     
    25322532                                     uint32_t cMax, const char *pszWhat)
    25332533{
    2534     bool        fGlobalChange = false;
    2535     uint32_t    iBit;
     2534    bool fGlobalChange = false;
    25362535    AssertCompile(sizeof(pTracker->acPerBitUsage) == 32 * sizeof(uint32_t));
    25372536
    2538     for (iBit = ASMBitFirstSetU32(fChanged) - 1; iBit < 32; iBit++)
    2539     {
     2537    while (fChanged)
     2538    {
     2539        uint32_t const iBit     = ASMBitFirstSetU32(fChanged) - 1;
    25402540        uint32_t const fBitMask = RT_BIT_32(iBit);
    2541         if (fBitMask & fChanged)
    2542         {
    2543             if (fChanged & fPrevious)
     2541        Assert(iBit < 32); Assert(fBitMask & fChanged);
     2542
     2543        if (fBitMask & fPrevious)
     2544        {
     2545            pTracker->acPerBitUsage[iBit] -= 1;
     2546            AssertMsg(pTracker->acPerBitUsage[iBit] <= cMax,
     2547                      ("%s: acPerBitUsage[%u]=%#x cMax=%#x\n", pszWhat, iBit, pTracker->acPerBitUsage[iBit], cMax));
     2548            if (pTracker->acPerBitUsage[iBit] == 0)
    25442549            {
    2545                 pTracker->acPerBitUsage[iBit] -= 1;
    2546                 AssertMsg(pTracker->acPerBitUsage[iBit] <= cMax,
    2547                           ("%s: acPerBitUsage[%u]=%#x cMax=%#x\n", pszWhat, iBit, pTracker->acPerBitUsage[iBit], cMax));
    2548                 if (pTracker->acPerBitUsage[iBit] == 0)
    2549                 {
    2550                     fGlobalChange = true;
    2551                     pTracker->fMask &= ~fBitMask;
    2552                 }
     2550                fGlobalChange = true;
     2551                pTracker->fMask &= ~fBitMask;
    25532552            }
    2554             else
     2553        }
     2554        else
     2555        {
     2556            pTracker->acPerBitUsage[iBit] += 1;
     2557            AssertMsg(pTracker->acPerBitUsage[iBit] > 0 && pTracker->acPerBitUsage[iBit] <= cMax,
     2558                      ("pTracker->acPerBitUsage[%u]=%#x cMax=%#x\n", pszWhat, iBit, pTracker->acPerBitUsage[iBit], cMax));
     2559            if (pTracker->acPerBitUsage[iBit] == 1)
    25552560            {
    2556                 pTracker->acPerBitUsage[iBit] += 1;
    2557                 AssertMsg(pTracker->acPerBitUsage[iBit] > 0 && pTracker->acPerBitUsage[iBit] <= cMax,
    2558                           ("pTracker->acPerBitUsage[%u]=%#x cMax=%#x\n", pszWhat, iBit, pTracker->acPerBitUsage[iBit], cMax));
    2559                 if (pTracker->acPerBitUsage[iBit] == 1)
    2560                 {
    2561                     fGlobalChange = true;
    2562                     pTracker->fMask |= fBitMask;
    2563                 }
     2561                fGlobalChange = true;
     2562                pTracker->fMask |= fBitMask;
    25642563            }
    2565             fChanged &= ~fBitMask;
    2566             if (!fChanged)
    2567                 break;
    2568         }
     2564        }
     2565
     2566        fChanged &= ~fBitMask;
    25692567    }
    25702568
     
    28992897
    29002898    /*
    2901      * Note! Reads pSession->u32AquiredGuestCaps and pDevExt->u32AcquireModeGuestCaps
     2899     * Note! Reads pSession->fAcquiredGuestCaps and pDevExt->fAcquireModeGuestCaps
    29022900     *       WITHOUT holding VBOXGUESTDEVEXT::SessionSpinlock.
    29032901     */
    2904     fAcquireModeGuestCaps = ASMAtomicUoReadU32(&pDevExt->u32AcquireModeGuestCaps);
     2902    fAcquireModeGuestCaps = ASMAtomicUoReadU32(&pDevExt->fAcquireModeGuestCaps);
    29052903    if (fAcquireModeGuestCaps == 0)
    29062904        return VMMDEV_EVENT_VALID_EVENT_MASK;
    2907     fAcquiredGuestCaps = ASMAtomicUoReadU32(&pSession->u32AquiredGuestCaps);
     2905    fAcquiredGuestCaps = ASMAtomicUoReadU32(&pSession->fAcquiredGuestCaps);
    29082906
    29092907    /*
     
    29622960    uint32_t iBit;
    29632961
    2964     pReq->u32OrMask = pDevExt->u32GuestCapsAcquired | pDevExt->SetGuestCapsTracker.fMask;
     2962    pReq->u32OrMask = pDevExt->fAcquiredGuestCaps | pDevExt->SetGuestCapsTracker.fMask;
    29652963    if (pReq->u32OrMask == pDevExt->fGuestCapsHost)
    29662964        rc = VINF_SUCCESS;
     
    30673065    RTSpinlockAcquire(pDevExt->EventSpinlock);
    30683066
    3069     if (!(pDevExt->u32SetModeGuestCaps & fOrMask))
    3070         pDevExt->u32AcquireModeGuestCaps |= fOrMask;
     3067    if (!(pDevExt->fSetModeGuestCaps & fOrMask))
     3068        pDevExt->fAcquireModeGuestCaps |= fOrMask;
    30713069    else
    30723070    {
     
    31013099     *       failure, this is intentional.
    31023100     */
    3103     fCurrentOwnedCaps      = pSession->u32AquiredGuestCaps;
     3101    fCurrentOwnedCaps      = pSession->fAcquiredGuestCaps;
    31043102    fSessionRemovedCaps    = fCurrentOwnedCaps & fNotMask;
    31053103    fSessionAddedCaps      = fOrMask & ~fCurrentOwnedCaps;
    3106     fOtherConflictingCaps  = pDevExt->u32GuestCapsAcquired & ~fCurrentOwnedCaps;
     3104    fOtherConflictingCaps  = pDevExt->fAcquiredGuestCaps & ~fCurrentOwnedCaps;
    31073105    fOtherConflictingCaps &= fSessionAddedCaps;
    31083106
     
    31113109        if (fSessionAddedCaps)
    31123110        {
    3113             pSession->u32AquiredGuestCaps |= fSessionAddedCaps;
    3114             pDevExt->u32GuestCapsAcquired |= fSessionAddedCaps;
     3111            pSession->fAcquiredGuestCaps |= fSessionAddedCaps;
     3112            pDevExt->fAcquiredGuestCaps |= fSessionAddedCaps;
    31153113        }
    31163114
    31173115        if (fSessionRemovedCaps)
    31183116        {
    3119             pSession->u32AquiredGuestCaps &= ~fSessionRemovedCaps;
    3120             pDevExt->u32GuestCapsAcquired &= ~fSessionRemovedCaps;
     3117            pSession->fAcquiredGuestCaps &= ~fSessionRemovedCaps;
     3118            pDevExt->fAcquiredGuestCaps &= ~fSessionRemovedCaps;
    31213119        }
    31223120
     
    31353133                    if (fSessionAddedCaps)
    31363134                    {
    3137                         pSession->u32AquiredGuestCaps &= ~fSessionAddedCaps;
    3138                         pDevExt->u32GuestCapsAcquired &= ~fSessionAddedCaps;
     3135                        pSession->fAcquiredGuestCaps &= ~fSessionAddedCaps;
     3136                        pDevExt->fAcquiredGuestCaps &= ~fSessionAddedCaps;
    31393137                    }
    31403138                    if (fSessionRemovedCaps)
    31413139                    {
    3142                         pSession->u32AquiredGuestCaps |= fSessionRemovedCaps;
    3143                         pDevExt->u32GuestCapsAcquired |= fSessionRemovedCaps;
     3140                        pSession->fAcquiredGuestCaps |= fSessionRemovedCaps;
     3141                        pDevExt->fAcquiredGuestCaps |= fSessionRemovedCaps;
    31443142                    }
    31453143
     
    32603258     * (Acquire mode is only used on windows at the time of writing.)
    32613259     */
    3262     if (!(fOrMask & pDevExt->u32AcquireModeGuestCaps))
     3260    if (!(fOrMask & pDevExt->fAcquireModeGuestCaps))
    32633261#endif
    32643262    {
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h

    r54608 r54613  
    216216     * Protected by VBOXGUESTDEVEXT::SessionSpinlock, but is unfortunately read
    217217     * without holding the lock in a couple of places. */
    218     uint32_t volatile           u32AcquireModeGuestCaps;
     218    uint32_t volatile           fAcquireModeGuestCaps;
    219219    /** Guest capabilities which have been set to "set" mode.  This just means
    220220     * that they have been blocked from ever being set to "acquire" mode. */
    221     uint32_t                    u32SetModeGuestCaps;
     221    uint32_t                    fSetModeGuestCaps;
    222222    /** Mask of all capabilities which are currently acquired by some session
    223223     * and as such reported to the host. */
    224     uint32_t                    u32GuestCapsAcquired;
     224    uint32_t                    fAcquiredGuestCaps;
    225225    /** Usage counters for guest capabilities in "set" mode. Indexed by
    226226     *  capability bit number, one count per session using a capability. */
     
    283283     * Protected by VBOXGUESTDEVEXT::SessionSpinlock, but is unfortunately read
    284284     * without holding the lock in a couple of places. */
    285     uint32_t volatile           u32AquiredGuestCaps;
     285    uint32_t volatile           fAcquiredGuestCaps;
    286286    /** Guest capabilities in "set" mode for this session.
    287287     * These accumulated for sessions via VBOXGUESTDEVEXT::acGuestCapsSet and
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