CVS commit: src/sys/dev/pci
Module Name:src Committed By: skrll Date: Tue Feb 23 07:17:58 UTC 2021 Modified Files: src/sys/dev/pci: mpii.c Log Message: Whitespace (mostly trailing) To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/mpii.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/mpii.c diff -u src/sys/dev/pci/mpii.c:1.26 src/sys/dev/pci/mpii.c:1.27 --- src/sys/dev/pci/mpii.c:1.26 Tue Feb 23 07:15:30 2021 +++ src/sys/dev/pci/mpii.c Tue Feb 23 07:17:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mpii.c,v 1.26 2021/02/23 07:15:30 skrll Exp $ */ +/* $NetBSD: mpii.c,v 1.27 2021/02/23 07:17:58 skrll Exp $ */ /* $OpenBSD: mpii.c,v 1.115 2018/08/14 05:22:21 jmatthew Exp $ */ /* * Copyright (c) 2010, 2012 Mike Belopuhov @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.26 2021/02/23 07:15:30 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.27 2021/02/23 07:17:58 skrll Exp $"); #include "bio.h" @@ -46,7 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.2 #if NBIO > 0 #include -#include +#include #include #endif @@ -445,10 +445,10 @@ mpii_match(device_t parent, cfdata_t mat struct pci_attach_args *pa = aux; const struct mpii_pci_product *mpii; - for (mpii = mpii_devices; mpii->mpii_vendor != 0; mpii++) { - if (PCI_VENDOR(pa->pa_id) == mpii->mpii_vendor && - PCI_PRODUCT(pa->pa_id) == mpii->mpii_product) - return (1); + for (mpii = mpii_devices; mpii->mpii_vendor != 0; mpii++) { + if (PCI_VENDOR(pa->pa_id) == mpii->mpii_vendor && + PCI_PRODUCT(pa->pa_id) == mpii->mpii_product) + return (1); } return (0); } @@ -618,7 +618,7 @@ mpii_attach(device_t parent, device_t se memset(chan, 0, sizeof(*chan)); chan->chan_adapter = adapt; chan->chan_bustype = &scsi_sas_bustype; - chan->chan_channel = 0; + chan->chan_channel = 0; chan->chan_flags = 0; chan->chan_nluns = 8; chan->chan_ntargets = sc->sc_max_devices; @@ -719,7 +719,7 @@ mpii_detach(device_t self, int flags) } static int -mpii_rescan(device_t self, const char *ifattr, const int *locators) +mpii_rescan(device_t self, const char *ifattr, const int *locators) { struct mpii_softc *sc = device_private(self); @@ -737,11 +737,11 @@ mpii_childdetached(device_t self, device { struct mpii_softc *sc = device_private(self); - KASSERT(self == sc->sc_dev); + KASSERT(self == sc->sc_dev); KASSERT(child == sc->sc_child); - if (child == sc->sc_child) - sc->sc_child = NULL; + if (child == sc->sc_child) + sc->sc_child = NULL; } @@ -1884,7 +1884,7 @@ mpii_event_sas(struct mpii_softc *sc, st le16toh(pe->dev_handle), sc->sc_pd_id_start + tcl->start_phy_num + i, tcl->start_phy_num + i, le16toh(tcl->enclosure_handle), le16toh(tcl->expander_handle)); - + switch (pe->phy_status & MPII_EVENT_SAS_TOPO_PS_RC_MASK) { case MPII_EVENT_SAS_TOPO_PS_RC_ADDED: handle = le16toh(pe->dev_handle); @@ -1972,7 +1972,7 @@ mpii_event_sas_work(struct work *wq, voi le16toh(pe->dev_handle), sc->sc_pd_id_start + tcl->start_phy_num + i, tcl->start_phy_num + i, le16toh(tcl->enclosure_handle), le16toh(tcl->expander_handle)); - + switch (pe->phy_status & MPII_EVENT_SAS_TOPO_PS_RC_MASK) { case MPII_EVENT_SAS_TOPO_PS_RC_ADDED: /* already handled */ @@ -2955,18 +2955,18 @@ mpii_scsipi_request(struct scsipi_channe switch (req) { case ADAPTER_REQ_GROW_RESOURCES: - /* Not supported. */ + /* Not supported. */ return; case ADAPTER_REQ_SET_XFER_MODE: { struct scsipi_xfer_mode *xm = arg; xm->xm_mode = PERIPH_CAP_TQING; - xm->xm_period = 0; - xm->xm_offset = 0; + xm->xm_period = 0; + xm->xm_offset = 0; scsipi_async_event(&sc->sc_chan, ASYNC_EVENT_XFER_MODE, xm); return; } - case ADAPTER_REQ_RUN_XFER: + case ADAPTER_REQ_RUN_XFER: break; } @@ -3132,33 +3132,33 @@ static u_int8_t map_scsi_status(u_int8_t mpii_scsi_status) { u_int8_t scsi_status; - - switch (mpii_scsi_status) + + switch (mpii_scsi_status) { case MPII_SCSIIO_STATUS_GOOD: scsi_status = SCSI_OK; break; - + case MPII_SCSIIO_STATUS_CHECK_COND: scsi_status = SCSI_CHECK; break; - + case MPII_SCSIIO_STATUS_BUSY: scsi_status = SCSI_BUSY; break; - + case MPII_SCSIIO_STATUS_INTERMEDIATE: scsi_status = SCSI_INTERM; break; - + case MPII_SCSIIO_STATUS_INTERMEDIATE_CONDMET: scsi_status = SCSI_INTERM; break; - + case MPII_SCSIIO_STATUS_RESERVATION_CONFLICT: scsi_status = SCSI_RESV_CONFLICT; break; - + case MPII_SCSIIO_STATUS_CMD_TERM: case MPII_SCSIIO_STATUS_TASK_ABORTED: scsi_status = SCSI_TERMINATED; @@ -3203,11 +3203,11 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb) bus_dmamap_unload(sc->sc_dmat, dmap); } - + KASSERT(xs->error == XS_NOERROR); KASSERT(xs->resid == xs->datalen); KASSERT(xs->st
CVS commit: src/usr.bin/who
Module Name:src Committed By: wiz Date: Tue Feb 23 07:15:41 UTC 2021 Modified Files: src/usr.bin/who: who.1 Log Message: Fix Fl argument. >From Kouichi Hashikawa in PR 56009. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/who/who.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/who/who.1 diff -u src/usr.bin/who/who.1:1.25 src/usr.bin/who/who.1:1.26 --- src/usr.bin/who/who.1:1.25 Sun Sep 1 18:46:22 2019 +++ src/usr.bin/who/who.1 Tue Feb 23 07:15:41 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: who.1,v 1.25 2019/09/01 18:46:22 sevan Exp $ +.\" $NetBSD: who.1,v 1.26 2021/02/23 07:15:41 wiz Exp $ .\" .\" Copyright (c) 1986, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -52,7 +52,7 @@ Available options: .Bl -tag -width file .It Fl a Same as -.Fl -bdlprTtuv . +.Fl bdlprTtuv . .It Fl b Time of last system boot. .It Fl d
CVS commit: src/sys/dev/pci
Module Name:src Committed By: skrll Date: Tue Feb 23 07:15:30 UTC 2021 Modified Files: src/sys/dev/pci: mpii.c Log Message: Use the PCI_MAPREG_TYPE macro. No binary change. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/mpii.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/mpii.c diff -u src/sys/dev/pci/mpii.c:1.25 src/sys/dev/pci/mpii.c:1.26 --- src/sys/dev/pci/mpii.c:1.25 Sat Aug 8 19:39:28 2020 +++ src/sys/dev/pci/mpii.c Tue Feb 23 07:15:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mpii.c,v 1.25 2020/08/08 19:39:28 jnemeth Exp $ */ +/* $NetBSD: mpii.c,v 1.26 2021/02/23 07:15:30 skrll Exp $ */ /* $OpenBSD: mpii.c,v 1.115 2018/08/14 05:22:21 jmatthew Exp $ */ /* * Copyright (c) 2010, 2012 Mike Belopuhov @@ -20,7 +20,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.25 2020/08/08 19:39:28 jnemeth Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.26 2021/02/23 07:15:30 skrll Exp $"); #include "bio.h" @@ -479,7 +479,7 @@ mpii_attach(device_t parent, device_t se /* find the appropriate memory base */ for (r = PCI_MAPREG_START; r < PCI_MAPREG_END; r += sizeof(memtype)) { memtype = pci_mapreg_type(sc->sc_pc, sc->sc_tag, r); - if ((memtype & PCI_MAPREG_TYPE_MASK) == PCI_MAPREG_TYPE_MEM) + if (PCI_MAPREG_TYPE(memtype) == PCI_MAPREG_TYPE_MEM) break; } if (r >= PCI_MAPREG_END) {
CVS commit: src/sys
Module Name:src Committed By: mrg Date: Tue Feb 23 07:13:53 UTC 2021 Modified Files: src/sys/arch/aarch64/aarch64: db_machdep.c src/sys/arch/alpha/alpha: db_interface.c src/sys/arch/amd64/amd64: db_interface.c src/sys/arch/arm/arm32: db_machdep.c src/sys/arch/hppa/hppa: db_machdep.c src/sys/arch/i386/i386: db_interface.c src/sys/arch/ia64/ia64: db_interface.c src/sys/arch/mips/mips: db_interface.c src/sys/arch/powerpc/powerpc: db_interface.c src/sys/arch/sh3/sh3: db_interface.c src/sys/arch/sparc/sparc: db_interface.c db_machdep.c src/sys/arch/sparc64/sparc64: db_interface.c db_machdep.c src/sys/arch/sun3/sun3: db_machdep.c src/sys/arch/vax/vax: db_machdep.c src/sys/ddb: db_command.c db_command.h src/sys/dev/sbus: esp_sbus.c src/sys/dev/usb: usb.c src/sys/modules/examples/ddbping: ddbping.c Log Message: introduce DDB_END_CMD and replace more than 20 copies of the same list of NULLs and 0. idea from rillig@. all touched ports built, several booted. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/aarch64/db_machdep.c cvs rdiff -u -r1.35 -r1.36 src/sys/arch/alpha/alpha/db_interface.c cvs rdiff -u -r1.38 -r1.39 src/sys/arch/amd64/amd64/db_interface.c cvs rdiff -u -r1.38 -r1.39 src/sys/arch/arm/arm32/db_machdep.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hppa/hppa/db_machdep.c cvs rdiff -u -r1.85 -r1.86 src/sys/arch/i386/i386/db_interface.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/ia64/ia64/db_interface.c cvs rdiff -u -r1.91 -r1.92 src/sys/arch/mips/mips/db_interface.c cvs rdiff -u -r1.54 -r1.55 src/sys/arch/powerpc/powerpc/db_interface.c cvs rdiff -u -r1.65 -r1.66 src/sys/arch/sh3/sh3/db_interface.c cvs rdiff -u -r1.95 -r1.96 src/sys/arch/sparc/sparc/db_interface.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc/sparc/db_machdep.c cvs rdiff -u -r1.135 -r1.136 src/sys/arch/sparc64/sparc64/db_interface.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/sparc64/db_machdep.c cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sun3/sun3/db_machdep.c cvs rdiff -u -r1.58 -r1.59 src/sys/arch/vax/vax/db_machdep.c cvs rdiff -u -r1.175 -r1.176 src/sys/ddb/db_command.c cvs rdiff -u -r1.40 -r1.41 src/sys/ddb/db_command.h cvs rdiff -u -r1.55 -r1.56 src/sys/dev/sbus/esp_sbus.c cvs rdiff -u -r1.190 -r1.191 src/sys/dev/usb/usb.c cvs rdiff -u -r1.1 -r1.2 src/sys/modules/examples/ddbping/ddbping.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/aarch64/db_machdep.c diff -u src/sys/arch/aarch64/aarch64/db_machdep.c:1.33 src/sys/arch/aarch64/aarch64/db_machdep.c:1.34 --- src/sys/arch/aarch64/aarch64/db_machdep.c:1.33 Fri Feb 5 21:44:34 2021 +++ src/sys/arch/aarch64/aarch64/db_machdep.c Tue Feb 23 07:13:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.33 2021/02/05 21:44:34 joerg Exp $ */ +/* $NetBSD: db_machdep.c,v 1.34 2021/02/23 07:13:51 mrg Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.33 2021/02/05 21:44:34 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.34 2021/02/23 07:13:51 mrg Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd32.h" @@ -163,10 +163,8 @@ const struct db_command db_machine_comma }, #endif { - DDB_ADD_CMD(NULL, NULL, 0, - NULL, - NULL, NULL) - } + DDB_END_CMD + }, }; const struct db_variable db_regs[] = { Index: src/sys/arch/alpha/alpha/db_interface.c diff -u src/sys/arch/alpha/alpha/db_interface.c:1.35 src/sys/arch/alpha/alpha/db_interface.c:1.36 --- src/sys/arch/alpha/alpha/db_interface.c:1.35 Fri Sep 18 00:02:43 2020 +++ src/sys/arch/alpha/alpha/db_interface.c Tue Feb 23 07:13:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.35 2020/09/18 00:02:43 thorpej Exp $ */ +/* $NetBSD: db_interface.c,v 1.36 2021/02/23 07:13:51 mrg Exp $ */ /* * Mach Operating System @@ -52,7 +52,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.35 2020/09/18 00:02:43 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.36 2021/02/23 07:13:51 mrg Exp $"); #include #include @@ -95,7 +95,7 @@ const struct db_command db_machine_comma { DDB_ADD_CMD("cpu", db_mach_cpu, 0, "switch to another cpu", "cpu-no", NULL) }, #endif - { DDB_ADD_CMD(NULL, NULL, 0,NULL,NULL,NULL) }, + { DDB_END_CMD }, }; static int db_alpha_regop(const struct db_variable *, db_expr_t *, int); Index: src/sys/arch/amd64/amd64/db_interface.c diff -u src/sys/arch/amd64/amd64/db_interface.c:1.38 src/sys/arch/amd64/amd64/db_interface.c:1.39 --- src/sys/arch/amd64/amd64/db_interface.c:1.38 Tue Jul 14 00:45:52 2020 +++ src/sys/arch/amd64/amd64/db_interface.c Tue Feb 23 07:13:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.38 20
CVS commit: src/bin/ksh
Module Name:src Committed By: christos Date: Tue Feb 23 01:31:30 UTC 2021 Modified Files: src/bin/ksh: siglist.sh Log Message: PR/56007: Greg A. Woods: ksh unable to execute ERR traps (probably since 2016/03/17 - i.e. 8.x and 9.x) To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/siglist.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ksh/siglist.sh diff -u src/bin/ksh/siglist.sh:1.12 src/bin/ksh/siglist.sh:1.13 --- src/bin/ksh/siglist.sh:1.12 Thu Mar 17 09:59:02 2016 +++ src/bin/ksh/siglist.sh Mon Feb 22 20:31:30 2021 @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: siglist.sh,v 1.12 2016/03/17 13:59:02 christos Exp $ +# $NetBSD: siglist.sh,v 1.13 2021/02/23 01:31:30 christos Exp $ # # Script to generate a sorted, complete list of signals, suitable # for inclusion in trap.c as array initializer. @@ -21,16 +21,17 @@ CPP="${1-cc -E}" # The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap (trap $trapsigs; echo '#include "sh.h"'; - echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals" },'; + echo ' { QwErTy /* dummy for sed sillies */ },'; ${SED} -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\ { QwErTy .signal = SIG\1 , .name = "\1", .mess = "\2" },\ #endif/') > $in -# work around for gcc 5 +echo ' { QwErTy .signal = SIGNALS , .name = "DUMMY", .mess = "hook to expand array to total signals" },' >> $in +# work around for gcc > 5 $CPP $in | grep -v '^#' | tr -d '\n' | ${SED} 's/},/},\ /g' > $out ${SED} -n 's/{ QwErTy/{/p' < $out | ${AWK} '{print NR, $0}' | sort -k 5n -k 1n | -${SED} 's/^[0-9]* //' | -${AWK} 'BEGIN { last=0; nsigs=0; } +${SED} -E -e 's/^[0-9]* //' -e 's/ +/ /' | +${AWK} 'BEGIN { last=0; } { if ($4 ~ /^[0-9][0-9]*$/ && $5 == ",") { n = $4;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Feb 23 00:27:48 UTC 2021 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp Log Message: make: quote ':S' in error message about missing delimiter To generate a diff of this commit: cvs rdiff -u -r1.845 -r1.846 src/usr.bin/make/var.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/moderrs.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.845 src/usr.bin/make/var.c:1.846 --- src/usr.bin/make/var.c:1.845 Tue Feb 23 00:25:06 2021 +++ src/usr.bin/make/var.c Tue Feb 23 00:27:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.845 2021/02/23 00:25:06 rillig Exp $ */ +/* $NetBSD: var.c,v 1.846 2021/02/23 00:27:47 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.845 2021/02/23 00:25:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.846 2021/02/23 00:27:47 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -2801,7 +2801,7 @@ ApplyModifier_Subst(const char **pp, App char delim = (*pp)[1]; if (delim == '\0') { - Error("Missing delimiter for :S modifier"); + Error("Missing delimiter for modifier ':S'"); (*pp)++; return AMR_CLEANUP; } Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.24 src/usr.bin/make/unit-tests/moderrs.exp:1.25 --- src/usr.bin/make/unit-tests/moderrs.exp:1.24 Tue Feb 23 00:04:48 2021 +++ src/usr.bin/make/unit-tests/moderrs.exp Tue Feb 23 00:27:48 2021 @@ -57,7 +57,7 @@ make: Unfinished modifier for "!" ('!' m mod-subst-delimiter: -make: Missing delimiter for :S modifier +make: Missing delimiter for modifier ':S' 1: make: Unfinished modifier for "VAR" (',' missing) 2:
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Feb 23 00:25:06 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: extract ParseModifier_Match into separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.844 -r1.845 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.844 src/usr.bin/make/var.c:1.845 --- src/usr.bin/make/var.c:1.844 Tue Feb 23 00:15:22 2021 +++ src/usr.bin/make/var.c Tue Feb 23 00:25:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.844 2021/02/23 00:15:22 rillig Exp $ */ +/* $NetBSD: var.c,v 1.845 2021/02/23 00:25:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.844 2021/02/23 00:15:22 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.845 2021/02/23 00:25:06 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -2696,26 +2696,28 @@ ApplyModifier_Range(const char **pp, App return AMR_OK; } -/* :Mpattern or :Npattern */ -static ApplyModifierResult -ApplyModifier_Match(const char **pp, ApplyModifiersState *st) +/* Parse a ':M' or ':N' modifier. */ +static void +ParseModifier_Match(const char **pp, const ApplyModifiersState *st, + char **out_pattern) { - Expr *expr = st->expr; const char *mod = *pp; + Expr *expr = st->expr; Boolean copy = FALSE; /* pattern should be, or has been, copied */ Boolean needSubst = FALSE; const char *endpat; char *pattern; - ModifyWordProc modifyWord; /* * In the loop below, ignore ':' unless we are at (or back to) the * original brace level. * XXX: This will likely not work right if $() and ${} are intermixed. */ - /* XXX: This code is similar to the one in Var_Parse. + /* + * XXX: This code is similar to the one in Var_Parse. * See if the code can be merged. - * See also ApplyModifier_Defined. */ + * See also ApplyModifier_Defined. + */ int nest = 0; const char *p; for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 0); p++) { @@ -2769,6 +2771,19 @@ ApplyModifier_Match(const char **pp, App DEBUG3(VAR, "Pattern[%s] for [%s] is [%s]\n", expr->var->name.str, expr->value.str, pattern); + *out_pattern = pattern; +} + +/* :Mpattern or :Npattern */ +static ApplyModifierResult +ApplyModifier_Match(const char **pp, ApplyModifiersState *st) +{ + const char *mod = *pp; + char *pattern; + ModifyWordProc modifyWord; + + ParseModifier_Match(pp, st, &pattern); + modifyWord = mod[0] == 'M' ? ModifyWord_Match : ModifyWord_NoMatch; ModifyWords(st, modifyWord, pattern, st->oneBigWord); free(pattern);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Feb 23 00:15:22 UTC 2021 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-range.exp Log Message: make: add context information to error message about ':range' modifier To generate a diff of this commit: cvs rdiff -u -r1.843 -r1.844 src/usr.bin/make/var.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-range.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.843 src/usr.bin/make/var.c:1.844 --- src/usr.bin/make/var.c:1.843 Tue Feb 23 00:11:07 2021 +++ src/usr.bin/make/var.c Tue Feb 23 00:15:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.843 2021/02/23 00:11:07 rillig Exp $ */ +/* $NetBSD: var.c,v 1.844 2021/02/23 00:15:22 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.843 2021/02/23 00:11:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.844 2021/02/23 00:15:22 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -2666,7 +2666,8 @@ ApplyModifier_Range(const char **pp, App const char *p = mod + 6; if (!TryParseSize(&p, &n)) { Parse_Error(PARSE_FATAL, - "Invalid number: %s", mod + 6); + "Invalid number \"%s\" for ':range' modifier", + mod + 6); return AMR_CLEANUP; } *pp = p; Index: src/usr.bin/make/unit-tests/varmod-range.exp diff -u src/usr.bin/make/unit-tests/varmod-range.exp:1.7 src/usr.bin/make/unit-tests/varmod-range.exp:1.8 --- src/usr.bin/make/unit-tests/varmod-range.exp:1.7 Mon Dec 21 21:04:18 2020 +++ src/usr.bin/make/unit-tests/varmod-range.exp Tue Feb 23 00:15:22 2021 @@ -1,4 +1,4 @@ -make: "varmod-range.mk" line 53: Invalid number: x}Rest" != "Rest" +make: "varmod-range.mk" line 53: Invalid number "x}Rest" != "Rest"" for ':range' modifier make: "varmod-range.mk" line 53: Malformed conditional ("${:U:range=x}Rest" != "Rest") make: "varmod-range.mk" line 62: Unknown modifier 'x' make: "varmod-range.mk" line 62: Malformed conditional ("${:U:range=0x0}Rest" != "Rest")
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Feb 23 00:11:07 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: fix local variable name for parsing arguments The variable name 'arg' was misleading since after a successful TryParseTime, it would no longer point to the argument of the variable modifier, but to the _end_ of the argument. To reduce confusion, use p instead, like everywhere else. This name is less specific, which is still better than a wrong name. To generate a diff of this commit: cvs rdiff -u -r1.842 -r1.843 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.842 src/usr.bin/make/var.c:1.843 --- src/usr.bin/make/var.c:1.842 Tue Feb 23 00:04:48 2021 +++ src/usr.bin/make/var.c Tue Feb 23 00:11:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.842 2021/02/23 00:04:48 rillig Exp $ */ +/* $NetBSD: var.c,v 1.843 2021/02/23 00:11:07 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.842 2021/02/23 00:04:48 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.843 2021/02/23 00:11:07 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -2538,13 +2538,13 @@ ApplyModifier_Gmtime(const char **pp, Ap return AMR_UNKNOWN; if (mod[6] == '=') { - const char *arg = mod + 7; - if (!TryParseTime(&arg, &utc)) { + const char *p = mod + 7; + if (!TryParseTime(&p, &utc)) { Parse_Error(PARSE_FATAL, "Invalid time value: %s", mod + 7); return AMR_CLEANUP; } - *pp = arg; + *pp = p; } else { utc = 0; *pp = mod + 6; @@ -2565,13 +2565,13 @@ ApplyModifier_Localtime(const char **pp, return AMR_UNKNOWN; if (mod[9] == '=') { - const char *arg = mod + 10; - if (!TryParseTime(&arg, &utc)) { + const char *p = mod + 10; + if (!TryParseTime(&p, &utc)) { Parse_Error(PARSE_FATAL, "Invalid time value: %s", mod + 10); return AMR_CLEANUP; } - *pp = arg; + *pp = p; } else { utc = 0; *pp = mod + 9;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Feb 23 00:04:48 UTC 2021 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp varmod-assign.exp varmod-edge.exp varmod-edge.mk varmod-sysv.exp Log Message: make: add quotes around variable name in an error message To generate a diff of this commit: cvs rdiff -u -r1.841 -r1.842 src/usr.bin/make/var.c cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-assign.exp \ src/usr.bin/make/unit-tests/varmod-sysv.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-edge.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.841 src/usr.bin/make/var.c:1.842 --- src/usr.bin/make/var.c:1.841 Mon Feb 22 23:46:03 2021 +++ src/usr.bin/make/var.c Tue Feb 23 00:04:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.841 2021/02/22 23:46:03 rillig Exp $ */ +/* $NetBSD: var.c,v 1.842 2021/02/23 00:04:48 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.841 2021/02/22 23:46:03 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.842 2021/02/23 00:04:48 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -2234,7 +2234,7 @@ ParseModifierPartSubst( if (*p != delim) { *pp = p; - Error("Unfinished modifier for %s ('%c' missing)", + Error("Unfinished modifier for \"%s\" ('%c' missing)", st->expr->var->name.str, delim); *out_part = NULL; return VPR_ERR; Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.23 src/usr.bin/make/unit-tests/moderrs.exp:1.24 --- src/usr.bin/make/unit-tests/moderrs.exp:1.23 Sun Nov 1 14:36:25 2020 +++ src/usr.bin/make/unit-tests/moderrs.exp Tue Feb 23 00:04:48 2021 @@ -20,15 +20,15 @@ VAR:S,V,v,=Thevariable unfinished-indirect: want: Unfinished modifier for VAR (',' missing) -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) VAR:S,V,v= unfinished-loop: want: Unfinished modifier for UNDEF ('@' missing) -make: Unfinished modifier for UNDEF ('@' missing) +make: Unfinished modifier for "UNDEF" ('@' missing) want: Unfinished modifier for UNDEF ('@' missing) -make: Unfinished modifier for UNDEF ('@' missing) +make: Unfinished modifier for "UNDEF" ('@' missing) 1 2 3 @@ -39,10 +39,10 @@ make: Unclosed variable specification (e words: want: Unfinished modifier for UNDEF (']' missing) -make: Unfinished modifier for UNDEF (']' missing) +make: Unfinished modifier for "UNDEF" (']' missing) want: Unfinished modifier for UNDEF (']' missing) -make: Unfinished modifier for UNDEF (']' missing) +make: Unfinished modifier for "UNDEF" (']' missing) 13= make: Bad modifier `:[123451234512345123451234512345]' for UNDEF @@ -50,22 +50,22 @@ make: Bad modifier `:[123451234512345123 exclam: want: Unfinished modifier for VARNAME ('!' missing) -make: Unfinished modifier for VARNAME ('!' missing) +make: Unfinished modifier for "VARNAME" ('!' missing) want: Unfinished modifier for ! ('!' missing) -make: Unfinished modifier for ! ('!' missing) +make: Unfinished modifier for "!" ('!' missing) mod-subst-delimiter: make: Missing delimiter for :S modifier 1: -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) 2: -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) 3: -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) 4: -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) 5: make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier S 6: TheVariable @@ -74,13 +74,13 @@ make: Unclosed variable specification (e mod-regex-delimiter: make: Missing delimiter for :C modifier 1: -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) 2: -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) 3: -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) 4: -make: Unfinished modifier for VAR (',' missing) +make: Unfinished modifier for "VAR" (',' missing) 5: make: Unclosed variable specification (expecting '}') for "VAR" (value "TheVariable") modifier C 6: TheVariable @@ -114,13 +114,13 @@ make: Bad modifier `:t' for FIB M*} mod-ifelse-parse: -make: Unfinished modifier for FIB (':' missing) +make: Unfinished modifier for "FIB" (':' missing) -make: Unfinished modifier for FIB (':'
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Mon Feb 22 23:59:43 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk Log Message: make: add test for confusing double space in error message To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-edge.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/varmod-edge.exp diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.10 src/usr.bin/make/unit-tests/varmod-edge.exp:1.11 --- src/usr.bin/make/unit-tests/varmod-edge.exp:1.10 Sun Dec 20 19:47:34 2020 +++ src/usr.bin/make/unit-tests/varmod-edge.exp Mon Feb 22 23:59:43 2021 @@ -18,6 +18,10 @@ make: "varmod-edge.mk" line 166: ok colo make: "varmod-edge.mk" line 165: Unknown modifier ':' make: "varmod-edge.mk" line 165: Unknown modifier ':' make: "varmod-edge.mk" line 166: ok colons +make: "varmod-edge.mk" line 175: Unknown modifier 'Z' +make: "varmod-edge.mk" line 175: Malformed conditional (${:Z}) +make: Unfinished modifier for (',' missing) +make: "varmod-edge.mk" line 184: Malformed conditional (${:S,}) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-edge.mk diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.13 src/usr.bin/make/unit-tests/varmod-edge.mk:1.14 --- src/usr.bin/make/unit-tests/varmod-edge.mk:1.13 Sat Oct 24 08:46:08 2020 +++ src/usr.bin/make/unit-tests/varmod-edge.mk Mon Feb 22 23:59:43 2021 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-edge.mk,v 1.13 2020/10/24 08:46:08 rillig Exp $ +# $NetBSD: varmod-edge.mk,v 1.14 2021/02/22 23:59:43 rillig Exp $ # # Tests for edge cases in variable modifiers. # @@ -169,5 +169,23 @@ EXP.colons= # empty . endif .endfor +# Even in expressions based on an unnamed variable, there may be errors. +# XXX: The error message should mention the variable name of the expression, +# even though that name is empty in this case. +.if ${:Z} +. error +.else +. error +.endif + +# Even in expressions based on an unnamed variable, there may be errors. +# XXX: The error message should not contain two spaces in a row. +# XXX: The error message should report the filename:lineno. +.if ${:S,} +. error +.else +. error +.endif + all: @echo ok
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 23:46:03 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: reorder code in ModifyWords No functional change. To generate a diff of this commit: cvs rdiff -u -r1.840 -r1.841 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.840 src/usr.bin/make/var.c:1.841 --- src/usr.bin/make/var.c:1.840 Mon Feb 22 23:42:29 2021 +++ src/usr.bin/make/var.c Mon Feb 22 23:46:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.840 2021/02/22 23:42:29 rillig Exp $ */ +/* $NetBSD: var.c,v 1.841 2021/02/22 23:46:03 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.840 2021/02/22 23:42:29 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.841 2021/02/22 23:46:03 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -2376,13 +2376,12 @@ ModifyWords(ApplyModifiersState *st, goto done; } - SepBuf_Init(&result, st->sep); - words = Str_Words(val, FALSE); DEBUG2(VAR, "ModifyWords: split \"%s\" into %u words\n", val, (unsigned)words.len); + SepBuf_Init(&result, st->sep); for (i = 0; i < words.len; i++) { modifyWord(words.words[i], &result, modifyWord_args); if (result.buf.len > 0)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 23:42:29 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: use more common parameter order for VarSelectWords No functional change. To generate a diff of this commit: cvs rdiff -u -r1.839 -r1.840 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.839 src/usr.bin/make/var.c:1.840 --- src/usr.bin/make/var.c:1.839 Mon Feb 22 23:39:24 2021 +++ src/usr.bin/make/var.c Mon Feb 22 23:42:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.839 2021/02/22 23:39:24 rillig Exp $ */ +/* $NetBSD: var.c,v 1.840 2021/02/22 23:42:29 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.839 2021/02/22 23:39:24 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.840 2021/02/22 23:42:29 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -1737,8 +1737,8 @@ ModifyWord_Loop(const char *word, SepBuf * It can also reverse the words. */ static char * -VarSelectWords(char sep, Boolean oneBigWord, const char *str, int first, - int last) +VarSelectWords(const char *str, int first, int last, + char sep, Boolean oneBigWord) { Words words; int len, start, end, step; @@ -3150,8 +3150,8 @@ ApplyModifier_Words(const char **pp, App /* Normal case: select the words described by first and last. */ Expr_SetValueOwn(expr, - VarSelectWords(st->sep, st->oneBigWord, expr->value.str, - first, last)); + VarSelectWords(expr->value.str, first, last, + st->sep, st->oneBigWord)); ok: free(estr);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 23:39:24 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: make ModifyWord_Subst a little easier to understand Addition is easier than subtraction, and the expression 'word + wordLen' obviously means 'the end of the word', which was not as easy to spot before. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.838 -r1.839 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.838 src/usr.bin/make/var.c:1.839 --- src/usr.bin/make/var.c:1.838 Mon Feb 22 23:21:33 2021 +++ src/usr.bin/make/var.c Mon Feb 22 23:39:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.838 2021/02/22 23:21:33 rillig Exp $ */ +/* $NetBSD: var.c,v 1.839 2021/02/22 23:39:24 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.838 2021/02/22 23:21:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.839 2021/02/22 23:39:24 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -1541,13 +1541,13 @@ ModifyWord_Subst(const char *word, SepBu memcmp(word, args->lhs, args->lhsLen) != 0) goto nosub; - if ((args->pflags.anchorEnd) && wordLen != args->lhsLen) + if (args->pflags.anchorEnd && wordLen != args->lhsLen) goto nosub; /* :S,^prefix,replacement, or :S,^whole$,replacement, */ SepBuf_AddBytes(buf, args->rhs, args->rhsLen); - SepBuf_AddBytes(buf, word + args->lhsLen, - wordLen - args->lhsLen); + SepBuf_AddBytesBetween(buf, + word + args->lhsLen, word + wordLen); args->matched = TRUE; return; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 23:21:33 UTC 2021 Modified Files: src/usr.bin/make: cond.c meta.c parse.c var.c Log Message: make: remove freestanding freeIt variables These variables all belong to a string variable. Connect them using FStr, which reduces the number of variables to keep track of. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.256 -r1.257 src/usr.bin/make/cond.c cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/meta.c cvs rdiff -u -r1.549 -r1.550 src/usr.bin/make/parse.c cvs rdiff -u -r1.837 -r1.838 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.256 src/usr.bin/make/cond.c:1.257 --- src/usr.bin/make/cond.c:1.256 Fri Feb 5 05:15:12 2021 +++ src/usr.bin/make/cond.c Mon Feb 22 23:21:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.256 2021/02/05 05:15:12 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.257 2021/02/22 23:21:33 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.256 2021/02/05 05:15:12 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.257 2021/02/22 23:21:33 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -440,7 +440,7 @@ CondParser_StringExpr(CondParser *par, c } /* * XXX: Can there be any situation in which a returned - * var_Error requires freeIt? + * var_Error needs to be freed? */ FStr_Done(inout_str); /* @@ -473,7 +473,6 @@ CondParser_StringExpr(CondParser *par, c * Results: * Returns the string, absent any quotes, or NULL on error. * Sets out_quoted if the string was quoted. - * Sets out_freeIt. */ static void CondParser_String(CondParser *par, Boolean doEval, Boolean strictLHS, Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.177 src/usr.bin/make/meta.c:1.178 --- src/usr.bin/make/meta.c:1.177 Fri Feb 5 19:19:17 2021 +++ src/usr.bin/make/meta.c Mon Feb 22 23:21:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.177 2021/02/05 19:19:17 sjg Exp $ */ +/* $NetBSD: meta.c,v 1.178 2021/02/22 23:21:33 rillig Exp $ */ /* * Implement 'meta' mode. @@ -373,17 +373,19 @@ any_is_submake(GNode *gn) } static void -printCMD(const char *cmd, FILE *fp, GNode *gn) +printCMD(const char *ucmd, FILE *fp, GNode *gn) { -char *cmd_freeIt = NULL; +FStr xcmd = FStr_InitRefer(ucmd); -if (strchr(cmd, '$') != NULL) { - (void)Var_Subst(cmd, gn, VARE_WANTRES, &cmd_freeIt); +if (strchr(ucmd, '$') != NULL) { + char *expanded; + (void)Var_Subst(ucmd, gn, VARE_WANTRES, &expanded); /* TODO: handle errors */ - cmd = cmd_freeIt; + xcmd = FStr_InitOwn(expanded); } -fprintf(fp, "CMD %s\n", cmd); -free(cmd_freeIt); + +fprintf(fp, "CMD %s\n", xcmd.str); +FStr_Done(&xcmd); } static void Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.549 src/usr.bin/make/parse.c:1.550 --- src/usr.bin/make/parse.c:1.549 Fri Feb 5 05:46:27 2021 +++ src/usr.bin/make/parse.c Mon Feb 22 23:21:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.549 2021/02/05 05:46:27 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.550 2021/02/22 23:21:33 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.549 2021/02/05 05:46:27 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.550 2021/02/22 23:21:33 rillig Exp $"); /* types and constants */ @@ -2266,25 +2266,24 @@ ParseDoInclude(char *directive) static void SetFilenameVars(const char *filename, const char *dirvar, const char *filevar) { - const char *slash, *dirname, *basename; - void *freeIt; + const char *slash, *basename; + FStr dirname; slash = strrchr(filename, '/'); if (slash == NULL) { - dirname = curdir; + dirname = FStr_InitRefer(curdir); basename = filename; - freeIt = NULL; } else { - dirname = freeIt = bmake_strsedup(filename, slash); + dirname = FStr_InitOwn(bmake_strsedup(filename, slash)); basename = slash + 1; } - Global_SetExpand(dirvar, dirname); + Global_SetExpand(dirvar, dirname.str); Global_SetExpand(filevar, basename); DEBUG5(PARSE, "%s: ${%s} = `%s' ${%s} = `%s'\n", - __func__, dirvar, dirname, filevar, basename); - free(freeIt); + __func__, dirvar, dirname.str, filevar, basename); + FStr_Done(&dirname); } /* Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.837 src/usr.bin/make/var.c:1.838 --- src/usr.bin/make/var.c:1.837 Mon Feb 22 22:55:43 2021 +++ src/usr.bin/make/var.c Mon Feb 22 23:21:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.837 2021/02/22 22:55:43 rillig Exp $ */ +/* $NetBSD: var.c,v 1.838 2021/02/22 23:21:3
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 22:55:43 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: remove boolean parameter and return type from VarFreeEnv There was only a single case where this parameter was false. Inline that case. That was the only case that needed the return value, so remove that as well. To generate a diff of this commit: cvs rdiff -u -r1.836 -r1.837 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.836 src/usr.bin/make/var.c:1.837 --- src/usr.bin/make/var.c:1.836 Mon Feb 22 22:34:04 2021 +++ src/usr.bin/make/var.c Mon Feb 22 22:55:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.836 2021/02/22 22:34:04 rillig Exp $ */ +/* $NetBSD: var.c,v 1.837 2021/02/22 22:55:43 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.836 2021/02/22 22:34:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.837 2021/02/22 22:55:43 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -462,28 +462,21 @@ VarFind(const char *name, GNode *scope, } /* - * If the variable is an environment variable, free it. - * - * Input: - * v the variable - * freeValue true if the variable value should be freed as well + * If the variable is an environment variable, free it, including its value. * * Results: - * TRUE if it is an environment variable, FALSE otherwise. + * TRUE if it was an environment variable, + * FALSE if it is still a regular variable. */ -static Boolean -VarFreeEnv(Var *v, Boolean freeValue) +static void +VarFreeEnv(Var *v) { if (!(v->flags & VFL_FROM_ENV)) - return FALSE; + return; FStr_Done(&v->name); - if (freeValue) - Buf_Done(&v->val); - else - Buf_DoneData(&v->val); + Buf_Done(&v->val); free(v); - return TRUE; } /* Add a new variable of the given name and value to the given scope. */ @@ -952,7 +945,7 @@ ExistsInCmdline(const char *name, const return TRUE; } - VarFreeEnv(v, TRUE); + VarFreeEnv(v); return FALSE; } @@ -1031,7 +1024,7 @@ Var_SetWithFlags(GNode *scope, const cha save_dollars = ParseBoolean(val, save_dollars); if (v != NULL) - VarFreeEnv(v, TRUE); + VarFreeEnv(v); } /* See Var_Set for documentation. */ @@ -1204,7 +1197,7 @@ Var_Exists(GNode *scope, const char *nam if (v == NULL) return FALSE; - (void)VarFreeEnv(v, TRUE); + VarFreeEnv(v); return TRUE; } @@ -1255,10 +1248,14 @@ Var_Value(GNode *scope, const char *name if (v == NULL) return FStr_InitRefer(NULL); - value = v->val.data; - return VarFreeEnv(v, FALSE) - ? FStr_InitOwn(value) - : FStr_InitRefer(value); + if (!(v->flags & VFL_FROM_ENV)) + return FStr_InitRefer(v->val.data); + + /* Since environment variables are short-lived, free it now. */ + FStr_Done(&v->name); + value = Buf_DoneData(&v->val); + free(v); + return FStr_InitOwn(value); } /* @@ -3322,7 +3319,7 @@ ok: if (gv == NULL) scope = SCOPE_GLOBAL; else - VarFreeEnv(gv, TRUE); + VarFreeEnv(gv); } switch (op[0]) {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 22:34:04 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: add a few open questions to Var_SetWithFlags To generate a diff of this commit: cvs rdiff -u -r1.835 -r1.836 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.835 src/usr.bin/make/var.c:1.836 --- src/usr.bin/make/var.c:1.835 Mon Feb 22 22:26:50 2021 +++ src/usr.bin/make/var.c Mon Feb 22 22:34:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.835 2021/02/22 22:26:50 rillig Exp $ */ +/* $NetBSD: var.c,v 1.836 2021/02/22 22:34:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.835 2021/02/22 22:26:50 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.836 2021/02/22 22:34:04 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -1020,6 +1020,9 @@ Var_SetWithFlags(GNode *scope, const cha */ if (!opts.varNoExportEnv) setenv(name, val, 1); + /* XXX: What about .MAKE.EXPORTED? */ + /* XXX: Why not just mark the variable for needing export, + * as in ExportVarPlain? */ Global_Append(MAKEOVERRIDES, name); }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 22:26:50 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: do not expand variable name from the command line twice in a row When 1. there is a global variable containing a dollar in its expanded name (very unlikely since there are lots of undocumented edge cases that make variable names containing dollar signs fragile), and 2. after that (unlikely since that requires .MAKEFLAGS instead of a normal command line) 3. there is a command line variable of the same name (again very unlikely since that variable name would contain a dollar sign as well in the expanded form), the global variable would not be undefined as promised by the comments since its name was expanded once more than intended. Because of the two 'very unlikely' above, this edge case hopefully does not affect any practical use cases. Note that this is not about VAR.${param} (which has a dollar sign in its unexpanded form), but about the case where param itself would expand to a dollar sign, such as after param=$$. To generate a diff of this commit: cvs rdiff -u -r1.834 -r1.835 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.834 src/usr.bin/make/var.c:1.835 --- src/usr.bin/make/var.c:1.834 Mon Feb 22 21:43:57 2021 +++ src/usr.bin/make/var.c Mon Feb 22 22:26:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.834 2021/02/22 21:43:57 rillig Exp $ */ +/* $NetBSD: var.c,v 1.835 2021/02/22 22:26:50 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.834 2021/02/22 21:43:57 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.835 2021/02/22 22:26:50 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -985,10 +985,9 @@ Var_SetWithFlags(GNode *scope, const cha * added to SCOPE_GLOBAL, so delete it from there if * needed. Otherwise -V name may show the wrong value. * - * See 'scope == SCOPE_GLOBAL' above. + * See ExistsInCmdline. */ - /* XXX: name is expanded for the second time */ - Var_DeleteExpand(SCOPE_GLOBAL, name); + Var_Delete(SCOPE_GLOBAL, name); } v = VarAdd(name, val, scope, flags); } else {
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Mon Feb 22 22:04:28 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: var-class-cmdline.exp var-class-cmdline.mk Log Message: make: add test for cmdline variables overriding global variables To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-class-cmdline.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-class-cmdline.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/var-class-cmdline.exp diff -u src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.1 src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.2 --- src/usr.bin/make/unit-tests/var-class-cmdline.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/var-class-cmdline.exp Mon Feb 22 22:04:28 2021 @@ -1 +1,4 @@ +make: "var-class-cmdline.mk" line 23: global +make: "var-class-cmdline.mk" line 30: makeflags +makeflags exit status 0 Index: src/usr.bin/make/unit-tests/var-class-cmdline.mk diff -u src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.2 src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.3 --- src/usr.bin/make/unit-tests/var-class-cmdline.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/var-class-cmdline.mk Mon Feb 22 22:04:28 2021 @@ -1,8 +1,34 @@ -# $NetBSD: var-class-cmdline.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: var-class-cmdline.mk,v 1.3 2021/02/22 22:04:28 rillig Exp $ # # Tests for variables specified on the command line. +# +# Variables that are specified on the command line override those from the +# global scope. +# +# For performance reasons, variable lookup often starts in the global scope +# since that is where most practically used variables are stored. But even +# in these cases, variables from the command line scope must override the +# global variables. Therefore, whenever a global variable is tried to be +# set, it is ignored when there is already a variable of the same name in +# the cmdline scope. In the same vein, when a cmdline variable is set and +# there is already a variable of the same name in the global scope, that +# global variable is deleted first. +# +# Most cmdline variables are set at the very beginning, when parsing the +# command line arguments. Using the special target '.MAKEFLAGS', it is +# possible to set cmdline variables at any later time. + +# A normal global variable, without any cmdline variable nearby. +VAR= global +.info ${VAR} -# TODO: Implementation +# The global variable is "overridden" by simply deleting it and then +# installing the cmdline variable instead. Since there is no way to +# undefine a cmdline variable, there is no need to remember the old value +# of the global variable could become visible again. +.MAKEFLAGS: VAR=makeflags +.info ${VAR} -all: - @:; +# If Var_SetWithFlags should ever forget to delete the global variable, +# the below line would print "global" instead of the current "makeflags". +.MAKEFLAGS: -V VAR
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 21:43:57 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: extract ExistsInCmdline from Var_SetWithFlags No functional change. To generate a diff of this commit: cvs rdiff -u -r1.833 -r1.834 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.833 src/usr.bin/make/var.c:1.834 --- src/usr.bin/make/var.c:1.833 Mon Feb 22 21:30:33 2021 +++ src/usr.bin/make/var.c Mon Feb 22 21:43:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.833 2021/02/22 21:30:33 rillig Exp $ */ +/* $NetBSD: var.c,v 1.834 2021/02/22 21:43:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.833 2021/02/22 21:30:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.834 2021/02/22 21:43:57 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -930,6 +930,32 @@ Var_UnExport(Boolean isEnv, const char * FStr_Done(&varnames); } +/* + * When there is a variable of the same name in the command line scope, the + * global variable would not be visible anywhere. Therefore there is no + * point in setting it at all. + * + * See 'scope == SCOPE_CMDLINE' in Var_SetWithFlags. + */ +static Boolean +ExistsInCmdline(const char *name, const char *val) +{ + Var *v; + + v = VarFind(name, SCOPE_CMDLINE, FALSE); + if (v == NULL) + return FALSE; + + if (v->flags & VFL_FROM_CMD) { + DEBUG3(VAR, "%s:%s = %s ignored!\n", + SCOPE_GLOBAL->name, name, val); + return TRUE; + } + + VarFreeEnv(v, TRUE); + return FALSE; +} + /* Set the variable to the value; the name is not expanded. */ void Var_SetWithFlags(GNode *scope, const char *name, const char *val, @@ -943,25 +969,8 @@ Var_SetWithFlags(GNode *scope, const cha return; } - if (scope == SCOPE_GLOBAL) { - v = VarFind(name, SCOPE_CMDLINE, FALSE); - if (v != NULL) { - /* - * When there is a variable of the same name in the - * command line scope, the global variable would not - * be visible anywhere. Therefore there is no point - * in setting it at all. - * - * See 'scope == SCOPE_CMDLINE' below. - */ - if (v->flags & VFL_FROM_CMD) { -DEBUG3(VAR, "%s:%s = %s ignored!\n", -scope->name, name, val); -return; - } - VarFreeEnv(v, TRUE); - } - } + if (scope == SCOPE_GLOBAL && ExistsInCmdline(name, val)) + return; /* * Only look for a variable in the given scope since anything set
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 21:30:33 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: save a hash map lookup when defining a cmdline variable This is a preparation to extract the code for exporting a cmdline variable. That code differs in several details from the other code in ExportVar. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.832 -r1.833 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.832 src/usr.bin/make/var.c:1.833 --- src/usr.bin/make/var.c:1.832 Mon Feb 22 21:14:15 2021 +++ src/usr.bin/make/var.c Mon Feb 22 21:30:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.832 2021/02/22 21:14:15 rillig Exp $ */ +/* $NetBSD: var.c,v 1.833 2021/02/22 21:30:33 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.832 2021/02/22 21:14:15 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.833 2021/02/22 21:30:33 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -487,7 +487,7 @@ VarFreeEnv(Var *v, Boolean freeValue) } /* Add a new variable of the given name and value to the given scope. */ -static void +static Var * VarAdd(const char *name, const char *value, GNode *scope, VarSetFlags flags) { HashEntry *he = HashTable_CreateEntry(&scope->vars, name, NULL); @@ -495,6 +495,7 @@ VarAdd(const char *name, const char *val flags & VAR_SET_READONLY ? VFL_READONLY : VFL_NONE); HashEntry_Set(he, v); DEBUG3(VAR, "%s:%s = %s\n", scope->name, name, value); + return v; } /* @@ -980,7 +981,7 @@ Var_SetWithFlags(GNode *scope, const cha /* XXX: name is expanded for the second time */ Var_DeleteExpand(SCOPE_GLOBAL, name); } - VarAdd(name, val, scope, flags); + v = VarAdd(name, val, scope, flags); } else { if ((v->flags & VFL_READONLY) && !(flags & VAR_SET_READONLY)) { DEBUG3(VAR, "%s:%s = %s ignored (read-only)\n", @@ -994,15 +995,13 @@ Var_SetWithFlags(GNode *scope, const cha if (v->flags & VFL_EXPORTED) ExportVar(name, VEM_PLAIN); } + /* * Any variables given on the command line are automatically exported - * to the environment (as per POSIX standard) - * Other than internals. + * to the environment (as per POSIX standard), except for internals. */ if (scope == SCOPE_CMDLINE && !(flags & VAR_SET_NO_EXPORT) && name[0] != '.') { - if (v == NULL) - v = VarFind(name, scope, FALSE); /* we just added it */ v->flags |= VFL_FROM_CMD; /* @@ -1016,6 +1015,7 @@ Var_SetWithFlags(GNode *scope, const cha Global_Append(MAKEOVERRIDES, name); } + if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0) save_dollars = ParseBoolean(val, save_dollars);
CVS commit: src/sys/arch/arm/pic
Module Name:src Committed By: jmcneill Date: Mon Feb 22 21:16:25 UTC 2021 Modified Files: src/sys/arch/arm/pic: pic_splfuncs.c Log Message: Make the splx fast path smaller. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/pic/pic_splfuncs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/pic/pic_splfuncs.c diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.17 src/sys/arch/arm/pic/pic_splfuncs.c:1.18 --- src/sys/arch/arm/pic/pic_splfuncs.c:1.17 Sun Feb 21 17:07:45 2021 +++ src/sys/arch/arm/pic/pic_splfuncs.c Mon Feb 22 21:16:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pic_splfuncs.c,v 1.17 2021/02/21 17:07:45 jmcneill Exp $ */ +/* $NetBSD: pic_splfuncs.c,v 1.18 2021/02/22 21:16:25 jmcneill Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -28,7 +28,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.17 2021/02/21 17:07:45 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.18 2021/02/22 21:16:25 jmcneill Exp $"); #define _INTR_PRIVATE #include @@ -46,23 +46,34 @@ __KERNEL_RCSID(0, "$NetBSD: pic_splfuncs #include +#if defined(__HAVE_CPU_DOSOFTINTS_CI) +#define CPU_DOSOFTINTS(ci) cpu_dosoftints_ci((ci)) +#else +#define CPU_DOSOFTINTS(ci) cpu_dosoftints() +#endif + +#if defined(__HAVE_PIC_PENDING_INTRS) +static void splx_dopendingints(struct cpu_info *, const int); +#endif + int _splraise(int newipl) { struct cpu_info * const ci = curcpu(); const int oldipl = ci->ci_cpl; - KASSERT(newipl < NIPL); + KDASSERT(newipl < NIPL); if (newipl > ci->ci_cpl) { pic_set_priority(ci, newipl); } return oldipl; } + int _spllower(int newipl) { struct cpu_info * const ci = curcpu(); const int oldipl = ci->ci_cpl; - KASSERT(panicstr || newipl <= ci->ci_cpl); + KDASSERT(panicstr || newipl <= ci->ci_cpl); if (newipl < ci->ci_cpl) { register_t psw = cpsid(I32_bit); ci->ci_intr_depth++; @@ -79,17 +90,29 @@ void splx(int savedipl) { struct cpu_info * const ci = curcpu(); - KASSERT(savedipl < NIPL); + KDASSERT(savedipl < NIPL); if (__predict_false(savedipl == ci->ci_cpl)) { return; } #if defined(__HAVE_PIC_PENDING_INTRS) - if (__predict_true(ci->ci_pending_ipls == 0)) { - goto skip_pending; + if (__predict_false(ci->ci_pending_ipls != 0)) { + splx_dopendingints(ci, savedipl); } +#endif + + pic_set_priority(ci, savedipl); + CPU_DOSOFTINTS(ci); + KDASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d", + ci->ci_cpl, savedipl); +} + +#if defined(__HAVE_PIC_PENDING_INTRS) +static void __noinline +splx_dopendingints(struct cpu_info *ci, const int savedipl) +{ const register_t psw = cpsid(I32_bit); ci->ci_intr_depth++; while ((ci->ci_pending_ipls & ~__BIT(savedipl)) > __BIT(savedipl)) { @@ -110,16 +133,5 @@ splx(int savedipl) if ((psw & I32_bit) == 0) { cpsie(I32_bit); } -skip_pending: -#endif - - pic_set_priority(ci, savedipl); -#if defined(__HAVE_CPU_DOSOFTINTS_CI) - cpu_dosoftints_ci(ci); -#else - cpu_dosoftints(); -#endif - - KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d", - ci->ci_cpl, savedipl); } +#endif
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 21:14:15 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: document interaction between cmdline and global variables Make prevents global variables from being or becoming visible when a command line variable of the same name is already defined. There is a double safety net here. Even if the call to Var_DeleteExpand were removed, there would be no noticeable effect, other than one less line in the debug log. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.831 -r1.832 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.831 src/usr.bin/make/var.c:1.832 --- src/usr.bin/make/var.c:1.831 Tue Feb 16 19:46:15 2021 +++ src/usr.bin/make/var.c Mon Feb 22 21:14:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.831 2021/02/16 19:46:15 rillig Exp $ */ +/* $NetBSD: var.c,v 1.832 2021/02/22 21:14:15 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.831 2021/02/16 19:46:15 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.832 2021/02/22 21:14:15 rillig Exp $"); typedef enum VarFlags { VFL_NONE = 0, @@ -945,6 +945,14 @@ Var_SetWithFlags(GNode *scope, const cha if (scope == SCOPE_GLOBAL) { v = VarFind(name, SCOPE_CMDLINE, FALSE); if (v != NULL) { + /* + * When there is a variable of the same name in the + * command line scope, the global variable would not + * be visible anywhere. Therefore there is no point + * in setting it at all. + * + * See 'scope == SCOPE_CMDLINE' below. + */ if (v->flags & VFL_FROM_CMD) { DEBUG3(VAR, "%s:%s = %s ignored!\n", scope->name, name, val); @@ -966,6 +974,8 @@ Var_SetWithFlags(GNode *scope, const cha * This var would normally prevent the same name being * added to SCOPE_GLOBAL, so delete it from there if * needed. Otherwise -V name may show the wrong value. + * + * See 'scope == SCOPE_GLOBAL' above. */ /* XXX: name is expanded for the second time */ Var_DeleteExpand(SCOPE_GLOBAL, name);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 20:45:46 UTC 2021 Modified Files: src/usr.bin/make: Makefile Log Message: make: fix report-coverage On NetBSD 8.0 it still worked. Maybe gcov doesn't support .c files as arguments anymore. Using the .gcda files works and is more reliable anyway since it covers the inline functions in the headers as well. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/usr.bin/make/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/Makefile diff -u src/usr.bin/make/Makefile:1.112 src/usr.bin/make/Makefile:1.113 --- src/usr.bin/make/Makefile:1.112 Sat Jan 30 16:05:45 2021 +++ src/usr.bin/make/Makefile Mon Feb 22 20:45:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.112 2021/01/30 16:05:45 rillig Exp $ +# $NetBSD: Makefile,v 1.113 2021/02/22 20:45:46 rillig Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 PROG= make @@ -202,7 +202,7 @@ test-coverage: .PHONY report-coverage: .PHONY @echo 'covered uncovered file' - @${GCOV} ${GCOV_OPTS} ${SRCS} 2>&1 \ + @${GCOV} ${GCOV_OPTS} *.gcda 2>&1 \ | perl -ne ${GCOV_PERL:Q} \ | sort -nr @sed -i 's,^\([^:]*\): *[0-9]*:,\1: ,' *.gcov
CVS commit: src/sys/dev/usb
Module Name:src Committed By: mrg Date: Mon Feb 22 20:45:29 UTC 2021 Modified Files: src/sys/dev/usb: usb.c Log Message: fix formatting and db_usb_command_table[] static. idea from rillig@. To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.190 src/sys/dev/usb/usb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb.c diff -u src/sys/dev/usb/usb.c:1.189 src/sys/dev/usb/usb.c:1.190 --- src/sys/dev/usb/usb.c:1.189 Sun Feb 21 23:06:39 2021 +++ src/sys/dev/usb/usb.c Mon Feb 22 20:45:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: usb.c,v 1.189 2021/02/21 23:06:39 mrg Exp $ */ +/* $NetBSD: usb.c,v 1.190 2021/02/22 20:45:28 mrg Exp $ */ /* * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.189 2021/02/21 23:06:39 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.190 2021/02/22 20:45:28 mrg Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -341,7 +341,7 @@ db_usb_xfer(db_expr_t addr, bool have_ad { struct usbd_xfer *xfer = (struct usbd_xfer *)addr; - if (!have_addr){ + if (!have_addr) { db_printf("%s: need usbd_xfer address\n", __func__); return; } @@ -363,7 +363,7 @@ db_usb_xferlist(db_expr_t addr, bool hav struct usbd_pipe *pipe = (struct usbd_pipe *)addr; struct usbd_xfer *xfer; - if (!have_addr){ + if (!have_addr) { db_printf("%s: need usbd_pipe address\n", __func__); return; } @@ -374,7 +374,7 @@ db_usb_xferlist(db_expr_t addr, bool hav } } -const struct db_command db_usb_command_table[] = { +static const struct db_command db_usb_command_table[] = { { DDB_ADD_CMD("usbxfer", db_usb_xfer, 0, "display a USB xfer structure", NULL, NULL) },
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Feb 22 20:38:55 UTC 2021 Modified Files: src/usr.bin/make: targ.c src/usr.bin/make/unit-tests: cond-func-empty.mk varparse-dynamic.mk Log Message: make: update constant names in comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.165 -r1.166 src/usr.bin/make/targ.c cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varparse-dynamic.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/targ.c diff -u src/usr.bin/make/targ.c:1.165 src/usr.bin/make/targ.c:1.166 --- src/usr.bin/make/targ.c:1.165 Thu Feb 4 21:42:46 2021 +++ src/usr.bin/make/targ.c Mon Feb 22 20:38:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: targ.c,v 1.165 2021/02/04 21:42:46 rillig Exp $ */ +/* $NetBSD: targ.c,v 1.166 2021/02/22 20:38:55 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -113,7 +113,7 @@ #include "dir.h" /* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: targ.c,v 1.165 2021/02/04 21:42:46 rillig Exp $"); +MAKE_RCSID("$NetBSD: targ.c,v 1.166 2021/02/22 20:38:55 rillig Exp $"); /* * All target nodes that appeared on the left-hand side of one of the @@ -246,7 +246,7 @@ GNode_Free(void *gnp) * SCOPE_GLOBAL), it should be safe to free the variables as well, * since each node manages the memory for all its variables itself. * - * XXX: The GNodes that are only used as variable scopes (VAR_CMD, + * XXX: The GNodes that are only used as variable scopes (SCOPE_CMD, * SCOPE_GLOBAL, SCOPE_INTERNAL) are not freed at all (see Var_End, * where they are not mentioned). These might be freed at all, if * their variable values are indeed not used anywhere else (see Index: src/usr.bin/make/unit-tests/cond-func-empty.mk diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.11 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.12 --- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.11 Sat Nov 28 14:08:37 2020 +++ src/usr.bin/make/unit-tests/cond-func-empty.mk Mon Feb 22 20:38:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-empty.mk,v 1.11 2020/11/28 14:08:37 rillig Exp $ +# $NetBSD: cond-func-empty.mk,v 1.12 2021/02/22 20:38:55 rillig Exp $ # # Tests for the empty() function in .if conditions, which tests a variable # expression for emptiness. @@ -42,7 +42,7 @@ WORD= word .endif # The :U modifier modifies expressions based on undefined variables -# (VAR_JUNK) by adding the VAR_KEEP flag, which marks the expression +# (DEF_UNDEF) by adding the DEF_DEFINED flag, which marks the expression # as "being interesting enough to be further processed". # .if empty(UNDEF:S,^$,value,W:Ufallback) Index: src/usr.bin/make/unit-tests/varparse-dynamic.mk diff -u src/usr.bin/make/unit-tests/varparse-dynamic.mk:1.4 src/usr.bin/make/unit-tests/varparse-dynamic.mk:1.5 --- src/usr.bin/make/unit-tests/varparse-dynamic.mk:1.4 Thu Feb 4 21:42:47 2021 +++ src/usr.bin/make/unit-tests/varparse-dynamic.mk Mon Feb 22 20:38:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: varparse-dynamic.mk,v 1.4 2021/02/04 21:42:47 rillig Exp $ +# $NetBSD: varparse-dynamic.mk,v 1.5 2021/02/22 20:38:55 rillig Exp $ # Before 2020-07-27, there was an off-by-one error in Var_Parse that skipped # the last character in the variable name. @@ -15,8 +15,8 @@ # expression is returned as the variable value, hoping that it can be # resolved at a later point. # -# This test covers the code in Var_Parse that deals with VAR_JUNK but not -# VAR_KEEP for dynamic variables. +# This test covers the code in Var_Parse that deals with DEF_UNDEF but not +# DEF_DEFINED for dynamic variables. .if ${.TARGET:S,^,,} != "\${.TARGET:S,^,,}" . error .endif
CVS commit: src/games/cgram
Module Name:src Committed By: rillig Date: Mon Feb 22 19:34:07 UTC 2021 Modified Files: src/games/cgram: cgram.c Log Message: cgram: fix assertion when substituting at the end of the longest line Reported by Weitian LI via GitHub. Contrary to the patch suggested in [1], still allow the cursor to be placed to the very right of the text in a line since that is the usual behavior of text editors. Split the function substitute() into two parts: one that handles the curses-specific part of checking whether a substitution is possible at the current cursor position, and one that performs the actual substitution. Only the latter is kept in the code section for the string manipulation functions, the other is moved to the section for curses code. Having all the curses code in one place reduces the places that call beep(). Previously, as well as now, there is a single beep per invalid key before, but that was not obvious from the previous code. [1]: https://github.com/DragonFlyBSD/DragonFlyBSD/commit/18d09f18cf4c To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/games/cgram/cgram.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/cgram/cgram.c diff -u src/games/cgram/cgram.c:1.13 src/games/cgram/cgram.c:1.14 --- src/games/cgram/cgram.c:1.13 Mon Feb 22 17:36:42 2021 +++ src/games/cgram/cgram.c Mon Feb 22 19:34:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cgram.c,v 1.13 2021/02/22 17:36:42 rillig Exp $ */ +/* $NetBSD: cgram.c,v 1.14 2021/02/22 19:34:07 rillig Exp $ */ /*- * Copyright (c) 2013, 2021 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.c,v 1.13 2021/02/22 17:36:42 rillig Exp $"); +__RCSID("$NetBSD: cgram.c,v 1.14 2021/02/22 19:34:07 rillig Exp $"); #endif #include @@ -279,40 +279,26 @@ encode(void) } } -static bool -substitute(char ch) +static void +substitute(char a, char b) { - assert(cursor_x >= 0 && cursor_x < extent_x); - assert(cursor_y >= 0 && cursor_y < extent_y); - if (cursor_x >= cur_max_x()) { - beep(); - return false; - } - - char och = char_at_cursor(); - if (!ch_isalpha(och)) { - beep(); - return false; - } - - char loch = ch_tolower(och); - char uoch = ch_toupper(och); - char lch = ch_tolower(ch); - char uch = ch_toupper(ch); + char la = ch_tolower(a); + char ua = ch_toupper(a); + char lb = ch_tolower(b); + char ub = ch_toupper(b); for (int y = 0; y < (int)lines.num; y++) { for (char *p = lines.v[y].s; *p != '\0'; p++) { - if (*p == loch) -*p = lch; - else if (*p == uoch) -*p = uch; - else if (*p == lch) -*p = loch; - else if (*p == uch) -*p = uoch; + if (*p == la) +*p = lb; + else if (*p == ua) +*p = ub; + else if (*p == lb) +*p = la; + else if (*p == ub) +*p = ua; } } - return true; } static bool @@ -457,19 +443,24 @@ go_to_next_word(void) go_right(); } +static bool +can_substitute_here(int ch) +{ + return isascii(ch) && + ch_isalpha((char)ch) && + cursor_x < cur_max_x() && + ch_isalpha(char_at_cursor()); +} + static void handle_char_input(int ch) { - if (isascii(ch) && ch_isalpha((char)ch)) { - if (substitute((char)ch)) { - if (cursor_x < cur_max_x()) -cursor_x++; - if (cursor_x == cur_max_x()) -go_to_next_line(); - } - } else if (ch == char_at_cursor()) + if (ch == char_at_cursor()) + go_right(); + else if (can_substitute_here(ch)) { + substitute(char_at_cursor(), (char)ch); go_right(); - else + } else beep(); }
CVS commit: src/games/cgram
Module Name:src Committed By: rillig Date: Mon Feb 22 17:36:42 UTC 2021 Modified Files: src/games/cgram: cgram.c Log Message: cgram: add advanced cursor movement with tab, shift+tab, return To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/games/cgram/cgram.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/cgram/cgram.c diff -u src/games/cgram/cgram.c:1.12 src/games/cgram/cgram.c:1.13 --- src/games/cgram/cgram.c:1.12 Mon Feb 22 16:28:20 2021 +++ src/games/cgram/cgram.c Mon Feb 22 17:36:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cgram.c,v 1.12 2021/02/22 16:28:20 rillig Exp $ */ +/* $NetBSD: cgram.c,v 1.13 2021/02/22 17:36:42 rillig Exp $ */ /*- * Copyright (c) 2013, 2021 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.c,v 1.12 2021/02/22 16:28:20 rillig Exp $"); +__RCSID("$NetBSD: cgram.c,v 1.13 2021/02/22 17:36:42 rillig Exp $"); #endif #include @@ -73,6 +73,12 @@ ch_islower(char ch) } static bool +ch_isspace(char ch) +{ + return isspace((unsigned char)ch) != 0; +} + +static bool ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; @@ -193,6 +199,23 @@ cur_max_y(void) return extent_y - 1; } +static char +char_left_of_cursor(void) +{ + if (cursor_x > 0) + return lines.v[cursor_y].s[cursor_x - 1]; + assert(cursor_y > 0); + return '\n'; /* eol of previous line */ +} + +static char +char_at_cursor(void) +{ + if (cursor_x == cur_max_x()) + return '\n'; + return lines.v[cursor_y].s[cursor_x]; +} + static void readquote(void) { @@ -266,7 +289,7 @@ substitute(char ch) return false; } - char och = lines.v[cursor_y].s[cursor_x]; + char och = char_at_cursor(); if (!ch_isalpha(och)) { beep(); return false; @@ -292,8 +315,6 @@ substitute(char ch) return true; } - - static bool is_solved(void) { @@ -303,6 +324,8 @@ is_solved(void) return true; } + + static void redraw(void) { @@ -342,21 +365,6 @@ redraw(void) refresh(); } -static void -opencurses(void) -{ - initscr(); - cbreak(); - noecho(); - keypad(stdscr, true); -} - -static void -closecurses(void) -{ - endwin(); -} - static void @@ -383,6 +391,72 @@ scroll_into_view(void) offset_y = cursor_y - (LINES - 2); } +static bool +can_go_left(void) +{ + return cursor_y > 0 || + (cursor_y == 0 && cursor_x > 0); +} + +static bool +can_go_right(void) +{ + return cursor_y < cur_max_y() || + (cursor_y == cur_max_y() && cursor_x < cur_max_x()); +} + +static void +go_to_prev_line(void) +{ + cursor_y--; + cursor_x = cur_max_x(); +} + +static void +go_to_next_line(void) +{ + cursor_x = 0; + cursor_y++; +} + +static void +go_left(void) +{ + if (cursor_x > 0) + cursor_x--; + else if (cursor_y > 0) + go_to_prev_line(); +} + +static void +go_right(void) +{ + if (cursor_x < cur_max_x()) + cursor_x++; + else if (cursor_y < cur_max_y()) + go_to_next_line(); +} + +static void +go_to_prev_word(void) +{ + while (can_go_left() && ch_isspace(char_left_of_cursor())) + go_left(); + + while (can_go_left() && !ch_isspace(char_left_of_cursor())) + go_left(); +} + +static void +go_to_next_word(void) +{ + while (can_go_right() && !ch_isspace(char_at_cursor())) + go_right(); + + while (can_go_right() && ch_isspace(char_at_cursor())) + go_right(); +} + static void handle_char_input(int ch) { @@ -390,23 +464,13 @@ handle_char_input(int ch) if (substitute((char)ch)) { if (cursor_x < cur_max_x()) cursor_x++; - if (cursor_x == cur_max_x() && - cursor_y < cur_max_y()) { -cursor_x = 0; -cursor_y++; - } - } - } else if (cursor_x < cur_max_x() && - ch == lines.v[cursor_y].s[cursor_x]) { - cursor_x++; - if (cursor_x == cur_max_x() && - cursor_y < cur_max_y()) { - cursor_x = 0; - cursor_y++; + if (cursor_x == cur_max_x()) +go_to_next_line(); } - } else { + } else if (ch == char_at_cursor()) + go_right(); + else beep(); - } } static bool @@ -421,12 +485,7 @@ handle_key(void) break; case 2: /* ^B */ case KEY_LEFT: - if (cursor_x > 0) { - cursor_x--; - } else if (cursor_y > 0) { - cursor_y--; - cursor_x = cur_max_x(); - } + go_left(); break; case 5: /* ^E */ case KEY_END: @@ -434,12 +493,16 @@ handle_key(void) break; case 6: /* ^F */ case KEY_RIGHT: - if (cursor_x < cur_max_x()) { - cursor_x++; - } else if (cursor_y < cur_max_y()) { - cursor_y++; - cursor_x = 0; - } + go_right(); + break; + case '\t': + go_to_next_word(); + break; + case KEY_BTAB: + go_to_prev_word(); + break; + case '\n': + go_to_next_line(); break; case 12: /* ^L */ clear(); @@ -478,7 +541,11 @@ init(void) srandom((unsigned int)time(NUL
CVS commit: src/games/cgram
Module Name:src Committed By: rillig Date: Mon Feb 22 16:28:20 UTC 2021 Modified Files: src/games/cgram: cgram.c Log Message: cgram: properly handle input errors On both NetBSD and Cygwin, a missing /usr/bin/fortune would previously continue since popen does not return an error (as /bin/sh is found and can be executed), so the next chance to catch an error is pclose. At that point, the shell has already printed an informative error message about what happened (or what didn't happen), so that cgram does not need to print an error by itself. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/games/cgram/cgram.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/cgram/cgram.c diff -u src/games/cgram/cgram.c:1.11 src/games/cgram/cgram.c:1.12 --- src/games/cgram/cgram.c:1.11 Sun Feb 21 22:21:56 2021 +++ src/games/cgram/cgram.c Mon Feb 22 16:28:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cgram.c,v 1.11 2021/02/21 22:21:56 rillig Exp $ */ +/* $NetBSD: cgram.c,v 1.12 2021/02/22 16:28:20 rillig Exp $ */ /*- * Copyright (c) 2013, 2021 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.c,v 1.11 2021/02/21 22:21:56 rillig Exp $"); +__RCSID("$NetBSD: cgram.c,v 1.12 2021/02/22 16:28:20 rillig Exp $"); #endif #include @@ -227,7 +227,8 @@ readquote(void) for (int i = 0; i < extent_y; i++) extent_x = imax(extent_x, (int)lines.v[i].len); - pclose(f); + if (pclose(f) != 0) + exit(1); /* error message must come from child process */ } static void
CVS commit: src
Module Name:src Committed By: rillig Date: Mon Feb 22 15:09:50 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_init.exp d_struct_init_nested.exp msg_175.c msg_175.exp msg_185.c msg_186.c msg_186.exp msg_210.c msg_210.exp msg_221.c msg_221.exp msg_238.c msg_277.c src/usr.bin/xlint/lint1: decl.c err.c func.c init.c lex.c lint1.h tree.c src/usr.bin/xlint/lint2: chk.c emit2.c Log Message: lint: change spelling of initialisation to initialization That's the wording from the ISO C99 standard. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_c99_init.exp \ src/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_175.c \ src/tests/usr.bin/xlint/lint1/msg_175.exp \ src/tests/usr.bin/xlint/lint1/msg_185.c \ src/tests/usr.bin/xlint/lint1/msg_186.exp \ src/tests/usr.bin/xlint/lint1/msg_221.exp \ src/tests/usr.bin/xlint/lint1/msg_238.c \ src/tests/usr.bin/xlint/lint1/msg_277.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_186.c \ src/tests/usr.bin/xlint/lint1/msg_210.c \ src/tests/usr.bin/xlint/lint1/msg_210.exp \ src/tests/usr.bin/xlint/lint1/msg_221.c cvs rdiff -u -r1.137 -r1.138 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.72 -r1.73 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.65 -r1.66 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.217 -r1.218 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/lint2/emit2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/xlint/lint1/d_c99_init.exp diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.4 src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.5 --- src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.4 Sun Feb 21 13:10:57 2021 +++ src/tests/usr.bin/xlint/lint1/d_c99_init.exp Mon Feb 22 15:09:50 2021 @@ -1,3 +1,3 @@ d_c99_init.c(22): invalid initializer type int [176] d_c99_init.c(23): too many initializers [174] -d_c99_init.c(49): initialisation type mismatch (pointer to const void) and (struct any) [185] +d_c99_init.c(49): initialization type mismatch (pointer to const void) and (struct any) [185] Index: src/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp diff -u src/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp:1.4 src/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp:1.5 --- src/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp:1.4 Sun Feb 21 10:28:33 2021 +++ src/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp Mon Feb 22 15:09:50 2021 @@ -1,4 +1,4 @@ -d_struct_init_nested.c(35): initialisation type mismatch (enum I1) and (struct Inner1) [185] +d_struct_init_nested.c(35): initialization type mismatch (enum I1) and (struct Inner1) [185] d_struct_init_nested.c(37): too many struct/union initializers [172] -d_struct_init_nested.c(62): initialisation type mismatch (enum I1) and (struct Inner2) [185] -d_struct_init_nested.c(64): warning: enum type mismatch between 'enum I2' and 'enum O3' in initialisation [210] +d_struct_init_nested.c(62): initialization type mismatch (enum I1) and (struct Inner2) [185] +d_struct_init_nested.c(64): warning: enum type mismatch between 'enum I2' and 'enum O3' in initialization [210] Index: src/tests/usr.bin/xlint/lint1/msg_175.c diff -u src/tests/usr.bin/xlint/lint1/msg_175.c:1.2 src/tests/usr.bin/xlint/lint1/msg_175.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_175.c:1.2 Sun Jan 24 16:12:45 2021 +++ src/tests/usr.bin/xlint/lint1/msg_175.c Mon Feb 22 15:09:50 2021 @@ -1,7 +1,7 @@ -/* $NetBSD: msg_175.c,v 1.2 2021/01/24 16:12:45 rillig Exp $ */ +/* $NetBSD: msg_175.c,v 1.3 2021/02/22 15:09:50 rillig Exp $ */ # 3 "msg_175.c" -// Test for message: initialisation of an incomplete type [175] +// Test for message: initialization of an incomplete type [175] struct incomplete; /* expect: 233 */ Index: src/tests/usr.bin/xlint/lint1/msg_175.exp diff -u src/tests/usr.bin/xlint/lint1/msg_175.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_175.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_175.exp:1.2 Sun Jan 24 16:12:45 2021 +++ src/tests/usr.bin/xlint/lint1/msg_175.exp Mon Feb 22 15:09:50 2021 @@ -1,3 +1,3 @@ -msg_175.c(8): initialisation of an incomplete type [175] +msg_175.c(8): initialization of an incomplete type [175] msg_175.c(10): incomplete structure or union incomplete: incomplete [31] msg_175.c(6): warning: struct incomplete never defined [233] Index: src/tests/usr.bin/xlint/lint1/msg_185.c diff -u src/tests/usr.bin/xlint/lint1/msg_185.c:1.2 src/tests/usr.bin/xlint/lint1/msg_185.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_185.c:1
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Feb 22 15:01:03 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: init.c tree.c Log Message: lint: improve debug message and comment To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.216 -r1.217 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.87 src/usr.bin/xlint/lint1/init.c:1.88 --- src/usr.bin/xlint/lint1/init.c:1.87 Sun Feb 21 15:02:16 2021 +++ src/usr.bin/xlint/lint1/init.c Mon Feb 22 15:01:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.87 2021/02/21 15:02:16 rillig Exp $ */ +/* $NetBSD: init.c,v 1.88 2021/02/22 15:01:03 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: init.c,v 1.87 2021/02/21 15:02:16 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.88 2021/02/22 15:01:03 rillig Exp $"); #endif #include @@ -491,7 +491,7 @@ initstack_push(void) again: istk = initstk; - debug_step("typename %s", type_name(istk->i_type)); + debug_step("expecting type '%s'", type_name(istk->i_type)); switch (istk->i_type->t_tspec) { case ARRAY: if (namedmem != NULL) { Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.216 src/usr.bin/xlint/lint1/tree.c:1.217 --- src/usr.bin/xlint/lint1/tree.c:1.216 Sun Feb 21 15:02:16 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Feb 22 15:01:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.216 2021/02/21 15:02:16 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.217 2021/02/22 15:01:03 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.216 2021/02/21 15:02:16 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.217 2021/02/22 15:01:03 rillig Exp $"); #endif #include @@ -3732,8 +3732,8 @@ is_constcond_false(const tnode_t *tn, ts * functions called by build(). These tests must be done here because * we need some information about the context in which the operations * are performed. - * After all tests are performed, expr() frees the memory which is used - * for the expression. + * After all tests are performed and dofreeblk is true, expr() frees the + * memory which is used for the expression. */ void expr(tnode_t *tn, bool vctx, bool tctx, bool dofreeblk, bool constcond_zero_ok)
CVS commit: src/usr.sbin/intrctl
Module Name:src Committed By: jmcneill Date: Mon Feb 22 11:38:13 UTC 2021 Modified Files: src/usr.sbin/intrctl: intrctl.8 Log Message: Adjust description of compact list view output. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/intrctl/intrctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/intrctl/intrctl.8 diff -u src/usr.sbin/intrctl/intrctl.8:1.7 src/usr.sbin/intrctl/intrctl.8:1.8 --- src/usr.sbin/intrctl/intrctl.8:1.7 Tue Sep 24 11:31:06 2019 +++ src/usr.sbin/intrctl/intrctl.8 Mon Feb 22 11:38:13 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: intrctl.8,v 1.7 2019/09/24 11:31:06 wiz Exp $ +.\" $NetBSD: intrctl.8,v 1.8 2021/02/22 11:38:13 jmcneill Exp $ .\" .\" Copyright (c) 2015 Internet Initiative Japan Inc. .\" All rights reserved. @@ -24,7 +24,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 23, 2019 +.Dd February 22, 2021 .Dt INTRCTL 8 .Os .Sh NAME @@ -63,7 +63,7 @@ The intrid is an interrupt name such as If .Fl c is specified, display compact list with total counts per interrupt, -and CPU affinity as comma separated list of CPU indexes. +and CPU affinity as list of CPU indexes. .Pp If .Fl w
CVS commit: src/usr.sbin/intrctl
Module Name:src Committed By: jmcneill Date: Mon Feb 22 11:33:34 UTC 2021 Modified Files: src/usr.sbin/intrctl: intrctl.c Log Message: In compact view, show the CPUs as a range (0-n) instead of a list (0, 1, 2, ...) when the interrupt is assigned to all CPUs in the system. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/intrctl/intrctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/intrctl/intrctl.c diff -u src/usr.sbin/intrctl/intrctl.c:1.11 src/usr.sbin/intrctl/intrctl.c:1.12 --- src/usr.sbin/intrctl/intrctl.c:1.11 Tue Sep 24 11:31:06 2019 +++ src/usr.sbin/intrctl/intrctl.c Mon Feb 22 11:33:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: intrctl.c,v 1.11 2019/09/24 11:31:06 wiz Exp $ */ +/* $NetBSD: intrctl.c,v 1.12 2021/02/22 11:33:34 jmcneill Exp $ */ /* * Copyright (c) 2015 Internet Initiative Japan Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: intrctl.c,v 1.11 2019/09/24 11:31:06 wiz Exp $"); +__RCSID("$NetBSD: intrctl.c,v 1.12 2021/02/22 11:33:34 jmcneill Exp $"); #include #include @@ -110,6 +110,22 @@ usage(void) static int intrctl_io_alloc_retry_count = 4; +static bool +intrctl_list_line_allcpus(struct intrio_list_line *illine, int ncpus) +{ + struct intrio_list_line_cpu *illc; + int i; + + for (i = 0; i < ncpus; i++) { + illc = &illine->ill_cpu[i]; + if (illc->illc_assigned == false) { + return false; + } + } + + return true; +} + static void intrctl_list_one(bool compact, bool skipzero) { @@ -187,14 +203,20 @@ intrctl_list_one(bool compact, bool skip printf("%-*s ", (int)intridlen, illine->ill_intrid); if (compact) { uint64_t total = 0; + bool allcpus = ncpus > 1 && + intrctl_list_line_allcpus(illine, ncpus); char *affinity = NULL, *oaffinity = NULL; for (i = 0; i < ncpus; i++) { illc = &illine->ill_cpu[i]; total += illc->illc_count; +if (allcpus && i != 0 && i != ncpus - 1) { + continue; +} if (illc->illc_assigned) { + const char *sep = allcpus ? "-" : ", "; asprintf(&affinity, "%s%s%d", oaffinity ? oaffinity : "", - oaffinity ? ", " : "", + oaffinity ? sep : "", i); if (oaffinity) free(oaffinity);
CVS commit: src/sys/arch/sparc64/doc
Module Name:src Committed By: palle Date: Mon Feb 22 10:30:57 UTC 2021 Modified Files: src/sys/arch/sparc64/doc: TODO Log Message: sun4v: update current status of sun4v To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sparc64/doc/TODO Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/doc/TODO diff -u src/sys/arch/sparc64/doc/TODO:1.33 src/sys/arch/sparc64/doc/TODO:1.34 --- src/sys/arch/sparc64/doc/TODO:1.33 Sun Feb 14 20:30:31 2021 +++ src/sys/arch/sparc64/doc/TODO Mon Feb 22 10:30:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: TODO,v 1.33 2021/02/14 20:30:31 palle Exp $ */ +/* $NetBSD: TODO,v 1.34 2021/02/22 10:30:57 palle Exp $ */ Things to be done: @@ -11,23 +11,14 @@ sun4u: - GENERIC.UP kernel hangs on v445 (missing interrupt?) sun4v: - - current status (verified on T5 ldom with 2 VCPU and 4GB): - The kernel boots and starts userland. - During the execution of the sysinst process, a sub-process crashes. - The crash happens when a call to sysctl from /bin/sh causes a mmu trap. - Part of the TRAP_SETUP() call in sun4v_datatrap issues a 'save' instruction. - Since %cansave is 0 (%canrestore is 6 and %otherwin is 0) a SPILL trap is generated. - The current code ends up in the pcbspill codepath (which is based on code from openbsd). - This code assumes that it is the register window in the OTHERWIN window that must be spilled - to the pcb. - Since %otherwin in this scenario actually is zero, we end up putting incorrect register - window values to the pcb. - So - this code should not save data to the pcb when %otherwin is 0 - it should spill the - values to the stack of the user process. Special care should be taken here, since we - may end up with a mmu fault again if the stack address is not present in the mmu, so - perhaps spilling to the physical address of the stack will work. - Time will show if this is correct... - Status on T2000 ldom with 8 VCPU and 4GB is that is crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) + - current status + T5 ldom with 2 VCPU and 4GB: + The kernel boots and starts userland when booting miniroot.fs. + The sysinst tool starts properly and requests terminal type. + Upon entering characters on the console, a crash occurs inside + OpenBoot (properly trashed registers). + T2000 ldom with 8 VCPU and 4GB: + On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero) - 64-bit kernel support - 32-bit kernel support - libkvm
CVS commit: src/sys/arch/sparc64/sparc64
Module Name:src Committed By: palle Date: Mon Feb 22 09:56:42 UTC 2021 Modified Files: src/sys/arch/sparc64/sparc64: locore.s Log Message: sun4v: handle spill normal user traps properly when current trap level is 1 - registers are spilled to the PA of the stack to avoid further mmu-related traps, since sun4v only has 2 trap levels To generate a diff of this commit: cvs rdiff -u -r1.424 -r1.425 src/sys/arch/sparc64/sparc64/locore.s Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/sparc64/locore.s diff -u src/sys/arch/sparc64/sparc64/locore.s:1.424 src/sys/arch/sparc64/sparc64/locore.s:1.425 --- src/sys/arch/sparc64/sparc64/locore.s:1.424 Sun Dec 20 11:58:58 2020 +++ src/sys/arch/sparc64/sparc64/locore.s Mon Feb 22 09:56:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.424 2020/12/20 11:58:58 palle Exp $ */ +/* $NetBSD: locore.s,v 1.425 2021/02/22 09:56:42 palle Exp $ */ /* * Copyright (c) 2006-2010 Matthew R. Green @@ -228,7 +228,7 @@ .endm .macro sun4v_tl1_uspill_normal - ba,a,pt %xcc, pcbspill_normals + ba,a,pt %xcc, spill_normal_to_user_stack nop .align 128 .endm @@ -3485,6 +3485,58 @@ pcbspill_fail: Debugger() NOTREACHED +spill_normal_to_user_stack: + mov %sp, %g6 ! calculate virtual address of destination stack + add %g6, BIAS, %g6 + + mov CTX_SECONDARY, %g2! Is this context ok or should it be CTX_PRIMARY? XXX + GET_MMU_CONTEXTID %g3, %g2, %g1 + sllx %g3, 3, %g3 ! Make it into an offset into ctxbusy (see below) + + GET_CTXBUSY %g1 + ldx [%g1 + %g3], %g1! Fetch pmap for current context id + + ! Start of code to extract PA + srlx %g6, STSHIFT, %g7 + and %g7, STMASK, %g7 + sll %g7, 3, %g7 ! byte offset into ctxbusy + add %g7, %g1, %g1 + ldxa [%g1] ASI_PHYS_CACHED, %g1 ! Load pointer to directory + srlx %g6, PDSHIFT, %g7 ! Do page directory + and %g7, PDMASK, %g7 + sll %g7, 3, %g7 + brz,pn %g1, spill_normal_to_user_stack_fail + add %g7, %g1, %g1 + + ldxa [%g1] ASI_PHYS_CACHED, %g1 + srlx %g6, PTSHIFT, %g7 ! Convert to ptab offset + and %g7, PTMASK, %g7 + brz %g1, spill_normal_to_user_stack_fail + sll %g7, 3, %g7 + + add %g1, %g7, %g7 + ldxa [%g7] ASI_PHYS_CACHED, %g7 ! This one is not + brgez %g7, spill_normal_to_user_stack_fail + srlx %g7, PGSHIFT, %g7 ! Isolate PA part + + sll %g6, 32-PGSHIFT, %g6 ! And offset + sllx %g7, PGSHIFT+8, %g7 ! There are 8 bits to the left of the PA in the TTE + srl %g6, 32-PGSHIFT, %g6 + srax %g7, 8, %g7 + or %g7, %g6, %g6 ! Then combine them to form PA + ! End of code to extract PA + + wr %g0, ASI_PHYS_CACHED, %asi ! Use ASI_PHYS_CACHED to prevent possible page faults + SPILL stxa, %g6, 8, %asi ! Store the locals and ins + saved + + retry + NOTREACHED + +spill_normal_to_user_stack_fail: + sir + nop + /* * End of traps for sun4v. */
CVS commit: src/sys/arch/aarch64/include
Module Name:src Committed By: ryo Date: Mon Feb 22 09:29:38 UTC 2021 Modified Files: src/sys/arch/aarch64/include: cpu_counter.h Log Message: PR/56002: aarch64 has a true 64bit CPU cycle counter, we will use it. This fix solves PR/56002 on aarch64, but this problems can occur on all other architectures where cpu_counter() is 32bit. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/cpu_counter.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/aarch64/include/cpu_counter.h diff -u src/sys/arch/aarch64/include/cpu_counter.h:1.1 src/sys/arch/aarch64/include/cpu_counter.h:1.2 --- src/sys/arch/aarch64/include/cpu_counter.h:1.1 Sun Aug 10 05:47:38 2014 +++ src/sys/arch/aarch64/include/cpu_counter.h Mon Feb 22 09:29:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_counter.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ +/* $NetBSD: cpu_counter.h,v 1.2 2021/02/22 09:29:38 ryo Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -44,7 +44,12 @@ #include #define cpu_hascounter() (curcpu()->ci_data.cpu_cc_freq != 0) -#define cpu_counter() cpu_counter32() + +static __inline uint64_t +cpu_counter(void) +{ + return reg_pmccntr_el0_read(); +} static __inline uint32_t cpu_counter32(void)