[corlib] Improve System.Security.Claims. Fixes #22282
[mono.git] / mono / interpreter / interp.c
index 2e7d8da72d77a5d1b6478a43c04ef5a43bf1cb6b..4525ff69ab35c533d92938550de86dddec4ed887 100644 (file)
@@ -24,7 +24,7 @@
 #include <math.h>
 #include <locale.h>
 
-#include <mono/os/gc_wrapper.h>
+#include <mono/utils/gc_wrapper.h>
 
 #ifdef HAVE_ALLOCA_H
 #   include <alloca.h>
@@ -254,7 +254,7 @@ interp_create_remoting_trampoline (MonoMethod *method, MonoRemotingTarget target
        return mono_interp_get_runtime_method (mono_marshal_get_remoting_invoke_for_target (method, target));
 }
 
-static CRITICAL_SECTION runtime_method_lookup_section;
+static mono_mutex_t runtime_method_lookup_section;
 
 RuntimeMethod*
 mono_interp_get_runtime_method (MonoMethod *method)
@@ -262,9 +262,9 @@ mono_interp_get_runtime_method (MonoMethod *method)
        MonoDomain *domain = mono_domain_get ();
        RuntimeMethod *rtm;
 
-       EnterCriticalSection (&runtime_method_lookup_section);
-       if ((rtm = g_hash_table_lookup (domain->jit_code_hash, method))) {
-               LeaveCriticalSection (&runtime_method_lookup_section);
+       mono_mutex_lock (&runtime_method_lookup_section);
+       if ((rtm = mono_internal_hash_table_lookup (&domain->jit_code_hash, method))) {
+               mono_mutex_unlock (&runtime_method_lookup_section);
                return rtm;
        }
        rtm = mono_mempool_alloc (domain->mp, sizeof (RuntimeMethod));
@@ -273,8 +273,8 @@ mono_interp_get_runtime_method (MonoMethod *method)
        rtm->param_count = mono_method_signature (method)->param_count;
        rtm->hasthis = mono_method_signature (method)->hasthis;
        rtm->valuetype = method->klass->valuetype;
-       g_hash_table_insert (domain->jit_code_hash, method, rtm);
-       LeaveCriticalSection (&runtime_method_lookup_section);
+       mono_internal_hash_table_insert (&domain->jit_code_hash, method, rtm);
+       mono_mutex_unlock (&runtime_method_lookup_section);
 
        return rtm;
 }
@@ -833,7 +833,7 @@ dump_stack (stackval *stack, stackval *sp)
                return g_string_free (str, FALSE);
        
        while (s < sp) {
-               g_string_sprintfa (str, "[%lld/0x%0llx] ", s->data.l, s->data.l);
+               g_string_append_printf (str, "[%lld/0x%0llx] ", s->data.l, s->data.l);
                ++s;
        }
        return g_string_free (str, FALSE);
@@ -851,7 +851,7 @@ dump_stackval (GString *str, stackval *s, MonoType *type)
        case MONO_TYPE_U4:
        case MONO_TYPE_CHAR:
        case MONO_TYPE_BOOLEAN:
-               g_string_sprintfa (str, "[%d] ", s->data.i);
+               g_string_append_printf (str, "[%d] ", s->data.i);
                break;
        case MONO_TYPE_STRING:
        case MONO_TYPE_SZARRAY:
@@ -861,22 +861,22 @@ dump_stackval (GString *str, stackval *s, MonoType *type)
        case MONO_TYPE_PTR:
        case MONO_TYPE_I:
        case MONO_TYPE_U:
-               g_string_sprintfa (str, "[%p] ", s->data.p);
+               g_string_append_printf (str, "[%p] ", s->data.p);
                break;
        case MONO_TYPE_VALUETYPE:
                if (type->data.klass->enumtype)
-                       g_string_sprintfa (str, "[%d] ", s->data.i);
+                       g_string_append_printf (str, "[%d] ", s->data.i);
                else
-                       g_string_sprintfa (str, "[vt:%p] ", s->data.p);
+                       g_string_append_printf (str, "[vt:%p] ", s->data.p);
                break;
        case MONO_TYPE_R4:
        case MONO_TYPE_R8:
