VirtualBox

Changeset 19499 in vbox for trunk


Ignore:
Timestamp:
May 7, 2009 6:10:25 PM (16 years ago)
Author:
vboxsync
Message:

TMInternal.h: Made TMTIMER::offShcduleNext volatile and switched from ASMAtomicXchgSize to ASMAtomicXchgU32 for updating the state.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/TMInternal.h

    r19486 r19499  
    2727#include <iprt/time.h>
    2828#include <iprt/timer.h>
     29#include <iprt/assert.h>
    2930#include <VBox/stam.h>
    3031#include <VBox/pdmcritsect.h>
     
    166167    volatile TMTIMERSTATE   enmState;
    167168    /** Timer relative offset to the next timer in the schedule list. */
    168     int32_t                 offScheduleNext;
     169    int32_t volatile        offScheduleNext;
    169170
    170171    /** Timer relative offset to the next timer in the chain. */
     
    189190#endif
    190191} TMTIMER;
     192AssertCompileMemberSize(TMTIMER, enmState, sizeof(uint32_t));
    191193
    192194
     
    196198#if 1
    197199# define TM_SET_STATE(pTimer, state) \
    198     ASMAtomicXchgSize(&(pTimer)->enmState, state)
     200    ASMAtomicWriteU32((uint32_t volatile *)&(pTimer)->enmState, state)
    199201#else
    200202# define TM_SET_STATE(pTimer, state) \
    201     do { Log(("%s: %p: %d -> %d\n", __FUNCTION__, (pTimer), (pTimer)->enmState, state)); \
    202          ASMAtomicXchgSize(&(pTimer)->enmState, state);\
     203    do { \
     204        uint32_t uOld1 = (pTimer)->enmState; \
     205        Log(("%s: %p: %d -> %d\n", __FUNCTION__, (pTimer), (pTimer)->enmState, state)); \
     206        uint32_t uOld2 = ASMAtomicXchgU32((uint32_t volatile *)&(pTimer)->enmState, state); \
     207        Assert(uOld1 == uOld2); \
    203208    } while (0)
    204209#endif
     
    209214#if 1
    210215# define TM_TRY_SET_STATE(pTimer, StateNew, StateOld, fRc) \
    211     ASMAtomicCmpXchgSize(&(pTimer)->enmState, StateNew, StateOld, fRc)
     216    (fRc) = ASMAtomicCmpXchgU32((uint32_t volatile *)&(pTimer)->enmState, StateNew, StateOld)
    212217#else
    213218# define TM_TRY_SET_STATE(pTimer, StateNew, StateOld, fRc) \
    214     do { ASMAtomicCmpXchgSize(&(pTimer)->enmState, StateNew, StateOld, fRc); \
     219    do { (fRc) = ASMAtomicCmpXchgU32((uint32_t volatile *)&(pTimer)->enmState, StateNew, StateOld); \
    215220         Log(("%s: %p: %d -> %d %RTbool\n", __FUNCTION__, (pTimer), StateOld, StateNew, fRc)); \
    216221    } while (0)
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