[RUNTIME] Ensure that we initialize the cpu for every thread [Bug #650439]
authorGeoff Norton <grompf@sublimeintervention.com>
Thu, 4 Nov 2010 15:28:30 +0000 (11:28 -0400)
committerGeoff Norton <grompf@sublimeintervention.com>
Thu, 4 Nov 2010 15:30:07 +0000 (11:30 -0400)
It appears that on OSX the FPU settings on x86/amd64 are not inherited
to child threads of a process, leading to differences in precision between
the main thread and the sub thread.  We now call mono_arch_cpu_init
on every thread on every platform

mono/mini/mini-ppc.c
mono/mini/mini.c

index dc169c6adde7d9a17b61eca57ee888ceef9bb1d1..f407042f96d090b35d4352a63ceadf53efe38e9b 100644 (file)
@@ -564,6 +564,14 @@ linux_find_auxv (int *count)
 void
 mono_arch_cpu_init (void)
 {
+}
+
+/*
+ * Initialize architecture specific code.
+ */
+void
+mono_arch_init (void)
+{
 #ifdef __APPLE__
        int mib [3];
        size_t len;
@@ -629,14 +637,6 @@ mono_arch_cpu_init (void)
 
        if (mono_cpu_count () > 1)
                cpu_hw_caps |= PPC_SMP_CAPABLE;
-}
-
-/*
- * Initialize architecture specific code.
- */
-void
-mono_arch_init (void)
-{
        InitializeCriticalSection (&mini_arch_mutex);
 
        ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
index 24b66e7511b392c4d3f0df098d9978ba5e50283f..d6738df13fef5726f842f5976eb8ac3bca917579 100644 (file)
@@ -2524,6 +2524,8 @@ mono_thread_start_cb (intptr_t tid, gpointer stack_start, gpointer func)
        mono_debugger_thread_created (tid, thread->root_domain_thread, jit_tls, func);
        if (thread)
                thread->jit_data = jit_tls;
+
+       mono_arch_cpu_init ();
 }
 
 void (*mono_thread_attach_aborted_cb ) (MonoObject *obj) = NULL;
@@ -2548,6 +2550,8 @@ mono_thread_attach_cb (intptr_t tid, gpointer stack_start)
                thread->jit_data = jit_tls;
        if (mono_profiler_get_events () & MONO_PROFILE_STATISTICAL)
                mono_runtime_setup_stat_profiler ();
+
+       mono_arch_cpu_init ();
 }
 
 static void