[runtime] Add arch size InterlockedAdd
authorVlad Brezae <brezaevlad@gmail.com>
Mon, 3 Apr 2017 21:30:45 +0000 (00:30 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Tue, 4 Apr 2017 22:16:47 +0000 (01:16 +0300)
mono/utils/atomic.h
mono/utils/mono-mmap.c

index 2fd9ebb27389386b12a0c6ae4c8b899ed086b17e..decab93c7a96e58094b18a6a97047fb533a8c0b2 100755 (executable)
@@ -458,4 +458,10 @@ extern void InterlockedWritePointer(volatile gpointer *dst, gpointer val);
 
 #endif
 
+#if SIZEOF_VOID_P == 4
+#define InterlockedAddP(p,add) InterlockedAdd ((volatile gint32*)p, (gint32)add)
+#else
+#define InterlockedAddP(p,add) InterlockedAdd64 ((volatile gint64*)p, (gint64)add)
+#endif
+
 #endif /* _WAPI_ATOMIC_H_ */
index d579d5a46a5cadbed0d515f4ed79d6803cea00d9..b5e2ee2757d8df361f2d6be23da71166b745b881 100644 (file)
@@ -88,13 +88,8 @@ static size_t alloc_limit;
 void
 account_mem (MonoMemAccountType type, ssize_t size)
 {
-#if SIZEOF_VOID_P == 4
-       InterlockedAdd ((volatile gint32*)&allocation_count [type], (gint32)size);
-       InterlockedAdd ((volatile gint32*)&total_allocation_count, (gint32)size);
-#else
-       InterlockedAdd64 ((volatile gint64*)&allocation_count [type], (gint64)size);
-       InterlockedAdd64 ((volatile gint64*)&total_allocation_count, (gint64)size);
-#endif
+       InterlockedAddP (&allocation_count [type], size);
+       InterlockedAddP (&total_allocation_count, size);
 }
 
 void