Solaris 2.5 and SunC compiler

Gilles Dauphin dauphin at sig.enst.fr
Thu Mar 13 01:05:32 PST 1997


I suggest you add this files in kaffe:

kaffe-0.8.2/config/sparc/sunc-threads.h ------------------------
/*
 * sparc/sunc-threads.h
 * Sparc threading information.
 *
 */

#ifndef __sparc_sunc_threads_h
#define __sparc_sunc_threads_h

#ifndef USE_SPARC_PROF_C
/* we don't use SparcWorks professional */

#else
		/* We use SparcWorks Prof C  G.D. 12/Mars/97  */

/**/
/* Thread handling */
/**/

void ThreadSwitch( ctx * to,  ctx * from );
int ThreadFrames( thread* tid);
void ThreadInit( ctx * to, void (*)() );  /* ou func = void *  */
void ThreadInfo(ctx * ee);

#pragma unknow_control_flow (ThreadSwitch)

void ThreadSwitch( ctx * to,  ctx * from )
{
        int regstore[6];
        register int *reg;		/* %i5 */
        register uint8 ** frp;		/* %i4 */
        register uint8 ** trp;		/* %i3 */
 
 
        reg = regstore; /* avoid compiler optimisation */
        frp =  &((from)->restorePoint);
        trp =  &((to)->restorePoint);
 
        asm("                                                   \n\
                call 1f                                         \n\
                nop                                             \n\
1:                                                              \n\
                add %o7,%lo(2f-1b+8),%l0                        \n\
                                                                \n\
                ta 3                                            \n\
                st %l0,[%i5+0]                                  \n\
                st %fp,[%i5+4]                                  \n\
                st %sp,[%i5+8]                                  \n\
                st %i5,[%i5+12]                                 \n\
                st %i7,[%i5+16]                                 \n\
                st %i5,[%i4]                                    \n\
                                                                \n\
                ld [%i3],%i5                                    \n\
                ld [%i5+16],%i7                                 \n\
                ld [%i5+12],%i5                                 \n\
                ld [%i5+8],%sp                                  \n\
                ld [%i5+4],%fp                                  \n\
                ld [%i5+0],%l0                                  \n\
                                                                \n\
                jmpl %l0,%g0                                    \n\
                nop                                             \n\
2:              nop"
        );
}

void ThreadInit( ctx * to, void (*func)() )  /* ou func = void *  */
{
        int* regstore = (int*)((to)->stackEnd - (6 * 4));

        (to)->restorePoint = (void*)regstore;
        regstore[0] = (int)func;
        regstore[1] = ((int)regstore) - (16 * 4);
        regstore[2] = regstore[1];
        regstore[3] = 0;
        regstore[4] = 0;
}
 
void ThreadInfo(ctx * ee)
{
        void** ptr;     /* %fp -4 */
        int i;          /* %fp -8 */
                        /* no return value */
 
        asm("   ta 3");              
/* gnu as       asm("mov %%sp,%0" : "=r" (ptr)); */
        asm("   mov %sp,%o4");       
        asm("   st %o4,[%fp-4]");    
                                     
        for (i = 0; i != 2; i++) {   
                ptr = (void**)ptr[14];
        }                            
                                     
        (ee)->restorePoint = 0;      
        (ee)->stackEnd = (void*)ptr; 
        (ee)->stackBase = (ee)->stackEnd - threadStackSize;
        (ee)->flags = THREAD_FLAGS_NOSTACKALLOC;
}                                    
                                     
int ThreadFrames( thread* tid)       
{                                    
        void** ptr;             /* %fp -8 */
        int cnt = 0;            /* %fp -12 */
                                /* return value is in %fp-4 */
                                     
        if (tid == currentThread) {  
                asm("   ta 3");      
/* gcc asm              asm("mov %%sp,%0" : "=r" (ptr));*/
                asm("   mov %sp,%o3");
                asm("   st %o3,[%fp-8]"); 
        } else {                     
                ptr = ((void***)TCTX(tid)->restorePoint)[2];
        }                            
        while (*ptr != 0) {          
                cnt++ ;              
                ptr = (void**)ptr[14];
        }                            
        return cnt;                  
}                                    

#endif

#endif
--------------------------------------------------------

Modification to file kaffe-0.8.2/config/sparc/threads.h ----------------------
#define THREADSTACKSIZE         (32 * 1024)

#ifndef USE_SPARC_PROF_C
/* we don't use SparcWorks professional */

#define THREADSWITCH(to, from) {                                \
        int regstore[6];                                        \
        asm("                                                   \n\
                call 1f                                         \n\
.... GNU C as code

#else
                /* We use SparcWorks Prof C  G.D. 12/Mars/97  */
                                        
                                        
/**/                                    
/* Thread handling */                   
/**/                                    
                                        
#define THREADSWITCH(to, from) ThreadSwitch(to, from)
                                        
#define THREADINIT(to, func) ThreadInit(to, func)
                                        
#define THREADINFO(ee) ThreadInfo(ee)   
                                        
#define THREADFRAMES(tid, cnt) cnt = ThreadFrames(tid)
                                        
#endif    /* USE_SPARC_PROF_C */

#endif    /* __sparc_threads_h */
---------------------------------------------


Hope this help

Gilles


More information about the kaffe mailing list