summaryrefslogtreecommitdiff
path: root/mach_dep.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-07-26 14:51:28 +0400
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 14:51:28 +0400
commitacf2e57f2091522924a0064b318642253e2b2bac (patch)
tree81d1d9fe63ae4d7b109b494d171ac33bc361c803 /mach_dep.c
parent7fd4efa1d0dbab63e6d9bddd1d72fa4aafc8ad52 (diff)
downloadbdwgc-acf2e57f2091522924a0064b318642253e2b2bac.tar.gz
gc4.8 tarball importgc4_8
Diffstat (limited to 'mach_dep.c')
-rw-r--r--mach_dep.c156
1 files changed, 116 insertions, 40 deletions
diff --git a/mach_dep.c b/mach_dep.c
index cd441f97..c2d22a61 100644
--- a/mach_dep.c
+++ b/mach_dep.c
@@ -11,7 +11,7 @@
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, May 19, 1994 1:58 pm PDT */
+/* Boehm, November 17, 1995 12:13 pm PST */
# include "gc_priv.h"
# include <stdio.h>
# include <setjmp.h>
@@ -19,7 +19,44 @@
# define _setjmp(b) setjmp(b)
# define _longjmp(b,v) longjmp(b,v)
# endif
+# ifdef AMIGA
+# include <dos.h>
+# endif
+#if defined(__MWERKS__) && !defined(POWERPC)
+
+asm static void PushMacRegisters()
+{
+ sub.w #4,sp // reserve space for one parameter.
+ move.l a2,(sp)
+ jsr GC_push_one
+ move.l a3,(sp)
+ jsr GC_push_one
+ move.l a4,(sp)
+ jsr GC_push_one
+# if !__option(a6frames)
+ // <pcb> perhaps a6 should be pushed if stack frames are not being used.
+ move.l a6,(sp)
+ jsr GC_push_one
+# endif
+ // skip a5 (globals), a6 (frame pointer), and a7 (stack pointer)
+ move.l d2,(sp)
+ jsr GC_push_one
+ move.l d3,(sp)
+ jsr GC_push_one
+ move.l d4,(sp)
+ jsr GC_push_one
+ move.l d5,(sp)
+ jsr GC_push_one
+ move.l d6,(sp)
+ jsr GC_push_one
+ move.l d7,(sp)
+ jsr GC_push_one
+ add.w #4,sp // fix stack.
+ rts
+}
+
+#endif /* __MWERKS__ */
/* Routine to mark from registers that are preserved by the C compiler. */
/* This must be ported to every new architecture. There is a generic */
@@ -27,22 +64,7 @@
/* on your architecture. Run the test_setjmp program to see whether */
/* there is any chance it will work. */
-#ifdef AMIGA
-__asm GC_push_regs(
- register __a2 word a2,
- register __a3 word a3,
- register __a4 word a4,
- register __a5 word a5,
- register __a6 word a6,
- register __d2 const word d2,
- register __d3 const word d3,
- register __d4 const word d4,
- register __d5 const word d5,
- register __d6 const word d6,
- register __d7 const word d7)
-#else
- void GC_push_regs()
-#endif
+void GC_push_regs()
{
# ifdef RT
register long TMP_SP; /* must be bound to r11 */
@@ -105,63 +127,104 @@ __asm GC_push_regs(
# ifdef AMIGA
/* AMIGA - could be replaced by generic code */
- /* SAS/C optimizer mangles this so compile with "noopt" */
/* a0, a1, d0 and d1 are caller save */
- GC_push_one(a2);
- GC_push_one(a3);
- GC_push_one(a4);
- GC_push_one(a5);
- GC_push_one(a6);
+ GC_push_one(getreg(REG_A2));
+ GC_push_one(getreg(REG_A3));
+ GC_push_one(getreg(REG_A4));
+ GC_push_one(getreg(REG_A5));
+ GC_push_one(getreg(REG_A6));
/* Skip stack pointer */
- GC_push_one(d2);
- GC_push_one(d3);
- GC_push_one(d4);
- GC_push_one(d5);
- GC_push_one(d6);
- GC_push_one(d7);
+ GC_push_one(getreg(REG_D2));
+ GC_push_one(getreg(REG_D3));
+ GC_push_one(getreg(REG_D4));
+ GC_push_one(getreg(REG_D5));
+ GC_push_one(getreg(REG_D6));
+ GC_push_one(getreg(REG_D7));
# endif
-# if defined(I386) &&!defined(OS2) &&!defined(SUNOS5) &&!defined(MSWIN32)
+# if defined(M68K) && defined(MACOS)
+# if defined(THINK_C)
+# define PushMacReg(reg) \
+ move.l reg,(sp) \
+ jsr GC_push_one
+ asm {
+ sub.w #4,sp ; reserve space for one parameter.
+ PushMacReg(a2);
+ PushMacReg(a3);
+ PushMacReg(a4);
+ ; skip a5 (globals), a6 (frame pointer), and a7 (stack pointer)
+ PushMacReg(d2);
+ PushMacReg(d3);
+ PushMacReg(d4);
+ PushMacReg(d5);
+ PushMacReg(d6);
+ PushMacReg(d7);
+ add.w #4,sp ; fix stack.
+ }
+# undef PushMacReg
+# endif /* THINK_C */
+# if defined(__MWERKS__)
+ PushMacRegisters();
+# endif /* __MWERKS__ */
+# endif /* MACOS */
+
+# if defined(I386) &&!defined(OS2) &&!defined(SVR4) &&!defined(MSWIN32) && !defined(SCO) && (!defined(LINUX) || !defined(__ELF__))
/* I386 code, generic code does not appear to work */
/* It does appear to work under OS2, and asms dont */
asm("pushl %eax"); asm("call _GC_push_one"); asm("addl $4,%esp");
asm("pushl %ecx"); asm("call _GC_push_one"); asm("addl $4,%esp");
asm("pushl %edx"); asm("call _GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %ebp"); asm("call _GC_push_one"); asm("addl $4,%esp");
asm("pushl %esi"); asm("call _GC_push_one"); asm("addl $4,%esp");
asm("pushl %edi"); asm("call _GC_push_one"); asm("addl $4,%esp");
asm("pushl %ebx"); asm("call _GC_push_one"); asm("addl $4,%esp");
# endif
+# if defined(I386) && defined(LINUX) && defined(__ELF__)
+ /* This is modified for Linux with ELF (Note: _ELF_ only) */
+ asm("pushl %eax"); asm("call GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %ecx"); asm("call GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %edx"); asm("call GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %ebp"); asm("call GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %esi"); asm("call GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %edi"); asm("call GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %ebx"); asm("call GC_push_one"); asm("addl $4,%esp");
+# endif
+
# if defined(I386) && defined(MSWIN32)
/* I386 code, Microsoft variant */
__asm push eax
__asm call GC_push_one
__asm add esp,4
+ __asm push ebx
+ __asm call GC_push_one
+ __asm add esp,4
__asm push ecx
__asm call GC_push_one
__asm add esp,4
__asm push edx
__asm call GC_push_one
__asm add esp,4
- __asm push esi
+ __asm push ebp
__asm call GC_push_one
__asm add esp,4
- __asm push edi
+ __asm push esi
__asm call GC_push_one
__asm add esp,4
- __asm push ebx
+ __asm push edi
__asm call GC_push_one
__asm add esp,4
# endif
-# if defined(I386) && defined(SUNOS5)
+# if defined(I386) && (defined(SVR4) || defined(SCO))
/* I386 code, SVR4 variant, generic code does not appear to work */
asm("pushl %eax"); asm("call GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %ebx"); asm("call GC_push_one"); asm("addl $4,%esp");
asm("pushl %ecx"); asm("call GC_push_one"); asm("addl $4,%esp");
asm("pushl %edx"); asm("call GC_push_one"); asm("addl $4,%esp");
+ asm("pushl %ebp"); asm("call GC_push_one"); asm("addl $4,%esp");
asm("pushl %esi"); asm("call GC_push_one"); asm("addl $4,%esp");
asm("pushl %edi"); asm("call GC_push_one"); asm("addl $4,%esp");
- asm("pushl %ebx"); asm("call GC_push_one"); asm("addl $4,%esp");
# endif
# ifdef NS32K
@@ -238,7 +301,7 @@ __asm GC_push_regs(
# endif /* M68K/SYSV */
-# if defined(HP_PA) || defined(M88K) || (defined(I386) && defined(OS2))
+# if defined(HP_PA) || defined(M88K) || defined(POWERPC) || (defined(I386) && defined(OS2))
/* Generic code */
/* The idea is due to Parag Patel at HP. */
/* We're not sure whether he would like */
@@ -253,7 +316,11 @@ __asm GC_push_regs(
for (; (char *)i < lim; i++) {
*i = 0;
}
- (void) _setjmp(regs);
+# ifdef POWERPC
+ (void) setjmp(regs);
+# else
+ (void) _setjmp(regs);
+# endif
GC_push_all_stack((ptr_t)regs, lim);
}
# endif
@@ -261,7 +328,7 @@ __asm GC_push_regs(
/* other machines... */
# if !(defined M68K) && !(defined VAX) && !(defined RT)
# if !(defined SPARC) && !(defined I386) && !(defined NS32K)
-# if !defined(HP_PA) && !defined(M88K)
+# if !defined(HP_PA) && !defined(M88K) && !defined(POWERPC)
--> bad news <--
# endif
# endif
@@ -272,9 +339,10 @@ __asm GC_push_regs(
/* the stack. Return sp. */
# ifdef SPARC
asm(" .seg \"text\"");
-# ifdef SUNOS5
+# ifdef SVR4
asm(" .globl GC_save_regs_in_stack");
asm("GC_save_regs_in_stack:");
+ asm(" .type GC_save_regs_in_stack,#function");
# else
asm(" .globl _GC_save_regs_in_stack");
asm("_GC_save_regs_in_stack:");
@@ -283,7 +351,10 @@ __asm GC_push_regs(
asm(" mov %sp,%o0");
asm(" retl");
asm(" nop");
-
+# ifdef SVR4
+ asm(" .GC_save_regs_in_stack_end:");
+ asm(" .size GC_save_regs_in_stack,.GC_save_regs_in_stack_end-GC_save_regs_in_stack");
+# endif
# ifdef LINT
word GC_save_regs_in_stack() { return(0 /* sp really */);}
# endif
@@ -304,6 +375,7 @@ __asm GC_push_regs(
# else
asm(".globl GC_clear_stack_inner");
asm("GC_clear_stack_inner:");
+ asm(".type GC_save_regs_in_stack,#function");
# endif
asm("mov %sp,%o2"); /* Save sp */
asm("add %sp,-8,%o3"); /* p = sp-8 */
@@ -320,6 +392,10 @@ __asm GC_push_regs(
asm("retl");
asm("mov %o2,%sp"); /* Restore sp., delay slot */
/* First argument = %o0 = return value */
+# ifdef SVR4
+ asm(" .GC_clear_stack_inner_end:");
+ asm(" .size GC_clear_stack_inner,.GC_clear_stack_inner_end-GC_clear_stack_inner");
+# endif
# ifdef LINT
/*ARGSUSED*/