Subject: #elif in cpp, disklabels in HK(4), more (#439) Index: lib/cpp/cpp.c,sys/pdpstand/hk.c,... 2.11BSD Description: This is a collection of fixes that have been gathering virtual dust in the Inbox for several months. Special thanks go to a couple folks: Anders Magnusson (ragge@ludd.luth.se) and Fred van Kempen (Fred.van.Kempen@microwalt.nl) for their hard work and fixes. 1) Disklabel support is badly broken in the HK (rk06/7) driver. 2) cpp does not properly support '#elif' 3) Error in the ld(1) manpage. 4) Syntax error in the /sys/sys/ioctl_compat.h file 5) The sample printcap lacks a definition for a parallel port printer 6) Resource limit setting does not permit a process to limit its memory size 7) Yet another error in the 'tmac' macro package used by troff 8) Error in the :rofix script used when building 'cpp' Repeat-By: 1) Your choice of either trying to load 2.11 onto an RK07 or by observation. The disklabel support that was present was done without access to actual (or emulated) hardware and was obviously never tested ;( 2) The '#elif' support that was present would simply toggle the true/false status of the existing '#if ...' and not allow usage such as "#elif defined(...) ...". 3) There was a lingering reference to an overlaid C library ('-lovc'). That is incorrect and was causing confusion because there has not been such a library in 2.11 (it was a throwback to 2.9BSD). 4) Compiling a program that actually used the old compatibility define for LTILDE would stumble across the misbalanced parens. Since the value of LTILDE is 0 the #define was simplified. 5) At one time serial printers were much more common and the sample printcap reflected that fact. Today as more people are using emulators rather than actual PDP-11 hardware the use of emulated parallel printers is increasing and it is time to update the sample printcap file. 6) The ability to restrict how large a program can grow was not implemented originally because the thinking at the time was: who would want to restrict a 64KB address space even further? Seems there are folks who want to do that so the setrlimit(2) syscall was modified. 7) Harmless error (an extra .ie directive) was accidentally included in the tmac macro package. Removing it makes a small efficiency improvement I suppose ;) 8) There were errors in the :rofix script used when building cpp. Even if the errors were fixed placing readonly data in the code section is the "Wrong Thing" to do because it would break badly in a split I/D program. Fix: The following files are modified by this patch: /usr/src/sys/pdpuba/hk.c /usr/src/sys/conf/GENERIC /usr/src/sys/sys/kern_mman.c /usr/src/sys/h/ioctl_compat.h /usr/src/sys/pdp/conf.c /usr/src/sys/pdpstand/hk.c /usr/src/sys/GENERIC/rl.h /usr/src/bin/ld/ld.1 /usr/src/etc/printcap /usr/src/lib/cpp/cpp.c /usr/src/lib/pcc/:yyfix /usr/src/share/tmac/tmac.s /VERSION To apply this patch cut where indicated and save to a file (/tmp/439) and then: patch -p0 < /tmp/439 First the non-kernel related items are built/installed: cd /usr/src/lib/cpp make make install make clean cd /usr/src/share/tmac make install cd /usr/src/bin/ld make ld.0 install -c -o bin -g bin -m 444 ld.0 /usr/man/cat1 Next the standalone and boot programs: cd /sys/pdpstand make clean make cp boot disklabel toyset / Lastly the kernel. Since a couple of the kernel sources have grown in size (especially if you have RK06/7 devices configured) you may need to adjust the overlay configuration in YOUR_KERNEL/Makefile. It is a good idea (especially if basic device drivers are updated) to rebuild and install a GENERIC kernel as /genunix: cd /sys/GENERIC make clean make mv unix /genunix Next and last your own kernel: cd /sys/YOUR_KERNEL make clean make mv /netnix /onetnix mv /unix /ounix mv unix netnix / chmod 744 /unix /netnix And with that you're done. Enjoy. As always this and previous updates to 2.11BSD are available via anonymous FTP to either FTP.TO.GD-ES.COM or MOE.2BSD.COM in the directory /pub/2.11BSD. -------------------------cut here--------------------- *** /usr/src/sys/pdpuba/hk.c.old Fri Apr 3 22:11:19 1998 --- /usr/src/sys/pdpuba/hk.c Mon Aug 13 15:38:07 2001 *************** *** 3,14 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)hk.c 2.3 (2.11BSD GTE) 1998/4/3 */ /* * RK611/RK0[67] disk driver * * Heavily modified for disklabel support. Still only supports 1 controller * (but who'd have more than one of these on a system anyhow?) - 1997/11/11 sms * --- 3,16 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)hk.c 2.4 (2.11BSD) 2001/8/13 */ /* * RK611/RK0[67] disk driver * + * 2001/8/11 - major disklabel handling bug fixed (basically they did not work) + * * Heavily modified for disklabel support. Still only supports 1 controller * (but who'd have more than one of these on a system anyhow?) - 1997/11/11 sms * *************** *** 60,65 **** --- 62,68 ---- daddr_t hksize(); void hkdfltlbl(); int hkstrategy(); + static daddr_t hkabsbn(); /* Can be u_char because all are less than 0377 */ u_char hk_offset[] = *************** *** 344,350 **** if (s == 0) goto done; ! bp->b_cylin = bp->b_blkno / HK_NSPC; mapalloc(bp); dp = &hkutab[drive]; s = splbio(); --- 347,353 ---- if (s == 0) goto done; ! bp->b_cylin = hkabsbn(bp) / HK_NSPC; mapalloc(bp); dp = &hkutab[drive]; s = splbio(); *************** *** 489,495 **** hktab.b_active++; unit = dkunit(bp->b_dev); disk = &hk_dk[unit]; ! bn = bp->b_blkno; sn = bn % HK_NSPC; tn = sn / HK_NSECT; --- 492,498 ---- hktab.b_active++; unit = dkunit(bp->b_dev); disk = &hk_dk[unit]; ! bn = hkabsbn(bp); sn = bn % HK_NSPC; tn = sn / HK_NSECT; *************** *** 681,686 **** --- 684,700 ---- hkaddr->hkcs1 = HK_IE; } + hkioctl(dev, cmd, data, flag) + dev_t dev; + int cmd; + caddr_t data; + int flag; + { + struct dkdevice *disk = &hk_dk[dkunit(dev)]; + + return(ioctldisklabel(dev, cmd, data, flag, disk, hkstrategy)); + } + #ifdef HK_DUMP /* * Dump routine for RK06/07 *************** *** 803,809 **** npx = ndone / NBPG; } unit = dkunit(bp->b_dev); ! bn = bp->b_blkno; cn = bp->b_cylin - bn / HK_NSPC; bn += npx; cn += bn / HK_NSPC; --- 817,823 ---- npx = ndone / NBPG; } unit = dkunit(bp->b_dev); ! bn = hkabsbn(bp); cn = bp->b_cylin - bn / HK_NSPC; bn += npx; cn += bn / HK_NSPC; *************** *** 822,827 **** --- 836,845 ---- unsigned o; struct ubmap *ubp; + /* + * The use of the blkno below is intentional since it is relative to the + * partition. + */ log(LOG_WARNING, "hk%d%c: soft ecc sn %D\n", unit, 'a' + (bp->b_dev & 07), bp->b_blkno + npx - 1); mask = hkaddr->hkecpt; *************** *** 934,938 **** --- 952,968 ---- if (didopen) hkclose(dev, FREAD|FWRITE, S_IFBLK); return(psize); + } + + static daddr_t + hkabsbn(bp) + register struct buf *bp; + { + register struct partition *pi; + register struct dkdevice *disk; + + disk = &hk_dk[dkunit(bp->b_dev)]; + pi = &disk->dk_parts[dkpart(bp->b_dev)]; + return(bp->b_blkno + pi->p_offset); } #endif NHK > 0 *** /usr/src/sys/conf/GENERIC.old Tue Jan 21 20:04:45 1997 --- /usr/src/sys/conf/GENERIC Sat Aug 4 15:31:02 2001 *************** *** 148,154 **** NRK 8 # RK05 ! NRL 2 # RL01/02 NRX 2 # RX02 --- 148,154 ---- NRK 8 # RK05 ! NRL 4 # RL01/02 NRX 2 # RX02 *** /usr/src/sys/sys/kern_mman.c.old Sun Feb 20 17:52:21 2000 --- /usr/src/sys/sys/kern_mman.c Sun Aug 26 10:05:14 2001 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_mman.c 1.3 (2.11BSD) 2000/2/20 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)kern_mman.c 1.4 (2.11BSD) 2001/8/26 */ #include "param.h" *************** *** 31,36 **** --- 31,42 ---- n -= ctos(u.u_tsize) * stoc(1); if (n < 0) n = 0; + /* Check resource limits */ + if (u.u_rlimit[RLIMIT_DATA].rlim_cur != RLIM_INFINITY && + n > btoc(u.u_rlimit[RLIMIT_DATA].rlim_cur)) { + u.u_error = ENOMEM; + return -1; + } if (estabur(u.u_tsize, n, u.u_ssize, u.u_sep, RO)) return; expand(n, S_DATA); *************** *** 60,65 **** --- 66,76 ---- si = stoc(ctos(((-sp) + ctob(1) - 1) / ctob(1))) - u.u_ssize; if (si <= 0) return (0); + /* Check resource limits */ + if (u.u_rlimit[RLIMIT_STACK].rlim_cur != RLIM_INFINITY && + (u.u_ssize + si) > btoc(u.u_rlimit[RLIMIT_STACK].rlim_cur)) + return 0; + if (estabur(u.u_tsize, u.u_dsize, u.u_ssize + si, u.u_sep, RO)) return (0); /* *** /usr/src/sys/h/ioctl_compat.h.old Thu Oct 23 20:37:24 1997 --- /usr/src/sys/h/ioctl_compat.h Tue Aug 14 19:33:58 2001 *************** *** 1,5 **** /* ! * @(#)ioctl_compat.h 1.0 (2.11BSD SMS) 1997/3/28 * * These are flags which have (finally) been removed from ioctl.h. Several * of these have lacked any kernel support for quite a long time. For others --- 1,5 ---- /* ! * @(#)ioctl_compat.h 1.1 (2.11BSD) 2001/8/14 * * These are flags which have (finally) been removed from ioctl.h. Several * of these have lacked any kernel support for quite a long time. For others *************** *** 39,45 **** #define BS1 0x0 #define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY) #define TILDE 0x0 /* (obsolete) place holder */ ! #define LTILDE ((int)TILDE>>16)) /* (obsolete) place holder */ ! #define L001000 0x0 #endif --- 39,44 ---- #define BS1 0x0 #define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY) #define TILDE 0x0 /* (obsolete) place holder */ ! #define LTILDE 0x0 /* (obsolete) place holder */ #define L001000 0x0 #endif *** /usr/src/sys/pdp/conf.c.old Wed Nov 12 20:29:41 1997 --- /usr/src/sys/pdp/conf.c Mon Aug 13 15:33:01 2001 *************** *** 45,51 **** #include "hk.h" #if NHK > 0 ! int hkopen(), hkstrategy(), hkroot(), hkclose(); daddr_t hksize(); #else #define hkopen nodev --- 45,51 ---- #include "hk.h" #if NHK > 0 ! int hkopen(), hkstrategy(), hkroot(), hkclose(), hkioctl(); daddr_t hksize(); #else #define hkopen nodev *************** *** 53,58 **** --- 53,59 ---- #define hkroot nulldev #define hkstrategy nodev #define hksize NULL + #define hkioctl nodev #endif #include "xp.h" *************** *** 411,417 **** drstrategy, /* hk = 13 */ hkopen, hkclose, rawrw, rawrw, ! nodev, nulldev, 0, seltrue, hkstrategy, /* ra = 14 */ raopen, raclose, rawrw, rawrw, --- 412,418 ---- drstrategy, /* hk = 13 */ hkopen, hkclose, rawrw, rawrw, ! hkioctl, nulldev, 0, seltrue, hkstrategy, /* ra = 14 */ raopen, raclose, rawrw, rawrw, *** /usr/src/sys/pdpstand/hk.c.old Fri Nov 7 20:04:14 1997 --- /usr/src/sys/pdpstand/hk.c Sat Aug 11 17:58:15 2001 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)hk.c 2.3 (2.11BSD) 1997/11/7 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)hk.c 2.3 (2.11BSD) 2001/8/11 */ /* *************** *** 101,107 **** { register struct hkdevice *hkaddr; int drvbit; - int unit, ctlr; drvbit = 1 << io->i_unit; --- 101,106 ---- *************** *** 108,125 **** if (genopen(NHK, io) < 0) return(-1); ! if ((hk_mntflg[ctlr] & drvbit) == 0) { ! hkaddr = HKcsr[ctlr]; ! hkaddr->hkcs2 = unit; hkaddr->hkcs1 = HK_SELECT|HK_GO; while ((hkaddr->hkcs1 & HK_CRDY) == 0) continue; if (hkaddr->hkcs1 & HK_CERR && hkaddr->hker & HKER_DTYE) ! hk_drvtyp[ctlr] |= drvbit; else ! hk_drvtyp[ctlr] &= ~drvbit; ! hk_mntflg[ctlr] |= drvbit; } if (devlabel(io, READLABEL) < 0) return(-1); --- 107,124 ---- if (genopen(NHK, io) < 0) return(-1); ! if ((hk_mntflg[io->i_ctlr] & drvbit) == 0) { ! hkaddr = HKcsr[io->i_ctlr]; ! hkaddr->hkcs2 = io->i_unit; hkaddr->hkcs1 = HK_SELECT|HK_GO; while ((hkaddr->hkcs1 & HK_CRDY) == 0) continue; if (hkaddr->hkcs1 & HK_CERR && hkaddr->hker & HKER_DTYE) ! hk_drvtyp[io->i_ctlr] |= drvbit; else ! hk_drvtyp[io->i_ctlr] &= ~drvbit; ! hk_mntflg[io->i_ctlr] |= drvbit; } if (devlabel(io, READLABEL) < 0) return(-1); *** /usr/src/sys/GENERIC/rl.h.old Mon Jun 17 20:03:58 1996 --- /usr/src/sys/GENERIC/rl.h Sat Aug 4 15:31:19 2001 *************** *** 1 **** ! #define NRL 2 --- 1 ---- ! #define NRL 4 *** /usr/src/bin/ld/ld.1.old Mon May 8 21:30:13 1995 --- /usr/src/bin/ld/ld.1 Tue Aug 14 19:35:26 2001 *************** *** 2,10 **** .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" ! .\" @(#)ld.1 6.4 (2.11BSD GTE) 1995/05/08 .\" ! .TH LD 1 "May 08, 1995" .UC 2 .SH NAME ld \- link editor (2BSD) --- 2,10 ---- .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" ! .\" @(#)ld.1 6.5 (2.11BSD) 2001/08/14 .\" ! .TH LD 1 "August 14, 2001" .UC 2 .SH NAME ld \- link editor (2BSD) *************** *** 277,283 **** \fB\-Z\fP ov1a.o ov1b.o ... \fB\-Z\fP ov2a.o ov2b.o ... ... ! \fB\-Y\fP base3.o ... \-lovc .fi .PP Assembly source code must be compiled using the assembler overlay flags: --- 277,283 ---- \fB\-Z\fP ov1a.o ov1b.o ... \fB\-Z\fP ov2a.o ov2b.o ... ... ! \fB\-Y\fP base3.o ... \-lc .fi .PP Assembly source code must be compiled using the assembler overlay flags: *** /usr/src/etc/printcap.old Fri Oct 25 21:22:43 1996 --- /usr/src/etc/printcap Sat Oct 13 17:51:02 2001 *************** *** 3,30 **** # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)etc.printcap 5.1.1 (2.11BSD) 1996/10/25 # # This is a sample of printcap entries used by various printers/plotters ! # # DecWriter over a tty line. ! lp|B300:\ ! :lp=/dev/ttyS5:\ ! :sd=/usr/spool/lpd:\ ! :lf=/usr/spool/lpd/errs:\ ! :af=/usr/spool/lpd/acct:\ ! :of=/usr/libexec/lpr/lpf:\ ! :if=/usr/libexec/lpr/lpf:\ ! :br#9600:xc#0:xs#040040:fc#077777:fs#06320:\ ! :pw#132:\ ! :pl#66 # :tr=\f:\ # Postscript printer, a HP4M with a Jetdirect 2552A installed. - ps0|HP4MX:sd=/usr/spool/lpr/ps0:rp=raw:rm=dogbert:lp=:sf:sh:mx#0:\ - :lf=/usr/adm/lpd-errs:\ - :af=/usr/spool/lpr/ps0/acct - # Text printer, a HP4m with a JetDirect 2552A installed. ! lz0|d630|HP4MX|Home:sd=/usr/spool/lpr/lz0:rp=text:rm=dogbert:if=if.laserjet --- 3,40 ---- # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)etc.printcap 5.1.2 (2.11BSD) 2001/10/13 # # This is a sample of printcap entries used by various printers/plotters ! ! # Standard text printer on the LP(V)11 interface. ! lp|Line Printer:\ ! :lp=/dev/lp0:\ ! :sd=/usr/spool/lpd:\ ! :lf=/usr/spool/lpd/errs:\ ! :af=/usr/spool/lpd/acct:\ ! :of=/usr/libexec/lpr/lpf:\ ! :if=/usr/libexec/lpr/lpf:\ ! :pw#132:\ ! :pl#66: ! # DecWriter over a tty line. ! #lp|B300:\ ! # :lp=/dev/ttyS5:\ ! # :sd=/usr/spool/lpd:\ ! # :lf=/usr/spool/lpd/errs:\ ! # :af=/usr/spool/lpd/acct:\ ! # :of=/usr/libexec/lpr/lpf:\ ! # :if=/usr/libexec/lpr/lpf:\ ! # :br#9600:xc#0:xs#040040:fc#077777:fs#06320:\ ! # :pw#132:\ ! # :pl#66 # :tr=\f:\ # Postscript printer, a HP4M with a Jetdirect 2552A installed. + #ps0|HP4MX:sd=/usr/spool/lpr/ps0:rp=raw:rm=dogbert:lp=:sf:sh:mx#0:\ + # :lf=/usr/adm/lpd-errs:\ + # :af=/usr/spool/lpr/ps0/acct # Text printer, a HP4m with a JetDirect 2552A installed. ! #lz0|d630|HP4MX|Home:sd=/usr/spool/lpr/lz0:rp=text:rm=dogbert:if=if.laserjet *** /usr/src/lib/cpp/cpp.c.old Thu Jul 11 16:46:18 1996 --- /usr/src/lib/cpp/cpp.c Sun Aug 26 09:36:03 2001 *************** *** 1,4 **** ! /* static char sccsid[] = "@(#)cpp.c 1.8.2 1996/7/11"; */ #ifdef FLEXNAMES #define NCPS 128 --- 1,4 ---- ! /* static char sccsid[] = "@(#)cpp.c 1.8.3 2001/8/26"; */ #ifdef FLEXNAMES #define NCPS 128 *************** *** 197,202 **** --- 197,203 ---- STATIC struct symtab *ifloc; STATIC struct symtab *elsloc; STATIC struct symtab *eifloc; + STATIC struct symtab *elfloc; STATIC struct symtab *ifdloc; STATIC struct symtab *ifnloc; STATIC struct symtab *ysysloc; *************** *** 206,211 **** --- 207,214 ---- STATIC struct symtab *uflloc; STATIC int trulvl; STATIC int flslvl; + STATIC int elflvl; + STATIC int elslvl; sayline(where) int where; *************** *** 748,760 **** if (flslvl) {if (--flslvl==0) sayline(CONT);} else if (trulvl) --trulvl; else pperror("If-less endif",0); } else if (np==elsloc) {/* else */ if (flslvl) { ! if (--flslvl!=0) ++flslvl; else {++trulvl; sayline(CONT);} } else if (trulvl) {++flslvl; --trulvl;} else pperror("If-less else",0); } else if (np==udfloc) {/* undefine */ if (flslvl==0) { ++flslvl; p=skipbl(p); slookup(inp,p,DROP); --flslvl; --- 751,780 ---- if (flslvl) {if (--flslvl==0) sayline(CONT);} else if (trulvl) --trulvl; else pperror("If-less endif",0); + if (flslvl==0) elflvl=0; + elslvl=0; + } else if (np==elfloc) {/* elif */ + if (flslvl == 0) elflvl = trulvl; + if (flslvl) { + if (elflvl > trulvl); + else if (--flslvl!=0) ++flslvl; + else { newp=p; + if (yyparse()) {++trulvl;sayline(CONT);} + else ++flslvl; + p=newp; + } + } else if (trulvl) {++flslvl; --trulvl;} + else pperror("If-less elif",0); } else if (np==elsloc) {/* else */ if (flslvl) { ! if (elflvl > trulvl); ! else if (--flslvl!=0) ++flslvl; else {++trulvl; sayline(CONT);} } else if (trulvl) {++flslvl; --trulvl;} else pperror("If-less else",0); + if (elslvl==trulvl+flslvl) pperror("Too many else", 0); + elslvl=trulvl+flslvl; } else if (np==udfloc) {/* undefine */ if (flslvl==0) { ++flslvl; p=skipbl(p); slookup(inp,p,DROP); --flslvl; *************** *** 1177,1182 **** --- 1197,1203 ---- udfloc=ppsym("undef"); incloc=ppsym("include"); elsloc=ppsym("else"); + elfloc=ppsym("elif"); eifloc=ppsym("endif"); ifdloc=ppsym("ifdef"); ifnloc=ppsym("ifndef"); *** /usr/src/lib/pcc/:yyfix.old Thu Jun 17 09:14:33 1982 --- /usr/src/lib/pcc/:yyfix Sun Aug 26 09:51:57 2001 *************** *** 1,3 **** --- 1,4 ---- + #!/bin/sh >rodata.c for i in $* do ed - y.tab.c <