#include <mono/metadata/tokentype.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/reflection-internals.h>
+#include <mono/metadata/abi-details.h>
#include <mono/utils/mono-uri.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-path.h>
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
-#define MONO_CORLIB_VERSION 151
+#define MONO_CORLIB_VERSION 160
typedef struct
{
int version = mono_get_corlib_version ();
if (version != MONO_CORLIB_VERSION)
return g_strdup_printf ("expected corlib version %d, found %d.", MONO_CORLIB_VERSION, version);
- else
- return NULL;
+
+ /* Check that the managed and unmanaged layout of MonoInternalThread matches */
+ guint32 native_offset = (guint32) MONO_STRUCT_OFFSET (MonoInternalThread, last);
+ guint32 managed_offset = mono_field_get_offset (mono_class_get_field_from_name (mono_defaults.internal_thread_class, "last"));
+ if (native_offset != managed_offset)
+ return g_strdup_printf ("expected InternalThread.last field offset %u, found %u. See InternalThread.last comment", native_offset, managed_offset);
+
+ return NULL;
}
/**
mono_domain_assemblies_unlock (domain);
}
-static guint32 WINAPI
+static gsize WINAPI
unload_thread_main (void *arg)
{
MonoError error;
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 ()); */
* First we create a separate thread for unloading, since
* we might have to abort some threads, including the current one.
*/
- tp.priority = 0;
- tp.stack_size = 0;
- tp.creation_flags = CREATE_SUSPENDED;
- thread_handle = mono_threads_create_thread ((LPTHREAD_START_ROUTINE)unload_thread_main, thread_data, &tp, &tid);
+ thread_handle = mono_threads_create_thread (unload_thread_main, thread_data, NULL, &tid);
if (thread_handle == NULL)
return;
- mono_thread_info_resume (tid);
/* Wait for the thread */
while (!thread_data->done && guarded_wait (thread_handle, INFINITE, TRUE) == WAIT_IO_COMPLETION) {
if (mono_thread_internal_has_appdomain_ref (mono_thread_internal_current (), domain) && (mono_thread_interruption_requested ())) {
/* The unload thread tries to abort us */
/* The icall wrapper will execute the abort */
- CloseHandle (thread_handle);
+ mono_threads_close_thread_handle (thread_handle);
unload_data_unref (thread_data);
return;
}
}
- CloseHandle (thread_handle);
+
+ mono_threads_close_thread_handle (thread_handle);
if (thread_data->failure_reason) {
/* Roll back the state change */