Back to index

lightning-sunbird  0.9+nobinonly
Functions
mach_dep.c File Reference
#include "gc_priv.h"
#include <stdio.h>
#include <setjmp.h>

Go to the source code of this file.

Functions

void foo ()
void GC_push_regs ()

Function Documentation

void foo ( )

Definition at line 26 of file mach_dep.c.

{
       foo();
}

Definition at line 101 of file mach_dep.c.

{
#       ifdef RT
         register long TMP_SP; /* must be bound to r11 */
#       endif
#       ifdef VAX
         /* VAX - generic code below does not work under 4.2 */
         /* r1 through r5 are caller save, and therefore     */
         /* on the stack or dead.                            */
         asm("pushl r11");     asm("calls $1,_GC_push_one");
         asm("pushl r10");  asm("calls $1,_GC_push_one");
         asm("pushl r9");   asm("calls $1,_GC_push_one");
         asm("pushl r8");   asm("calls $1,_GC_push_one");
         asm("pushl r7");   asm("calls $1,_GC_push_one");
         asm("pushl r6");   asm("calls $1,_GC_push_one");
#       endif
#       if defined(M68K) && (defined(SUNOS4) || defined(NEXT))
       /*  M68K SUNOS - could be replaced by generic code */
         /* a0, a1 and d1 are caller save          */
         /*  and therefore are on stack or dead.   */
       
         asm("subqw #0x4,sp");            /* allocate word on top of stack */

         asm("movl a2,sp@");       asm("jbsr _GC_push_one");
         asm("movl a3,sp@");       asm("jbsr _GC_push_one");
         asm("movl a4,sp@");       asm("jbsr _GC_push_one");
         asm("movl a5,sp@");       asm("jbsr _GC_push_one");
         /* Skip frame pointer and stack pointer */
         asm("movl d1,sp@");       asm("jbsr _GC_push_one");
         asm("movl d2,sp@");       asm("jbsr _GC_push_one");
         asm("movl d3,sp@");       asm("jbsr _GC_push_one");
         asm("movl d4,sp@");       asm("jbsr _GC_push_one");
         asm("movl d5,sp@");       asm("jbsr _GC_push_one");
         asm("movl d6,sp@");       asm("jbsr _GC_push_one");
         asm("movl d7,sp@");       asm("jbsr _GC_push_one");

         asm("addqw #0x4,sp");            /* put stack back where it was     */
#       endif

#       if defined(M68K) && defined(HP)
       /*  M68K HP - could be replaced by generic code */
         /* a0, a1 and d1 are caller save.  */
       
         asm("subq.w &0x4,%sp");   /* allocate word on top of stack */

         asm("mov.l %a2,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %a3,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %a4,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %a5,(%sp)"); asm("jsr _GC_push_one");
         /* Skip frame pointer and stack pointer */
         asm("mov.l %d1,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %d2,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %d3,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %d4,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %d5,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %d6,(%sp)"); asm("jsr _GC_push_one");
         asm("mov.l %d7,(%sp)"); asm("jsr _GC_push_one");

         asm("addq.w &0x4,%sp");   /* put stack back where it was     */
#       endif /* M68K HP */

#       ifdef AMIGA
       /*  AMIGA - could be replaced by generic code                  */
         /* a0, a1, d0 and d1 are caller save */
         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(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(MACOS)
#      if defined(M68K) && 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 && M68K */
#        if defined(__MWERKS__)
           PushMacRegisters();
#        endif       /* __MWERKS__ */
#   endif     /* MACOS */

#       if defined(I386) &&!defined(OS2) &&!defined(SVR4) &&!defined(MSWIN32) \
       && !defined(SCO) && !defined(SCO_ELF) \
       && !(defined(LINUX)       && defined(__ELF__)) \
       && !(defined(__FreeBSD__) && defined(__ELF__)) \
       && !defined(DOS4GW)
       /* I386 code, generic code does not appear to work */
       /* It does appear to work under OS2, and asms dont */
       /* This is used for some 38g UNIX variants and for CYGWIN32 */
         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__) ) \
       || ( defined(I386) && defined(__FreeBSD__) && defined(__ELF__) )

       /* This is modified for Linux with ELF (Note: _ELF_ only) */
       /* This section handles FreeBSD with ELF. */
         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) && !defined(USE_GENERIC)
       /* 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 ebp
         __asm  call GC_push_one
         __asm  add esp,4
         __asm  push esi
         __asm  call GC_push_one
         __asm  add esp,4
         __asm  push edi
         __asm  call GC_push_one
         __asm  add esp,4
#       endif

#       if defined(I386) && (defined(SVR4) || defined(SCO) || defined(SCO_ELF))
       /* 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");
#       endif

#       ifdef NS32K
         asm ("movd r3, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4");
         asm ("movd r4, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4");
         asm ("movd r5, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4");
         asm ("movd r6, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4");
         asm ("movd r7, tos"); asm ("bsr ?_GC_push_one"); asm ("adjspb $-4");
#       endif

#       ifdef SPARC
         {
             word GC_save_regs_in_stack();
             
             /* generic code will not work */
             (void)GC_save_regs_in_stack();
         }
