Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / metadata / runtime.c
index 078b4cef997d8ec11653d69df65bba2bd521bf1a..226983cef696d42657e2dde5dd87a62418814243 100644 (file)
@@ -1,8 +1,9 @@
-/*
- * runtime.c: Runtime functions
+/**
+ * \file
+ * Runtime functions
  *
  * Authors:
- *  Jonathan Pryor 
+ *  Jonathan Pryor
  *
  * Copyright 2010 Novell, Inc (http://www.novell.com)
  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
 #include <mono/metadata/runtime.h>
 #include <mono/metadata/monitor.h>
 #include <mono/metadata/threads-types.h>
-#include <mono/metadata/threadpool-ms.h>
+#include <mono/metadata/threadpool.h>
 #include <mono/metadata/marshal.h>
 #include <mono/utils/atomic.h>
+#include <mono/utils/unlocked.h>
 
 static gboolean shutting_down_inited = FALSE;
 static gboolean shutting_down = FALSE;
 
-/** 
+/**
  * mono_runtime_set_shutting_down:
+ * \deprecated This function can break the shutdown sequence.
  *
- * Invoked by System.Environment.Exit to flag that the runtime
+ * Invoked by \c System.Environment.Exit to flag that the runtime
  * is shutting down.
- *
- * Deprecated. This function can break the shutdown sequence.
  */
 void
 mono_runtime_set_shutting_down (void)
 {
-       shutting_down = TRUE;
+       UnlockedWriteBool (&shutting_down, TRUE);
 }
 
 /**
  * mono_runtime_is_shutting_down:
- *
- * Returns whether the runtime has been flagged for shutdown.
- *
- * This is consumed by the P:System.Environment.HasShutdownStarted
- * property.
- *
+ * This is consumed by the \c P:System.Environment.HasShutdownStarted property.
+ * \returns whether the runtime has been flagged for shutdown.
  */
 gboolean
 mono_runtime_is_shutting_down (void)
 {
-       return shutting_down;
+       return UnlockedReadBool (&shutting_down);
 }
 
 static void
@@ -65,7 +62,7 @@ fire_process_exit_event (MonoDomain *domain, gpointer user_data)
        field = mono_class_get_field_from_name (mono_defaults.appdomain_class, "ProcessExit");
        g_assert (field);
 
-       delegate = *(MonoObject **)(((char *)domain->domain) + field->offset); 
+       delegate = *(MonoObject **)(((char *)domain->domain) + field->offset);
        if (delegate == NULL)
                return;
 
@@ -83,7 +80,6 @@ mono_runtime_fire_process_exit_event (void)
 #endif
 }
 
-
 /**
  * mono_runtime_try_shutdown:
  *
@@ -101,17 +97,12 @@ mono_runtime_try_shutdown (void)
 
        mono_runtime_fire_process_exit_event ();
 
-       shutting_down = TRUE;
+       mono_runtime_set_shutting_down ();
 
        mono_threads_set_shutting_down ();
 
        /* No new threads will be created after this point */
 
-       mono_runtime_set_shutting_down ();
-
-       /* This will kill the tp threads which cannot be suspended */
-       mono_threadpool_ms_cleanup ();
-
        /*TODO move the follow to here:
        mono_thread_suspend_all_other_threads (); OR  mono_thread_wait_all_other_threads
 
@@ -121,13 +112,6 @@ mono_runtime_try_shutdown (void)
        return TRUE;
 }
 
-
-gboolean
-mono_runtime_is_critical_method (MonoMethod *method)
-{
-       return FALSE;
-}
-
 /*
 Coordinate the creation of all remaining TLS slots in the runtime.
 No further TLS slots should be created after this function finishes.
@@ -138,5 +122,25 @@ void
 mono_runtime_init_tls (void)
 {
        mono_marshal_init_tls ();
-       mono_thread_init_tls ();
+}
+
+char*
+mono_runtime_get_aotid (void)
+{
+       int i;
+       guint8 aotid_sum = 0;
+       MonoDomain* domain = mono_domain_get ();
+
+       if (!domain->entry_assembly || !domain->entry_assembly->image)
+               return NULL;
+
+       guint8 (*aotid)[16] = &domain->entry_assembly->image->aotid;
+
+       for (i = 0; i < 16; ++i)
+               aotid_sum |= (*aotid)[i];
+
+       if (aotid_sum == 0)
+               return NULL;
+
+       return mono_guid_to_string ((guint8*) aotid);
 }