X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fhazard-pointer.c;h=0d7d37ac736c04065cf200e8be8a0ae10ab9a925;hb=e87716bc7e10e2b482d72604b866906ff9fcad06;hp=b412e77d7d535ed088203c81a839caa74c545133;hpb=5e4093ab13c236eeb250cae17323bee655ccc936;p=mono.git diff --git a/mono/utils/hazard-pointer.c b/mono/utils/hazard-pointer.c index b412e77d7d5..0d7d37ac736 100644 --- a/mono/utils/hazard-pointer.c +++ b/mono/utils/hazard-pointer.c @@ -6,16 +6,24 @@ #include +#include + #include #include #include -#include #include -#include #include -#include #include +#include +#ifdef SGEN_WITHOUT_MONO +#include +#include +#else +#include +#include +#include #include +#endif typedef struct { gpointer p; @@ -46,7 +54,7 @@ static volatile gint32 overflow_busy [HAZARD_TABLE_OVERFLOW]; static MonoLockFreeArrayQueue delayed_free_queue = MONO_LOCK_FREE_ARRAY_QUEUE_INIT (sizeof (DelayedFreeItem)); /* The table for small ID assignment */ -static CRITICAL_SECTION small_id_mutex; +static mono_mutex_t small_id_mutex; static int small_id_next; static int highest_small_id = -1; static MonoBitSet *small_id_table; @@ -63,7 +71,7 @@ mono_thread_small_id_alloc (void) { int i, id = -1; - EnterCriticalSection (&small_id_mutex); + mono_mutex_lock (&small_id_mutex); if (!small_id_table) small_id_table = mono_bitset_new (1, 0); @@ -101,7 +109,7 @@ mono_thread_small_id_alloc (void) int num_pages = (hazard_table_size * sizeof (MonoThreadHazardPointers) + pagesize - 1) / pagesize; if (hazard_table == NULL) { - hazard_table = mono_valloc (NULL, + hazard_table = (MonoThreadHazardPointers *volatile) mono_valloc (NULL, sizeof (MonoThreadHazardPointers) * HAZARD_TABLE_MAX_SIZE, MONO_MMAP_NONE); } @@ -125,7 +133,7 @@ mono_thread_small_id_alloc (void) mono_memory_write_barrier (); } - LeaveCriticalSection (&small_id_mutex); + mono_mutex_unlock (&small_id_mutex); return id; } @@ -134,13 +142,13 @@ void mono_thread_small_id_free (int id) { /* MonoBitSet operations are not atomic. */ - EnterCriticalSection (&small_id_mutex); + mono_mutex_lock (&small_id_mutex); g_assert (id >= 0 && id < small_id_table->size); g_assert (mono_bitset_test_fast (small_id_table, id)); mono_bitset_clear_fast (small_id_table, id); - LeaveCriticalSection (&small_id_mutex); + mono_mutex_unlock (&small_id_mutex); } static gboolean @@ -345,7 +353,7 @@ mono_thread_smr_init (void) { int i; - InitializeCriticalSection(&small_id_mutex); + mono_mutex_init_recursive(&small_id_mutex); mono_counters_register ("Hazardous pointers", MONO_COUNTER_JIT | MONO_COUNTER_INT, &hazardous_pointer_count); for (i = 0; i < HAZARD_TABLE_OVERFLOW; ++i) {