tsun support - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 8a708fb239f4272ac7e4f16f437093c56b2cab39
 (DIR) parent cd7ddc9b5f34da33a2eb0ea761681c2330284e69
 (HTM) Author: rsc <devnull@localhost>
       Date:   Sun, 23 Nov 2003 18:18:41 +0000
       
       sun support
       
       Diffstat:
         A src/libthread/asm-SunOS-sun4u.s     |      51 +++++++++++++++++++++++++++++++
         M src/libthread/exec-unix.c           |      11 -----------
         A src/libthread/sun4u.c               |      25 +++++++++++++++++++++++++
       
       3 files changed, 76 insertions(+), 11 deletions(-)
       ---
 (DIR) diff --git a/src/libthread/asm-SunOS-sun4u.s b/src/libthread/asm-SunOS-sun4u.s
       t@@ -0,0 +1,51 @@
       +.globl _setlabel
       +.type  _setlabel,#function
       +
       +_setlabel:
       +        ta        3
       +        st        %i0, [%o0]
       +        st        %i1, [%o0+4]
       +        st        %i2, [%o0+8]
       +        st        %i3, [%o0+12]
       +        st        %i4, [%o0+16]
       +        st        %i5, [%o0+20]
       +        st        %i6, [%o0+24]
       +        st        %i7, [%o0+28]
       +        st        %l0, [%o0+32]
       +        st        %l1, [%o0+36]
       +        st        %l2, [%o0+40]
       +        st        %l3, [%o0+44]
       +        st        %l4, [%o0+48]
       +        st        %l5, [%o0+52]
       +        st        %l6, [%o0+56]
       +        st        %l7, [%o0+60]
       +        st        %sp, [%o0+64]
       +        st        %o7, [%o0+68]
       +        jmpl        %o7+8, %g0
       +        or        %g0, %g0, %o0
       +
       +.globl _gotolabel
       +.type        _gotolabel,#function
       +
       +_gotolabel:
       +        ta        3
       +        ld        [%o0], %i0
       +        ld        [%o0+4], %i1
       +        ld        [%o0+8], %i2
       +        ld        [%o0+12], %i3
       +        ld        [%o0+16], %i4
       +        ld        [%o0+20], %i5
       +        ld        [%o0+24], %i6
       +        ld        [%o0+28], %i7
       +        ld        [%o0+32], %l0
       +        ld        [%o0+36], %l1
       +        ld        [%o0+40], %l2
       +        ld        [%o0+44], %l3
       +        ld        [%o0+48], %l4
       +        ld        [%o0+52], %l5
       +        ld        [%o0+56], %l6
       +        ld        [%o0+60], %l7
       +        ld        [%o0+64], %sp
       +        ld        [%o0+68], %o7
       +        jmpl        %o7+8, %g0
       +        or        %g0, 1, %o0
 (DIR) diff --git a/src/libthread/exec-unix.c b/src/libthread/exec-unix.c
       t@@ -9,13 +9,11 @@ procexec(Channel *pidc, char *prog, char *args[])
                Proc *p;
                Thread *t;
        
       -print("procexec\n");
                _threaddebug(DBGEXEC, "procexec %s", prog);
                /* must be only thread in proc */
                p = _threadgetproc();
                t = p->thread;
                if(p->threads.head != t || p->threads.head->nextt != nil){
       -print("not only thread\n");
                        werrstr("not only thread in proc");
                Bad:
                        if(pidc)
       t@@ -36,35 +34,26 @@ print("not only thread\n");
                 * pipe to us.
                 */
                if(pipe(p->exec.fd) < 0)
       -{
       -print("pipe\n");
                        goto Bad;
       -}
                if(fcntl(p->exec.fd[1], F_SETFD, 1) < 0)
       -{
       -print("fcntl\n");
                        goto Bad;
       -}
        
                /* exec in parallel via the scheduler */
                assert(p->needexec==0);
                p->exec.prog = prog;
                p->exec.args = args;
                p->needexec = 1;
       -print("sched\n");
                _sched();
        
                close(p->exec.fd[1]);
                if((n = read(p->exec.fd[0], p->exitstr, ERRMAX-1)) > 0){        /* exec failed */
                        p->exitstr[n] = '\0';
       -print("read got %s\n", p->exitstr);
                        errstr(p->exitstr, ERRMAX);
                        close(p->exec.fd[0]);
                        goto Bad;
                }
                close(p->exec.fd[0]);
        
       -print("exec %d\n", pidc);
                if(pidc)
                        sendul(pidc, t->ret);
        
 (DIR) diff --git a/src/libthread/sun4u.c b/src/libthread/sun4u.c
       t@@ -0,0 +1,25 @@
       +#include "threadimpl.h"
       +
       +static void
       +launchersparc(int o0, int o1, int o2, int o3, int o4,
       +        void (*f)(void *arg), void *arg)
       +{
       +        (*f)(arg);
       +        threadexits(nil);
       +}
       +
       +void
       +_threadinitstack(Thread *t, void (*f)(void*), void *arg)
       +{
       +        ulong *tos, *stk;
       +
       +        tos = (ulong*)&t->stk[t->stksize&~7];
       +        stk = tos;
       +        --stk;
       +        *--stk = (ulong)arg;
       +        *--stk = (ulong)f;
       +        t->sched.link = (ulong)launchersparc - 8;
       +        t->sched.input[6] = 0;
       +        t->sched.sp = (ulong)stk - 0x5c;
       +}
       +