diff options
-rw-r--r-- | src/util/u_atomic.h | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/util/u_atomic.h b/src/util/u_atomic.h index 728322bfe50..192cc8d1e0e 100644 --- a/src/util/u_atomic.h +++ b/src/util/u_atomic.h @@ -90,57 +90,57 @@ /* Implement _InterlockedCompareExchange8 in terms of _InterlockedCompareExchange16 */ static __inline char -_InterlockedCompareExchange8(char volatile *Destination8, char Exchange8, char Comparand8) +_InterlockedCompareExchange8(char volatile *destination8, char exchange8, char comparand8) { - INT_PTR DestinationAddr = (INT_PTR)Destination8; - short volatile *Destination16 = (short volatile *)(DestinationAddr & ~1); - const short Shift8 = (DestinationAddr & 1) * 8; - const short Mask8 = 0xff << Shift8; - short Initial16 = *Destination16; - char Initial8 = Initial16 >> Shift8; - while (Initial8 == Comparand8) { - /* initial *Destination8 matches, so try exchange it while keeping the + INT_PTR destinationAddr = (INT_PTR)destination8; + short volatile *destination16 = (short volatile *)(destinationAddr & ~1); + const short shift8 = (destinationAddr & 1) * 8; + const short mask8 = 0xff << shift8; + short initial16 = *destination16; + char initial8 = initial16 >> shift8; + while (initial8 == comparand8) { + /* initial *destination8 matches, so try exchange it while keeping the * neighboring byte untouched */ - short Exchange16 = (Initial16 & ~Mask8) | ((short)Exchange8 << Shift8); - short Comparand16 = Initial16; - short Initial16 = _InterlockedCompareExchange16(Destination16, Exchange16, Comparand16); - if (Initial16 == Comparand16) { + short exchange16 = (initial16 & ~mask8) | ((short)exchange8 << shift8); + short comparand16 = initial16; + short initial16 = _InterlockedCompareExchange16(destination16, exchange16, comparand16); + if (initial16 == comparand16) { /* succeeded */ - return Comparand8; + return comparand8; } /* something changed, retry with the new initial value */ - Initial8 = Initial16 >> Shift8; + initial8 = initial16 >> shift8; } - return Initial8; + return initial8; } /* Implement _InterlockedExchangeAdd16 in terms of _InterlockedCompareExchange16 */ static __inline short -_InterlockedExchangeAdd16(short volatile *Addend, short Value) +_InterlockedExchangeAdd16(short volatile *addend, short value) { - short Initial = *Addend; - short Comparand; + short initial = *addend; + short comparand; do { - short Exchange = Initial + Value; - Comparand = Initial; - /* if *Addend==Comparand then *Addend=Exchange, return original *Addend */ - Initial = _InterlockedCompareExchange16(Addend, Exchange, Comparand); - } while(Initial != Comparand); - return Comparand; + short exchange = initial + value; + comparand = initial; + /* if *addend==comparand then *addend=exchange, return original *addend */ + initial = _InterlockedCompareExchange16(addend, exchange, comparand); + } while(initial != comparand); + return comparand; } /* Implement _InterlockedExchangeAdd8 in terms of _InterlockedCompareExchange8 */ static __inline char -_InterlockedExchangeAdd8(char volatile *Addend, char Value) +_InterlockedExchangeAdd8(char volatile *addend, char value) { - char Initial = *Addend; - char Comparand; + char initial = *addend; + char comparand; do { - char Exchange = Initial + Value; - Comparand = Initial; - Initial = _InterlockedCompareExchange8(Addend, Exchange, Comparand); - } while(Initial != Comparand); - return Comparand; + char exchange = initial + value; + comparand = initial; + initial = _InterlockedCompareExchange8(addend, exchange, comparand); + } while(initial != comparand); + return comparand; } #endif /* _MSC_VER < 1600 */ |