--- /mips/include/u.h Tue Apr 30 22:01:39 2013 +++ /mips/include/u.h Thu Jun 13 00:02:56 2013 @@ -20,13 +20,13 @@ typedef unsigned int u32int; typedef unsigned long long u64int; -/* FCR */ -#define FPINEX (1<<7) +/* FCR (FCR31) */ +#define FPINEX (1<<7) /* enables */ #define FPUNFL (1<<8) #define FPOVFL (1<<9) #define FPZDIV (1<<10) #define FPINVAL (1<<11) -#define FPRNR (0<<0) +#define FPRNR (0<<0) /* rounding modes */ #define FPRZ (1<<0) #define FPRPINF (2<<0) #define FPRNINF (3<<0) @@ -35,12 +35,15 @@ #define FPPSGL 0 #define FPPDBL 0 #define FPPMASK 0 -/* FSR */ -#define FPAINEX (1<<2) +#define FPCOND (1<<23) + +/* FSR (also FCR31) */ +#define FPAINEX (1<<2) /* flags */ #define FPAOVFL (1<<4) #define FPAUNFL (1<<3) #define FPAZDIV (1<<5) -#define FPAINVAL (1<<6) +#define FPAINVAL (1<<6) + union FPdbleword { double x; --- /rc/bin/fshalt Sat May 25 03:57:16 2013 +++ /rc/bin/fshalt Thu Jun 13 23:27:53 2013 @@ -1,16 +1,28 @@ #!/bin/rc -# fshalt [-r] - sync (flush) and, if possible, halt all file servers -# and optionally reboot +# fshalt [-r] [new-kernel] - sync (flush) and, if possible, halt all +# file servers and optionally reboot rfork nes +kern=() kerncopy=() reboot=no +fn usage { + echo usage: $1 '[-r] [new-kernel]' >[1=2] + exit usage +} +if (! ~ $#* 0) + switch ($1) { + case -r + reboot=yes + shift + case -* + usage $0 + } switch ($#*) { case 0 case 1 - reboot=yes + kern = $1 case * - echo usage: $0 '[-r]' >[1=2] - exit usage + usage $0 } path=(/bin) @@ -42,8 +54,9 @@ # make a copy of the right kernel if (~ $reboot yes) { - kern=`{echo $terminal | - sed 's;^([^ ]+) .*/([^/ ]+).*$;/n/boot/'$cputype'/9\2;'} + if (~ $#kern 0) + kern=`{echo $terminal | + sed 's;^([^ ]+) .*/([^/ ]+).*$;/n/boot/'$cputype'/9\2;'} if (isbootable $kern) usekernel $kern if not { --- /sys/games/lib/fortunes Mon May 20 14:36:31 2013 +++ /sys/games/lib/fortunes Thu Jun 13 22:40:09 2013 @@ -4311,3 +4311,4 @@ To maintain backward compatibility, the relationships between the many options are quite complex. - ls(1) OS X Manual Page qemu: could not open serial device 'dev': Success DSM Terminator [ ABORT ] Finished [ 0 request(s) + 0 call(s) distributed in 5ms] +Microsoft Office PowerPoint has encountered a problem and cannot exit. We are sorry for the inconvenience. --- /sys/man/3/proc Wed Jul 13 23:16:05 2011 +++ /sys/man/3/proc Fri Jun 14 20:02:28 2013 @@ -170,6 +170,10 @@ a read of .B wait will block. +If the file's length is non-zero +(see +.IR stat (2)), +there is at least one wait record to read. It is an error for a process to attempt to read its own .B wait file when it has no children. --- /sys/man/4/rdbfs Mon Dec 3 00:42:24 2007 +++ /sys/man/4/rdbfs Fri Jun 14 20:05:24 2013 @@ -11,6 +11,10 @@ .I pid ] [ +.B -s +.I srvname +] +[ .B -t .I text ] @@ -28,6 +32,15 @@ .I device (default .BR /dev/eia0 ). +If the +.B -s +option is given, +.I rdbfs +will post its channel in +.BI /srv/ srvname +(see +.IR srv (3)), +allowing the session to be shared or reattached later. .PP The .B text --- /sys/man/8/booting Fri Mar 22 20:57:50 2013 +++ /sys/man/8/booting Thu Jun 13 22:42:28 2013 @@ -67,43 +67,13 @@ .B /386/9pccpu or .BR /386/9pccpudisk . -.SS SGI Challenge multiprocessor CPU Server -The Challenge ROM monitor can boot from the Ethernet. -To boot from the Ethernet, type -.IP -.EX -.B bootp()/mips/9ch -.EE -.PP -or use the ROM command -.B setenv -to set the variable -.B bootfile -to that same string and type -.BR boot . -To load a different file, tell -.B bootp -which file to load, -and to force the download to come from a particular system, -.BR bootp()system:file . -Any arguments after -.B bootp()file -are passed to -.BR /boot . -If you are running a Plan 9 -.SM BOOTP -server (see -.IR dhcpd (8)), -the file name can be omitted and the -file specified by the -.B bootf -parameter for the machine in -.B /lib/ndb -will be downloaded by default. -.PP -Once the kernel is loaded, -it prompts for the Ethernet -protocol to use to reach the root file server; request the default. +. +.SS MIPS Routerboard CPU Server +Configure RouterBOOT via the serial port (115200 baud) +to always boot from Ethernet, and arrange to load +.B /mips/9rb.elf +in +.IR ndb (6). . .SS ARM Systems All ARM systems are started by --- /sys/man/8/fshalt Mon Dec 3 00:42:27 2007 +++ /sys/man/8/fshalt Thu Jun 13 23:28:02 2013 @@ -5,6 +5,8 @@ .B fshalt [ .B -r +] [ +.I new-kernel ] .br .B reboot @@ -25,6 +27,10 @@ .BR -r , .I fshalt will then reboot the machine. +If +.I new-kernel +is given, it will be loaded as the new kernel rather than +the currently-loaded kernel. The halting and rebooting is done by copying all necessary commands into a .IR ramfs (4) --- /sys/src/9/ip/arp.c Thu Feb 7 15:55:44 2013 +++ /sys/src/9/ip/arp.c Fri Jun 14 00:23:52 2013 @@ -523,10 +523,10 @@ char *aformat = "%-6.6s %-8.8s %-40.40I %-32.32s\n"; static void -convmac(char *p, uchar *mac, int n) +convmac(char *p, char *ep, uchar *mac, int n) { while(n-- > 0) - p += sprint(p, "%2.2ux", *mac++); + p = seprint(p, ep, "%2.2ux", *mac++); } int @@ -552,8 +552,9 @@ } len--; qlock(arp); - convmac(mac, a->mac, a->type->maclen); - n += sprint(p+n, aformat, a->type->name, arpstate[a->state], a->ip, mac); + convmac(mac, &mac[sizeof mac], a->mac, a->type->maclen); + n += snprint(p+n, Alinelen+1, aformat, a->type->name, + arpstate[a->state], a->ip, mac); /* +1 for NUL */ qunlock(arp); } --- /sys/src/9/ip/chandial.c Fri Oct 29 05:20:48 2004 +++ /sys/src/9/ip/chandial.c Fri Jun 14 00:16:11 2013 @@ -66,7 +66,7 @@ name[n] = 0; for(p = name; *p == ' '; p++) ; - sprint(name, "%lud", strtoul(p, 0, 0)); + snprint(name, sizeof name, "%lud", strtoul(p, 0, 0)); p = strrchr(clone, '/'); *p = 0; if(ds->dir) --- /sys/src/9/ip/ethermedium.c Wed Aug 22 00:39:02 2007 +++ /sys/src/9/ip/ethermedium.c Fri Jun 14 00:14:06 2013 @@ -412,7 +412,7 @@ int version; version = multicastea(mac, a); - sprint(buf, "addmulti %E", mac); + snprint(buf, sizeof buf, "addmulti %E", mac); switch(version){ case V4: devtab[er->cchan4->type]->write(er->cchan4, buf, strlen(buf), 0); @@ -434,7 +434,7 @@ int version; version = multicastea(mac, a); - sprint(buf, "remmulti %E", mac); + snprint(buf, sizeof buf, "remmulti %E", mac); switch(version){ case V4: devtab[er->cchan4->type]->write(er->cchan4, buf, strlen(buf), 0); --- /sys/src/9/ip/icmp.c Thu Feb 7 15:55:43 2013 +++ /sys/src/9/ip/icmp.c Thu Jun 13 23:28:45 2013 @@ -393,7 +393,7 @@ break; case TimeExceed: if(p->code == 0){ - sprint(m2, "ttl exceeded at %V", p->src); + snprint(m2, sizeof m2, "ttl exceeded at %V", p->src); bp->rp += ICMP_IPSIZE+ICMP_HDRSIZE; if(blocklen(bp) < MinAdvise){ --- /sys/src/9/ip/icmp6.c Mon Jan 11 22:25:07 2010 +++ /sys/src/9/ip/icmp6.c Thu Jun 13 23:28:45 2013 @@ -765,7 +765,7 @@ case TimeExceedV6: if(p->code == 0){ - sprint(m2, "ttl exceeded at %I", p->src); + snprint(m2, sizeof m2, "ttl exceeded at %I", p->src); bp->rp += IPICMPSZ; if(blocklen(bp) < 8){ --- /sys/src/9/ip/ipifc.c Wed Aug 4 21:58:07 2010 +++ /sys/src/9/ip/ipifc.c Thu Jun 13 23:28:35 2013 @@ -1650,8 +1650,8 @@ if(!ifc->m->pref2addr) return Ebadarg; ifc->m->pref2addr(prefix, ifc->mac); /* mac → v6 link-local addr */ - sprint(addr, "%I", prefix); - sprint(preflen, "/%d", plen); + snprint(addr, sizeof addr, "%I", prefix); + snprint(preflen, sizeof preflen, "/%d", plen); params[0] = "add"; params[1] = addr; params[2] = preflen; --- /sys/src/9/ip/rudp.c Thu Feb 7 15:55:44 2013 +++ /sys/src/9/ip/rudp.c Thu Jun 13 23:28:30 2013 @@ -202,7 +202,8 @@ if(rpriv->ackprocstarted == 0){ qlock(&rpriv->apl); if(rpriv->ackprocstarted == 0){ - sprint(kpname, "#I%drudpack", rudp->f->dev); + snprint(kpname, sizeof kpname, "#I%drudpack", + rudp->f->dev); kproc(kpname, relackproc, rudp); rpriv->ackprocstarted = 1; } --- /sys/src/9/pc/dat.h Wed Aug 15 21:06:06 2012 +++ /sys/src/9/pc/dat.h Thu Jun 13 23:02:15 2013 @@ -19,6 +19,7 @@ typedef struct PMMU PMMU; typedef struct Proc Proc; typedef struct Segdesc Segdesc; +typedef struct SFPssestate SFPssestate; typedef vlong Tval; typedef struct Ureg Ureg; typedef struct Vctl Vctl; @@ -101,7 +102,13 @@ ulong mxcsr; /* MXCSR register state */ ulong mxcsr_mask; /* MXCSR mask register */ uchar xregs[480]; /* extended registers */ - uchar alignpad[FPalign]; +}; + +struct SFPssestate /* SSE fp state with alignment slop */ +{ + FPssestate; + uchar alignpad[FPalign]; /* slop to allow copying to aligned addr */ + ulong magic; /* debugging: check for overrun */ }; /* @@ -110,7 +117,7 @@ */ union FPsave { FPstate; - FPssestate; + SFPssestate; }; struct Confmem --- /sys/src/9/pc/devarch.c Wed Aug 15 21:12:39 2012 +++ /sys/src/9/pc/devarch.c Thu Jun 13 23:01:18 2013 @@ -414,7 +414,8 @@ for(m = iomap.m; n > 0 && m != nil; m = m->next){ if(offset-- > 0) continue; - sprint(p, "%8lux %8lux %-12.12s\n", m->start, m->end-1, m->tag); + seprint(p, &buf[n], "%8lux %8lux %-12.12s\n", m->start, + m->end-1, m->tag); p += Linelen; n--; } @@ -722,8 +723,8 @@ int i; char buf[128]; - i = sprint(buf, "cpu%d: %s%dMHz ", m->machno, m->machno < 10? " ": "", - m->cpumhz); + i = snprint(buf, sizeof buf, "cpu%d: %s%dMHz ", m->machno, + m->machno < 10? " ": "", m->cpumhz); if(m->cpuidid[0]) i += sprint(buf+i, "%12.12s ", m->cpuidid); seprint(buf+i, buf + sizeof buf - 1, --- /sys/src/9/pc/fns.h Tue May 28 22:52:16 2013 +++ /sys/src/9/pc/fns.h Thu Jun 13 23:01:35 2013 @@ -34,6 +34,7 @@ void fpon(void); void (*fprestore)(FPsave*); void (*fpsave)(FPsave*); +void fpsavealloc(void); void fpsserestore(FPsave*); void fpsserestore0(FPsave*); void fpssesave(FPsave*); --- /sys/src/9/pc/main.c Tue May 28 22:53:37 2013 +++ /sys/src/9/pc/main.c Thu Jun 13 23:02:40 2013 @@ -76,6 +76,14 @@ extern void (*i8237alloc)(void); void +fpsavealloc(void) +{ + m->fpsavalign = mallocalign(sizeof(FPssestate), FPalign, 0, 0); + if (m->fpsavalign == nil) + panic("cpu%d: can't allocate fpsavalign", m->machno); +} + +void main(void) { cgapost(0); @@ -104,6 +112,7 @@ printinit(); cpuidprint(); mmuinit(); + fpsavealloc(); if(arch->intrinit) /* launches other processors on an mp */ arch->intrinit(); timersinit(); @@ -306,10 +315,11 @@ cp[BOOTLINELEN-1] = 0; buf[0] = 0; if(strncmp(cp, "fd", 2) == 0){ - sprint(buf, "local!#f/fd%lddisk", strtol(cp+2, 0, 0)); + snprint(buf, sizeof buf, "local!#f/fd%lddisk", + strtol(cp+2, 0, 0)); av[ac++] = pusharg(buf); } else if(strncmp(cp, "sd", 2) == 0){ - sprint(buf, "local!#S/sd%c%c/fs", *(cp+2), *(cp+3)); + snprint(buf, sizeof buf, "local!#S/sd%c%c/fs", *(cp+2), *(cp+3)); av[ac++] = pusharg(buf); } else if(strncmp(cp, "ether", 5) == 0) av[ac++] = pusharg("-n"); @@ -527,7 +537,7 @@ /* * sse fp save and restore buffers have to be 16-byte (FPalign) aligned, - * so we shuffle the data up and down as needed or make copies. + * so we shuffle the data down as needed or make copies. */ void @@ -535,10 +545,13 @@ { FPsave *afps; + fps->magic = 0x1234; afps = (FPsave *)ROUND(((uintptr)fps), FPalign); fpssesave0(afps); if (fps != afps) /* not aligned? shuffle down from aligned buffer */ - memmove(fps, afps, sizeof(FPssestate) - FPalign); + memmove(fps, afps, sizeof(FPssestate)); + if (fps->magic != 0x1234) + print("fpssesave: magic corrupted\n"); } void @@ -546,20 +559,15 @@ { FPsave *afps; + fps->magic = 0x4321; afps = (FPsave *)ROUND(((uintptr)fps), FPalign); if (fps != afps) { - if (m->fpsavalign == nil) - m->fpsavalign = mallocalign(sizeof(FPssestate), - FPalign, 0, 0); - if (m->fpsavalign) - afps = m->fpsavalign; - /* copy or shuffle up to make aligned */ - memmove(afps, fps, sizeof(FPssestate) - FPalign); + afps = m->fpsavalign; + memmove(afps, fps, sizeof(FPssestate)); /* make aligned copy */ } fpsserestore0(afps); - /* if we couldn't make a copy, shuffle regs back down */ - if (fps != afps && afps != m->fpsavalign) - memmove(fps, afps, sizeof(FPssestate) - FPalign); + if (fps->magic != 0x4321) + print("fpsserestore: magic corrupted\n"); } /* --- /sys/src/9/pc/mp.c Fri Aug 24 20:04:03 2012 +++ /sys/src/9/pc/mp.c Thu Jun 13 23:01:42 2013 @@ -399,6 +399,7 @@ // iprint("Hello Squidboy\n"); machinit(); + fpsavealloc(); mmuinit(); cpuidentify(); --- /sys/src/9/pc/trap.c Fri Jan 11 20:24:49 2013 +++ /sys/src/9/pc/trap.c Thu Jun 13 23:00:46 2013 @@ -363,7 +363,7 @@ } else if(vno < nelem(excname) && user){ spllo(); - sprint(buf, "sys: trap: %s", excname[vno]); + snprint(buf, sizeof buf, "sys: trap: %s", excname[vno]); postnote(up, 1, buf, NDebug); } else if(vno >= VectorPIC && vno != VectorSYSCALL){ @@ -591,7 +591,7 @@ panic("kernel bpt"); /* restore pc to instruction that caused the trap */ ureg->pc--; - sprint(buf, "sys: breakpoint"); + snprint(buf, sizeof buf, "sys: breakpoint"); postnote(up, 1, buf, NDebug); } @@ -641,7 +641,7 @@ } checkpages(); checkfault(addr, ureg->pc); - sprint(buf, "sys: trap: fault %s addr=0x%lux", + snprint(buf, sizeof buf, "sys: trap: fault %s addr=0x%lux", read ? "read" : "write", addr); postnote(up, 1, buf, NDebug); } @@ -806,7 +806,8 @@ l = strlen(n->msg); if(l > ERRMAX-15) /* " pc=0x12345678\0" */ l = ERRMAX-15; - sprint(n->msg+l, " pc=0x%.8lux", ureg->pc); + seprint(n->msg+l, &n->msg[sizeof n->msg], " pc=0x%.8lux", + ureg->pc); } if(n->flag!=NUser && (up->notified || up->notify==0)){ --- /sys/src/9/pcboot/conf.c Thu May 31 20:22:57 2012 +++ /sys/src/9/pcboot/conf.c Tue Jun 18 08:14:40 2013 @@ -320,13 +320,13 @@ mi = &mitem[i]; p = str; - p += sprint(p, "menuitem=%s\n", mi->mb->name); + p += snprint(p, len, "menuitem=%s\n", mi->mb->name); for(i = 0; i < nmblock; i++){ mb = &mblock[i]; if(mi->mb != mb && cistrcmp(mb->name, "common") != 0) continue; for(n = mb->start; n < mb->end; n++) - p += sprint(p, "%s\n", line[n]); + p += snprint(p, &str[len] - p, "%s\n", line[n]); } if(show){ --- /sys/src/9/port/devcap.c Fri May 11 14:20:40 2007 +++ /sys/src/9/port/devcap.c Thu Jun 13 23:25:24 2013 @@ -112,7 +112,7 @@ int i; for(i = 0; i < Hashlen; i++) - sprint(buf+2*i, "%2.2ux", hash[i]); + seprint(buf+2*i, &buf[sizeof buf], "%2.2ux", hash[i]); buf[2*Hashlen] = 0; return buf; } --- /sys/src/9/port/devdraw.c Tue Mar 8 00:27:40 2011 +++ /sys/src/9/port/devdraw.c Thu Jun 13 23:24:21 2013 @@ -228,9 +228,10 @@ case Q3rd: cl = drawclientofpath(c->qid.path); if(cl == nil) - strcpy(up->genbuf, "??"); + strncpy(up->genbuf, "??", sizeof up->genbuf); else - sprint(up->genbuf, "%d", cl->clientid); + snprint(up->genbuf, sizeof up->genbuf, + "%d", cl->clientid); mkqid(&q, Q2nd, 0, QTDIR); devdir(c, q, up->genbuf, 0, eve, 0500, dp); break; @@ -272,7 +273,8 @@ cl = sdraw.client[s-1]; if(cl == 0) return 0; - sprint(up->genbuf, "%d", cl->clientid); + snprint(up->genbuf, sizeof up->genbuf, "%d", + cl->clientid); mkqid(&q, (s<genbuf, 0, eve, 0555, dp); return 1; @@ -1186,10 +1188,13 @@ error(Enodrawimage); i = di->image; } - n = sprint(a, "%11d %11d %11s %11d %11d %11d %11d %11d %11d %11d %11d %11d ", - cl->clientid, cl->infoid, chantostr(buf, i->chan), (i->flags&Frepl)==Frepl, + n = snprint(a, n, + "%11d %11d %11s %11d %11d %11d %11d %11d %11d %11d %11d %11d ", + cl->clientid, cl->infoid, chantostr(buf, i->chan), + (i->flags&Frepl)==Frepl, i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y, - i->clipr.min.x, i->clipr.min.y, i->clipr.max.x, i->clipr.max.y); + i->clipr.min.x, i->clipr.min.y, i->clipr.max.x, + i->clipr.max.y); cl->infoid = -1; break; @@ -1201,7 +1206,9 @@ m = 0; for(index = 0; index < 256; index++){ getcolor(index, &red, &green, &blue); - m += sprint((char*)p+m, "%11d %11lud %11lud %11lud\n", index, red>>24, green>>24, blue>>24); + m += snprint((char*)p+m, 4*12*256+1 - m, + "%11d %11lud %11lud %11lud\n", index, + red>>24, green>>24, blue>>24); } n = readstr(offset, a, n, (char*)p); free(p); @@ -1370,7 +1377,7 @@ { char buf[256]; char *p, *q; - int s; + int s, left; if(1|| plsprnt==0){ SET(s,q,p); @@ -1380,32 +1387,34 @@ q = buf; *q++ = *a++; for(p=fmt; *p; p++){ + left = sizeof buf - 2 - (q - buf); /* 2 for \n\0 */ switch(*p){ case 'l': - q += sprint(q, " %ld", (long)BGLONG(a)); + q += snprint(q, left, " %ld", (long)BGLONG(a)); a += 4; break; case 'L': - q += sprint(q, " %.8lux", (ulong)BGLONG(a)); + q += snprint(q, left, " %.8lux", (ulong)BGLONG(a)); a += 4; break; case 'R': - q += sprint(q, " [%d %d %d %d]", BGLONG(a), BGLONG(a+4), BGLONG(a+8), BGLONG(a+12)); + q += snprint(q, left, " [%d %d %d %d]", BGLONG(a), + BGLONG(a+4), BGLONG(a+8), BGLONG(a+12)); a += 16; break; case 'P': - q += sprint(q, " [%d %d]", BGLONG(a), BGLONG(a+4)); + q += snprint(q, left, " [%d %d]", BGLONG(a), BGLONG(a+4)); a += 8; break; case 'b': - q += sprint(q, " %d", *a++); + q += snprint(q, left, " %d", *a++); break; case 's': - q += sprint(q, " %d", BGSHORT(a)); + q += snprint(q, left, " %d", BGSHORT(a)); a += 2; break; case 'S': - q += sprint(q, " %.4ux", BGSHORT(a)); + q += snprint(q, left, " %.4ux", BGSHORT(a)); a += 2; break; } --- /sys/src/9/port/devdup.c Tue Nov 27 18:39:32 2007 +++ /sys/src/9/port/devdup.c Thu Jun 13 23:25:41 2013 @@ -29,10 +29,10 @@ return 0; if(s & 1){ p = 0400; - sprint(up->genbuf, "%dctl", s/2); + snprint(up->genbuf, sizeof up->genbuf, "%dctl", s/2); }else{ p = perm[f->mode&3]; - sprint(up->genbuf, "%d", s/2); + snprint(up->genbuf, sizeof up->genbuf, "%d", s/2); } mkqid(&q, s+1, 0, QTFILE); devdir(c, q, up->genbuf, 0, eve, p, dp); --- /sys/src/9/port/devflash.c Wed Jul 13 19:13:06 2011 +++ /sys/src/9/port/devflash.c Thu Jun 13 23:26:08 2013 @@ -89,7 +89,7 @@ mkqid(&q, QID(0, Qtopdir), 0, QTDIR); n = "#F"; if(c->dev != 0){ - sprint(up->genbuf, "#F%ld", c->dev); + snprint(up->genbuf, sizeof up->genbuf, "#F%ld", c->dev); n = up->genbuf; } devdir(c, q, n, 0, eve, 0555, dp); @@ -102,7 +102,8 @@ mkqid(&q, QID(0, Qflashdir), 0, QTDIR); n = "flash"; if(c->dev != 0){ - sprint(up->genbuf, "flash%ld", c->dev); + snprint(up->genbuf, sizeof up->genbuf, "flash%ld", + c->dev); n = up->genbuf; } devdir(c, q, n, 0, eve, 0555, dp); --- /sys/src/9/port/devmouse.c Fri Mar 29 20:04:32 2013 +++ /sys/src/9/port/devmouse.c Thu Jun 13 23:25:32 2013 @@ -303,7 +303,7 @@ b = 16; else if (b == 16) b = 8; - sprint(buf, "m%11d %11d %11d %11lud ", + snprint(buf, sizeof buf, "m%11d %11d %11d %11lud ", m.xy.x, m.xy.y, b, m.msec); --- /sys/src/9/port/devproc.c Mon Apr 8 20:18:31 2013 +++ /sys/src/9/port/devproc.c Thu Jun 13 23:15:39 2013 @@ -215,7 +215,7 @@ pid = p->pid; if(pid == 0) return 0; - sprint(up->genbuf, "%lud", pid); + snprint(up->genbuf, sizeof up->genbuf, "%lud", pid); /* * String comparison is done in devwalk so name must match its formatted pid */ @@ -528,7 +528,7 @@ { char buf[32]; - return sprint(buf, "%lud", c->qid.vers); + return snprint(buf, sizeof buf, "%lud", c->qid.vers); } int @@ -875,7 +875,8 @@ sg = p->seg[i]; if(sg == 0) continue; - j += sprint(statbuf+j, "%-6s %c%c %.8lux %.8lux %4ld\n", + j += snprint(statbuf+j, sizeof statbuf - j, + "%-6s %c%c %.8lux %.8lux %4ld\n", sname[sg->type&SG_TYPE], sg->type&SG_RONLY ? 'R' : ' ', sg->profile ? 'P' : ' ', --- /sys/src/9/port/devsd.c Fri Jul 13 20:51:38 2012 +++ /sys/src/9/port/devsd.c Thu Jun 13 23:25:53 2013 @@ -485,7 +485,8 @@ case Qtopdir: if(s == DEVDOTDOT){ mkqid(&q, QID(0, 0, 0, Qtopdir), 0, QTDIR); - sprint(up->genbuf, "#%C", sddevtab.dc); + snprint(up->genbuf, sizeof up->genbuf, "#%C", + sddevtab.dc); devdir(c, q, up->genbuf, 0, eve, 0555, dp); return 1; } @@ -533,7 +534,8 @@ case Qunitdir: if(s == DEVDOTDOT){ mkqid(&q, QID(0, 0, 0, Qtopdir), 0, QTDIR); - sprint(up->genbuf, "#%C", sddevtab.dc); + snprint(up->genbuf, sizeof up->genbuf, "#%C", + sddevtab.dc); devdir(c, q, up->genbuf, 0, eve, 0555, dp); return 1; } --- /sys/src/9/port/devsdp.c Mon Jun 28 20:29:57 2010 +++ /sys/src/9/port/devsdp.c Thu Jun 13 23:24:49 2013 @@ -557,7 +557,7 @@ qunlock(c); return n; case Qctl: - sprint(buf, "%lud", CONV(ch->qid)); + snprint(buf, sizeof buf, "%lud", CONV(ch->qid)); return readstr(off, a, n, buf); case Qcontrol: b = readcontrol(sdp->conv[CONV(ch->qid)], n); --- /sys/src/9/port/devsegment.c Sun Aug 10 06:17:41 2008 +++ /sys/src/9/port/devsegment.c Thu Jun 13 23:05:09 2013 @@ -327,7 +327,8 @@ g = c->aux; if(g->s == nil) error("segment not yet allocated"); - sprint(buf, "va %#lux %#lux\n", g->s->base, g->s->top-g->s->base); + snprint(buf, sizeof buf, "va %#lux %#lux\n", g->s->base, + g->s->top-g->s->base); return readstr(voff, a, n, buf); case Qdata: g = c->aux; --- /sys/src/9/port/devsrv.c Sun May 23 22:32:59 2010 +++ /sys/src/9/port/devsrv.c Thu Jun 13 23:26:53 2013 @@ -86,13 +86,15 @@ char* srvname(Chan *c) { + int size; Srv *sp; char *s; for(sp = srv; sp; sp = sp->link) if(sp->chan == c){ - s = smalloc(3+strlen(sp->name)+1); - sprint(s, "#s/%s", sp->name); + size = 3+strlen(sp->name)+1; + s = smalloc(size); + snprint(s, size, "#s/%s", sp->name); return s; } return nil; --- /sys/src/9/port/devssl.c Thu Mar 29 22:13:44 2012 +++ /sys/src/9/port/devssl.c Thu Jun 13 23:24:42 2013 @@ -168,7 +168,7 @@ else nm = eve; if(dsname[s] == nil){ - sprint(name, "%d", s); + snprint(name, sizeof name, "%d", s); kstrdup(&dsname[s], name); } devdir(c, q, dsname[s], 0, nm, 0555, dp); @@ -671,7 +671,7 @@ error(Ebadusefd); case Qctl: ft = CONV(c->qid); - sprint(buf, "%d", ft); + snprint(buf, sizeof buf, "%d", ft); return readstr(offset, a, n, buf); case Qdata: b = sslbread(c, n, offset); --- /sys/src/9/port/devtls.c Fri Jan 25 00:23:04 2013 +++ /sys/src/9/port/devtls.c Thu Jun 13 23:24:42 2013 @@ -324,7 +324,7 @@ nm = eve; if((name = trnames[s]) == nil){ name = trnames[s] = smalloc(16); - sprint(name, "%d", s); + snprint(name, 16, "%d", s); } devdir(c, q, name, 0, nm, 0555, dp); unlock(&tdlock); --- /sys/src/9/port/edf.c Sun Aug 10 06:18:34 2008 +++ /sys/src/9/port/edf.c Thu Jun 13 23:04:51 2013 @@ -72,13 +72,14 @@ sign = ""; if (t > Onesecond){ t += OneRound; - sprint(buf, "%s%d.%.3ds", sign, (int)(t / Onesecond), + snprint(buf, sizeof buf, "%s%d.%.3ds", sign, + (int)(t / Onesecond), (int)(t % Onesecond)/Onemillisecond); }else if (t > Onemillisecond) - sprint(buf, "%s%d.%.3dms", sign, (int)(t / Onemillisecond), - (int)(t % Onemillisecond)); + snprint(buf, sizeof buf, "%s%d.%.3dms", sign, + (int)(t / Onemillisecond), (int)(t % Onemillisecond)); else - sprint(buf, "%s%dµs", sign, (int)t); + snprint(buf, sizeof buf, "%s%dµs", sign, (int)t); return fmtstrcpy(f, buf); } --- /sys/src/9/port/fault.c Tue Dec 11 23:46:11 2012 +++ /sys/src/9/port/fault.c Thu Jun 13 23:04:13 2013 @@ -22,7 +22,7 @@ spllo(); m->pfault++; - for(tries = 200; tries > 0; tries--) { /* TODO: reset to 20 */ + for(tries = 200; tries > 0; tries--) { s = seg(up, addr, 1); /* leaves s->lk qlocked if seg != nil */ if(s == 0) { up->psstate = sps; @@ -41,8 +41,7 @@ /* * if we loop more than a few times, we're probably stuck on * an unfixable address, almost certainly due to a bug - * elsewhere (e.g., bad page tables) so there's no point - * in spinning forever. + * elsewhere, so there's no point in spinning forever. */ if (tries <= 0) panic("fault: fault stuck on va %#8.8p read %d\n", addr, read); --- /sys/src/9/port/fpi.c Tue Apr 23 21:37:04 2013 +++ /sys/src/9/port/fpi.c Thu Jun 13 22:35:53 2013 @@ -1,6 +1,9 @@ /* * Floating Point Interpreter. * shamelessly stolen from an original by ark. + * + * NB: the Internal arguments to fpisub and fpidiv are reversed from + * what you might naively expect: they compute y-x and y/x, respectively. */ #include "fpi.h" --- /sys/src/9/port/fpi.h Mon Mar 25 21:09:58 2013 +++ /sys/src/9/port/fpi.h Thu Jun 13 22:35:49 2013 @@ -1,4 +1,5 @@ typedef long Word; +typedef long long Vlong; typedef unsigned long Single; typedef struct { unsigned long l; @@ -24,8 +25,10 @@ }; typedef struct { + /* order matters: must start with s, e, l, h in that order */ unsigned char s; short e; + /* double bits */ long l; /* 0000FFFFFFFFFFFFFFFFFFFFFFFFFGGG */ long h; /* 0000HFFFFFFFFFFFFFFFFFFFFFFFFFFF */ } Internal; @@ -56,6 +59,8 @@ extern void fpis2i(Internal *, void *); extern void fpid2i(Internal *, void *); extern void fpiw2i(Internal *, void *); +extern void fpiv2i(Internal *, void *); extern void fpii2s(void *, Internal *); extern void fpii2d(void *, Internal *); extern void fpii2w(Word *, Internal *); +extern void fpii2v(Vlong *, Internal *); --- /sys/src/9/port/fpimem.c Mon Mar 25 21:24:04 2013 +++ /sys/src/9/port/fpimem.c Tue Jun 18 07:07:29 2013 @@ -4,13 +4,17 @@ * the following routines depend on memory format, not the machine */ +enum { + Sign = 1u << 31, +}; + void fpis2i(Internal *i, void *v) { Single *s = v; - i->s = (*s & 0x80000000) ? 1: 0; - if((*s & ~0x80000000) == 0){ + i->s = (*s & Sign) ? 1: 0; + if((*s & ~Sign) == 0){ SetZero(i); return; } @@ -28,7 +32,7 @@ { Double *d = v; - i->s = (d->h & 0x80000000) ? 1: 0; + i->s = (d->h & Sign) ? 1: 0; i->e = (d->h>>20) & 0x07FF; i->h = ((d->h & 0x000FFFFF)<<(4+NGuardBits))|((d->l>>25) & 0x7F); i->l = (d->l & 0x01FFFFFF)<s = 1; + word = -word; + } + else + i->s = 0; + if(word == 0){ + SetZero(i); + return; + } + if(word > 0){ + for (e = 0, w = word; w; w >>= 1, e++) + ; + } else + e = 64; + if(e > FractBits){ + i->h = word>>(e - FractBits); + i->l = (word & ((1<<(e - FractBits)) - 1))<<(2*FractBits - e); + } + else { + i->h = word<<(FractBits - e); + i->l = 0; + } + i->e = (e - 1) + ExpBias; +} + +/* + * Note that all of these conversions from Internal format + * potentially alter *i, so it should be a disposable copy + * of the value to be converted. + */ + +void fpii2s(void *v, Internal *i) { short e; @@ -81,7 +123,7 @@ i->h &= ~HiddenBit; else i->e--; - *s = i->s ? 0x80000000: 0; + *s = i->s ? Sign: 0; e = i->e; if(e < ExpBias){ if(e <= (ExpBias - SingleExpBias)) @@ -109,7 +151,7 @@ i->e--; i->l = ((i->h & GuardMask)<<25)|(i->l>>NGuardBits); i->h >>= NGuardBits; - d->h = i->s ? 0x80000000: 0; + d->h = i->s ? Sign: 0; d->h |= (i->e<<20)|((i->h & 0x00FFFFFF)>>4); d->l = (i->h<<28)|i->l; } @@ -128,6 +170,27 @@ w = 0x7FFFFFFF; else if(e > FractBits) w = (i->h<<(e - FractBits))|(i->l>>(2*FractBits - e)); + else + w = i->h>>(FractBits-e); + if(i->s) + w = -w; + *word = w; +} + +void +fpii2v(Vlong *word, Internal *i) +{ + Vlong w; + short e; + + fpiround(i); + e = (i->e - ExpBias) + 1; + if(e <= 0) + w = 0; + else if(e > 63) + w = (1ull<<63) - 1; /* maxlong */ + else if(e > FractBits) + w = (Vlong)i->h<<(e - FractBits) | i->l>>(2*FractBits - e); else w = i->h>>(FractBits-e); if(i->s) --- /sys/src/9/port/rebootcmd.c Mon Mar 4 22:45:40 2002 +++ /sys/src/9/port/rebootcmd.c Thu Jun 13 23:27:17 2013 @@ -72,7 +72,13 @@ entry = l2be(exec.entry); text = l2be(exec.text); data = l2be(exec.data); - if(magic != AOUT_MAGIC) + /* + * AOUT_MAGIC is sometimes defined like this: + * #define AOUT_MAGIC V_MAGIC || magic==M_MAGIC + * so we can only use it in a fairly stylized manner. + */ + if(magic == AOUT_MAGIC) { + } else error(Ebadexec); /* round text out to page boundary */ --- /sys/src/ape/lib/ap/mips/c_fcr0.s Thu Jan 1 01:00:00 1970 +++ /sys/src/ape/lib/ap/mips/c_fcr0.s Wed Jun 12 22:06:55 2013 @@ -0,0 +1,3 @@ + TEXT C_fcr0(SB), $0 + MOVW FCR0, R1 + RET --- /sys/src/ape/lib/ap/mips/lock.c Sun Mar 11 02:17:06 2012 +++ /sys/src/ape/lib/ap/mips/lock.c Wed Jun 12 22:07:46 2013 @@ -43,7 +43,8 @@ case R4K: break; default: - abort(); + arch = R4K; + break; } } --- /sys/src/ape/lib/ap/mips/memmove.s Thu Feb 28 19:46:29 2002 +++ /sys/src/ape/lib/ap/mips/memmove.s Wed Jun 12 22:07:46 2013 @@ -26,7 +26,7 @@ /* * if not at least 4 chars, - * dont even mess around. + * don't even mess around. * 3 chars to guarantee any * rounding up to a word * boundary and 4 characters --- /sys/src/ape/lib/ap/mips/mkfile Wed May 29 03:52:45 2013 +++ /sys/src/ape/lib/ap/mips/mkfile Wed Jun 12 22:07:51 2013 @@ -2,6 +2,7 @@ <$APE/config LIB=/$objtype/lib/ape/libap.a OFILES=\ + c_fcr0.$O\ cycles.$O\ getfcr.$O\ lock.$O\ --- /sys/src/ape/lib/ap/mips/tas.s Thu Feb 28 19:46:29 2002 +++ /sys/src/ape/lib/ap/mips/tas.s Wed Jun 12 22:07:53 2013 @@ -1,5 +1,5 @@ /* - * magnum user level lock code + * mips user level lock code */ #define LL(base, rt) WORD $((060<<26)|((base)<<21)|((rt)<<16)) @@ -26,8 +26,4 @@ SC(2, 3) NOOP BEQ R3, tas1 - RET - - TEXT C_fcr0(SB), $0 - MOVW FCR0, R1 RET --- /sys/src/ape/lib/mp/mips/mkfile Mon Jan 28 23:24:15 2013 +++ /sys/src/ape/lib/mp/mips/mkfile Thu Jun 13 07:59:29 2013 @@ -8,7 +8,7 @@ mpvecdigmuladd.s\ mpvecdigmulsub.s\ mpvecsub.s\ - mpdigdiv.s\ +# mpdigdiv.s\ HFILES=\ /sys/include/ape/mp.h\ --- /sys/src/cmd/5c/gc.h Mon Mar 4 22:15:20 2013 +++ /sys/src/cmd/5c/gc.h Fri Jun 14 00:34:01 2013 @@ -125,7 +125,7 @@ }; #define R ((Reg*)0) -#define NRGN 600 +#define NRGN 1000 /* was 600; raised for paranoia.c */ struct Rgn { Reg* enter; --- /sys/src/cmd/postscript/download/download.c Sat Mar 17 01:33:24 2001 +++ /sys/src/cmd/postscript/download/download.c Thu Jun 13 22:54:08 2013 @@ -1,5 +1,4 @@ /* - * * download - host resident font downloader * * Prepends host resident fonts to PostScript input files. The program assumes @@ -49,15 +48,16 @@ * * Was written quickly, so there's much room for improvement. Undoubtedly should * be a more general program (e.g. scan for other comments). - * */ #include +#include +#include +#include +#include #include #include -#include #include -#include #include "comments.h" /* PostScript file structuring comments */ #include "gen.h" /* general purpose definitions */ @@ -236,7 +236,7 @@ return; if ( *mapname != '/' ) { - if ( (path = (char *)malloc(strlen(hostfontdir) + strlen(mapname) + + if ( (path = malloc(strlen(hostfontdir) + strlen(mapname) + strlen(suffix) + 2)) == NULL ) error(FATAL, "no memory"); sprintf(path, "%s/%s%s", hostfontdir, mapname, suffix); @@ -245,8 +245,8 @@ if ( (fd = open(path, 0)) != -1 ) { if ( fstat(fd, &sbuf) == -1 ) error(FATAL, "can't fstat %s", path); - if ( (stringspace = (char *)malloc(sbuf.st_size + 2)) == NULL ) - error(FATAL, "no memory"); + if ( (stringspace = malloc(sbuf.st_size + 2)) == NULL ) + error(FATAL, "no memory for %s (%d bytes)", path, sbuf.st_size + 2); if ( read(fd, stringspace, sbuf.st_size) == -1 ) error(FATAL, "can't read %s", path); close(fd); @@ -444,7 +444,7 @@ } /* End if */ if ( (n = lookup(font)) < next ) { if ( *map[n].file != '/' ) { - if ( (path = (char *)malloc(strlen(hostfontdir)+strlen(map[n].file)+2)) == NULL ) + if ( (path = malloc(strlen(hostfontdir)+strlen(map[n].file)+2)) == NULL ) error(FATAL, "no memory"); sprintf(path, "%s/%s", hostfontdir, map[n].file); cat(path); @@ -512,32 +512,18 @@ } /* End of lookup */ -/*****************************************************************************/ - -Map *allocate(ptr, num) - - Map *ptr; - int num; - -{ - /* - * * Allocates space for num Map elements. Calls malloc() if ptr is NULL and * realloc() otherwise. - * */ - - if ( ptr == NULL ) - ptr = (Map *)malloc(num * sizeof(Map)); - else ptr = (Map *)realloc(ptr, num * sizeof(Map)); - - if ( ptr == NULL ) - error(FATAL, "no map memory"); - - return(ptr); - -} /* End of allocate */ - -/*****************************************************************************/ - +Map * +allocate(Map *ptr, int num) +{ + if (ptr == NULL) + ptr = (Map *)malloc(num * sizeof(Map)); + else + ptr = (Map *)realloc(ptr, num * sizeof(Map)); + if (ptr == NULL) + error(FATAL, "no map memory"); + return ptr; +} --- /sys/src/cmd/rc/exec.c Wed Jul 23 02:52:07 2008 +++ /sys/src/cmd/rc/exec.c Fri Jun 14 01:21:27 2013 @@ -154,6 +154,7 @@ :(word *)0); setvar("rcname", newword(argv[0], (word *)0)); i = 0; + memset(bootstrap, 0, sizeof bootstrap); bootstrap[i++].i = 1; bootstrap[i++].f = Xmark; bootstrap[i++].f = Xword; @@ -202,14 +203,18 @@ * Xconc(left, right) concatenate, push results * Xcount(name) push var count * Xdelfn(name) delete function definition - * Xdeltraps(names) delete named traps + * Xdelhere * Xdol(name) get variable value - * Xqdol(name) concatenate variable components * Xdup[i j] dup file descriptor + * Xeflag + * Xerror * Xexit rc exits with status * Xfalse{...} execute {} if false * Xfn(name){... Xreturn} define function * Xfor(var, list){... Xreturn} for loop + * Xglob + * Xif + * Xifnot * Xjump[addr] goto * Xlocal(name, val) create local variable, assign value * Xmark mark stack @@ -218,16 +223,21 @@ * wait for both * Xpipefd[type]{... Xreturn} connect {} to pipe (input or output, * depending on type), push /dev/fd/?? + * Xpipewait * Xpopm(value) pop value from stack + * Xpopredir + * Xrdcmds + * Xrdfn * Xrdwr(file)[fd] open file for reading and writing * Xread(file)[fd] open file to read - * Xsettraps(names){... Xreturn} define trap functions - * Xshowtraps print trap list - * Xsimple(args) run command and wait + * Xqdol(name) concatenate variable components * Xreturn kill thread + * Xsimple(args) run command and wait + * Xsub * Xsubshell{... Xexit} execute {} in a subshell and wait * Xtrue{...} execute {} if true * Xunlocal delete local variable + * Xwastrue * Xword[string] push string * Xwrite(file)[fd] open file to write */ --- /sys/src/cmd/rc/lex.c Wed May 15 23:10:33 2013 +++ /sys/src/cmd/rc/lex.c Fri Jun 14 01:22:59 2013 @@ -366,8 +366,7 @@ return c; } for(;;){ - /* next line should have (char)c==GLOB, but ken's compiler is broken */ - if(c=='*' || c=='[' || c=='?' || c==(unsigned char)GLOB) + if(c=='*' || c=='[' || c=='?' || c==GLOB) w = addtok(w, GLOB); w = addutf(w, c); c = nextc(); --- /sys/src/cmd/rc/pcmd.c Fri Nov 19 20:54:37 2004 +++ /sys/src/cmd/rc/pcmd.c Fri Jun 14 01:15:00 2013 @@ -21,8 +21,9 @@ { if(t==0) return; + assert(f != nil); switch(t->type){ - default: pfmt(f, "bad %d %p %p %p", t->type, c0, c1, c2); + default: pfmt(f, "bad cmd %d %p %p %p", t->type, c0, c1, c2); break; case '$': pfmt(f, "$%t", c0); break; --- /sys/src/cmd/rc/pfnc.c Mon Dec 12 02:00:57 2011 +++ /sys/src/cmd/rc/pfnc.c Fri Jun 14 01:22:17 2013 @@ -2,55 +2,58 @@ #include "exec.h" #include "io.h" #include "fns.h" + struct{ - void (*f)(void); - char *name; -}fname[] = { + void (*f)(void); + char *name; +} fname[] = { Xappend, "Xappend", + Xassign, "Xassign", Xasync, "Xasync", + Xbackq, "Xbackq", Xbang, "Xbang", + Xcase, "Xcase", Xclose, "Xclose", + Xconc, "Xconc", + Xcount, "Xcount", + Xdelfn, "Xdelfn", + Xdelhere, "Xdelhere", + Xdol, "Xdol", Xdup, "Xdup", Xeflag, "Xeflag", + (void (*)(void))Xerror, "Xerror", Xexit, "Xexit", Xfalse, "Xfalse", + Xfn, "Xfn", + Xfor, "Xfor", + Xglob, "Xglob", + Xif, "Xif", Xifnot, "Xifnot", Xjump, "Xjump", + Xlocal, "Xlocal", Xmark, "Xmark", + Xmatch, "Xmatch", + Xpipe, "Xpipe", + Xpipefd, "Xpipefd", + Xpipewait, "Xpipewait", Xpopm, "Xpopm", + Xpopredir, "Xpopredir", + Xqdol, "Xqdol", + Xrdcmds, "Xrdcmds", + Xrdfn, "Xrdfn", Xrdwr, "Xrdwr", Xread, "Xread", Xreturn, "Xreturn", + Xsimple, "Xsimple", + Xsub, "Xsub", + Xsubshell, "Xsubshell", Xtrue, "Xtrue", - Xif, "Xif", + Xunlocal, "Xunlocal", Xwastrue, "Xwastrue", Xword, "Xword", Xwrite, "Xwrite", - Xmatch, "Xmatch", - Xcase, "Xcase", - Xconc, "Xconc", - Xassign, "Xassign", - Xdol, "Xdol", - Xcount, "Xcount", - Xlocal, "Xlocal", - Xunlocal, "Xunlocal", - Xfn, "Xfn", - Xdelfn, "Xdelfn", - Xpipe, "Xpipe", - Xpipewait, "Xpipewait", - Xrdcmds, "Xrdcmds", - (void (*)(void))Xerror, "Xerror", - Xbackq, "Xbackq", - Xpipefd, "Xpipefd", - Xsubshell, "Xsubshell", - Xdelhere, "Xdelhere", - Xfor, "Xfor", - Xglob, "Xglob", - Xrdfn, "Xrdfn", - Xsimple, "Xsimple", - Xsub, "Xsub", - Xqdol, "Xqdol", -0}; + 0 +}; void pfnc(io *fd, thread *t) @@ -58,14 +61,17 @@ int i; void (*fn)(void) = t->code[t->pc].f; list *a; + pfmt(fd, "pid %d cycle %p %d ", getpid(), t->code, t->pc); - for(i = 0;fname[i].f;i++) if(fname[i].f==fn){ - pstr(fd, fname[i].name); - break; - } - if(!fname[i].f) + for (i = 0; fname[i].f; i++) + if (fname[i].f == fn) { + pstr(fd, fname[i].name); + break; + } + if (!fname[i].f) pfmt(fd, "%p", fn); - for(a = t->argv;a;a = a->next) pfmt(fd, " (%v)", a->words); + for (a = t->argv; a; a = a->next) + pfmt(fd, " (%v)", a->words); pchr(fd, '\n'); flush(fd); } --- /sys/src/cmd/rc/plan9.c Fri Mar 1 20:53:47 2013 +++ /sys/src/cmd/rc/plan9.c Fri Jun 14 01:21:10 2013 @@ -621,7 +621,7 @@ void* Malloc(ulong n) { - return malloc(n); + return mallocz(n, 1); } int *waitpids; --- /sys/src/cmd/rc/rc.h Wed May 15 23:10:33 2013 +++ /sys/src/cmd/rc/rc.h Fri Jun 14 01:14:33 2013 @@ -125,7 +125,7 @@ * GLOB[...] matches anything in the brackets * GLOBGLOB matches GLOB */ -#define GLOB ((char)0x01) +#define GLOB '\001' char **argp; char **args; --- /sys/src/cmd/rc/simple.c Fri Mar 1 22:29:17 2013 +++ /sys/src/cmd/rc/simple.c Fri Jun 14 01:21:01 2013 @@ -460,6 +460,7 @@ return; } setstatus(""); + memset(out, 0, sizeof out); out->fd = mapfd(1); out->bufp = out->buf; out->ebuf = &out->buf[NBUF]; --- /sys/src/cmd/rc/var.c Sun Jun 15 19:39:41 2003 +++ /sys/src/cmd/rc/var.c Fri Jun 14 01:22:45 2013 @@ -2,14 +2,19 @@ #include "exec.h" #include "fns.h" -int -hash(char *s, int n) +unsigned +hash(char *as, int n) { - int h = 0, i = 1; - while(*s) h+=*s++*i++; - h%=n; - return h<0?h+n:h; + int i = 1; + unsigned h = 0; + uchar *s; + + s = (uchar *)as; + while (*s) + h += *s++ * i++; + return h % n; } + #define NKW 30 struct kw{ char *name; --- /sys/src/cmd/rdbfs.c Tue Mar 14 14:16:59 2006 +++ /sys/src/cmd/rdbfs.c Fri Jun 14 20:05:24 2013 @@ -137,12 +137,13 @@ char* portname = "/dev/eia0"; char* textfile = "/386/9pc"; char* procname = "1"; +char* srvname; Channel* rchan; void usage(void) { - fprint(2, "usage: rdbfs [-p procnum] [-t textfile] [serialport]\n"); + fprint(2, "usage: rdbfs [-p procnum] [-s srvname] [-t textfile] [serialport]\n"); exits("usage"); } @@ -397,6 +398,9 @@ case 'p': procname = EARGF(usage()); break; + case 's': + srvname = EARGF(usage()); + break; case 't': textfile = EARGF(usage()); break; @@ -427,7 +431,7 @@ for(i=0; iorigin = l->p0 = l->p1 = 0; frinit(&l->f, insetrect(flrect(l, r), FLMARGIN), ft, screen, cols); l->f.maxtab = maxtab*stringwidth(ft, "0"); + if(l->f.maxtab == 0) + fontbuggered(ft->name); newvisibilities(1); draw(screen, l->entire, l->f.cols[BACK], nil, ZP); scrdraw(l, 0L); @@ -414,6 +423,8 @@ n = f->nchars; frinit(f, f->entire, f->font, f->b, 0); f->maxtab = maxtab*stringwidth(f->font, "0"); + if(f->maxtab == 0) + fontbuggered(f->font->name); r = (*l->textfn)(l, n, &n); frinsert(f, r, r+n, (ulong)0); frdrawsel(f, frptofchar(f, f->p0), f->p0, f->p1, 0); --- /sys/src/cmd/vc/gc.h Mon Mar 4 22:15:21 2013 +++ /sys/src/cmd/vc/gc.h Fri Jun 14 00:29:26 2013 @@ -120,7 +120,7 @@ }; #define R ((Reg*)0) -#define NRGN 600 +#define NRGN 1000 /* was 600; raised for paranoia.c */ struct Rgn { Reg* enter; --- /sys/src/cmd/vi/mips.h Sun Nov 6 17:02:23 2005 +++ /sys/src/cmd/vi/mips.h Tue Jun 18 07:09:21 2013 @@ -229,7 +229,7 @@ Extern int rtrace; /* Plan9 Kernel constants */ -#define BY2PG 4096 +#define BY2PG (16*1024) #define BY2WD 4 #define UTZERO 0x1000 #define STACKTOP 0x80000000 --- /sys/src/cmd/vl/obj.c Wed Mar 27 00:16:29 2013 +++ /sys/src/cmd/vl/obj.c Fri Jun 14 00:42:06 2013 @@ -18,7 +18,7 @@ /* * -H0 -T0x40004C -D0x10000000 is abbrev unix * -H1 -T0x80020000 -R4 is bootp() format for 3k - * -H2 -T4128 -R4096 is plan9 format + * -H2 -T16416 -R16384 is plan9 format * -H3 -T0x80020000 -R8 is bootp() format for 4k * -H4 -T0x400000 -R4 is sgi unix coff executable * -H5 -T0x4000A0 -R4 is sgi unix elf executable @@ -153,12 +153,12 @@ break; case 2: /* plan 9 */ HEADR = 32L; - if(INITTEXT == -1) - INITTEXT = 4128; if(INITDAT == -1) INITDAT = 0; if(INITRND == -1) - INITRND = 4096; + INITRND = 16*1024; + if(INITTEXT == -1) + INITTEXT = INITRND + HEADR; break; case 3: /* boot for 4k */ HEADR = 20L+56L+3*40L; --- /sys/src/libc/mips/atom.s Fri Mar 18 22:48:36 2011 +++ /sys/src/libc/mips/atom.s Wed Jun 12 22:19:01 2013 @@ -49,9 +49,3 @@ fail: MOVW $0, R1 RET - -/* general-purpose abort */ -_trap: - MOVD $0, R0 - MOVD 0(R0), R0 - RET --- /sys/src/libmach/v.c Thu Apr 25 00:58:43 2013 +++ /sys/src/libmach/v.c Tue Jun 18 07:09:04 2013 @@ -106,9 +106,9 @@ "R31", /* name of link register */ "setR30", /* static base register name */ 0, /* value */ - 0x1000, /* page size */ - 0xC0000000ULL, /* kernel base */ - 0x40000000ULL, /* kernel text mask */ + 16*1024, /* page size */ + 0x80000000ULL, /* kernel base */ + 0x80000000ULL, /* kernel text mask */ 0x7FFFFFFFULL, /* user stack top */ 4, /* quantization of pc */ 4, /* szaddr */ --- /sys/src/libmach/vdb.c Thu Apr 25 00:57:32 2013 +++ /sys/src/libmach/vdb.c Tue Jun 18 07:08:57 2013 @@ -28,7 +28,12 @@ mipsexcep, /* print exception */ 0, /* breakpoint fixup */ beieeesftos, /* single precision float printer */ - beieeedftos, /* double precisioin float printer */ + /* + * this works for doubles in memory, but FP register pairs have + * the words in little-endian order, so they will print as + * denormalised doubles. + */ + beieeedftos, /* double precision float printer */ mipsfoll, /* following addresses */ mipsinst, /* print instruction */ mipsdas, /* dissembler */ @@ -48,7 +53,7 @@ mipsexcep, /* print exception */ 0, /* breakpoint fixup */ leieeesftos, /* single precision float printer */ - leieeedftos, /* double precisioin float printer */ + leieeedftos, /* double precision float printer */ mipsfoll, /* following addresses */ mipsinst, /* print instruction */ mipsdas, /* dissembler */ @@ -71,7 +76,7 @@ mipsexcep, /* print exception */ 0, /* breakpoint fixup */ leieeesftos, /* single precision float printer */ - leieeedftos, /* double precisioin float printer */ + leieeedftos, /* double precision float printer */ mipsfoll, /* following addresses */ mipsinst, /* print instruction */ mipsdas, /* dissembler */ @@ -94,7 +99,7 @@ mipsexcep, /* print exception */ 0, /* breakpoint fixup */ beieeesftos, /* single precision float printer */ - beieeedftos, /* double precisioin float printer */ + beieeedftos, /* double precision float printer */ mipsfoll, /* following addresses */ mipsinst, /* print instruction */ mipsdas, /* dissembler */ @@ -131,7 +136,8 @@ long c; c = (*rget)(map, "CAUSE"); - if(c & 0x00002000) /* INTR3 */ + /* i don't think this applies to any current machines */ + if(0 && c & 0x00002000) /* INTR3 */ e = 16; /* Floating point exception */ else e = (c>>2)&0x0F; --- /sys/src/libmp/mips/mkfile Mon Oct 14 22:23:17 2002 +++ /sys/src/libmp/mips/mkfile Wed Jun 12 22:19:30 2013 @@ -2,12 +2,13 @@ = 2^32 * divisor */ - SGTU R4,R3,R7 - BEQ R7,_digovfl - -_digdiv1: - SLLV $32,R2 - SLLV $32,R3 - SRLV $32,R2 - ADDVU R2,R3 - SLLV $32,R4 - SRLV $32,R4 - DIVVU R4,R3 - MOVW LO,R1 - MOVW R1,0(R5) - RET - -_digovfl: - MOVW $-1,R1 - MOVW R1,0(R5) - RET - --- /sys/src/libmp/mips/r4k/mpdigdiv.s Thu Jan 1 01:00:00 1970 +++ /sys/src/libmp/mips/r4k/mpdigdiv.s Wed Jun 12 22:20:50 2013 @@ -0,0 +1,40 @@ +/* + * This only works on R[45]000 chips that allow 64 bit + * integer arithmetic even when using 32 bit addresses + * + * R1 = dividend* + * R2 = dividend[low] + * R3 = dividend[high] + * R4 = 32 bit divisor + * R5 = quotient* + */ +TEXT mpdigdiv(SB),$0 + + MOVW 0(R1),R2 + MOVW 4(R1),R3 + MOVW divisor+4(FP),R4 + MOVW quotient+8(FP),R5 + + /* divisor == 0 */ + BEQ R4,_digovfl + + /* dividend >= 2^32 * divisor */ + SGTU R4,R3,R7 + BEQ R7,_digovfl + +_digdiv1: + SLLV $32,R2 + SLLV $32,R3 + SRLV $32,R2 + ADDVU R2,R3 + SLLV $32,R4 + SRLV $32,R4 + DIVVU R4,R3 + MOVW LO,R1 + MOVW R1,0(R5) + RET + +_digovfl: + MOVW $-1,R1 + MOVW R1,0(R5) + RET