Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2173)

Unified Diff: Source/wtf/Atomics.h

Issue 723513002: Oilpan: Refactor the way we calculate heap statistics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Source/platform/heap/Heap.cpp ('K') | « Source/platform/heap/ThreadState.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/Atomics.h
diff --git a/Source/wtf/Atomics.h b/Source/wtf/Atomics.h
index fb36bf6fb042a60996f0b929c3fc58b377e696c4..980f6fc275df5ae94effd28a1269b3e7cc1cecab 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;
}
+ALWAYS_INLINE unsigned long atomicAdd(unsigned long volatile* addend, unsigned long increment)
+{
+ return InterlockedExchangeAdd(reinterpret_cast<ULONG volatile*>(addend), static_cast<LONG>(increment)) + increment;
+}
+#if defined(_WIN64)
+ALWAYS_INLINE unsigned long long atomicAdd(unsigned long long volatile* addend, unsigned long long increment)
+{
+ return InterlockedExchangeAdd64(reinterpret_cast<ULONGLONG volatile*>(addend), static_cast<LONGLONG>(increment)) + increment;
+}
+#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 long atomicSubtract(unsigned long volatile* addend, unsigned long decrement)
+{
+ return InterlockedExchangeAdd(reinterpret_cast<ULONG volatile*>(addend), static_cast<LONG>(-decrement)) - decrement;
+}
+#if defined(_WIN64)
+ALWAYS_INLINE unsigned long long atomicSubtract(unsigned long long volatile* addend, unsigned long 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 long atomicAdd(unsigned long volatile* addend, unsigned long increment) { return __sync_add_and_fetch(addend, increment); }
+ALWAYS_INLINE unsigned long long atomicAdd(unsigned long long volatile* addend, unsigned long 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 long atomicSubtract(unsigned long volatile* addend, unsigned long decrement) { return __sync_sub_and_fetch(addend, decrement); }
+ALWAYS_INLINE unsigned long long atomicSubtract(unsigned long long volatile* addend, unsigned long 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); }
« Source/platform/heap/Heap.cpp ('K') | « Source/platform/heap/ThreadState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698