diff --git a/lib/troll b/lib/troll index 42da69dbb..3c3d2ee32 100644 --- a/lib/troll +++ b/lib/troll @@ -120,3 +120,5 @@ Subject: [nix] servers down I have an IDE HD with fossil (no venti) partition on it. It contains some data precious to me. Would it be possible to support file:// in acme ? i would not be at all surprised if the nix kernel (with or without the AC stuff) ends up being the basis for continuing evolution of plan9. +Subject: [9fans] Go tip build fails +FWIW may be it would make more sense to install Plan 9 (9front) then? diff --git a/rc/bin/netaudit b/rc/bin/netaudit index 075e73a07..f043df988 100755 --- a/rc/bin/netaudit +++ b/rc/bin/netaudit @@ -38,6 +38,16 @@ fn checknet { } if not echo ' we are in ipnet='^$ipnet + ipgw=`{ndb/ipquery sys $sysname ipgw | sed 's/^ipgw=//'} + if(~ $ipgw '' '::'){ + echo ' we do not have an internet gateway, no ipgw= entry' + } + if not { + if(! ~ $ipgw *.*.*.* *:*:*:*:*:*:*:* *::*) + echo ' ipgw='$ipgw 'does not look like an ip address' + if not + echo ' ipgw='$ipgw 'looks ok' + } dns=`{ndb/ipquery sys $sysname dns | sed 's/^dns=//'} if(~ $dns '') echo ' no dns= entry' diff --git a/sys/games/lib/fortunes b/sys/games/lib/fortunes index 15e36dcde..f7ce9d59d 100644 --- a/sys/games/lib/fortunes +++ b/sys/games/lib/fortunes @@ -4843,3 +4843,18 @@ BurnZeZ → I'm constantly dealing with scrolling text The development effort for 5ESS required 5000 employees, producing 100 million lines of code, with 100 million lines of header and makefiles. Don't forget the colon when referring to keyboards or printers. A Font For Supporters Of Marriage Equality +< mveety> im on facebook on my vax right now +(#cat-v) aiju → fiddling with russian machines is so not worth it +Subject: [9fans] Invitation to connect on LinkedIn +Subject: [9fans] [gsoc] Dart9P +The problem is that there aren't any decent languages where you can just sit down and write code, because you have to know so much about the language itself. +China's cyber forces are said to be around 400,000 including militia, and the US has 20,000. +readfile(): nonblocking read blocked +(#cat-v) lf94 → this is linux +no. -- Erik Quanstrom +But if you'll insert it carefull, and will take it out not often, it really will campatible +They look ugly and the fanbase is terrible. +Rio, the Plan 9 windowing system, looks and feels like a step back to the old Amiga and Atari ST days, as the façade is nearly the same. +But really, you need a CRT to be lagless. +is there any real reason for hating modern thinkpads besides the keyboard and screen resolution? +No. -- 20h diff --git a/sys/include/ape/lib9.h b/sys/include/ape/lib9.h index 84b7c3253..1d788ea04 100644 --- a/sys/include/ape/lib9.h +++ b/sys/include/ape/lib9.h @@ -64,12 +64,12 @@ extern int bind(char*, char*, int); extern int mount(int, int, char*, int, char*); extern int unmount(char*, char*); extern int rfork(int); -extern int segattach(int, char*, void*, unsigned long); -extern int segbrk(void*, void*); +extern void* segattach(int, char*, void*, unsigned long); +extern void* segbrk(void*, void*); extern int segdetach(void*); extern int segflush(void*, unsigned long); extern int segfree(void*, unsigned long); -extern unsigned long rendezvous(unsigned long, unsigned long); +extern void* rendezvous(void*, void*); extern unsigned long getfcr(void); extern unsigned long getfsr(void); extern void setfcr(unsigned long); diff --git a/sys/lib/kbmap/ru b/sys/lib/kbmap/ru index b6f22458f..a8ac25ffb 100644 --- a/sys/lib/kbmap/ru +++ b/sys/lib/kbmap/ru @@ -176,7 +176,7 @@ 1 47 'М 1 48 'И 1 49 'Т -1 50 'ь +1 50 'Ь 1 51 'Б 1 52 'Ю 1 53 ', diff --git a/sys/lib/kbmap/ua b/sys/lib/kbmap/ua index 31f2a5b28..31eebfc2f 100644 --- a/sys/lib/kbmap/ua +++ b/sys/lib/kbmap/ua @@ -176,7 +176,7 @@ 1 47 'М 1 48 'И 1 49 'Т -1 50 'ь +1 50 'Ь 1 51 'Б 1 52 'Ю 1 53 ', diff --git a/sys/man/1/jpg b/sys/man/1/jpg index 6ffc79e87..e3583d4bb 100644 --- a/sys/man/1/jpg +++ b/sys/man/1/jpg @@ -85,6 +85,8 @@ jpg, gif, png, ppm, bmp, v210, yuv, ico, tga, togif, toppm, topng, toico \- view .B -c .I comment ] [ +.B -r +] [ .I file ] .br @@ -93,7 +95,6 @@ jpg, gif, png, ppm, bmp, v210, yuv, ico, tga, togif, toppm, topng, toico \- view .B -c .I comment ] [ -[ .B -g .I gamma ] [ @@ -126,7 +127,7 @@ read files in the corresponding formats and, by default, display them in the current window; options cause them instead to convert the images to Plan 9 image format and write them to standard output. .IR Togif , -.IR Toppm , +.IR toppm , and .I topng read Plan 9 images files, convert them to GIF, PPM, or PNG, and write them to standard output. @@ -212,6 +213,12 @@ and have no display capability. Both accept an option .B -c to set the comment field of the resulting file. +The +.B -r +option makes +.I toppm +output raw PPM. +The default is to output plain PPM. If there is only one input picture, .I togif converts the image to GIF format. diff --git a/sys/man/6/ndb b/sys/man/6/ndb index 339572c69..da1af6fc9 100644 --- a/sys/man/6/ndb +++ b/sys/man/6/ndb @@ -199,7 +199,7 @@ Internet network name Internet network mask .TP .B ipgw -Internet gateway +Internet gateway (ip address) .TP .B auth authentication server to be used diff --git a/sys/src/9/pc/devether.c b/sys/src/9/pc/devether.c index 1a5d08bbd..91d1c8574 100644 --- a/sys/src/9/pc/devether.c +++ b/sys/src/9/pc/devether.c @@ -380,6 +380,10 @@ etherprobe(int cardno, int ctlrno) char buf[128], name[32]; ether = malloc(sizeof(Ether)); + if(ether == nil){ + print("etherprobe: no memory for Ether\n"); + return nil; + } memset(ether, 0, sizeof(Ether)); ether->ctlrno = ctlrno; ether->tbdf = BUSUNKNOWN; @@ -460,8 +464,7 @@ etherprobe(int cardno, int ctlrno) ether->limit = bsz; } if(ether->oq == nil) - panic("etherreset %s: can't allocate output queue of %ld bytes", - name, bsz); + panic("etherreset %s: can't allocate output queue of %ld bytes", name, bsz); ether->alen = Eaddrlen; memmove(ether->addr, ether->ea, Eaddrlen); memset(ether->bcast, 0xFF, Eaddrlen); diff --git a/sys/src/9/pc/ether8169.c b/sys/src/9/pc/ether8169.c index 6c9a610ec..cf9ebdf08 100644 --- a/sys/src/9/pc/ether8169.c +++ b/sys/src/9/pc/ether8169.c @@ -50,6 +50,8 @@ enum { /* registers */ Tbianar = 0x68, /* TBI Auto-Negotiation Advertisment */ Tbilpar = 0x6A, /* TBI Auto-Negotiation Link Partner */ Phystatus = 0x6C, /* PHY Status */ + Pmch = 0x6F, /* power management */ + Ldps = 0x82, /* link down power saving */ Rms = 0xDA, /* Receive Packet Maximum Size */ Cplusc = 0xE0, /* C+ Command */ @@ -117,6 +119,7 @@ enum { /* Tcr */ Macv27 = 0x2c800000, /* RTL8111e */ Macv28 = 0x2c000000, /* RTL8111/8168B */ Macv29 = 0x40800000, /* RTL8101/8102E */ + Macv30 = 0x24000000, /* RTL8101E? (untested) */ Ifg0 = 0x01000000, /* Interframe Gap 0 */ Ifg1 = 0x02000000, /* Interframe Gap 1 */ }; @@ -387,13 +390,27 @@ rtl8169mii(Ctlr* ctlr) ctlr->mii->miw = rtl8169miimiw; ctlr->mii->ctlr = ctlr; + /* + * PHY wakeup + */ + switch(ctlr->macv){ + case Macv25: + case Macv28: + case Macv29: + case Macv30: + csr8w(ctlr, Pmch, csr8r(ctlr, Pmch) | 0x80); + break; + } + rtl8169miimiw(ctlr->mii, 1, 0x1f, 0); + rtl8169miimiw(ctlr->mii, 1, 0x0e, 0); + /* * Get rev number out of Phyidr2 so can config properly. * There's probably more special stuff for Macv0[234] needed here. */ ctlr->phyv = rtl8169miimir(ctlr->mii, 1, Phyidr2) & 0x0F; if(ctlr->macv == Macv02){ - csr8w(ctlr, 0x82, 1); /* magic */ + csr8w(ctlr, Ldps, 1); /* magic */ rtl8169miimiw(ctlr->mii, 1, 0x0B, 0x0000); /* magic */ } @@ -405,6 +422,10 @@ rtl8169mii(Ctlr* ctlr) print("rtl8169: oui %#ux phyno %d, macv = %#8.8ux phyv = %#4.4ux\n", phy->oui, phy->phyno, ctlr->macv, ctlr->phyv); + miireset(ctlr->mii); + + microdelay(100); + miiane(ctlr->mii, ~0, ~0, ~0); return 0; @@ -1018,6 +1039,7 @@ vetmacv(Ctlr *ctlr, uint *macv) case Macv27: case Macv28: case Macv29: + case Macv30: break; } return 0; diff --git a/sys/src/9/pc/sdide.c b/sys/src/9/pc/sdide.c index 583bde63c..48a160538 100644 --- a/sys/src/9/pc/sdide.c +++ b/sys/src/9/pc/sdide.c @@ -2079,6 +2079,10 @@ atapnp(void) case (0x7111<<16)|0x8086: /* 82371[AE]B (PIIX4[E]) */ maxdma = 0x20000; break; + case (0x1c00<<16)|0x8086: /* SERIES6 SATA */ + case (0x1c01<<16)|0x8086: /* SERIES6 SATA */ + case (0x1c08<<16)|0x8086: /* SERIES6 SATA */ + case (0x1c09<<16)|0x8086: /* SERIES6 SATA */ case (0x2411<<16)|0x8086: /* 82801AA (ICH) */ case (0x2421<<16)|0x8086: /* 82801AB (ICH0) */ case (0x244A<<16)|0x8086: /* 82801BA (ICH2, Mobile) */ diff --git a/sys/src/9/pc/uarti8250.c b/sys/src/9/pc/uarti8250.c index fe14bdf0e..845e4401a 100644 --- a/sys/src/9/pc/uarti8250.c +++ b/sys/src/9/pc/uarti8250.c @@ -621,12 +621,14 @@ i8250alloc(int io, int irq, int tbdf) { Ctlr *ctlr; - if((ctlr = malloc(sizeof(Ctlr))) != nil){ - ctlr->io = io; - ctlr->irq = irq; - ctlr->tbdf = tbdf; + ctlr = malloc(sizeof(Ctlr)); + if(ctlr == nil){ + print("i8250alloc: no memory for Ctlr\n"); + return nil; } - + ctlr->io = io; + ctlr->irq = irq; + ctlr->tbdf = tbdf; return ctlr; } diff --git a/sys/src/9/pc/uartisa.c b/sys/src/9/pc/uartisa.c index f02080d70..f6b590724 100644 --- a/sys/src/9/pc/uartisa.c +++ b/sys/src/9/pc/uartisa.c @@ -18,16 +18,22 @@ uartisa(int ctlrno, ISAConf* isa) Uart *uart; char buf[64]; + uart = malloc(sizeof(Uart)); + if(uart == nil){ + print("uartisa: no memory for Uart\n"); + return nil; + } + io = isa->port; snprint(buf, sizeof(buf), "%s%d", isaphysuart.name, ctlrno); if(ioalloc(io, 8, 0, buf) < 0){ print("uartisa: I/O 0x%uX in use\n", io); + free(uart); return nil; } - uart = malloc(sizeof(Uart)); ctlr = i8250alloc(io, isa->irq, BUSUNKNOWN); - if(uart == nil || ctlr == nil){ + if(ctlr == nil){ iofree(io); free(uart); return nil; diff --git a/sys/src/9/pc/uartpci.c b/sys/src/9/pc/uartpci.c index ec8ce9e94..1f97bd930 100644 --- a/sys/src/9/pc/uartpci.c +++ b/sys/src/9/pc/uartpci.c @@ -21,17 +21,23 @@ uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name, char buf[64]; Uart *head, *uart; + head = malloc(sizeof(Uart)*n); + if(head == nil){ + print("uartpci: no memory for Uarts\n"); + return nil; + } + io = p->mem[barno].bar & ~0x01; snprint(buf, sizeof(buf), "%s%d", pciphysuart.name, ctlrno); if(ioalloc(io, p->mem[barno].size, 0, buf) < 0){ print("uartpci: I/O 0x%uX in use\n", io); + free(head); return nil; } - head = uart = malloc(sizeof(Uart)*n); + uart = head; for(i = 0; i < n; i++){ - ctlr = i8250alloc(io, p->intl, p->tbdf); - io += iosize; + ctlr = i8250alloc(io + i*iosize, p->intl, p->tbdf); if(ctlr == nil) continue; @@ -44,16 +50,20 @@ uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name, (uart-1)->next = uart; uart++; } - - if (head) { - if(perlehead != nil) - perletail->next = head; - else - perlehead = head; - for(perletail = head; perletail->next != nil; - perletail = perletail->next) - ; + if(head == uart){ + iofree(io); + free(head); + return nil; } + + if(perlehead != nil) + perletail->next = head; + else + perlehead = head; + for(perletail = head; perletail->next != nil; + perletail = perletail->next) + ; + return head; } diff --git a/sys/src/9/pc/wifi.c b/sys/src/9/pc/wifi.c index 84631a7b9..a23604569 100644 --- a/sys/src/9/pc/wifi.c +++ b/sys/src/9/pc/wifi.c @@ -464,8 +464,14 @@ wifiattach(Ether *ether, void (*transmit)(Wifi*, Wnode*, Block*)) Wifi *wifi; wifi = malloc(sizeof(Wifi)); - wifi->ether = ether; + if(wifi == nil) + error(Enomem); wifi->iq = qopen(8*1024, 0, 0, 0); + if(wifi->iq == nil){ + free(wifi); + error(Enomem); + } + wifi->ether = ether; wifi->transmit = transmit; wifi->status = Snone; diff --git a/sys/src/9/port/alloc.c b/sys/src/9/port/alloc.c index 194eb9f37..6e422c9e3 100644 --- a/sys/src/9/port/alloc.c +++ b/sys/src/9/port/alloc.c @@ -175,7 +175,7 @@ smalloc(ulong size) if(v != nil) break; if(!waserror()){ - tsleep(&up->sleep, return0, 0, 100); + resrcwait(0); poperror(); } } diff --git a/sys/src/9/port/devaoe.c b/sys/src/9/port/devaoe.c index 85ce88494..0512f7016 100644 --- a/sys/src/9/port/devaoe.c +++ b/sys/src/9/port/devaoe.c @@ -1362,7 +1362,7 @@ devlinkread(Chan *c, void *db, int len, int off) return 0; l = d->dl + i; - s = p = malloc(READSTR); + s = p = smalloc(READSTR); e = s + READSTR; p = seprint(p, e, "addr: "); @@ -1398,7 +1398,7 @@ topctlread(Chan *, void *db, int len, int off) char *s, *p, *e; Netlink *n; - s = p = malloc(READSTR); + s = p = smalloc(READSTR); e = s + READSTR; p = seprint(p, e, "debug: %d\n", debug); @@ -1463,7 +1463,7 @@ configwrite(Aoedev *d, void *db, long len) if(len > sizeof d->config) error(Etoobig); srb = srballoc(len); - s = malloc(len); + s = smalloc(len); memmove(s, db, len); if(waserror()){ srbfree(srb); @@ -1679,7 +1679,7 @@ unitwrite(Chan *c, void *db, long n, vlong off) case Qconfig: if(off + n > sizeof d->config) error(Etoobig); - buf = malloc(sizeof d->config); + buf = smalloc(sizeof d->config); if(waserror()){ free(buf); nexterror(); diff --git a/sys/src/9/port/devmnt.c b/sys/src/9/port/devmnt.c index 5f46b9467..da51d0366 100644 --- a/sys/src/9/port/devmnt.c +++ b/sys/src/9/port/devmnt.c @@ -61,7 +61,6 @@ Mntrpc* mntflushalloc(Mntrpc*, ulong); void mntflushfree(Mnt*, Mntrpc*); void mntfree(Mntrpc*); void mntgate(Mnt*); -void mntpntfree(Mnt*); void mntqrm(Mnt*, Mntrpc*); Mntrpc* mntralloc(Chan*, ulong); long mntrdwr(int, Chan*, void*, long, vlong); @@ -101,6 +100,7 @@ mntversion(Chan *c, char *version, int msize, int returnlen) uchar *msg; Mnt *m; char *v; + Queue *q; long k, l; uvlong oo; char buf[128]; @@ -199,6 +199,16 @@ mntversion(Chan *c, char *version, int msize, int returnlen) k = strlen(f.version); if(strncmp(f.version, v, k) != 0) error("bad 9P version returned from server"); + if(returnlen > 0 && returnlen < k) + error(Eshort); + + v = nil; + kstrdup(&v, f.version); + q = qopen(10*MAXRPC, 0, nil, nil); + if(q == nil){ + free(v); + exhausted("mount queues"); + } /* now build Mnt associated with this connection */ lock(&mntalloc); @@ -208,24 +218,22 @@ mntversion(Chan *c, char *version, int msize, int returnlen) else { m = malloc(sizeof(Mnt)); if(m == 0) { + qfree(q); + free(v); unlock(&mntalloc); exhausted("mount devices"); } } m->list = mntalloc.list; mntalloc.list = m; - m->version = nil; - kstrdup(&m->version, f.version); + m->version = v; m->id = mntalloc.id++; - m->q = qopen(10*MAXRPC, 0, nil, nil); + m->q = q; m->msize = f.msize; unlock(&mntalloc); - if(returnlen > 0){ - if(returnlen < k) - error(Eshort); - memmove(version, f.version, k); - } + if(returnlen > 0) + memmove(version, f.version, k); /* length was checked above */ poperror(); /* msg */ free(msg); @@ -564,23 +572,18 @@ mntclunk(Chan *c, int t) void muxclose(Mnt *m) { - Mntrpc *q, *r; + Mnt *f, **l; + Mntrpc *r; - for(q = m->queue; q; q = r) { - r = q->list; - mntfree(q); + while((r = m->queue) != nil){ + m->queue = r->list; + mntfree(r); } m->id = 0; free(m->version); m->version = nil; - mntpntfree(m); -} - -void -mntpntfree(Mnt *m) -{ - Mnt *f, **l; - Queue *q; + qfree(m->q); + m->q = nil; lock(&mntalloc); l = &mntalloc.list; @@ -593,10 +596,7 @@ mntpntfree(Mnt *m) } m->list = mntalloc.mntfree; mntalloc.mntfree = m; - q = m->q; unlock(&mntalloc); - - qfree(q); } static void diff --git a/sys/src/9/port/devsd.c b/sys/src/9/port/devsd.c index 0c53b6e47..5cc44b31c 100644 --- a/sys/src/9/port/devsd.c +++ b/sys/src/9/port/devsd.c @@ -847,9 +847,12 @@ sdbio(Chan* c, int write, char* a, long len, uvlong off) b = (uchar*)a; allocd = 0; }else{ - b = sdmalloc(nb*unit->secsize); - if(b == nil) - error(Enomem); + while((b = sdmalloc(nb*unit->secsize)) == nil){ + if(!waserror()){ + resrcwait("no memory for sdbio"); + poperror(); + } + } allocd = 1; } if(waserror()){ @@ -929,8 +932,12 @@ sdrio(SDreq* r, void* a, long n) } data = nil; - if(n > 0 && (data = sdmalloc(n)) == nil) - error(Enomem); + while(n > 0 && (data = sdmalloc(n)) == nil){ + if(!waserror()){ + resrcwait("no memory for sdrio"); + poperror(); + } + } if(waserror()){ sdfree(data); r->data = nil; @@ -1484,8 +1491,7 @@ sdwrite(Chan* c, void* a, long n, vlong off) } if(n < 6 || n > sizeof(req->cmd)) error(Ebadarg); - if((req = malloc(sizeof(SDreq))) == nil) - error(Enomem); + req = smalloc(sizeof(SDreq)); req->unit = unit; if(waserror()){ free(req); diff --git a/sys/src/9/port/pgrp.c b/sys/src/9/port/pgrp.c index 22fc78b56..21ac7af86 100644 --- a/sys/src/9/port/pgrp.c +++ b/sys/src/9/port/pgrp.c @@ -306,6 +306,10 @@ resrcwait(char *reason) p = up->psstate; if(reason) { + if(waserror()){ + up->psstate = p; + nexterror(); + } up->psstate = reason; now = seconds(); /* don't tie up the console with complaints */ @@ -314,7 +318,9 @@ resrcwait(char *reason) print("%s\n", reason); } } - - tsleep(&up->sleep, return0, 0, 300); - up->psstate = p; + tsleep(&up->sleep, return0, 0, 100+nrand(200)); + if(reason) { + up->psstate = p; + poperror(); + } } diff --git a/sys/src/9/port/sdscsi.c b/sys/src/9/port/sdscsi.c index defad953e..e6b53c0b8 100644 --- a/sys/src/9/port/sdscsi.c +++ b/sys/src/9/port/sdscsi.c @@ -384,8 +384,7 @@ scsibio(SDunit* unit, int lun, int write, void* data, long nb, uvlong bno) SDreq *r; long rlen; - if((r = malloc(sizeof(SDreq))) == nil) - error(Enomem); + r = smalloc(sizeof(SDreq)); r->unit = unit; r->lun = lun; again: diff --git a/sys/src/ape/lib/9/rendezvous.c b/sys/src/ape/lib/9/rendezvous.c index 0e184c2f6..ab788cd55 100644 --- a/sys/src/ape/lib/9/rendezvous.c +++ b/sys/src/ape/lib/9/rendezvous.c @@ -1,9 +1,9 @@ #include -extern unsigned long _RENDEZVOUS(unsigned long, unsigned long); +extern void* _RENDEZVOUS(void*, void*); -unsigned long -rendezvous(unsigned long tag, unsigned long value) +void* +rendezvous(void *tag, void *value) { return _RENDEZVOUS(tag, value); } diff --git a/sys/src/ape/lib/9/segattach.c b/sys/src/ape/lib/9/segattach.c index f99f4877d..98178550e 100644 --- a/sys/src/ape/lib/9/segattach.c +++ b/sys/src/ape/lib/9/segattach.c @@ -1,8 +1,8 @@ #include -extern int _SEGATTACH(int, char*, void*, unsigned long); +extern void* _SEGATTACH(int, char*, void*, unsigned long); -int +void* segattach(int attr, char *class, void *va, unsigned long len) { return _SEGATTACH(attr, class, va, len); diff --git a/sys/src/ape/lib/9/segbrk.c b/sys/src/ape/lib/9/segbrk.c index 9e8d10eae..2b664aced 100644 --- a/sys/src/ape/lib/9/segbrk.c +++ b/sys/src/ape/lib/9/segbrk.c @@ -1,8 +1,8 @@ #include -extern int _SEGBRK(void*, void*); +extern void* _SEGBRK(void*, void*); -int +void* segbrk(void *saddr, void *addr) { return _SEGBRK(saddr, addr); diff --git a/sys/src/ape/lib/ap/mips/lock.c b/sys/src/ape/lib/ap/mips/lock.c index f0ecbe22a..866d074e9 100644 --- a/sys/src/ape/lib/ap/mips/lock.c +++ b/sys/src/ape/lib/ap/mips/lock.c @@ -31,8 +31,7 @@ lockinit(void) arch = C_fcr0(); switch(arch) { case POWER: - n = _SEGATTACH(0, "lock", (void*)Lockaddr, Pagesize); - if(n < 0) { + if(_SEGATTACH(0, "lock", (void*)Lockaddr, Pagesize) == (void*)-1) { arch = MAGNUM; break; } diff --git a/sys/src/ape/lib/ap/plan9/9iounit.c b/sys/src/ape/lib/ap/plan9/9iounit.c index 7117a9fe0..cf6a497e3 100644 --- a/sys/src/ape/lib/ap/plan9/9iounit.c +++ b/sys/src/ape/lib/ap/plan9/9iounit.c @@ -14,7 +14,7 @@ static int getfields(char *str, char **args, int max, int mflag) { char r; - int nr, intok, narg; + int intok, narg; if(max <= 0) return 0; @@ -24,8 +24,8 @@ getfields(char *str, char **args, int max, int mflag) if(!mflag) narg++; intok = 0; - for(;;) { - r = *str++; + for(;; str++) { + r = *str; if(r == 0) break; if(r == ' ' || r == '\t'){ @@ -33,7 +33,7 @@ getfields(char *str, char **args, int max, int mflag) break; *str = 0; intok = 0; - args[narg] = str + nr; + args[narg] = str + 1; if(!mflag) narg++; } else { diff --git a/sys/src/ape/lib/ap/plan9/_buf.c b/sys/src/ape/lib/ap/plan9/_buf.c index 6a375672b..906c2335d 100644 --- a/sys/src/ape/lib/ap/plan9/_buf.c +++ b/sys/src/ape/lib/ap/plan9/_buf.c @@ -49,9 +49,10 @@ static int copynotehandler(void *, char *); int _startbuf(int fd) { - int i, pid, sid; + int i, pid; Fdinfo *f; Muxbuf *b; + void *v; if(mux == 0){ _RFORK(RFREND); @@ -111,16 +112,20 @@ Found: for(i=0; icopypid, (void*)_muxsid) == (void*)~0) + ; _copyproc(fd, b); } - /* parent process continues ... */ b->copypid = pid; f->buf = b; f->flags |= FD_BUFFERED; unlock(&mux->lock); - _muxsid = _RENDEZVOUS(0, 0); + + while((v = _RENDEZVOUS(&b->copypid, 0)) == (void*)~0) + ; + _muxsid = (int)v; + /* leave fd open in parent so system doesn't reuse it */ return 0; } @@ -168,7 +173,7 @@ _copyproc(int fd, Muxbuf *b) /* sleep until there's room */ b->roomwait = 1; unlock(&mux->lock); - _RENDEZVOUS((unsigned long)&b->roomwait, 0); + _RENDEZVOUS(&b->roomwait, 0); } } else unlock(&mux->lock); @@ -193,15 +198,15 @@ _copyproc(int fd, Muxbuf *b) if(mux->selwait && FD_ISSET(fd, &mux->ewant)) { mux->selwait = 0; unlock(&mux->lock); - _RENDEZVOUS((unsigned long)&mux->selwait, fd); + _RENDEZVOUS(&mux->selwait, (void*)fd); } else if(b->datawait) { b->datawait = 0; unlock(&mux->lock); - _RENDEZVOUS((unsigned long)&b->datawait, 0); + _RENDEZVOUS(&b->datawait, 0); } else if(mux->selwait && FD_ISSET(fd, &mux->rwant)) { mux->selwait = 0; unlock(&mux->lock); - _RENDEZVOUS((unsigned long)&mux->selwait, fd); + _RENDEZVOUS(&mux->selwait, (void*)fd); } else unlock(&mux->lock); _exit(0); @@ -214,12 +219,12 @@ _copyproc(int fd, Muxbuf *b) b->datawait = 0; unlock(&mux->lock); /* wake up _bufreading process */ - _RENDEZVOUS((unsigned long)&b->datawait, 0); + _RENDEZVOUS(&b->datawait, 0); } else if(mux->selwait && FD_ISSET(fd, &mux->rwant)) { mux->selwait = 0; unlock(&mux->lock); /* wake up selecting process */ - _RENDEZVOUS((unsigned long)&mux->selwait, fd); + _RENDEZVOUS(&mux->selwait, (void*)fd); } else unlock(&mux->lock); } else @@ -265,7 +270,7 @@ goteof: /* sleep until there's data */ b->datawait = 1; unlock(&mux->lock); - _RENDEZVOUS((unsigned long)&b->datawait, 0); + _RENDEZVOUS(&b->datawait, 0); lock(&mux->lock); if(b->fd != fd){ unlock(&mux->lock); @@ -287,7 +292,7 @@ goteof: b->roomwait = 0; unlock(&mux->lock); /* wake up copy process */ - _RENDEZVOUS((unsigned long)&b->roomwait, 0); + _RENDEZVOUS(&b->roomwait, 0); } else unlock(&mux->lock); return ngot; @@ -390,7 +395,7 @@ select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeo } mux->selwait = 1; unlock(&mux->lock); - fd = _RENDEZVOUS((unsigned long)&mux->selwait, 0); + fd = (int)_RENDEZVOUS(&mux->selwait, 0); if(fd >= 0 && fd < nfds) { b = _fdinfo[fd].buf; if(b == 0 || b->fd != fd) { @@ -435,7 +440,8 @@ _timerproc(void) signal(SIGALRM, alarmed); for(i=0; iwaittime); if(timerreset) { @@ -446,7 +452,7 @@ _timerproc(void) mux->selwait = 0; mux->waittime = LONGWAIT; unlock(&mux->lock); - _RENDEZVOUS((unsigned long)&mux->selwait, -2); + _RENDEZVOUS(&mux->selwait, (void*)-2); } else { mux->waittime = LONGWAIT; unlock(&mux->lock); @@ -454,9 +460,12 @@ _timerproc(void) } } } - atexit(_killtimerproc); /* parent process continues */ - _RENDEZVOUS(1, 0); + if(timerpid > 0){ + atexit(_killtimerproc); + while(_RENDEZVOUS(&timerpid, 0) == (void*)~0) + ; + } } static void diff --git a/sys/src/ape/lib/ap/plan9/_envsetup.c b/sys/src/ape/lib/ap/plan9/_envsetup.c index 083a75d17..6d76da87e 100644 --- a/sys/src/ape/lib/ap/plan9/_envsetup.c +++ b/sys/src/ape/lib/ap/plan9/_envsetup.c @@ -32,7 +32,6 @@ void _envsetup(void) { int dfd; - struct dirent *de; int n, nd, m, i, j, f; int psize, cnt; int nohandle; @@ -107,7 +106,7 @@ done: static void sigsetup(char *s, char *se) { - int i, sig; + int sig; char *e; while(s < se){ diff --git a/sys/src/ape/lib/ap/plan9/_exit.c b/sys/src/ape/lib/ap/plan9/_exit.c index e3886ff18..51a19f96b 100644 --- a/sys/src/ape/lib/ap/plan9/_exit.c +++ b/sys/src/ape/lib/ap/plan9/_exit.c @@ -19,7 +19,6 @@ _exit(int status) void _finish(int status, char *term) { - int i, nalive; char *cp; if(_finishing) diff --git a/sys/src/ape/lib/ap/plan9/_fdinfo.c b/sys/src/ape/lib/ap/plan9/_fdinfo.c index 7a3415c93..0bfb8299a 100644 --- a/sys/src/ape/lib/ap/plan9/_fdinfo.c +++ b/sys/src/ape/lib/ap/plan9/_fdinfo.c @@ -97,11 +97,9 @@ readprocfdinit(void) static void sfdinit(int usedproc, char *s, char *se) { - int i; Fdinfo *fi; unsigned long fd, fl, ofl; char *e; - struct stat sbuf; while(s < se){ fd = strtoul(s, &e, 10); diff --git a/sys/src/ape/lib/ap/plan9/access.c b/sys/src/ape/lib/ap/plan9/access.c index 527af63ee..971accb17 100644 --- a/sys/src/ape/lib/ap/plan9/access.c +++ b/sys/src/ape/lib/ap/plan9/access.c @@ -11,7 +11,7 @@ int access(const char *name, int mode) { - int fd, n; + int fd; Dir *db; struct stat st; static char omode[] = { diff --git a/sys/src/ape/lib/ap/plan9/ctime.c b/sys/src/ape/lib/ap/plan9/ctime.c index ce56c2d0f..e736140cf 100644 --- a/sys/src/ape/lib/ap/plan9/ctime.c +++ b/sys/src/ape/lib/ap/plan9/ctime.c @@ -148,7 +148,7 @@ localtime_r(const time_t *timp, struct tm *result) struct tm *ct; time_t t, tim; long *p; - int i, dlflag; + int dlflag; tim = *timp; if(tz.stname[0] == 0) diff --git a/sys/src/ape/lib/ap/plan9/dup.c b/sys/src/ape/lib/ap/plan9/dup.c index 37883be52..50842524f 100644 --- a/sys/src/ape/lib/ap/plan9/dup.c +++ b/sys/src/ape/lib/ap/plan9/dup.c @@ -11,8 +11,6 @@ dup(int oldd) int dup2(int oldd, int newd) { - int n; - if(newd < 0 || newd >= OPEN_MAX){ errno = EBADF; return -1; diff --git a/sys/src/ape/lib/ap/plan9/isatty.c b/sys/src/ape/lib/ap/plan9/isatty.c index e04cd891d..b0ccb54bf 100644 --- a/sys/src/ape/lib/ap/plan9/isatty.c +++ b/sys/src/ape/lib/ap/plan9/isatty.c @@ -8,7 +8,6 @@ int _isatty(int fd) { - int t; char buf[64]; if(_FD2PATH(fd, buf, sizeof buf) < 0) diff --git a/sys/src/ape/lib/ap/plan9/open.c b/sys/src/ape/lib/ap/plan9/open.c index bc088f197..fa45ea098 100644 --- a/sys/src/ape/lib/ap/plan9/open.c +++ b/sys/src/ape/lib/ap/plan9/open.c @@ -18,7 +18,6 @@ open(const char *path, int flags, ...) int mode; Fdinfo *fi; va_list va; - struct stat sbuf; f = flags&O_ACCMODE; if(flags&O_CREAT){ diff --git a/sys/src/ape/lib/ap/plan9/opendir.c b/sys/src/ape/lib/ap/plan9/opendir.c index ebc22dbf6..a007ba608 100644 --- a/sys/src/ape/lib/ap/plan9/opendir.c +++ b/sys/src/ape/lib/ap/plan9/opendir.c @@ -84,7 +84,7 @@ rewinddir(DIR *d) struct dirent * readdir(DIR *d) { - int i, n; + int i; struct dirent *dr; Dir *dirs; diff --git a/sys/src/ape/lib/ap/plan9/qlock.c b/sys/src/ape/lib/ap/plan9/qlock.c index b0882f789..3be8dae25 100644 --- a/sys/src/ape/lib/ap/plan9/qlock.c +++ b/sys/src/ape/lib/ap/plan9/qlock.c @@ -73,7 +73,7 @@ qlock(QLock *q) unlock(&q->lock); /* wait */ - while((*_rendezvousp)((ulong)mp, 1) == ~0) + while((*_rendezvousp)(mp, (void*)1) == (void*)~0) ; mp->inuse = 0; } @@ -91,7 +91,7 @@ qunlock(QLock *q) if(q->head == nil) q->tail = nil; unlock(&q->lock); - while((*_rendezvousp)((ulong)p, 0x12345) == ~0) + while((*_rendezvousp)(p, (void*)0x12345) == (void*)~0) ; return; } @@ -140,7 +140,7 @@ rlock(RWLock *q) unlock(&q->lock); /* wait in kernel */ - while((*_rendezvousp)((ulong)mp, 1) == ~0) + while((*_rendezvousp)(mp, (void*)1) == (void*)~0) ; mp->inuse = 0; } @@ -183,7 +183,7 @@ runlock(RWLock *q) unlock(&q->lock); /* wakeup waiter */ - while((*_rendezvousp)((ulong)p, 0) == ~0) + while((*_rendezvousp)(p, (void*)0) == (void*)~0) ; } @@ -213,7 +213,7 @@ wlock(RWLock *q) unlock(&q->lock); /* wait in kernel */ - while((*_rendezvousp)((ulong)mp, 1) == ~0) + while((*_rendezvousp)(mp, (void*)1) == (void*)~0) ; mp->inuse = 0; } @@ -252,7 +252,7 @@ wunlock(RWLock *q) if(q->head == nil) q->tail = nil; unlock(&q->lock); - while((*_rendezvousp)((ulong)p, 0) == ~0) + while((*_rendezvousp)(p, (void*)0) == (void*)~0) ; return; } @@ -265,7 +265,7 @@ wunlock(RWLock *q) p = q->head; q->head = p->next; q->readers++; - while((*_rendezvousp)((ulong)p, 0) == ~0) + while((*_rendezvousp)(p, (void*)0) == (void*)~0) ; } if(q->head == nil) @@ -303,7 +303,7 @@ rsleep(Rendez *r) if(r->l->head == nil) r->l->tail = nil; unlock(&r->l->lock); - while((*_rendezvousp)((ulong)t, 0x12345) == ~0) + while((*_rendezvousp)(t, (void*)0x12345) == (void*)~0) ; }else{ r->l->locked = 0; @@ -311,7 +311,7 @@ rsleep(Rendez *r) } /* wait for a wakeup */ - while((*_rendezvousp)((ulong)me, 1) == ~0) + while((*_rendezvousp)(me, (void*)1) == (void*)~0) ; me->inuse = 0; } diff --git a/sys/src/ape/lib/ap/plan9/rename.c b/sys/src/ape/lib/ap/plan9/rename.c index 73d051b11..182f49ce2 100644 --- a/sys/src/ape/lib/ap/plan9/rename.c +++ b/sys/src/ape/lib/ap/plan9/rename.c @@ -13,7 +13,6 @@ rename(const char *from, const char *to) int n, i; char *f, *t; Dir *d, nd; - long mode; if(access(to, 0) >= 0){ if(_REMOVE(to) < 0){ diff --git a/sys/src/ape/lib/ap/plan9/sys9.h b/sys/src/ape/lib/ap/plan9/sys9.h index b289273cb..b9e5bbc04 100644 --- a/sys/src/ape/lib/ap/plan9/sys9.h +++ b/sys/src/ape/lib/ap/plan9/sys9.h @@ -98,10 +98,10 @@ extern long _PREAD(int, void*, long, long long); extern long _PWRITE(int, void*, long, long long); extern long _READ(int, void*, long); extern int _REMOVE(const char*); -extern int _RENDEZVOUS(unsigned long, unsigned long); +extern void* _RENDEZVOUS(void*, void*); extern int _RFORK(int); -extern int _SEGATTACH(int, char*, void*, unsigned long); -extern int _SEGBRK(void*, void*); +extern void* _SEGATTACH(int, char*, void*, unsigned long); +extern void* _SEGBRK(void*, void*); extern int _SEGDETACH(void*); extern int _SEGFLUSH(void*, unsigned long); extern int _SEGFREE(void*, unsigned long); diff --git a/sys/src/ape/lib/bsd/listen.c b/sys/src/ape/lib/bsd/listen.c index b0408cd19..045ff3a91 100644 --- a/sys/src/ape/lib/bsd/listen.c +++ b/sys/src/ape/lib/bsd/listen.c @@ -31,14 +31,11 @@ extern void _killmuxsid(void); static int listenproc(Rock *r, int fd) { - Rock *nr; - char *net; - int cfd, nfd, dfd; - int pfd[2]; + char listen[Ctlsize], name[Ctlsize], *net, *p; + int cfd, nfd, dfd, pfd[2]; struct stat d; - char *p; - char listen[Ctlsize]; - char name[Ctlsize]; + Rock *nr; + void *v; switch(r->stype){ case SOCK_DGRAM: @@ -81,11 +78,14 @@ listenproc(Rock *r, int fd) _muxsid = getpgrp(); } else setpgid(getpid(), _muxsid); - _RENDEZVOUS(2, _muxsid); + while(_RENDEZVOUS(r, (void*)_muxsid) == (void*)~0) + ; break; default: + while((v = _RENDEZVOUS(r, 0)) == (void*)~0) + ; + _muxsid = (int)v; atexit(_killmuxsid); - _muxsid = _RENDEZVOUS(2, 0); close(pfd[1]); close(nfd); return 0; diff --git a/sys/src/ape/lib/draw/libc.h b/sys/src/ape/lib/draw/libc.h index 97e3deacb..f6c5e97a2 100644 --- a/sys/src/ape/lib/draw/libc.h +++ b/sys/src/ape/lib/draw/libc.h @@ -84,10 +84,10 @@ extern long _PREAD(int, void*, long, long long); extern long _PWRITE(int, void*, long, long long); extern long _READ(int, void*, long); extern int _REMOVE(const char*); -extern int _RENDEZVOUS(unsigned long, unsigned long); +extern void* _RENDEZVOUS(void*, void*); extern int _RFORK(int); -extern int _SEGATTACH(int, char*, void*, unsigned long); -extern int _SEGBRK(void*, void*); +extern void* _SEGATTACH(int, char*, void*, unsigned long); +extern void* _SEGBRK(void*, void*); extern int _SEGDETACH(void*); extern int _SEGFLUSH(void*, unsigned long); extern int _SEGFREE(void*, unsigned long); diff --git a/sys/src/cmd/acme/disk.c b/sys/src/cmd/acme/disk.c index 4c22d0a8c..9b76a5582 100644 --- a/sys/src/cmd/acme/disk.c +++ b/sys/src/cmd/acme/disk.c @@ -120,10 +120,20 @@ diskwrite(Disk *d, Block **bp, Rune *r, uint n) void diskread(Disk *d, Block *b, Rune *r, uint n) { + int tot, nr; + char *p; + if(n > b->n) error("internal error: diskread"); ntosize(b->n, nil); - if(pread(d->fd, r, n*sizeof(Rune), b->addr) != n*sizeof(Rune)) + n *= sizeof(Rune); + p = (char*)r; + for(tot = 0; tot < n; tot += nr){ + nr = pread(d->fd, p+tot, n-tot, b->addr+tot); + if(nr <= 0) + error("read error from temp file"); + } + if(tot != n) error("read error from temp file"); } diff --git a/sys/src/cmd/awk/mkfile b/sys/src/cmd/awk/mkfile index 1314ca560..35ee78d7c 100644 --- a/sys/src/cmd/awk/mkfile +++ b/sys/src/cmd/awk/mkfile @@ -41,7 +41,7 @@ clean:V: rm -f *.[$OS] [$OS].out [$OS].maketab y.tab.? y.debug y.output $TARG nuke:V: - rm -f *.[$OS] [$OS].out [$OS].maketab y.tab.? y.debug y.output awkgram.c $TARG + rm -f *.[$OS] [$OS].out [$OS].maketab y.tab.? y.debug y.output awkgram.c proctab.c $TARG proctab.c: $cpuobjtype.maketab ./$cpuobjtype.maketab >proctab.c diff --git a/sys/src/cmd/awk/proctab.c b/sys/src/cmd/awk/proctab.c deleted file mode 100644 index 7b19d2383..000000000 --- a/sys/src/cmd/awk/proctab.c +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include "awk.h" -#include "y.tab.h" - -static char *printname[92] = { - (char *) "FIRSTTOKEN", /* 57346 */ - (char *) "PROGRAM", /* 57347 */ - (char *) "PASTAT", /* 57348 */ - (char *) "PASTAT2", /* 57349 */ - (char *) "XBEGIN", /* 57350 */ - (char *) "XEND", /* 57351 */ - (char *) "NL", /* 57352 */ - (char *) "ARRAY", /* 57353 */ - (char *) "MATCH", /* 57354 */ - (char *) "NOTMATCH", /* 57355 */ - (char *) "MATCHOP", /* 57356 */ - (char *) "FINAL", /* 57357 */ - (char *) "DOT", /* 57358 */ - (char *) "ALL", /* 57359 */ - (char *) "CCL", /* 57360 */ - (char *) "NCCL", /* 57361 */ - (char *) "CHAR", /* 57362 */ - (char *) "OR", /* 57363 */ - (char *) "STAR", /* 57364 */ - (char *) "QUEST", /* 57365 */ - (char *) "PLUS", /* 57366 */ - (char *) "AND", /* 57367 */ - (char *) "BOR", /* 57368 */ - (char *) "APPEND", /* 57369 */ - (char *) "EQ", /* 57370 */ - (char *) "GE", /* 57371 */ - (char *) "GT", /* 57372 */ - (char *) "LE", /* 57373 */ - (char *) "LT", /* 57374 */ - (char *) "NE", /* 57375 */ - (char *) "IN", /* 57376 */ - (char *) "ARG", /* 57377 */ - (char *) "BLTIN", /* 57378 */ - (char *) "BREAK", /* 57379 */ - (char *) "CLOSE", /* 57380 */ - (char *) "CONTINUE", /* 57381 */ - (char *) "DELETE", /* 57382 */ - (char *) "DO", /* 57383 */ - (char *) "EXIT", /* 57384 */ - (char *) "FOR", /* 57385 */ - (char *) "FUNC", /* 57386 */ - (char *) "SUB", /* 57387 */ - (char *) "GSUB", /* 57388 */ - (char *) "IF", /* 57389 */ - (char *) "INDEX", /* 57390 */ - (char *) "LSUBSTR", /* 57391 */ - (char *) "MATCHFCN", /* 57392 */ - (char *) "NEXT", /* 57393 */ - (char *) "NEXTFILE", /* 57394 */ - (char *) "ADD", /* 57395 */ - (char *) "MINUS", /* 57396 */ - (char *) "MULT", /* 57397 */ - (char *) "DIVIDE", /* 57398 */ - (char *) "MOD", /* 57399 */ - (char *) "ASSIGN", /* 57400 */ - (char *) "ASGNOP", /* 57401 */ - (char *) "ADDEQ", /* 57402 */ - (char *) "SUBEQ", /* 57403 */ - (char *) "MULTEQ", /* 57404 */ - (char *) "DIVEQ", /* 57405 */ - (char *) "MODEQ", /* 57406 */ - (char *) "POWEQ", /* 57407 */ - (char *) "PRINT", /* 57408 */ - (char *) "PRINTF", /* 57409 */ - (char *) "SPRINTF", /* 57410 */ - (char *) "ELSE", /* 57411 */ - (char *) "INTEST", /* 57412 */ - (char *) "CONDEXPR", /* 57413 */ - (char *) "POSTINCR", /* 57414 */ - (char *) "PREINCR", /* 57415 */ - (char *) "POSTDECR", /* 57416 */ - (char *) "PREDECR", /* 57417 */ - (char *) "VAR", /* 57418 */ - (char *) "IVAR", /* 57419 */ - (char *) "VARNF", /* 57420 */ - (char *) "CALL", /* 57421 */ - (char *) "NUMBER", /* 57422 */ - (char *) "STRING", /* 57423 */ - (char *) "REGEXPR", /* 57424 */ - (char *) "GETLINE", /* 57425 */ - (char *) "RETURN", /* 57426 */ - (char *) "SPLIT", /* 57427 */ - (char *) "SUBSTR", /* 57428 */ - (char *) "WHILE", /* 57429 */ - (char *) "CAT", /* 57430 */ - (char *) "NOT", /* 57431 */ - (char *) "UMINUS", /* 57432 */ - (char *) "POWER", /* 57433 */ - (char *) "DECR", /* 57434 */ - (char *) "INCR", /* 57435 */ - (char *) "INDIRECT", /* 57436 */ - (char *) "LASTTOKEN", /* 57437 */ -}; - - -Cell *(*proctab[92])(Node **, int) = { - nullproc, /* FIRSTTOKEN */ - program, /* PROGRAM */ - pastat, /* PASTAT */ - dopa2, /* PASTAT2 */ - nullproc, /* XBEGIN */ - nullproc, /* XEND */ - nullproc, /* NL */ - array, /* ARRAY */ - matchop, /* MATCH */ - matchop, /* NOTMATCH */ - nullproc, /* MATCHOP */ - nullproc, /* FINAL */ - nullproc, /* DOT */ - nullproc, /* ALL */ - nullproc, /* CCL */ - nullproc, /* NCCL */ - nullproc, /* CHAR */ - nullproc, /* OR */ - nullproc, /* STAR */ - nullproc, /* QUEST */ - nullproc, /* PLUS */ - boolop, /* AND */ - boolop, /* BOR */ - nullproc, /* APPEND */ - relop, /* EQ */ - relop, /* GE */ - relop, /* GT */ - relop, /* LE */ - relop, /* LT */ - relop, /* NE */ - instat, /* IN */ - arg, /* ARG */ - bltin, /* BLTIN */ - jump, /* BREAK */ - closefile, /* CLOSE */ - jump, /* CONTINUE */ - awkdelete, /* DELETE */ - dostat, /* DO */ - jump, /* EXIT */ - forstat, /* FOR */ - nullproc, /* FUNC */ - sub, /* SUB */ - gsub, /* GSUB */ - ifstat, /* IF */ - sindex, /* INDEX */ - nullproc, /* LSUBSTR */ - matchop, /* MATCHFCN */ - jump, /* NEXT */ - jump, /* NEXTFILE */ - arith, /* ADD */ - arith, /* MINUS */ - arith, /* MULT */ - arith, /* DIVIDE */ - arith, /* MOD */ - assign, /* ASSIGN */ - nullproc, /* ASGNOP */ - assign, /* ADDEQ */ - assign, /* SUBEQ */ - assign, /* MULTEQ */ - assign, /* DIVEQ */ - assign, /* MODEQ */ - assign, /* POWEQ */ - printstat, /* PRINT */ - awkprintf, /* PRINTF */ - awksprintf, /* SPRINTF */ - nullproc, /* ELSE */ - intest, /* INTEST */ - condexpr, /* CONDEXPR */ - incrdecr, /* POSTINCR */ - incrdecr, /* PREINCR */ - incrdecr, /* POSTDECR */ - incrdecr, /* PREDECR */ - nullproc, /* VAR */ - nullproc, /* IVAR */ - getnf, /* VARNF */ - call, /* CALL */ - nullproc, /* NUMBER */ - nullproc, /* STRING */ - nullproc, /* REGEXPR */ - getline, /* GETLINE */ - jump, /* RETURN */ - split, /* SPLIT */ - substr, /* SUBSTR */ - whilestat, /* WHILE */ - cat, /* CAT */ - boolop, /* NOT */ - arith, /* UMINUS */ - arith, /* POWER */ - nullproc, /* DECR */ - nullproc, /* INCR */ - indirect, /* INDIRECT */ - nullproc, /* LASTTOKEN */ -}; - -char *tokname(int n) -{ - static char buf[100]; - - if (n < FIRSTTOKEN || n > LASTTOKEN) { - sprintf(buf, "token %d", n); - return buf; - } - return printname[n-FIRSTTOKEN]; -} diff --git a/sys/src/cmd/faces/main.c b/sys/src/cmd/faces/main.c index e5eee9e42..7d5c38481 100644 --- a/sys/src/cmd/faces/main.c +++ b/sys/src/cmd/faces/main.c @@ -113,7 +113,7 @@ init(void) tinyfont = openfont(display, "/lib/font/bit/misc/ascii.5x7.font"); if(tinyfont == nil) tinyfont = font; - mediumfont = openfont(display, "/lib/font/bit/dejavusans/dejavusans.12.font"); + mediumfont = openfont(display, "/lib/font/bit/misc/unicode.6x13.font"); if(mediumfont == nil) mediumfont = font; datefont = font; diff --git a/sys/src/cmd/file.c b/sys/src/cmd/file.c index b92f088ad..ee6db10b4 100644 --- a/sys/src/cmd/file.c +++ b/sys/src/cmd/file.c @@ -828,7 +828,11 @@ struct FILE_STRING "OggS", "ogg audio", 4, "audio/ogg", ".snd", "sun audio", 4, "audio/basic", "\211PNG", "PNG image", 4, "image/png", + "P1\n", "ppm", 3, "image/ppm", + "P2\n", "ppm", 3, "image/ppm", "P3\n", "ppm", 3, "image/ppm", + "P4\n", "ppm", 3, "image/ppm", + "P5\n", "ppm", 3, "image/ppm", "P6\n", "ppm", 3, "image/ppm", "/* XPM */\n", "xbm", 10, "image/xbm", ".HTML ", "troff -ms input", 6, "text/troff", diff --git a/sys/src/cmd/jpg/imagefile.h b/sys/src/cmd/jpg/imagefile.h index 2dbc461f2..d9ab871b9 100644 --- a/sys/src/cmd/jpg/imagefile.h +++ b/sys/src/cmd/jpg/imagefile.h @@ -71,8 +71,8 @@ void memendgif(Biobuf*); Image* onechan(Image*); Memimage* memonechan(Memimage*); -char* writeppm(Biobuf*, Image*, char*); -char* memwriteppm(Biobuf*, Memimage*, char*); +char* writeppm(Biobuf*, Image*, char*, int); +char* memwriteppm(Biobuf*, Memimage*, char*, int); Image* multichan(Image*); Memimage* memmultichan(Memimage*); diff --git a/sys/src/cmd/jpg/toppm.c b/sys/src/cmd/jpg/toppm.c index e30946555..724854e63 100644 --- a/sys/src/cmd/jpg/toppm.c +++ b/sys/src/cmd/jpg/toppm.c @@ -9,7 +9,7 @@ void usage(void) { - fprint(2, "usage: toppm [-c 'comment'] [file]\n"); + fprint(2, "usage: toppm [-c 'comment'] [-r] [file]\n"); exits("usage"); } @@ -18,10 +18,11 @@ main(int argc, char *argv[]) { Biobuf bout; Memimage *i, *ni; - int fd; + int fd, rflag; char buf[256]; char *err, *comment; + rflag = 0; comment = nil; ARGBEGIN{ case 'c': @@ -33,6 +34,9 @@ main(int argc, char *argv[]) usage(); } break; + case 'r': + rflag = 1; + break; default: usage(); }ARGEND @@ -45,8 +49,6 @@ main(int argc, char *argv[]) memimageinit(); - err = nil; - if(argc == 0){ i = readmemimage(0); if(i == nil) @@ -58,8 +60,7 @@ main(int argc, char *argv[]) freememimage(i); i = ni; } - if(err == nil) - err = memwriteppm(&bout, i, comment); + err = memwriteppm(&bout, i, comment, rflag); }else{ fd = open(argv[0], OREAD); if(fd < 0) @@ -70,16 +71,16 @@ main(int argc, char *argv[]) close(fd); ni = memmultichan(i); if(ni == nil) - sysfatal("converting image to RGBV: %r"); + sysfatal("converting image to RGB24: %r"); if(i != ni){ freememimage(i); i = ni; } if(comment) - err = memwriteppm(&bout, i, comment); + err = memwriteppm(&bout, i, comment, rflag); else{ snprint(buf, sizeof buf, "Converted by Plan 9 from %s", argv[0]); - err = memwriteppm(&bout, i, buf); + err = memwriteppm(&bout, i, buf, rflag); } freememimage(i); } diff --git a/sys/src/cmd/jpg/writeppm.c b/sys/src/cmd/jpg/writeppm.c index bf32f0d25..dd716cf46 100644 --- a/sys/src/cmd/jpg/writeppm.c +++ b/sys/src/cmd/jpg/writeppm.c @@ -12,12 +12,32 @@ static int log2[] = { -1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5 }; +static int bitc = 0; +static int nbit = 0; + +static +void +Bputbit(Biobufhdr *b, int c) +{ + if(c >= 0x0){ + bitc = (bitc << 1) | (c & 0x1); + nbit++; + }else if(nbit > 0){ + for(; nbit < 8; nbit++) + bitc <<= 1; + } + if(nbit == 8){ + Bputc(b, bitc); + bitc = nbit = 0; + } +} + /* * Write data */ static char* -writedata(Biobuf *fd, Image *image, Memimage *memimage) +writedata(Biobuf *fd, Image *image, Memimage *memimage, int rflag) { char *err; uchar *data; @@ -51,7 +71,7 @@ writedata(Biobuf *fd, Image *image, Memimage *memimage) err = malloc(ERRMAX); if(err == nil) return "WritePPM: malloc failed"; - snprint(err, ERRMAX, "WriteGIF: %r"); + snprint(err, ERRMAX, "WritePPM: %r"); free(data); return err; } @@ -70,18 +90,36 @@ writedata(Biobuf *fd, Image *image, Memimage *memimage) pix = (data[i]>>depth*((xmask-x)&xmask))&pmask; if(((x+1)&xmask) == 0) i++; - col += Bprint(fd, "%d ", pix); + if(chan == GREY1){ + pix ^= 1; + if(rflag){ + Bputbit(fd, pix); + continue; + } + } else { + if(rflag){ + Bputc(fd, pix); + continue; + } + } + col += Bprint(fd, "%d", pix); if(col >= MAXLINE-(2+1)){ Bprint(fd, "\n"); col = 0; }else col += Bprint(fd, " "); } + if(rflag) + Bputbit(fd, -1); } break; - case GREY8: + case GREY8: for(i=0; i= MAXLINE-(4+1)){ Bprint(fd, "\n"); col = 0; @@ -91,6 +129,12 @@ writedata(Biobuf *fd, Image *image, Memimage *memimage) break; case RGB24: for(i=0; i= MAXLINE-(4+4+4+1)){ Bprint(fd, "\n"); @@ -108,21 +152,21 @@ writedata(Biobuf *fd, Image *image, Memimage *memimage) static char* -writeppm0(Biobuf *fd, Image *image, Memimage *memimage, Rectangle r, int chan, char *comment) +writeppm0(Biobuf *fd, Image *image, Memimage *memimage, Rectangle r, int chan, char *comment, int rflag) { char *err; switch(chan){ case GREY1: - Bprint(fd, "P1\n"); + Bprint(fd, "%s\n", rflag? "P4": "P1"); break; case GREY2: case GREY4: - case GREY8: - Bprint(fd, "P2\n"); + case GREY8: + Bprint(fd, "%s\n", rflag? "P5": "P2"); break; case RGB24: - Bprint(fd, "P3\n"); + Bprint(fd, "%s\n", rflag? "P6": "P3"); break; default: return "WritePPM: can't handle channel type"; @@ -143,27 +187,28 @@ writeppm0(Biobuf *fd, Image *image, Memimage *memimage, Rectangle r, int chan, c case GREY4: Bprint(fd, "%d\n", 15); break; - case GREY8: + case GREY8: case RGB24: Bprint(fd, "%d\n", 255); break; } - err = writedata(fd, image, memimage); + err = writedata(fd, image, memimage, rflag); - Bprint(fd, "\n"); + if(!rflag) + Bprint(fd, "\n"); Bflush(fd); return err; } char* -writeppm(Biobuf *fd, Image *image, char *comment) +writeppm(Biobuf *fd, Image *image, char *comment, int rflag) { - return writeppm0(fd, image, nil, image->r, image->chan, comment); + return writeppm0(fd, image, nil, image->r, image->chan, comment, rflag); } char* -memwriteppm(Biobuf *fd, Memimage *memimage, char *comment) +memwriteppm(Biobuf *fd, Memimage *memimage, char *comment, int rflag) { - return writeppm0(fd, nil, memimage, memimage->r, memimage->chan, comment); + return writeppm0(fd, nil, memimage, memimage->r, memimage->chan, comment, rflag); } diff --git a/sys/src/cmd/nusb/kb/kb.c b/sys/src/cmd/nusb/kb/kb.c index 708ff05c3..0313a465e 100644 --- a/sys/src/cmd/nusb/kb/kb.c +++ b/sys/src/cmd/nusb/kb/kb.c @@ -56,6 +56,11 @@ struct KDev * besides wheel and regular up/down report the 4th byte as 1/-1 */ +/* + * scan codes >= 0x80 are extended (E0 XX) + */ +#define isext(sc) ((sc) >= 0x80) + /* * key code to scan code; for the page table used by * the logitech bluetooth keyboard. @@ -70,15 +75,15 @@ static char sctab[256] = [0x28] 0x1c, 0x1, 0xe, 0xf, 0x39, 0xc, 0xd, 0x1a, [0x30] 0x1b, 0x2b, 0x2b, 0x27, 0x28, 0x29, 0x33, 0x34, [0x38] 0x35, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, -[0x40] 0x41, 0x42, 0x43, 0x44, 0x57, 0x58, 0x63, 0x46, -[0x48] 0x77, 0x52, 0x47, 0x49, 0x53, 0x4f, 0x51, 0x4d, -[0x50] 0x4b, 0x50, 0x48, 0x45, 0x35, 0x37, 0x4a, 0x4e, -[0x58] 0x1c, 0x4f, 0x50, 0x51, 0x4b, 0x4c, 0x4d, 0x47, -[0x60] 0x48, 0x49, 0x52, 0x53, 0x56, 0x7f, 0x74, 0x75, -[0x68] 0x55, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, -[0x70] 0x78, 0x79, 0x7a, 0x7b, 0x0, 0x0, 0x0, 0x0, -[0x78] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71, -[0x80] 0x73, 0x72, 0x0, 0x0, 0x0, 0x7c, 0x0, 0x0, +[0x40] 0x41, 0x42, 0x43, 0x44, 0x57, 0x58, 0xe3, 0x46, +[0x48] 0xf7, 0xd2, 0xc7, 0xc9, 0xd3, 0xcf, 0xd1, 0xcd, +[0x50] 0xcb, 0xd0, 0xc8, 0x45, 0x35, 0x37, 0x4a, 0x4e, +[0x58] 0x1c, 0xcf, 0xd0, 0xd1, 0xcb, 0xcc, 0xcd, 0xc7, +[0x60] 0xc8, 0xc9, 0xd2, 0xd3, 0x56, 0xff, 0xf4, 0xf5, +[0x68] 0xd5, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, +[0x70] 0xf8, 0xf9, 0xfa, 0xfb, 0x0, 0x0, 0x0, 0x0, +[0x78] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf1, +[0x80] 0xf3, 0xf2, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, [0x88] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, [0x90] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, [0x98] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -90,8 +95,8 @@ static char sctab[256] = [0xc8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, [0xd0] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, [0xd8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -[0xe0] 0x1d, 0x2a, 0x38, 0x7d, 0x61, 0x36, 0x64, 0x7e, -[0xe8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x73, 0x72, 0x71, +[0xe0] 0x1d, 0x2a, 0xb8, 0xfd, 0xe1, 0x36, 0xe4, 0xfe, +[0xe8] 0x0, 0x0, 0x0, 0x0, 0x0, 0xf3, 0xf2, 0xf1, [0xf0] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, [0xf8] 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }; @@ -513,14 +518,16 @@ ptrwork(void* a) } static void -putscan(int fd, uchar esc, uchar sc) +putscan(int fd, uchar sc, uchar up) { uchar s[2] = {SCesc1, 0}; - s[1] = sc; - if(esc && sc != 0) + if(sc == 0) + return; + s[1] = up | sc&Keymask; + if(isext(sc)) write(fd, s, 2); - else if(sc != 0) + else write(fd, s+1, 1); } @@ -563,7 +570,7 @@ repeatproc(void* arg) Channel *repeatc, *sleepc; int kbdinfd; ulong l, t; - uchar esc1, sc; + uchar sc; Alt a[3]; repeatc = f->repeatc; @@ -590,13 +597,12 @@ repeatproc(void* arg) l = recvul(repeatc); continue; } - esc1 = l >> 8; - sc = l; + sc = l & 0xff; t = Kbdelay; if(alt(a) == 1){ t = Kbrepeat; while(alt(a) == 1) - putscan(kbdinfd, esc1, sc); + putscan(kbdinfd, sc, 0); } } if(sleepc != nil) @@ -612,19 +618,11 @@ stoprepeat(KDev *f) } static void -startrepeat(KDev *f, uchar esc1, uchar sc) +startrepeat(KDev *f, uchar sc) { - ulong c; - - if(esc1) - c = SCesc1 << 8 | (sc & 0xff); - else - c = sc; - sendul(f->repeatc, c); + sendul(f->repeatc, sc); } -#define hasesc1(sc) (((sc) >= 0x47) || ((sc) == 0x38)) - /* * This routine diffs the state with the last known state * and invents the scan codes that would have been sent @@ -654,8 +652,8 @@ putkeys(KDev *f, uchar buf[], uchar obuf[], int n, uchar dk) break; if(j == n && buf[i] != 0){ dk = sctab[buf[i]]; - putscan(fd, hasesc1(dk), dk); - startrepeat(f, hasesc1(dk), dk); + putscan(fd, dk, 0); + startrepeat(f, dk); } } @@ -667,7 +665,7 @@ putkeys(KDev *f, uchar buf[], uchar obuf[], int n, uchar dk) break; if(j == n && obuf[i] != 0){ uk = sctab[obuf[i]]; - putscan(fd, hasesc1(uk), uk|Keyup); + putscan(fd, uk, Keyup); } } if(uk && (dk == 0 || dk == uk)){ diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c index 8752090c7..6fd67a559 100644 --- a/sys/src/cmd/rio/wind.c +++ b/sys/src/cmd/rio/wind.c @@ -471,7 +471,7 @@ showcandidates(Window *w, Completion *c) int i; Fmt f; Rune *rp; - uint nr, qline, q0; + uint nr, qline; char *s; runefmtstrinit(&f); @@ -490,20 +490,21 @@ showcandidates(Window *w, Completion *c) } fmtprint(&f, "]\n"); } - /* place text at beginning of line before host point */ - qline = w->qh; - while(qline>0 && w->r[qline-1] != '\n') - qline--; - rp = runefmtstrflush(&f); nr = runestrlen(rp); - q0 = w->q0; - q0 += winsert(w, rp, nr, qline) - qline; - if(q0 >= w->qh) - w->qh += nr; + /* place text at beginning of line before cursor and host point */ + qline = min(w->qh, w->q0); + while(qline>0 && w->r[qline-1] != '\n') + qline--; + + if(qline == w->qh){ + /* advance host point to avoid readback */ + w->qh = winsert(w, rp, nr, qline)+nr; + } else { + winsert(w, rp, nr, qline); + } free(rp); - wsetselect(w, q0+nr, q0+nr); } Rune* diff --git a/sys/src/cmd/srv.c b/sys/src/cmd/srv.c index f4186f56c..9dd328e35 100644 --- a/sys/src/cmd/srv.c +++ b/sys/src/cmd/srv.c @@ -51,6 +51,7 @@ connectcmd(char *cmd) rfork(RFNOTEG); dup(p[0], 0); dup(p[0], 1); + close(p[0]); close(p[1]); execl("/bin/rc", "rc", "-c", cmd, nil); fprint(2, "exec failed: %r\n");