From 7cd551c42e918539babd17111b6aba4776a62e62 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 26 May 2016 15:59:23 +0200 Subject: [PATCH] [runtime] Update thread attach/detach according to mono changes. * Restore the mono_jit_thread_attach signature to how it's in the latest stable. * Don't use the new attach/detach methods when using the dynamic mono runtime, since the methods aren't available in any released version of mono. Also XM doesn't support coop yet, so it's not needed. * And finally don't use the new attach/detach methods for anything that isn't building using mono/master (iow only watchOS). This should be changed once the rest of the products starts using mono/master again. --- external/watch-mono | 2 +- runtime/exports.t4 | 22 +++++++++++++++------- runtime/xamarin/runtime.h | 15 +++++++++++++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/external/watch-mono b/external/watch-mono index e4d33f70d401..7ebae4c7f57a 160000 --- a/external/watch-mono +++ b/external/watch-mono @@ -1 +1 @@ -Subproject commit e4d33f70d401e579cf5345a6eb777c673d3a5964 +Subproject commit 7ebae4c7f57a6c1b4d0a38e69f270a016b6f3143 diff --git a/runtime/exports.t4 b/runtime/exports.t4 index e12768ac512e..11db2682934f 100644 --- a/runtime/exports.t4 +++ b/runtime/exports.t4 @@ -516,13 +516,7 @@ #region mini/mini.h new Export ("void*", "mono_jit_thread_attach", - "MonoDomain *", "domain", - "void *", "dummy" - ), - - new Export ("void", "mono_jit_thread_detach", - "void *", "cookie", - "void *", "dummy" + "MonoDomain *", "domain" ), new Export ("gboolean", "mono_exception_walk_trace", @@ -601,6 +595,20 @@ #region utils/mono-threads.h new Export ("void*", "mono_thread_info_current_unchecked" ), #endregion + + #region metadata/threads-types.h + + new Export (true, "void *", "mono_threads_attach_coop", + "MonoDomain *", "domain", + "gpointer*", "dummy" + ), + + new Export (true, "void *", "mono_threads_detach_coop", + "gpointer", "cookie", + "gpointer*", "dummy" + ), + + #endregion }; #><#+ class Arg diff --git a/runtime/xamarin/runtime.h b/runtime/xamarin/runtime.h index e19ae3106171..8ae912a55de5 100644 --- a/runtime/xamarin/runtime.h +++ b/runtime/xamarin/runtime.h @@ -258,15 +258,26 @@ class XamarinObject { #endif /* !TARGET_OS_WATCH */ +// Once we have one mono clone again the TARGET_OS_WATCH +// should be removed (DYNAMIC_MONO_RUNTIME should still +// be here though). +#if TARGET_OS_WATCH || DYNAMIC_MONO_RUNTIME #define MONO_THREAD_ATTACH \ do { \ gpointer __thread_dummy; \ - gpointer __thread_cookie = mono_jit_thread_attach (NULL, &__thread_dummy) \ + gpointer __thread_cookie = mono_threads_attach_coop (NULL, &__thread_dummy) \ #define MONO_THREAD_DETACH \ - mono_jit_thread_detach (__thread_cookie, &__thread_dummy); \ + mono_threads_detach_coop (__thread_cookie, &__thread_dummy); \ } while (0) +#else +#define MONO_THREAD_ATTACH \ + do { \ + mono_jit_thread_attach (NULL) \ +#define MONO_THREAD_DETACH \ + } while (0) +#endif #ifdef __cplusplus } /* extern "C" */