From e2b4f546cf3b87f70dc1245e076ed0e661f532ca Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Tue, 4 Apr 2017 00:30:45 +0300 Subject: [PATCH] [runtime] Add arch size InterlockedAdd --- mono/utils/atomic.h | 6 ++++++ mono/utils/mono-mmap.c | 9 ++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mono/utils/atomic.h b/mono/utils/atomic.h index 2fd9ebb2738..decab93c7a9 100755 --- a/mono/utils/atomic.h +++ b/mono/utils/atomic.h @@ -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_ */ diff --git a/mono/utils/mono-mmap.c b/mono/utils/mono-mmap.c index d579d5a46a5..b5e2ee2757d 100644 --- a/mono/utils/mono-mmap.c +++ b/mono/utils/mono-mmap.c @@ -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 -- 2.25.1