Merge pull request #2820 from kumpera/license-change-rebased
[mono.git] / mono / mini / mini-windows.c
index 125b4e4e7dce6e341b1fe30d9135f4d2321aa062..621a7a5fc31970e22d3e75e4993623ae10dddece 100644 (file)
@@ -8,6 +8,7 @@
  * Copyright 2003-2008 Ximian, Inc.
  *
  * See LICENSE for licensing information.
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 #include <config.h>
 #include <signal.h>
@@ -29,7 +30,7 @@
 #include <mono/metadata/mono-config.h>
 #include <mono/metadata/environment.h>
 #include <mono/metadata/mono-debug.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
 #include <mono/metadata/threads-types.h>
 #include <mono/metadata/verify.h>
 #include <mono/metadata/verify-internals.h>
@@ -38,7 +39,7 @@
 #include <mono/utils/mono-math.h>
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-counters.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
 #include <mono/utils/mono-mmap.h>
 #include <mono/utils/dtrace.h>
 
 
 #include "jit-icalls.h"
 
+#ifdef _WIN32
+#include <mmsystem.h>
+#endif
+
 void
 mono_runtime_install_handlers (void)
 {
 #ifndef MONO_CROSS_COMPILE
-       win32_seh_init();
-       win32_seh_set_handler(SIGFPE, mono_sigfpe_signal_handler);
-       win32_seh_set_handler(SIGILL, mono_sigill_signal_handler);
-       win32_seh_set_handler(SIGSEGV, mono_sigsegv_signal_handler);
-       if (mini_get_debug_options ()->handle_sigint)
-               win32_seh_set_handler(SIGINT, mono_sigint_signal_handler);
+       if (!mono_aot_only) {
+               win32_seh_init();
+               win32_seh_set_handler(SIGFPE, mono_sigfpe_signal_handler);
+               win32_seh_set_handler(SIGILL, mono_sigill_signal_handler);
+               win32_seh_set_handler(SIGSEGV, mono_sigsegv_signal_handler);
+               if (mini_get_debug_options ()->handle_sigint)
+                       win32_seh_set_handler(SIGINT, mono_sigint_signal_handler);
+       }
 #endif
 }
 
@@ -67,7 +74,9 @@ void
 mono_runtime_cleanup_handlers (void)
 {
 #ifndef MONO_CROSS_COMPILE
-       win32_seh_cleanup();
+       if (!mono_aot_only) {
+               win32_seh_cleanup();
+       }
 #endif
 }
 
@@ -79,7 +88,7 @@ mono_runtime_cleanup_handlers (void)
  * was called, false otherwise.
  */
 gboolean
-SIG_HANDLER_SIGNATURE (mono_chain_signal)
+MONO_SIG_HANDLER_SIGNATURE (mono_chain_signal)
 {
        MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
        jit_tls->mono_win_chained_exception_needs_run = TRUE;
@@ -170,34 +179,7 @@ mono_thread_state_init_from_handle (MonoThreadUnwindState *tctx, MonoThreadInfo
        ctx = &tctx->ctx;
 
        memset (ctx, 0, sizeof (MonoContext));
-#ifdef TARGET_AMD64
-       ctx->rip = context.Rip;
-       ctx->rax = context.Rax;
-       ctx->rcx = context.Rcx;
-       ctx->rdx = context.Rdx;
-       ctx->rbx = context.Rbx;
-       ctx->rsp = context.Rsp;
-       ctx->rbp = context.Rbp;
-       ctx->rsi = context.Rsi;
-       ctx->rdi = context.Rdi;
-       ctx->r8 = context.R8;
-       ctx->r9 = context.R9;
-       ctx->r10 = context.R10;
-       ctx->r11 = context.R11;
-       ctx->r12 = context.R12;
-       ctx->r13 = context.R13;
-       ctx->r14 = context.R14;
-       ctx->r15 = context.R15;
-#else
-       ctx->edi = context.Edi;
-       ctx->esi = context.Esi;
-       ctx->ebx = context.Ebx;
-       ctx->edx = context.Edx;
-       ctx->ecx = context.Ecx;
-       ctx->eax = context.Eax;
-       ctx->ebp = context.Ebp;
-       ctx->esp = context.Esp;
-#endif
+       mono_sigctx_to_monoctx (&context, ctx);
 
        /* mono_set_jit_tls () sets this */
        jit_tls = mono_thread_info_tls_get (info, TLS_KEY_JIT_TLS);