Skip to content

Commit

Permalink
[runtime] Update thread attach/detach according to mono changes.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
rolfbjarne committed May 26, 2016
1 parent 85a6bba commit 7cd551c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion external/watch-mono
Submodule watch-mono updated 591 files
22 changes: 15 additions & 7 deletions runtime/exports.t4
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions runtime/xamarin/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" */
Expand Down

0 comments on commit 7cd551c

Please sign in to comment.