[threads] Remove mono_threads_create_thread (#4411)
[mono.git] / mono / utils / monobitset.c
index 8c49c75397272a304d7fba368fb58a6a81d5549e..2f6b6c501037c6cd070612896455c227b3f2b9ae 100644 (file)
@@ -35,7 +35,7 @@ mono_bitset_new (guint32 max_size, guint32 flags) {
        guint32 real_size = (max_size + BITS_PER_CHUNK - 1) / BITS_PER_CHUNK;
        MonoBitSet *result;
 
-       result = g_malloc0 (sizeof (MonoBitSet) + sizeof (gsize) * (real_size - MONO_ZERO_LEN_ARRAY));
+       result = (MonoBitSet *) g_malloc0 (sizeof (MonoBitSet) + sizeof (gsize) * (real_size - MONO_ZERO_LEN_ARRAY));
        result->size = real_size * BITS_PER_CHUNK;
        result->flags = flags;
        return result;
@@ -54,7 +54,7 @@ mono_bitset_new (guint32 max_size, guint32 flags) {
 MonoBitSet *
 mono_bitset_mem_new (gpointer mem, guint32 max_size, guint32 flags) {
        guint32 real_size = (max_size + BITS_PER_CHUNK - 1) / BITS_PER_CHUNK;
-       MonoBitSet *result = mem;
+       MonoBitSet *result = (MonoBitSet *) mem;
 
        result->size = real_size * BITS_PER_CHUNK;
        result->flags = flags | MONO_BITSET_DONT_FREE;
@@ -211,7 +211,10 @@ mono_bitset_count (const MonoBitSet *set) {
        for (i = 0; i < set->size / BITS_PER_CHUNK; ++i) {
                d = set->data [i];
 #ifdef __GNUC__
-               count += __builtin_popcount (d);
+               if (sizeof (gsize) == sizeof (unsigned int))
+                       count += __builtin_popcount (d);
+               else
+                       count += __builtin_popcountll (d);
 #else
                while (d) {
                        count ++;