276a519f0d3d7d8b5b9bcd52dd0057367ebdf1f4
[mono.git] / mono / metadata / runtime.c
1 /*
2  * runtime.c: Runtime functions
3  *
4  * Authors:
5  *  Jonathan Pryor 
6  *
7  * Copyright 2010 Novell, Inc (http://www.novell.com)
8  */
9
10 #include <config.h>
11
12 #include <glib.h>
13
14 #include <mono/metadata/appdomain.h>
15 #include <mono/metadata/class.h>
16 #include <mono/metadata/class-internals.h>
17 #include <mono/metadata/runtime.h>
18 #include <mono/metadata/monitor.h>
19
20 static void
21 fire_process_exit_event (MonoDomain *domain, gpointer user_data)
22 {
23         MonoClassField *field;
24         gpointer pa [2];
25         MonoObject *delegate, *exc;
26
27         field = mono_class_get_field_from_name (mono_defaults.appdomain_class, "ProcessExit");
28         g_assert (field);
29
30         delegate = *(MonoObject **)(((char *)domain->domain) + field->offset); 
31         if (delegate == NULL)
32                 return;
33
34         pa [0] = domain;
35         pa [1] = NULL;
36         mono_runtime_delegate_invoke (delegate, pa, &exc);
37 }
38
39 void
40 mono_runtime_shutdown (void)
41 {
42         mono_domain_foreach (fire_process_exit_event, NULL);
43 }
44
45
46 gboolean
47 mono_runtime_is_critical_method (MonoMethod *method)
48 {
49         if (mono_monitor_is_il_fastpath_wrapper (method))
50                 return TRUE;
51         return FALSE;
52 }