#       endif

#      ifdef RT
           GC_push_one(TMP_SP);    /* GC_push_one from r11 */

           asm("cas r11, r6, r0"); GC_push_one(TMP_SP); /* r6 */
           asm("cas r11, r7, r0"); GC_push_one(TMP_SP); /* through */
           asm("cas r11, r8, r0"); GC_push_one(TMP_SP); /* r10 */
           asm("cas r11, r9, r0"); GC_push_one(TMP_SP);
           asm("cas r11, r10, r0"); GC_push_one(TMP_SP);

           asm("cas r11, r12, r0"); GC_push_one(TMP_SP); /* r12 */
           asm("cas r11, r13, r0"); GC_push_one(TMP_SP); /* through */
           asm("cas r11, r14, r0"); GC_push_one(TMP_SP); /* r15 */
           asm("cas r11, r15, r0"); GC_push_one(TMP_SP);
#       endif

#       if defined(M68K) && defined(SYSV)
       /*  Once again similar to SUN and HP, though setjmp appears to work.
              --Parag
        */
#        ifdef __GNUC__
         asm("subqw #0x4,%sp");    /* allocate word on top of stack */
  
         asm("movl %a2,%sp@");     asm("jbsr GC_push_one");
         asm("movl %a3,%sp@");     asm("jbsr GC_push_one");
         asm("movl %a4,%sp@");     asm("jbsr GC_push_one");
         asm("movl %a5,%sp@");     asm("jbsr GC_push_one");
         /* Skip frame pointer and stack pointer */
         asm("movl %d1,%sp@");     asm("jbsr GC_push_one");
         asm("movl %d2,%sp@");     asm("jbsr GC_push_one");
         asm("movl %d3,%sp@");     asm("jbsr GC_push_one");
         asm("movl %d4,%sp@");     asm("jbsr GC_push_one");
         asm("movl %d5,%sp@");     asm("jbsr GC_push_one");
         asm("movl %d6,%sp@");     asm("jbsr GC_push_one");
         asm("movl %d7,%sp@");     asm("jbsr GC_push_one");
  
         asm("addqw #0x4,%sp");    /* put stack back where it was     */
#        else /* !__GNUC__*/
         asm("subq.w &0x4,%sp");   /* allocate word on top of stack */
  
         asm("mov.l %a2,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %a3,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %a4,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %a5,(%sp)"); asm("jsr GC_push_one");
         /* Skip frame pointer and stack pointer */
         asm("mov.l %d1,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %d2,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %d3,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %d4,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %d5,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %d6,(%sp)"); asm("jsr GC_push_one");
         asm("mov.l %d7,(%sp)"); asm("jsr GC_push_one");
  
         asm("addq.w &0x4,%sp");   /* put stack back where it was     */
#        endif /* !__GNUC__ */
#       endif /* M68K/SYSV */


      /* other machines... */
#       if !(defined M68K) && !(defined VAX) && !(defined RT) 
#      if !(defined SPARC) && !(defined I386) && !(defined NS32K)
#      if !defined(POWERPC) && !defined(UTS4)
           --> bad news <--
#       endif
#       endif
#       endif
}

Here is the call graph for this function:

Here is the caller graph for this function: