Merge pull request #3387 from xmcclure/test-suite-bump
[mono.git] / mono / metadata / appdomain.c
index c57d8e9fb5b9f9db68819846e311953c5a4e6671..ae391b08948e86b49aa92aac222083d8e0214175 100644 (file)
@@ -67,6 +67,7 @@
 #include <mono/utils/atomic.h>
 #include <mono/utils/mono-memory-model.h>
 #include <mono/utils/mono-threads.h>
+#include <mono/utils/w32handle.h>
 #ifdef HOST_WIN32
 #include <direct.h>
 #endif
@@ -82,7 +83,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 150
+#define MONO_CORLIB_VERSION 152
 
 typedef struct
 {
@@ -961,7 +962,9 @@ ves_icall_System_AppDomain_createDomain (MonoString *friendly_name, MonoAppDomai
 {
        MonoError error;
        MonoAppDomain *ad = NULL;
+
 #ifdef DISABLE_APPDOMAINS
+       mono_error_init (&error);
        mono_error_set_not_supported (&error, "AppDomain creation is not supported on this runtime.");
 #else
        char *fname;
@@ -1513,97 +1516,6 @@ get_shadow_assembly_location (const char *filename, MonoError *error)
        return location;
 }
 
-static gboolean
-ensure_directory_exists (const char *filename)
-{
-#ifdef HOST_WIN32
-       gchar *dir_utf8 = g_path_get_dirname (filename);
-       gunichar2 *p;
-       gunichar2 *dir_utf16 = NULL;
-       int retval;
-       
-       if (!dir_utf8 || !dir_utf8 [0])
-               return FALSE;
-
-       dir_utf16 = g_utf8_to_utf16 (dir_utf8, strlen (dir_utf8), NULL, NULL, NULL);
-       g_free (dir_utf8);
-
-       if (!dir_utf16)
-               return FALSE;
-
-       p = dir_utf16;
-
-       /* make life easy and only use one directory seperator */
-       while (*p != '\0')
-       {
-               if (*p == '/')
-                       *p = '\\';
-               p++;
-       }
-
-       p = dir_utf16;
-
-       /* get past C:\ )*/
-       while (*p++ != '\\')    
-       {
-       }
-
-       while (1) {
-               BOOL bRet = FALSE;
-               p = wcschr (p, '\\');
-               if (p)
-                       *p = '\0';
-               retval = _wmkdir (dir_utf16);
-               if (retval != 0 && errno != EEXIST) {
-                       g_free (dir_utf16);
-                       return FALSE;
-               }
-               if (!p)
-                       break;
-               *p++ = '\\';
-       }
-       
-       g_free (dir_utf16);
-       return TRUE;
-#else
-       char *p;
-       gchar *dir = g_path_get_dirname (filename);
-       int retval;
-       struct stat sbuf;
-       
-       if (!dir || !dir [0]) {
-               g_free (dir);
-               return FALSE;
-       }
-       
-       if (stat (dir, &sbuf) == 0 && S_ISDIR (sbuf.st_mode)) {
-               g_free (dir);
-               return TRUE;
-       }
-       
-       p = dir;
-       while (*p == '/')
-               p++;
-
-       while (1) {
-               p = strchr (p, '/');
-               if (p)
-                       *p = '\0';
-               retval = mkdir (dir, 0777);
-               if (retval != 0 && errno != EEXIST) {
-                       g_free (dir);
-                       return FALSE;
-               }
-               if (!p)
-                       break;
-               *p++ = '/';
-       }
-       
-       g_free (dir);
-       return TRUE;
-#endif
-}
-
 static gboolean
 private_file_needs_copying (const char *src, struct stat *sbuf_src, char *dest)
 {
@@ -1802,7 +1714,7 @@ mono_make_shadow_copy (const char *filename, MonoError *oerror)
                return NULL;
        }
 
-       if (ensure_directory_exists (shadow) == FALSE) {
+       if (g_ensure_directory_exists (shadow) == FALSE) {
                g_free (shadow);
                mono_error_set_execution_engine (oerror, "Failed to create shadow copy (ensure directory exists).");
                return NULL;
@@ -1852,13 +1764,13 @@ mono_make_shadow_copy (const char *filename, MonoError *oerror)
        sibling_target_len = strlen (sibling_target);
        
        copy_result = shadow_copy_sibling (sibling_source, sibling_source_len, ".mdb", sibling_target, sibling_target_len, 7);
-       if (copy_result == TRUE)
+       if (copy_result)
                copy_result = shadow_copy_sibling (sibling_source, sibling_source_len, ".config", sibling_target, sibling_target_len, 7);
        
        g_free (sibling_source);
        g_free (sibling_target);
        
-       if (copy_result == FALSE)  {
+       if (!copy_result)  {
                g_free (shadow);
                mono_error_set_execution_engine (oerror, "Failed to create shadow copy of sibling data (CopyFile).");
                return NULL;
@@ -2443,7 +2355,7 @@ deregister_reflection_info_roots (MonoDomain *domain)
        mono_domain_assemblies_unlock (domain);
 }
 
-static guint32 WINAPI
+static gsize WINAPI
 unload_thread_main (void *arg)
 {
        MonoError error;
@@ -2593,6 +2505,7 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc)
        unload_data *thread_data;
        MonoNativeThreadId tid;
        MonoDomain *caller_domain = mono_domain_get ();
+       MonoThreadParm tp;
 
        /* printf ("UNLOAD STARTING FOR %s (%p) IN THREAD 0x%x.\n", domain->friendly_name, domain, mono_native_thread_id_get ()); */
 
@@ -2649,7 +2562,10 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc)
         * First we create a separate thread for unloading, since
         * we might have to abort some threads, including the current one.
         */
-       thread_handle = mono_threads_create_thread ((LPTHREAD_START_ROUTINE)unload_thread_main, thread_data, 0, CREATE_SUSPENDED, &tid);
+       tp.priority = MONO_THREAD_PRIORITY_NORMAL;
+       tp.stack_size = 0;
+       tp.creation_flags = CREATE_SUSPENDED;
+       thread_handle = mono_threads_create_thread (unload_thread_main, thread_data, &tp, &tid);
        if (thread_handle == NULL)
                return;
        mono_thread_info_resume (tid);