VirtualBox

Changeset 90649 in vbox


Ignore:
Timestamp:
Aug 12, 2021 10:16:42 AM (3 years ago)
Author:
vboxsync
Message:

iprt/critsectrw.h: Need to have the state union as a separate non-volatile type. bugref:6695

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/critsect.h

    r90637 r90649  
    382382
    383383/**
     384 * Union that allows us to atomically update both the state and
     385 * exclusive owner if the hardware supports cmpxchg16b or similar.
     386 */
     387typedef union RTCRITSECTRWSTATE
     388{
     389    struct
     390    {
     391        /** The state variable.
     392         * All accesses are atomic and it bits are defined like this:
     393         *      Bits 0..14  - cReads.
     394         *      Bit 15      - Unused.
     395         *      Bits 16..31 - cWrites.
     396         *      Bit 31      - fDirection; 0=Read, 1=Write.
     397         *      Bits 32..46 - cWaitingReads
     398         *      Bit 47      - Unused.
     399         *      Bits 48..62 - cWaitingWrites - doesn't make sense here, not used.
     400         *      Bit 63      - Unused.
     401         */
     402        uint64_t                    u64State;
     403        /** The write owner. */
     404        RTNATIVETHREAD              hNativeWriter;
     405    } s;
     406    RTUINT128U                      u128;
     407} RTCRITSECTRWSTATE;
     408
     409
     410/**
    384411 * Read/write critical section.
    385412 */
     
    402429     *  of the lock counts as the first one.) */
    403430    uint32_t volatile                   cWriteRecursions;
    404     /** Union that allows us to atomically update both the state and
    405      * exclusive owner if the hardware supports cmpxchg16b or similar. */
    406     union
    407     {
    408         struct
    409         {
    410             /** The state variable.
    411              * All accesses are atomic and it bits are defined like this:
    412              *      Bits 0..14  - cReads.
    413              *      Bit 15      - Unused.
    414              *      Bits 16..31 - cWrites.
    415              *      Bit 31      - fDirection; 0=Read, 1=Write.
    416              *      Bits 32..46 - cWaitingReads
    417              *      Bit 47      - Unused.
    418              *      Bits 48..62 - cWaitingWrites - doesn't make sense here, not used.
    419              *      Bit 63      - Unused.
    420              */
    421             uint64_t volatile           u64State;
    422             /** The write owner. */
    423             RTNATIVETHREAD volatile     hNativeWriter;
    424         } s;
    425         RTUINT128U volatile             u128;
    426     } u;
     431    /** The core state. */
     432    RTCRITSECTRWSTATE volatile          u;
    427433
    428434    /** What the writer threads are blocking on. */
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