Chromium Code Reviews| Index: Source/wtf/Atomics.h |
| diff --git a/Source/wtf/Atomics.h b/Source/wtf/Atomics.h |
| index fb36bf6fb042a60996f0b929c3fc58b377e696c4..793cb57f7df61db2fd4ffd6083f4d1d611874935 100644 |
| --- a/Source/wtf/Atomics.h |
| +++ b/Source/wtf/Atomics.h |
| @@ -54,14 +54,34 @@ namespace WTF { |
| // atomicAdd returns the result of the addition. |
| ALWAYS_INLINE int atomicAdd(int volatile* addend, int increment) |
| { |
| - return InterlockedExchangeAdd(reinterpret_cast<long volatile*>(addend), static_cast<long>(increment)) + increment; |
| + return InterlockedExchangeAdd(reinterpret_cast<LONG volatile*>(addend), static_cast<LONG>(increment)) + increment; |
|
tkent
2014/11/17 10:30:15
Replacing |long| with |LONG| is inconsistent with
haraken
2014/11/17 10:43:36
Done.
|
| } |
| +ALWAYS_INLINE unsigned atomicAdd(unsigned volatile* addend, unsigned increment) |
| +{ |
| + return InterlockedExchangeAdd(reinterpret_cast<ULONG volatile*>(addend), static_cast<ULONG>(increment)) + increment; |
|
tkent
2014/11/17 10:30:15
Why do you cast to ULONG? The arguments of Interl
haraken
2014/11/17 10:43:36
Fixed.
|
| +} |
| +#if defined(_WIN64) |
| +ALWAYS_INLINE unsigned long atomicAdd(unsigned long volatile* addend, unsigned long increment) |
| +{ |
| + return InterlockedExchangeAdd64(reinterpret_cast<ULONGLONG volatile*>(addend), static_cast<ULONGLONG>(increment)) + increment; |
|
tkent
2014/11/17 10:30:15
Ditto. |LONGLONG volatile*| and |LONGLONG|.
haraken
2014/11/17 10:43:36
Done.
|
| +} |
| +#endif |
| // atomicSubtract returns the result of the subtraction. |
| ALWAYS_INLINE int atomicSubtract(int volatile* addend, int decrement) |
| { |
| - return InterlockedExchangeAdd(reinterpret_cast<long volatile*>(addend), static_cast<long>(-decrement)) - decrement; |
| + return InterlockedExchangeAdd(reinterpret_cast<LONG volatile*>(addend), static_cast<LONG>(-decrement)) - decrement; |
| } |
| +ALWAYS_INLINE unsigned atomicSubtract(unsigned volatile* addend, unsigned decrement) |
| +{ |
| + return InterlockedExchangeAdd(reinterpret_cast<ULONG volatile*>(addend), -static_cast<LONG>(decrement)) - decrement; |
| +} |
| +#if defined(_WIN64) |
| +ALWAYS_INLINE unsigned long atomicSubtract(unsigned long volatile* addend, unsigned long decrement) |
| +{ |
| + return InterlockedExchangeAdd64(reinterpret_cast<ULONGLONG volatile*>(addend), -static_cast<LONGLONG>(decrement)) - decrement; |
| +} |
| +#endif |
| ALWAYS_INLINE int atomicIncrement(int volatile* addend) { return InterlockedIncrement(reinterpret_cast<long volatile*>(addend)); } |
| ALWAYS_INLINE int atomicDecrement(int volatile* addend) { return InterlockedDecrement(reinterpret_cast<long volatile*>(addend)); } |
| @@ -86,8 +106,12 @@ ALWAYS_INLINE void atomicSetOneToZero(int volatile* ptr) |
| // atomicAdd returns the result of the addition. |
| ALWAYS_INLINE int atomicAdd(int volatile* addend, int increment) { return __sync_add_and_fetch(addend, increment); } |
| +ALWAYS_INLINE unsigned atomicAdd(unsigned volatile* addend, unsigned increment) { return __sync_add_and_fetch(addend, increment); } |
| +ALWAYS_INLINE unsigned long atomicAdd(unsigned long volatile* addend, unsigned long increment) { return __sync_add_and_fetch(addend, increment); } |
| // atomicSubtract returns the result of the subtraction. |
| ALWAYS_INLINE int atomicSubtract(int volatile* addend, int decrement) { return __sync_sub_and_fetch(addend, decrement); } |
| +ALWAYS_INLINE unsigned atomicSubtract(unsigned volatile* addend, unsigned decrement) { return __sync_sub_and_fetch(addend, decrement); } |
| +ALWAYS_INLINE unsigned long atomicSubtract(unsigned long volatile* addend, unsigned long decrement) { return __sync_sub_and_fetch(addend, decrement); } |
| ALWAYS_INLINE int atomicIncrement(int volatile* addend) { return atomicAdd(addend, 1); } |
| ALWAYS_INLINE int atomicDecrement(int volatile* addend) { return atomicSubtract(addend, 1); } |