]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/50678 (FAIL: c52104y on x86_64-apple-darwin10)
authorSimon Wright <simon@pushface.org>
Thu, 7 Feb 2013 18:08:41 +0000 (18:08 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 7 Feb 2013 18:08:41 +0000 (18:08 +0000)
PR target/50678
* init.c (__darwin_major_version): New function for x86-64/Darwin.
(__gnat_adjust_context_for_raise) [Darwin]: Disable the workaround
on Darwin 12 and above.

From-SVN: r195864

gcc/ada/ChangeLog
gcc/ada/init.c

index 370eff8ac1b76360868155810048896c3a291e06..47b35cc93de6733aa7c26d5ea2fe69fe83a8e10b 100644 (file)
@@ -1,3 +1,10 @@
+2013-02-07  Simon Wright  <simon@pushface.org>
+
+       PR target/50678
+       * init.c (__darwin_major_version): New function for x86-64/Darwin.
+       (__gnat_adjust_context_for_raise) [Darwin]: Disable the workaround
+       on Darwin 12 and above.
+
 2012-12-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR ada/54614
index f6c1a5b4ed20e21917c8c66551b8ea985a01a4cc..431aa909561b3af21334fb4e30a87a1dca0e0386 100644 (file)
@@ -2179,7 +2179,9 @@ __gnat_install_handler(void)
 #elif defined(__APPLE__)
 
 #include <signal.h>
+#include <stdlib.h>
 #include <sys/syscall.h>
+#include <sys/sysctl.h>
 #include <mach/mach_vm.h>
 #include <mach/mach_init.h>
 #include <mach/vm_statistics.h>
@@ -2218,20 +2220,52 @@ __gnat_is_stack_guard (mach_vm_address_t addr)
 
 #define HAVE_GNAT_ADJUST_CONTEXT_FOR_RAISE
 
+#if defined (__x86_64__)
+static int
+__darwin_major_version (void)
+{
+  static int cache = -1;
+  if (cache < 0)
+    {
+      int mib[2] = {CTL_KERN, KERN_OSRELEASE};
+      size_t len;
+
+      /* Find out how big the buffer needs to be (and set cache to 0
+         on failure).  */
+      if (sysctl (mib, 2, NULL, &len, NULL, 0) == 0)
+        {
+          char release[len];
+          sysctl (mib, 2, release, &len, NULL, 0);
+          /* Darwin releases are of the form L.M.N where L is the major
+             version, so strtol will return L.  */
+          cache = (int) strtol (release, NULL, 10);
+        }
+      else
+        {
+          cache = 0;
+        }
+    }
+  return cache;
+}
+#endif
+
 void
 __gnat_adjust_context_for_raise (int signo ATTRIBUTE_UNUSED,
                                 void *ucontext ATTRIBUTE_UNUSED)
 {
 #if defined (__x86_64__)
-  /* Work around radar #10302855/pr50678, where the unwinders (libunwind or
-     libgcc_s depending on the system revision) and the DWARF unwind data for
-     the sigtramp have different ideas about register numbering (causing rbx
-     and rdx to be transposed)..  */
-  ucontext_t *uc = (ucontext_t *)ucontext ;
-  unsigned long t = uc->uc_mcontext->__ss.__rbx;
-
-  uc->uc_mcontext->__ss.__rbx = uc->uc_mcontext->__ss.__rdx;
-  uc->uc_mcontext->__ss.__rdx = t;
+  if (__darwin_major_version () < 12)
+    {
+      /* Work around radar #10302855, where the unwinders (libunwind or
+        libgcc_s depending on the system revision) and the DWARF unwind
+        data for sigtramp have different ideas about register numbering,
+        causing rbx and rdx to be transposed.  */
+      ucontext_t *uc = (ucontext_t *)ucontext;
+      unsigned long t = uc->uc_mcontext->__ss.__rbx;
+
+      uc->uc_mcontext->__ss.__rbx = uc->uc_mcontext->__ss.__rdx;
+      uc->uc_mcontext->__ss.__rdx = t;
+    }
 #endif
 }