gpointer res;
- MONO_PREPARE_RESET_BLOCKING
+ MONO_PREPARE_RESET_BLOCKING;
method = mono_marshal_get_thunk_invoke_wrapper (method);
res = mono_compile_method (method);
- MONO_FINISH_RESET_BLOCKING
+ MONO_FINISH_RESET_BLOCKING;
return res;
}
static inline void
dynamic_image_lock (MonoDynamicImage *image)
{
- MONO_TRY_BLOCKING;
+ MONO_PREPARE_BLOCKING;
mono_image_lock ((MonoImage*)image);
- MONO_FINISH_TRY_BLOCKING;
+ MONO_FINISH_BLOCKING;
}
static inline void
/* Write handshake message */
sprintf (handshake_msg, "DWP-Handshake");
/* Must use try blocking as this can nest into code that runs blocking */
- MONO_TRY_BLOCKING;
+ MONO_PREPARE_BLOCKING;
do {
res = transport_send (handshake_msg, strlen (handshake_msg));
} while (res == -1 && get_last_sock_error () == MONO_EINTR);
- MONO_FINISH_TRY_BLOCKING;
+ MONO_FINISH_BLOCKING;
g_assert (res != -1);
/* Read answer */
- MONO_TRY_BLOCKING;
+ MONO_PREPARE_BLOCKING;
res = transport_recv (buf, strlen (handshake_msg));
- MONO_FINISH_TRY_BLOCKING;
+ MONO_FINISH_BLOCKING;
if ((res != strlen (handshake_msg)) || (memcmp (buf, handshake_msg, strlen (handshake_msg)) != 0)) {
fprintf (stderr, "debugger-agent: DWP handshake failed.\n");
return FALSE;
mono_threads_prepare_blocking (stackdata);
}
-void*
-mono_threads_try_prepare_blocking (void* stackdata)
-{
- MonoThreadInfo *info;
-
- if (!mono_threads_is_coop_enabled ())
- return NULL;
-
- ++coop_try_blocking_count;
-
- info = mono_thread_info_current_unchecked ();
- /* If the thread is not attached, it doesn't make sense prepare for suspend. */
- if (!info || !mono_thread_info_is_live (info) || mono_thread_info_current_state (info) == STATE_BLOCKING) {
- THREADS_SUSPEND_DEBUG ("PREPARE-TRY-BLOCKING failed %p\n", mono_thread_info_get_tid (info));
- return NULL;
- }
-
- copy_stack_data (info, stackdata);
-
-retry:
- ++coop_save_count;
- mono_threads_get_runtime_callbacks ()->thread_state_init (&info->thread_saved_state [SELF_SUSPEND_STATE_INDEX]);
-
- switch (mono_threads_transition_do_blocking (info)) {
- case DoBlockingContinue:
- break;
- case DoBlockingPollAndRetry:
- mono_threads_state_poll ();
- goto retry;
- }
-
- return info;
-}
-
-void
-mono_threads_finish_try_blocking (void* cookie, void* stackdata)
-{
- if (!mono_threads_is_coop_enabled ())
- return;
-
- mono_threads_finish_blocking (cookie, stackdata);
-}
-
void
mono_threads_init_coop (void)
{
void* mono_threads_reset_blocking_start (void* stackdata);
void mono_threads_reset_blocking_end (void* cookie, void* stackdata);
-void* mono_threads_try_prepare_blocking (void* stackdata);
-void mono_threads_finish_try_blocking (void* cookie, void* stackdata);
-
static inline void
mono_threads_safepoint (void)
{
}
#define MONO_PREPARE_BLOCKING \
-{ \
- void *__dummy; \
- void *__blocking_cookie = mono_threads_prepare_blocking (&__dummy);
+ do { \
+ void *__dummy; \
+ void *__blocking_cookie = mono_threads_prepare_blocking (&__dummy)
#define MONO_FINISH_BLOCKING \
- mono_threads_finish_blocking (__blocking_cookie, &__dummy); \
-}
+ mono_threads_finish_blocking (__blocking_cookie, &__dummy); \
+ } while (0)
#define MONO_PREPARE_RESET_BLOCKING \
-{ \
- void *__dummy; \
- void *__reset_cookie = mono_threads_reset_blocking_start (&__dummy);
+ do { \
+ void *__dummy; \
+ void *__reset_cookie = mono_threads_reset_blocking_start (&__dummy)
#define MONO_FINISH_RESET_BLOCKING \
- mono_threads_reset_blocking_end (__reset_cookie, &__dummy); \
-}
-
-#define MONO_TRY_BLOCKING \
-{ \
- void *__dummy; \
- void *__try_block_cookie = mono_threads_try_prepare_blocking (&__dummy);
-
-#define MONO_FINISH_TRY_BLOCKING \
- mono_threads_finish_try_blocking (__try_block_cookie, &__dummy); \
-}
+ mono_threads_reset_blocking_end (__reset_cookie, &__dummy); \
+ } while (0)
#endif