From 97e095fdc7191eea3d9bbf098c5feccc9446dc67 Mon Sep 17 00:00:00 2001
From: Mike Stump <mrs@apple.com>
Date: Thu, 24 Mar 2005 00:48:39 +0000
Subject: [PATCH] darwin_stop_world.c: Update for -m64 multilib.

        * darwin_stop_world.c: Update for -m64 multilib.
        * include/private/gcconfig.h: Likewise.
        * powerpc_darwin_mach_dep.s: Likewise.

From-SVN: r96968
---
 boehm-gc/ChangeLog                  |  6 ++++++
 boehm-gc/darwin_stop_world.c        | 13 +++++++------
 boehm-gc/include/private/gcconfig.h | 12 +++++++++---
 boehm-gc/powerpc_darwin_mach_dep.s  | 19 +++++++++++++++----
 4 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/boehm-gc/ChangeLog b/boehm-gc/ChangeLog
index 9b5852d47776..413c261311a7 100644
--- a/boehm-gc/ChangeLog
+++ b/boehm-gc/ChangeLog
@@ -1,3 +1,9 @@
+2005-03-23  Mike Stump  <mrs@apple.com>
+
+	* darwin_stop_world.c: Update for -m64 multilib.
+	* include/private/gcconfig.h: Likewise.
+	* powerpc_darwin_mach_dep.s: Likewise.
+
 2005-03-01  Kelley Cook  <kcook@gcc.gnu.org>
 
 	* Makefile.in, include/Makefile.in: Regenerate.
diff --git a/boehm-gc/darwin_stop_world.c b/boehm-gc/darwin_stop_world.c
index 36378cbbce01..2fad9474716b 100644
--- a/boehm-gc/darwin_stop_world.c
+++ b/boehm-gc/darwin_stop_world.c
@@ -1,5 +1,7 @@
 #include "private/pthread_support.h"
 
+/* This probably needs more porting work to ppc64. */
+
 # if defined(GC_DARWIN_THREADS)
 
 /* From "Inside Mac OS X - Mach-O Runtime Architecture" published by Apple
@@ -14,13 +16,12 @@
 */
 #define PPC_RED_ZONE_SIZE 224
 
-/* Not 64-bit clean. Wait until Apple defines their 64-bit ABI */
 typedef struct StackFrame {
-  unsigned int	savedSP;
-  unsigned int	savedCR;
-  unsigned int	savedLR;
-  unsigned int	reserved[2];
-  unsigned int	savedRTOC;
+  unsigned long	savedSP;
+  unsigned long	savedCR;
+  unsigned long	savedLR;
+  unsigned long	reserved[2];
+  unsigned long	savedRTOC;
 } StackFrame;
 
 
diff --git a/boehm-gc/include/private/gcconfig.h b/boehm-gc/include/private/gcconfig.h
index 64cbde22c302..fbabdedd7728 100644
--- a/boehm-gc/include/private/gcconfig.h
+++ b/boehm-gc/include/private/gcconfig.h
@@ -277,8 +277,9 @@
 #   define MACOS
 #   define mach_type_known
 # endif
-# if defined(macosx) || \
-     defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
+# if defined(macosx) \
+     || defined(__APPLE__) && defined(__MACH__) && defined(__ppc__) \
+     || defined(__APPLE__) && defined(__MACH__) && defined(__ppc64__)
 #    define DARWIN
 #    define POWERPC
 #    define mach_type_known
@@ -756,7 +757,12 @@
 #     define DATAEND (_end)
 #   endif
 #   ifdef DARWIN
-#     define ALIGNMENT 4
+#     if (defined (__ppc64__))
+#       define ALIGNMENT 8
+#       define CPP_WORDSZ 64
+#     else
+#       define ALIGNMENT 4
+#     endif
 #     define OS_TYPE "DARWIN"
 #     define DYNAMIC_LOADING
       /* XXX: see get_end(3), get_etext() and get_end() should not be used.
diff --git a/boehm-gc/powerpc_darwin_mach_dep.s b/boehm-gc/powerpc_darwin_mach_dep.s
index 83f06cffca58..694005f416db 100644
--- a/boehm-gc/powerpc_darwin_mach_dep.s
+++ b/boehm-gc/powerpc_darwin_mach_dep.s
@@ -1,10 +1,21 @@
+#if defined(__ppc64__)
+#define MODE_CHOICE(x, y) y
+#else
+#define MODE_CHOICE(x, y) x
+#endif
+
+#define lgu     MODE_CHOICE(lwzu, ldu)
+
+#define g_long  MODE_CHOICE(long, quad)         /* usage is ".g_long" */
+
+#define LOG2_GPR_BYTES  MODE_CHOICE(2,3)        /* log2(GPR_BYTES) */
 
 ; GC_push_regs function. Under some optimization levels GCC will clobber
 ; some of the non-volatile registers before we get a chance to save them
 ; therefore, this can't be inline asm.
 
 .text
-	.align 2
+	.align LOG2_GPR_BYTES
 	.globl _GC_push_regs
 _GC_push_regs:
     
@@ -65,7 +76,7 @@ _GC_push_regs:
 
 .data
 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-	.align 2
+	.align LOG2_GPR_BYTES
 L_GC_push_one$stub:
 	.indirect_symbol _GC_push_one
 	mflr r0
@@ -74,11 +85,11 @@ L0$_GC_push_one:
 	mflr r11
 	addis r11,r11,ha16(L_GC_push_one$lazy_ptr-L0$_GC_push_one)
 	mtlr r0
-	lwzu r12,lo16(L_GC_push_one$lazy_ptr-L0$_GC_push_one)(r11)
+	lgu r12,lo16(L_GC_push_one$lazy_ptr-L0$_GC_push_one)(r11)
 	mtctr r12
 	bctr
 .data
 .lazy_symbol_pointer
 L_GC_push_one$lazy_ptr:
 	.indirect_symbol _GC_push_one
-	.long dyld_stub_binding_helper
+	.g_long dyld_stub_binding_helper
-- 
GitLab