-               g_string_sprintfa (str, "[%g] ", s->data.f);
+               g_string_append_printf (str, "[%g] ", s->data.f);
                break;
        case MONO_TYPE_I8:
        case MONO_TYPE_U8:
        default:
-               g_string_sprintfa (str, "[%lld/0x%0llx] ", s->data.l, s->data.l);
+               g_string_append_printf (str, "[%lld/0x%0llx] ", s->data.l, s->data.l);
                break;
        }
 }
@@ -892,7 +892,7 @@ dump_args (MonoInvocation *inv)
                return g_string_free (str, FALSE);
 
        if (signature->hasthis)
-               g_string_sprintfa (str, "%p ", inv->obj);
+               g_string_append_printf (str, "%p ", inv->obj);
 
        for (i = 0; i < signature->param_count; ++i)
                dump_stackval (str, inv->stack_args + i, signature->params [i]);
@@ -947,10 +947,10 @@ dump_frame (MonoInvocation *inv)
                        args = dump_args (inv);
                        name = mono_method_full_name (method, TRUE);
                        if (source)
-                               g_string_sprintfa (str, "#%d: 0x%05x %-10s in %s (%s) at %s\n", i, codep, opname,
+                               g_string_append_printf (str, "#%d: 0x%05x %-10s in %s (%s) at %s\n", i, codep, opname,
                                                   name, args, source);
                        else
-                               g_string_sprintfa (str, "#%d: 0x%05x %-10s in %s (%s)\n", i, codep, opname,
+                               g_string_append_printf (str, "#%d: 0x%05x %-10s in %s (%s)\n", i, codep, opname,
                                                   name, args);
                        g_free (name);
                        g_free (args);
@@ -1301,7 +1301,7 @@ do_icall (ThreadContext *context, int op, stackval *sp, gpointer ptr)
        return sp;
 }
 
-static CRITICAL_SECTION create_method_pointer_mutex;
+static mono_mutex_t create_method_pointer_mutex;
 
 static MonoGHashTable *method_pointer_hash = NULL;
 
@@ -1311,14 +1311,14 @@ mono_create_method_pointer (MonoMethod *method)
        gpointer addr;
        MonoJitInfo *ji;
 
-       EnterCriticalSection (&create_method_pointer_mutex);
+       mono_mutex_lock (&create_method_pointer_mutex);
        if (!method_pointer_hash) {
                MONO_GC_REGISTER_ROOT (method_pointer_hash);
                method_pointer_hash = mono_g_hash_table_new (NULL, NULL);
        }
        addr = mono_g_hash_table_lookup (method_pointer_hash, method);
        if (addr) {
-               LeaveCriticalSection (&create_method_pointer_mutex);
+               mono_mutex_unlock (&create_method_pointer_mutex);
                return addr;
        }
 
@@ -1338,7 +1338,7 @@ mono_create_method_pointer (MonoMethod *method)
                addr = mono_arch_create_method_pointer (method);
 
        mono_g_hash_table_insert (method_pointer_hash, method, addr);
-       LeaveCriticalSection (&create_method_pointer_mutex);
+       mono_mutex_unlock (&create_method_pointer_mutex);
 
        return addr;
 }
@@ -4148,7 +4148,7 @@ test_load_class (MonoImage* image)
 static void
 add_signal_handler (int signo, void (*handler)(int))
 {
-#ifdef PLATFORM_WIN32
+#ifdef HOST_WIN32
        signal (signo, handler);
 #else
        struct sigaction sa;
@@ -4394,8 +4394,8 @@ mono_interp_init(const char *file)
 
        thread_context_id = TlsAlloc ();
        TlsSetValue (thread_context_id, NULL);
-       InitializeCriticalSection (&runtime_method_lookup_section);
-       InitializeCriticalSection (&create_method_pointer_mutex);
+       mono_mutex_init_recursive (&runtime_method_lookup_section);
+       mono_mutex_init_recursive (&create_method_pointer_mutex);
 
        mono_runtime_install_handlers ();
        mono_interp_transform_init ();