#include <mono/utils/mono-os-mutex.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-compiler.h>
+#include <mono/utils/unlocked.h>
#if HAVE_BOEHM_GC
#define THREAD_LOCAL_ALLOC 1
#include "private/pthread_support.h"
-#if defined(PLATFORM_MACOSX) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
+#if defined(HOST_DARWIN) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
void *pthread_get_stackaddr_np(pthread_t);
#endif
default_push_other_roots = GC_push_other_roots;
GC_push_other_roots = mono_push_other_roots;
-#if !defined(PLATFORM_ANDROID)
+#if !defined(HOST_ANDROID)
/* If GC_no_dls is set to true, GC_find_limit is not called. This causes a seg fault on Android. */
GC_no_dls = TRUE;
#endif
mono_gc_collect (int generation)
{
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->gc_induced++;
+ InterlockedIncrement (&mono_perfcounters->gc_induced);
#endif
GC_gcollect ();
}
MONO_GC_BEGIN (1);
#ifndef DISABLE_PERFCOUNTERS
if (mono_perfcounters)
- mono_perfcounters->gc_collections0++;
+ InterlockedIncrement (&mono_perfcounters->gc_collections0);
#endif
- gc_stats.major_gc_count ++;
+ InterlockedIncrement (&gc_stats.major_gc_count);
gc_start_time = mono_100ns_ticks ();
break;
if (mono_perfcounters) {
guint64 heap_size = GC_get_heap_size ();
guint64 used_size = heap_size - GC_get_free_bytes ();
- mono_perfcounters->gc_total_bytes = used_size;
- mono_perfcounters->gc_committed_bytes = heap_size;
- mono_perfcounters->gc_reserved_bytes = heap_size;
- mono_perfcounters->gc_gen0size = heap_size;
+ /* FIXME: change these to InterlockedWrite64 () */
+ UnlockedWrite64 (&mono_perfcounters->gc_total_bytes, used_size);
+ UnlockedWrite64 (&mono_perfcounters->gc_committed_bytes, heap_size);
+ UnlockedWrite64 (&mono_perfcounters->gc_reserved_bytes, heap_size);
+ UnlockedWrite64 (&mono_perfcounters->gc_gen0size, heap_size);
}
#endif
- gc_stats.major_gc_time += mono_100ns_ticks () - gc_start_time;
+ UnlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
mono_trace_message (MONO_TRACE_GC, "gc took %" G_GINT64_FORMAT " usecs", (mono_100ns_ticks () - gc_start_time) / 10);
break;
default:
guint64 heap_size = GC_get_heap_size ();
#ifndef DISABLE_PERFCOUNTERS
if (mono_perfcounters) {
- mono_perfcounters->gc_committed_bytes = heap_size;
- mono_perfcounters->gc_reserved_bytes = heap_size;
- mono_perfcounters->gc_gen0size = heap_size;
+ /* FIXME: change these to InterlockedWrite64 () */
+ UnlockedWrite64 (&mono_perfcounters->gc_committed_bytes, heap_size);
+ UnlockedWrite64 (&mono_perfcounters->gc_reserved_bytes, heap_size);
+ UnlockedWrite64 (&mono_perfcounters->gc_gen0size, heap_size);
}
#endif
}
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->gc_num_handles++;
+ InterlockedIncrement (&mono_perfcounters->gc_num_handles);
#endif
unlock_handles (handles);
res = MONO_GC_HANDLE (slot, handles->type);
/* print a warning? */
}
#ifndef DISABLE_PERFCOUNTERS
- mono_perfcounters->gc_num_handles--;
+ InterlockedDecrement (&mono_perfcounters->gc_num_handles);
#endif
/*g_print ("freed entry %d of type %d\n", slot, handles->type);*/
unlock_handles (handles);