+ MonoContext mctx;
+
+ /*
+ * Handling the exception in the signal handler is problematic, since the original
+ * signal is disabled, and we could run arbitrary code though the debugger. So
+ * resume into the normal stack and do most work there if possible.
+ */
+ MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
+
+ /* Pass the ctx parameter in TLS */
+ mono_sigctx_to_monoctx (sigctx, &jit_tls->ex_ctx);
+
+ mctx = jit_tls->ex_ctx;
+ mono_arch_setup_async_callback (&mctx, handle_signal_exception, obj);
+ mono_monoctx_to_sigctx (&mctx, sigctx);
+
+ return TRUE;
+}
+
+/*========================= End of Function ========================*/
+
+/*------------------------------------------------------------------*/
+/* */
+/* Name - mono_arch_setup_async_callback */
+/* */
+/* Function - Establish the async callback. */
+/* */
+/* Parameters - ctx - Context */
+/* async_cb - Callback routine address */
+/* user_data - Data to be passed to callback */
+/* */
+/*------------------------------------------------------------------*/
+
+void
+mono_arch_setup_async_callback (MonoContext *ctx, void (*async_cb)(void *fun), gpointer user_data)
+{
+ uintptr_t sp = (uintptr_t) MONO_CONTEXT_GET_SP(ctx);
+
+ ctx->uc_mcontext.gregs[2] = (unsigned long) user_data;
+
+ sp -= S390_MINIMAL_STACK_SIZE;
+ *(unsigned long *)sp = MONO_CONTEXT_GET_SP(ctx);
+ MONO_CONTEXT_SET_BP(ctx, sp);
+ MONO_CONTEXT_SET_IP(ctx, (unsigned long) async_cb);