tSunOS can rot in hell. - 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 be22ae2d0729f68672e3202c91cfe13c9e74cccc
 (DIR) parent 4e3a2cc1f96f4479f951958f9ca1860f57a0771b
 (HTM) Author: rsc <devnull@localhost>
       Date:   Fri, 26 Mar 2004 01:59:35 +0000
       
       SunOS can rot in hell.
       
       Diffstat:
         M include/draw.h                      |      62 +++++++++++++++----------------
         M src/cmd/9p.c                        |       2 +-
         M src/cmd/9term/9term.c               |      32 ++++++++++++++++++++++---------
         M src/cmd/9term/SunOS.c               |      19 +++++++++++++++++--
         M src/cmd/9term/rcstart.c             |       7 ++++++-
         M src/cmd/9term/win.c                 |       4 ++--
         M src/cmd/acme/addr.c                 |       6 +++---
         M src/cmd/acme/exec.c                 |       2 +-
         M src/cmd/acme/fns.h                  |       1 +
         M src/cmd/acme/fsys.c                 |      10 +++++-----
         M src/cmd/acme/look.c                 |       4 ++--
         M src/cmd/acme/text.c                 |       2 +-
         M src/cmd/acme/util.c                 |      10 ++++++++++
         M src/cmd/acme/xfid.c                 |      10 +++++-----
         M src/cmd/dict/ahd.c                  |      23 ++++++++++++++---------
         M src/cmd/dict/movie.c                |       2 +-
         M src/cmd/dict/oed.c                  |       4 ++--
         M src/cmd/grep/grep.y                 |       2 +-
         M src/cmd/plumb/fsys.c                |      36 +++++++++++++++++--------------
         M src/cmd/ramfs.c                     |      35 ++++++++++++++++++-------------
         M src/cmd/rc/plan9ish.c               |       7 +++----
         M src/cmd/sam/unix.c                  |       1 +
         M src/cmd/samterm/plan9.c             |       1 +
         M src/lib9/date.c                     |       2 +-
         M src/libdraw/devdraw.c               |       8 ++++----
         M src/libdraw/ellipse.c               |       8 ++++----
         M src/libdraw/md-draw.c               |       2 +-
         M src/libdraw/ml-lsetrefresh.c        |       2 +-
         M src/libdraw/unix.c                  |       3 +--
         M src/libdraw/x11-alloc.c             |       3 +--
         M src/libdraw/x11-cload.c             |       3 +--
         M src/libdraw/x11-draw.c              |       3 +--
         M src/libdraw/x11-event.c             |       3 +--
         M src/libdraw/x11-fill.c              |       3 +--
         M src/libdraw/x11-get.c               |       3 +--
         M src/libdraw/x11-init.c              |       9 +++++----
         M src/libdraw/x11-itrans.c            |      11 +++++------
         M src/libdraw/x11-keyboard.c          |       2 +-
         M src/libdraw/x11-load.c              |       3 +--
         M src/libdraw/x11-mouse.c             |       2 +-
         M src/libdraw/x11-pixelbits.c         |       3 +--
         M src/libdraw/x11-unload.c            |       3 +--
         M src/libdraw/x11-wsys.c              |       2 +-
         M src/libfs/wstat.c                   |       2 +-
         M src/libmp/port/dat.h                |       2 +-
         M src/libsec/port/x509.c              |       2 +-
         M src/libthread/exec-unix.c           |       1 +
         M src/libthread/exit.c                |       1 +
         M src/libthread/ioopen.c              |       1 +
         M src/libthread/kill.c                |       1 +
         M src/libthread/main.c                |       1 +
         M src/libthread/note.c                |       4 ++--
       
       52 files changed, 213 insertions(+), 162 deletions(-)
       ---
 (DIR) diff --git a/include/draw.h b/include/draw.h
       t@@ -21,39 +21,35 @@ typedef struct        Subfont Subfont;
        extern        int        Rfmt(Fmt*);
        extern        int        Pfmt(Fmt*);
        
       -enum
       -{
       -        DOpaque                = 0xFFFFFFFF,
       -        DTransparent        = 0x00000000,                /* only useful for allocimage, memfillcolor */
       -        DBlack                = 0x000000FF,
       -        DWhite                = 0xFFFFFFFF,
       -        DRed                = 0xFF0000FF,
       -        DGreen                = 0x00FF00FF,
       -        DBlue                = 0x0000FFFF,
       -        DCyan                = 0x00FFFFFF,
       -        DMagenta                = 0xFF00FFFF,
       -        DYellow                = 0xFFFF00FF,
       -        DPaleyellow        = 0xFFFFAAFF,
       -        DDarkyellow        = 0xEEEE9EFF,
       -        DDarkgreen        = 0x448844FF,
       -        DPalegreen        = 0xAAFFAAFF,
       -        DMedgreen        = 0x88CC88FF,
       -        DDarkblue        = 0x000055FF,
       -        DPalebluegreen= 0xAAFFFFFF,
       -        DPaleblue                = 0x0000BBFF,
       -        DBluegreen        = 0x008888FF,
       -        DGreygreen        = 0x55AAAAFF,
       -        DPalegreygreen        = 0x9EEEEEFF,
       -        DYellowgreen        = 0x99994CFF,
       -        DMedblue                = 0x000099FF,
       -        DGreyblue        = 0x005DBBFF,
       -        DPalegreyblue        = 0x4993DDFF,
       -        DPurpleblue        = 0x8888CCFF,
       -
       -        DNotacolor        = 0xFFFFFF00,
       -        DNofill                = DNotacolor,
       -        
       -};
       +#define         DOpaque                0xFFFFFFFF
       +#define         DTransparent        0x00000000                /* only useful for allocimage memfillcolor */
       +#define         DBlack                0x000000FF
       +#define         DWhite                0xFFFFFFFF
       +#define         DRed                0xFF0000FF
       +#define         DGreen                0x00FF00FF
       +#define         DBlue                0x0000FFFF
       +#define         DCyan                0x00FFFFFF
       +#define         DMagenta                0xFF00FFFF
       +#define         DYellow                0xFFFF00FF
       +#define         DPaleyellow        0xFFFFAAFF
       +#define         DDarkyellow        0xEEEE9EFF
       +#define         DDarkgreen        0x448844FF
       +#define         DPalegreen        0xAAFFAAFF
       +#define         DMedgreen        0x88CC88FF
       +#define         DDarkblue        0x000055FF
       +#define         DPalebluegreen 0xAAFFFFFF
       +#define         DPaleblue                0x0000BBFF
       +#define         DBluegreen        0x008888FF
       +#define         DGreygreen        0x55AAAAFF
       +#define         DPalegreygreen        0x9EEEEEFF
       +#define         DYellowgreen        0x99994CFF
       +#define         DMedblue                0x000099FF
       +#define         DGreyblue        0x005DBBFF
       +#define         DPalegreyblue        0x4993DDFF
       +#define         DPurpleblue        0x8888CCFF
       +
       +#define         DNotacolor        0xFFFFFF00
       +#define         DNofill                DNotacolor
        
        enum
        {
 (DIR) diff --git a/src/cmd/9p.c b/src/cmd/9p.c
       t@@ -239,7 +239,7 @@ xstat(int argc, char **argv)
                        usage();
        
                fid = xwalk(argv[0]);
       -        if((d = fsdirfstat(fid)) < 0)
       +        if((d = fsdirfstat(fid)) == 0)
                        sysfatal("dirfstat: %r");
                fmtinstall('D', dirfmt);
                fmtinstall('M', dirmodefmt);
 (DIR) diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c
       t@@ -214,7 +214,7 @@ threadmain(int argc, char *argv[])
                if(maxtab <= 0)
                        maxtab = 8;
        
       -        initdraw(nil, nil, "9term");
       +        initdraw(0, nil, "9term");
                notify(hangupnote);
        
                mc = initmouse(nil, screen);
       t@@ -299,13 +299,27 @@ loop(void)
        {
                Rune r;
                int i;
       -        Alt a[] = {
       -                {mc->c, &mc->m, CHANRCV},
       -                {kc->c, &r, CHANRCV},
       -                {hostc, &i, CHANRCV},
       -                {mc->resizec, nil, CHANRCV},
       -                {nil, nil, CHANEND},
       -        };
       +        Alt a[5];
       +
       +        a[0].c = mc->c;
       +        a[0].v = &mc->m;
       +        a[0].op = CHANRCV;
       +
       +        a[1].c = kc->c;
       +        a[1].v = &r;
       +        a[1].op = CHANRCV;
       +
       +        a[2].c = hostc;
       +        a[2].v = &i;
       +        a[2].op = CHANRCV;
       +
       +        a[3].c = mc->resizec;
       +        a[3].v = nil;
       +        a[3].op = CHANRCV;
       +
       +        a[4].c = nil;
       +        a[4].v = nil;
       +        a[4].op = CHANEND;
        
                for(;;) {
                        tcheck();
       t@@ -326,7 +340,7 @@ loop(void)
                                key(r);
                                break;
                        case 2:
       -                        conswrite(rcbuf[i].data, rcbuf[i].n);
       +                        conswrite((char*)rcbuf[i].data, rcbuf[i].n);
                                break;
                        case 3:
                                doreshape();
 (DIR) diff --git a/src/cmd/9term/SunOS.c b/src/cmd/9term/SunOS.c
       t@@ -1,6 +1,8 @@
       -#include "9term.h"
       +#include <u.h>
        #include <termios.h>
        #include <sys/termios.h>
       +#include <libc.h>
       +#include "term.h"
        
        int
        getpts(int fd[], char *slave)
       t@@ -14,6 +16,19 @@ getpts(int fd[], char *slave)
                return 0;
        }
        
       +int
       +childpty(int fd[], char *slave)
       +{
       +        int sfd;
       +
       +        close(fd[1]);
       +        setsid();
       +        sfd = open(slave, ORDWR);
       +        if(sfd < 0)
       +                sysfatal("open %s: %r\n", slave);
       +        return sfd;
       +}
       +
        struct winsize ows;
        
        void
       t@@ -26,7 +41,7 @@ updatewinsize(int row, int col, int dx, int dy)
                ws.ws_xpixel = dx;
                ws.ws_ypixel = dy;
                if(ws.ws_row != ows.ws_row || ws.ws_col != ows.ws_col)
       -        if(ioctl(rcfd[0], TIOCSWINSZ, &ws) < 0)
       +        if(ioctl(rcfd, TIOCSWINSZ, &ws) < 0)
                        fprint(2, "ioctl: %r\n");
                ows = ws;
        }
 (DIR) diff --git a/src/cmd/9term/rcstart.c b/src/cmd/9term/rcstart.c
       t@@ -35,7 +35,12 @@ rcstart(int argc, char **argv, int *pfd)
                        dup(sfd, 0);
                        dup(sfd, 1);
                        dup(sfd, 2);
       -                system("stty tabs -onlcr -echo erase ^h intr ^?");
       +//                system("stty tabs -onlcr -echo erase '^h' intr '^?'");
       +                system("echo tabs; stty tabs");
       +                system("echo onlcr; stty -onlcr");
       +                system("echo echo; stty -echo");
       +                system("echo erase; stty erase '^h'");
       +                system("echo intr; stty intr '^?'");
                        execvp(argv[0], argv);
                        fprint(2, "exec %s failed: %r\n", argv[0]);
                        _exits("oops");
 (DIR) diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c
       t@@ -133,10 +133,10 @@ threadmain(int argc, char **argv)
                        name = "gnot";
        
                threadnotify(nopipes, 1);
       -        if((fs = nsmount("acme", "")) < 0)
       +        if((fs = nsmount("acme", "")) == 0)
                        sysfatal("nsmount acme: %r");
                ctlfd = fsopen(fs, "new/ctl", ORDWR|OCEXEC);
       -        if(ctlfd < 0 || fsread(ctlfd, buf, 12) != 12)
       +        if(ctlfd == 0 || fsread(ctlfd, buf, 12) != 12)
                        sysfatal("ctl: %r");
                id = atoi(buf);
                sprint(buf, "%d/tag", id);
 (DIR) diff --git a/src/cmd/acme/addr.c b/src/cmd/acme/addr.c
       t@@ -64,7 +64,7 @@ number(Mntdir *md, Text *t, Range r, int line, int dir, int size, int *evalp)
                        if(line<0 || line>t->file->b.nc)
                                goto Rescue;
                        *evalp = TRUE;
       -                return (Range){line, line};
       +                return range(line, line);
                }
                q0 = r.q0;
                q1 = r.q1;
       t@@ -104,7 +104,7 @@ number(Mntdir *md, Text *t, Range r, int line, int dir, int size, int *evalp)
                                --q0;
                }
                *evalp = TRUE;
       -        return (Range){q0, q1};
       +        return range(q0, q1);
        
            Rescue:
                if(md != nil)
       t@@ -197,7 +197,7 @@ address(Mntdir *md, Text *t, Range lim, Range ar, void *a, uint q0, uint q1, int
                                        if(c == '.')
                                                r = ar;
                                        else
       -                                        r = (Range){t->file->b.nc, t->file->b.nc};
       +                                        r = range(t->file->b.nc, t->file->b.nc);
                                if(q < q1)
                                        dir = Fore;
                                else
 (DIR) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c
       t@@ -106,7 +106,7 @@ Exectab exectab[] = {
                { LTab,                tab,                FALSE,        XXX,                XXX                },
                { LUndo,                undo,        FALSE,        TRUE,        XXX                },
                { LZerox,        zeroxx,        FALSE,        XXX,                XXX                },
       -        { nil,                         nil,                0,                0,                0                },
       +        { nil,                         0,                0,                0,                0                },
        };
        
        Exectab*
 (DIR) diff --git a/src/cmd/acme/fns.h b/src/cmd/acme/fns.h
       t@@ -91,6 +91,7 @@ void                flushwarnings(void);
        void                startplumbing(void);
        
        Runestr        runestr(Rune*, uint);
       +Range range(int, int);
        
        #define        runemalloc(a)                (Rune*)emalloc((a)*sizeof(Rune))
        #define        runerealloc(a, b)        (Rune*)erealloc((a), (b)*sizeof(Rune))
 (DIR) diff --git a/src/cmd/acme/fsys.c b/src/cmd/acme/fsys.c
       t@@ -310,7 +310,7 @@ Xfid*
        fsysflush(Xfid *x, Fid *f)
        {
                USED(f);
       -        sendp(x->c, xfidflush);
       +        sendp(x->c, (void*)xfidflush);
                return nil;
        }
        
       t@@ -526,7 +526,7 @@ fsysopen(Xfid *x, Fid *f)
                if(((f->dir->perm&~(DMDIR|DMAPPEND))&m) != m)
                        goto Deny;
        
       -        sendp(x->c, xfidopen);
       +        sendp(x->c, (void*)xfidopen);
                return nil;
        
            Deny:
       t@@ -624,7 +624,7 @@ fsysread(Xfid *x, Fid *f)
                        free(b);
                        return x;
                }
       -        sendp(x->c, xfidread);
       +        sendp(x->c, (void*)xfidread);
                return nil;
        }
        
       t@@ -633,7 +633,7 @@ Xfid*
        fsyswrite(Xfid *x, Fid *f)
        {
                USED(f);
       -        sendp(x->c, xfidwrite);
       +        sendp(x->c, (void*)xfidwrite);
                return nil;
        }
        
       t@@ -642,7 +642,7 @@ Xfid*
        fsysclunk(Xfid *x, Fid *f)
        {
                fsysdelid(f->mntdir);
       -        sendp(x->c, xfidclose);
       +        sendp(x->c, (void*)xfidclose);
                return nil;
        }
        
 (DIR) diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c
       t@@ -591,7 +591,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
                e->u.at = t;
                e->a0 = amin+1;
                eval = FALSE;
       -        address(nil, nil, (Range){-1,-1}, (Range){0, 0}, t, e->a0, amax, tgetc, &eval, (uint*)&e->a1);
       +        address(nil, nil, range(-1,-1), range(0,0), t, e->a0, amax, tgetc, &eval, (uint*)&e->a1);
                return TRUE;
        
           Isntfile:
       t@@ -723,7 +723,7 @@ openfile(Text *t, Expand *e)
                        eval = FALSE;
                else{
                        eval = TRUE;
       -                r = address(nil, t, (Range){-1, -1}, (Range){t->q0, t->q1}, e->u.at, e->a0, e->a1, e->agetc, &eval, &dummy);
       +                r = address(nil, t, range(-1,-1), range(t->q0, t->q1), e->u.at, e->a0, e->a1, e->agetc, &eval, &dummy);
                        if(eval == FALSE)
                                e->jump = FALSE;        /* don't jump if invalid address */
                }
 (DIR) diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
       t@@ -894,7 +894,7 @@ textselect(Text *t)
                        /* horrible botch: while asleep, may have lost selection altogether */
                        if(selectq > t->file->b.nc)
                                selectq = t->org + t->fr.p0;
       -                t->fr.scroll = nil;
       +                t->fr.scroll = 0;
                        if(selectq < t->org)
                                q0 = selectq;
                        else
 (DIR) diff --git a/src/cmd/acme/util.c b/src/cmd/acme/util.c
       t@@ -14,6 +14,16 @@
        static        Point                prevmouse;
        static        Window        *mousew;
        
       +Range
       +range(int q0, int q1)
       +{
       +        Range r;
       +
       +        r.q0 = q0;
       +        r.q1 = q1;
       +        return r;
       +}
       +
        Runestr
        runestr(Rune *r, uint n)
        {
 (DIR) diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c
       t@@ -47,7 +47,7 @@ xfidctl(void *arg)
                threadsetname("xfidctlthread");
                x = arg;
                for(;;){
       -                f = recvp(x->c);
       +                f = (void(*)(Xfid*))recvp(x->c);
                        (*f)(x);
                        flushimage(display, 1);
                        sendp(cxfidfree, x);
       t@@ -104,8 +104,8 @@ xfidopen(Xfid *x)
                        switch(q){
                        case QWaddr:
                                if(w->nopen[q]++ == 0){
       -                                w->addr = (Range){0,0};
       -                                w->limit = (Range){-1,-1};
       +                                w->addr = range(0,0);
       +                                w->limit = range(-1,-1);
                                }
                                break;
                        case QWdata:
       t@@ -164,7 +164,7 @@ xfidopen(Xfid *x)
                                seq++;
                                filemark(t->file);
                                cut(t, t, nil, FALSE, TRUE, nil, 0);
       -                        w->wrselrange = (Range){t->q1, t->q1};
       +                        w->wrselrange = range(t->q1, t->q1);
                                w->nomark = TRUE;
                                break;
                        case QWeditout:
       t@@ -173,7 +173,7 @@ xfidopen(Xfid *x)
                                        respond(x, &fc, Eperm);
                                        return;
                                }
       -                        w->wrselrange = (Range){t->q1, t->q1};
       +                        w->wrselrange = range(t->q1, t->q1);
                                break;
                        }
                        winunlock(w);
 (DIR) diff --git a/src/cmd/dict/ahd.c b/src/cmd/dict/ahd.c
       t@@ -7,15 +7,19 @@
         * American Heritage Dictionary (encrypted)
         */
        
       -static Rune intab[256] = {
       -        [0x82] 0xe9,
       -        [0x85] 0xe0,
       -        [0x89] 0xeb,
       -        [0x8a] 0xe8,
       -        [0xa4] 0xf1,
       -        [0xf8] 0xb0,
       -        [0xf9] 0xb7,
       -};
       +static Rune intab[256];
       +
       +static void
       +initintab(void)
       +{
       +        intab[0x82] =  0xe9;
       +        intab[0x85] =  0xe0;
       +        intab[0x89] =  0xeb;
       +        intab[0x8a] =  0xe8;
       +        intab[0xa4] =  0xf1;
       +        intab[0xf8] =  0xb0;
       +        intab[0xf9] =  0xb7;
       +}
        
        static char        tag[64];
        
       t@@ -33,6 +37,7 @@ ahdprintentry(Entry e, int cmd)
                int c, state = Run;
        
                if(!inited){
       +                initintab();
                        for(c=0; c<256; c++)
                                if(intab[c] == 0)
                                        intab[c] = c;
 (DIR) diff --git a/src/cmd/dict/movie.c b/src/cmd/dict/movie.c
       t@@ -67,7 +67,7 @@ inittagtab(void)
                tagtab[TI]=        "TI";
                tagtab[TX]=        "TX";
                tagtab[VD]=        "VD";
       -};
       +}
        
        static char        *mget(int, char *, char *, char **);
        #if 0
 (DIR) diff --git a/src/cmd/dict/oed.c b/src/cmd/dict/oed.c
       t@@ -992,7 +992,7 @@ static int        naux;
        static char        auxname[Maxaux][Buflen];
        static char        auxval[Maxaux][Buflen];
        static char        spec[Buflen];
       -static uchar        *auxstate[Naux];        /* vals for most recent tag */
       +static char        *auxstate[Naux];        /* vals for most recent tag */
        static Entry        curentry;
        #define cursize (curentry.end-curentry.start)
        
       t@@ -1154,7 +1154,7 @@ oedprintentry(Entry e, int cmd)
                                                                outchars(auxstate[Num]);
                                                                outchars(") ");
                                                        } else if(t == Sgk) {
       -                                                        i = grtab[auxstate[Num][0]];
       +                                                        i = grtab[(uchar)auxstate[Num][0]];
                                                                if(i != NONE)
                                                                        outrune(i);
                                                                outchars(".  ");
 (DIR) diff --git a/src/cmd/grep/grep.y b/src/cmd/grep/grep.y
       t@@ -124,7 +124,7 @@ yyerror(char *e, ...)
                exits("syntax");
        }
        
       -long
       +int
        yylex(void)
        {
                char *q, *eq;
 (DIR) diff --git a/src/cmd/plumb/fsys.c b/src/cmd/plumb/fsys.c
       t@@ -122,22 +122,25 @@ static Fcall* fsysremove(Fcall*, uchar*, Fid*);
        static Fcall* fsysstat(Fcall*, uchar*, Fid*);
        static Fcall* fsyswstat(Fcall*, uchar*, Fid*);
        
       -Fcall*         (*fcall[Tmax])(Fcall*, uchar*, Fid*) =
       -{
       -        [Tflush]        = fsysflush,
       -        [Tversion]        = fsysversion,
       -        [Tauth]        = fsysauth,
       -        [Tattach]        = fsysattach,
       -        [Twalk]        = fsyswalk,
       -        [Topen]        = fsysopen,
       -        [Tcreate]        = fsyscreate,
       -        [Tread]        = fsysread,
       -        [Twrite]        = fsyswrite,
       -        [Tclunk]        = fsysclunk,
       -        [Tremove]= fsysremove,
       -        [Tstat]        = fsysstat,
       -        [Twstat]        = fsyswstat,
       -};
       +Fcall*         (*fcall[Tmax])(Fcall*, uchar*, Fid*);
       +
       +static void
       +initfcall(void)
       +{
       +        fcall[Tflush]        = fsysflush;
       +        fcall[Tversion]        = fsysversion;
       +        fcall[Tauth]        = fsysauth;
       +        fcall[Tattach]        = fsysattach;
       +        fcall[Twalk]        = fsyswalk;
       +        fcall[Topen]        = fsysopen;
       +        fcall[Tcreate]        = fsyscreate;
       +        fcall[Tread]        = fsysread;
       +        fcall[Twrite]        = fsyswrite;
       +        fcall[Tclunk]        = fsysclunk;
       +        fcall[Tremove]= fsysremove;
       +        fcall[Tstat]        = fsysstat;
       +        fcall[Twstat]        = fsyswstat;
       +}
        
        char        Ebadfcall[] =        "bad fcall type";
        char        Eperm[] =         "permission denied";
       t@@ -208,6 +211,7 @@ fsysproc(void *v)
                uchar *buf;
        
                USED(v);
       +        initfcall();
                t = nil;
                for(;;){
                        buf = malloc(messagesize);        /* avoid memset of emalloc */
 (DIR) diff --git a/src/cmd/ramfs.c b/src/cmd/ramfs.c
       t@@ -89,21 +89,25 @@ char        *rflush(Fid*), *rversion(Fid*), *rauth(Fid*),
                *rread(Fid*), *rwrite(Fid*), *rclunk(Fid*),
                *rremove(Fid*), *rstat(Fid*), *rwstat(Fid*);
        
       -char         *(*fcalls[])(Fid*) = {
       -        [Tversion]        rversion,
       -        [Tflush]        rflush,
       -        [Tauth]        rauth,
       -        [Tattach]        rattach,
       -        [Twalk]                rwalk,
       -        [Topen]                ropen,
       -        [Tcreate]        rcreate,
       -        [Tread]                rread,
       -        [Twrite]        rwrite,
       -        [Tclunk]        rclunk,
       -        [Tremove]        rremove,
       -        [Tstat]                rstat,
       -        [Twstat]        rwstat,
       -};
       +char         *(*fcalls[Tmax])(Fid*);
       +
       +static void
       +initfcalls(void)
       +{
       +        fcalls[Tversion]=        rversion;
       +        fcalls[Tflush]=        rflush;
       +        fcalls[Tauth]=        rauth;
       +        fcalls[Tattach]=        rattach;
       +        fcalls[Twalk]=                rwalk;
       +        fcalls[Topen]=                ropen;
       +        fcalls[Tcreate]=        rcreate;
       +        fcalls[Tread]=                rread;
       +        fcalls[Twrite]=        rwrite;
       +        fcalls[Tclunk]=        rclunk;
       +        fcalls[Tremove]=        rremove;
       +        fcalls[Tstat]=                rstat;
       +        fcalls[Twstat]=        rwstat;
       +}
        
        char        Eperm[] =        "permission denied";
        char        Enotdir[] =        "not a directory";
       t@@ -141,6 +145,7 @@ main(int argc, char *argv[])
                int stdio = 0;
                char *service;
        
       +        initfcalls();
                service = "ramfs";
                defmnt = "/tmp";
                ARGBEGIN{
 (DIR) diff --git a/src/cmd/rc/plan9ish.c b/src/cmd/rc/plan9ish.c
       t@@ -216,10 +216,9 @@ void Updenv(void){
        }
        */
        int
       -cmpenv(a, b)
       -char **a, **b;
       +cmpenv(const void *a, const void *b)
        {
       -        return strcmp(*a, *b);
       +        return strcmp(*(char**)a, *(char**)b);
        }
        char **mkenv(){
                register char **env, **ep, *p, *q;
       t@@ -462,7 +461,7 @@ void Noerror(void){
                interrupted=0;
        }
        int
       -Isatty(fd){
       +Isatty(int fd){
                return isatty(fd);
        }
        void Abort(void){
 (DIR) diff --git a/src/cmd/sam/unix.c b/src/cmd/sam/unix.c
       t@@ -1,3 +1,4 @@
       +#include <u.h>
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <sys/wait.h>
 (DIR) diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c
       t@@ -1,3 +1,4 @@
       +#include <u.h>
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <errno.h>
 (DIR) diff --git a/src/lib9/date.c b/src/lib9/date.c
       t@@ -43,7 +43,7 @@ tm2Tm(struct tm *tm, Tm *bigtm)
                if(bigtm->zone[0] == 0){
                        s = getenv("TIMEZONE");
                        if(s){
       -                        strecpy(bigtm->zone, bigtm->zone+4, tm->tm_zone);
       +                        strecpy(bigtm->zone, bigtm->zone+4, s);
                                free(s);
                        }
                }
 (DIR) diff --git a/src/libdraw/devdraw.c b/src/libdraw/devdraw.c
       t@@ -834,7 +834,7 @@ _drawmsgwrite(Display *d, void *v, int n)
                                                err = "image parameters incompatibile with screen";
                                                goto error;
                                        }
       -                                reffn = nil;
       +                                reffn = 0;
                                        switch(refresh){
                                        case Refbackup:
                                                break;
       t@@ -985,9 +985,9 @@ _drawmsgwrite(Display *d, void *v, int n)
                                oy = BGLONG(a+41);
                                op = drawclientop(client);
                                /* high bit indicates arc angles are present */
       -                        if(ox & (1<<31)){
       -                                if((ox & (1<<30)) == 0)
       -                                        ox &= ~(1<<31);
       +                        if(ox & ((ulong)1<<31)){
       +                                if((ox & ((ulong)1<<30)) == 0)
       +                                        ox &= ~((ulong)1<<31);
                                        memarc(dst, p, e0, e1, c, src, sp, ox, oy, op);
                                }else
                                        memellipse(dst, p, e0, e1, c, src, sp, op);
 (DIR) diff --git a/src/libdraw/ellipse.c b/src/libdraw/ellipse.c
       t@@ -56,27 +56,27 @@ fillellipseop(Image *dst, Point c, int a, int b, Image *src, Point sp, Drawop op
        void
        arc(Image *dst, Point c, int a, int b, int thick, Image *src, Point sp, int alpha, int phi)
        {
       -        alpha |= 1<<31;
       +        alpha |= ((ulong)1)<<31;
                doellipse('e', dst, &c, a, b, thick, src, &sp, alpha, phi, SoverD);
        }
        
        void
        arcop(Image *dst, Point c, int a, int b, int thick, Image *src, Point sp, int alpha, int phi, Drawop op)
        {
       -        alpha |= 1<<31;
       +        alpha |= (ulong)1<<31;
                doellipse('e', dst, &c, a, b, thick, src, &sp, alpha, phi, op);
        }
        
        void
        fillarc(Image *dst, Point c, int a, int b, Image *src, Point sp, int alpha, int phi)
        {
       -        alpha |= 1<<31;
       +        alpha |= (ulong)1<<31;
                doellipse('E', dst, &c, a, b, 0, src, &sp, alpha, phi, SoverD);
        }
        
        void
        fillarcop(Image *dst, Point c, int a, int b, Image *src, Point sp, int alpha, int phi, Drawop op)
        {
       -        alpha |= 1<<31;
       +        alpha |= (ulong)1<<31;
                doellipse('E', dst, &c, a, b, 0, src, &sp, alpha, phi, op);
        }
 (DIR) diff --git a/src/libdraw/md-draw.c b/src/libdraw/md-draw.c
       t@@ -1906,7 +1906,7 @@ boolcopyfn(Memimage *img, Memimage *mask)
                default:
                        assert(0 /* boolcopyfn */);
                }
       -        return nil;
       +        return 0;
        }
        
        /*
 (DIR) diff --git a/src/libdraw/ml-lsetrefresh.c b/src/libdraw/ml-lsetrefresh.c
       t@@ -29,7 +29,7 @@ memlsetrefresh(Memimage *i, Refreshfn fn, void *ptr)
                        return 0;
                /* easiest way is just to update the entire save area */
                l->refreshfn(i, i->r, l->refreshptr);
       -        l->refreshfn = nil;
       +        l->refreshfn = 0;
                l->refreshptr = nil;
                return 1;
        }
 (DIR) diff --git a/src/libdraw/unix.c b/src/libdraw/unix.c
       t@@ -1,6 +1,5 @@
       -#include <sys/stat.h>
       -
        #include <u.h>
       +#include <sys/stat.h>
        #include <libc.h>
        #include <draw.h>
        
 (DIR) diff --git a/src/libdraw/x11-alloc.c b/src/libdraw/x11-alloc.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libdraw/x11-cload.c b/src/libdraw/x11-cload.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libdraw/x11-draw.c b/src/libdraw/x11-draw.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libdraw/x11-event.c b/src/libdraw/x11-event.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <cursor.h>
 (DIR) diff --git a/src/libdraw/x11-fill.c b/src/libdraw/x11-fill.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libdraw/x11-get.c b/src/libdraw/x11-get.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libdraw/x11-init.c b/src/libdraw/x11-init.c
       t@@ -1,8 +1,8 @@
        /*
         * Some of the stuff in this file is not X-dependent and should be elsewhere.
         */
       -#include "x11-inc.h"
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
       t@@ -69,7 +69,8 @@ _initdisplay(void (*error)(Display*, char*), char *label)
        static Image*
        getimage0(Display *d)
        {
       -        char *a, info[12*12+1];
       +        char info[12*12+1];
       +        uchar *a;
                int n;
                Image *image;
        
       t@@ -323,7 +324,7 @@ xattach(char *label)
                name.value = (uchar*)label;
                name.encoding = XA_STRING;
                name.format = 8;
       -        name.nitems = strlen(name.value);
       +        name.nitems = strlen((char*)name.value);
        
                memset(&normalhint, 0, sizeof normalhint);
                normalhint.flags = USSize|PMaxSize;
       t@@ -435,7 +436,7 @@ drawsetlabel(Display *d, char *label)
                name.value = (uchar*)label;
                name.encoding = XA_STRING;
                name.format = 8;
       -        name.nitems = strlen(name.value);
       +        name.nitems = strlen((char*)name.value);
        
                memset(&classhint, 0, sizeof classhint);
                classhint.res_name = label;
 (DIR) diff --git a/src/libdraw/x11-itrans.c b/src/libdraw/x11-itrans.c
       t@@ -1,8 +1,7 @@
        /* input event and data structure translation */
        
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
       t@@ -318,8 +317,8 @@ _xsetcursor(Cursor *c)
        
                fg = _x.map[0];
                bg = _x.map[255];
       -        xsrc = XCreateBitmapFromData(_x.display, _x.drawable, src, 16, 16);
       -        xmask = XCreateBitmapFromData(_x.display, _x.drawable, mask, 16, 16);
       +        xsrc = XCreateBitmapFromData(_x.display, _x.drawable, (char*)src, 16, 16);
       +        xmask = XCreateBitmapFromData(_x.display, _x.drawable, (char*)mask, 16, 16);
                xc = XCreatePixmapCursor(_x.display, xsrc, xmask, &fg, &bg, -c->offset.x, -c->offset.y);
                if(xc != 0) {
                        XDefineCursor(_x.display, _x.drawable, xc);
       t@@ -412,14 +411,14 @@ _xgetsnarf(XDisplay *xd)
                        data = nil;
                }else{
                        if(xdata){
       -                        data = strdup((char*)xdata);
       +                        data = (uchar*)strdup((char*)xdata);
                                XFree(xdata);
                        }else
                                data = nil;
                }
        out:
                qunlock(&clip.lk);
       -        return data;
       +        return (char*)data;
        }
        
        void
 (DIR) diff --git a/src/libdraw/x11-keyboard.c b/src/libdraw/x11-keyboard.c
       t@@ -1,5 +1,5 @@
       -#include "x11-inc.h"
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <thread.h>
 (DIR) diff --git a/src/libdraw/x11-load.c b/src/libdraw/x11-load.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libdraw/x11-mouse.c b/src/libdraw/x11-mouse.c
       t@@ -1,5 +1,5 @@
       -#include "x11-inc.h"
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <thread.h>
 (DIR) diff --git a/src/libdraw/x11-pixelbits.c b/src/libdraw/x11-pixelbits.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libdraw/x11-unload.c b/src/libdraw/x11-unload.c
       t@@ -1,6 +1,5 @@
       -#include "x11-inc.h"
       -
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libdraw/x11-wsys.c b/src/libdraw/x11-wsys.c
       t@@ -1,5 +1,5 @@
       -#include "x11-inc.h"
        #include <u.h>
       +#include "x11-inc.h"
        #include <libc.h>
        #include <draw.h>
        #include <memdraw.h>
 (DIR) diff --git a/src/libfs/wstat.c b/src/libfs/wstat.c
       t@@ -24,7 +24,7 @@ fsdirwstat(Fsys *fs, char *name, Dir *d)
        int
        fsdirfwstat(Fid *fid, Dir *d)
        {
       -        char *a;
       +        uchar *a;
                int n, nn;
                Fcall tx, rx;
        
 (DIR) diff --git a/src/libmp/port/dat.h b/src/libmp/port/dat.h
       t@@ -1,4 +1,4 @@
       -#define        mpdighi  (mpdigit)(1<<(Dbits-1))
       +#define        mpdighi  (mpdigit)((ulong)1<<(Dbits-1))
        #define DIGITS(x) ((Dbits - 1 + (x))/Dbits)
        
        // for converting between int's and mpint's
 (DIR) diff --git a/src/libsec/port/x509.c b/src/libsec/port/x509.c
       t@@ -1593,7 +1593,7 @@ static Ints *alg_oid_tab[NUMALGS+1] = {
                (Ints*)&oid_md5,
                nil
        };
       -static DigestFun digestalg[NUMALGS+1] = { md5, md5, md5, md5, sha1, md5, nil };
       +static DigestFun digestalg[NUMALGS+1] = { md5, md5, md5, md5, sha1, md5, 0 };
        
        static void
        freecert(CertX509* c)
 (DIR) diff --git a/src/libthread/exec-unix.c b/src/libthread/exec-unix.c
       t@@ -1,3 +1,4 @@
       +#include <u.h>
        #include <fcntl.h>
        #include <unistd.h>
        #include "threadimpl.h"
 (DIR) diff --git a/src/libthread/exit.c b/src/libthread/exit.c
       t@@ -1,3 +1,4 @@
       +#include <u.h>
        #include <signal.h>
        #include "threadimpl.h"
        
 (DIR) diff --git a/src/libthread/ioopen.c b/src/libthread/ioopen.c
       t@@ -1,3 +1,4 @@
       +#include <u.h>
        #include <unistd.h>
        #include <fcntl.h>
        #include "threadimpl.h"
 (DIR) diff --git a/src/libthread/kill.c b/src/libthread/kill.c
       t@@ -1,3 +1,4 @@
       +#include <u.h>
        #include <signal.h>
        #include "threadimpl.h"
        
 (DIR) diff --git a/src/libthread/main.c b/src/libthread/main.c
       t@@ -1,3 +1,4 @@
       +#include <u.h>
        #include <signal.h>
        #include "threadimpl.h"
        
 (DIR) diff --git a/src/libthread/note.c b/src/libthread/note.c
       t@@ -25,12 +25,12 @@ threadnotify(int (*f)(void*, char*), int in)
                int (*from)(void*, char*), (*to)(void*, char*);
        
                if(in){
       -                from = nil;
       +                from = 0;
                        to = f;
                        topid = _threadgetproc()->pid;
                }else{
                        from = f;
       -                to = nil;
       +                to = 0;
                        topid = 0;
                }
                lock(&onnotelock);