CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Nov 30 07:53:42 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Apply ixgbe.c rev. 1.204 which was for ixgbe_msix_admin() to ixgbe_legacy_irq(), too. > An interrupt might not arrive when a module is inserted. When an link > status change interrupt occurred and the driver still regard SFP as > unplugged, issue the module softint before issuing LSC interrupt. TODO: Reduce duplicated code. To generate a diff of this commit: cvs rdiff -u -r1.260 -r1.261 src/sys/dev/pci/ixgbe/ixgbe.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/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.260 src/sys/dev/pci/ixgbe/ixgbe.c:1.261 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.260 Tue Nov 17 04:50:29 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Mon Nov 30 07:53:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.260 2020/11/17 04:50:29 knakahara Exp $ */ +/* $NetBSD: ixgbe.c,v 1.261 2020/11/30 07:53:42 msaitoh Exp $ */ /** @@ -5220,10 +5220,6 @@ ixgbe_legacy_irq(void *arg) IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EICR_GPI_SDP1_BY_MAC(hw)); } - /* Link status change */ - if (eicr & IXGBE_EICR_LSC) - task_requests |= IXGBE_REQUEST_TASK_LSC; - if (ixgbe_is_sfp(hw)) { /* Pluggable optics-related interrupt */ if (hw->mac.type >= ixgbe_mac_X540) @@ -5231,7 +5227,15 @@ ixgbe_legacy_irq(void *arg) else eicr_mask = IXGBE_EICR_GPI_SDP2_BY_MAC(hw); - if (eicr & eicr_mask) { + /* + * An interrupt might not arrive when a module is inserted. + * When an link status change interrupt occurred and the driver + * still regard SFP as unplugged, issue the module softint + * and then issue LSC interrupt. + */ + if ((eicr & eicr_mask) + || ((hw->phy.sfp_type == ixgbe_sfp_type_not_present) + && (eicr & IXGBE_EICR_LSC))) { IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr_mask); task_requests |= IXGBE_REQUEST_TASK_MOD; } @@ -5244,6 +5248,10 @@ ixgbe_legacy_irq(void *arg) } } + /* Link status change */ + if (eicr & IXGBE_EICR_LSC) + task_requests |= IXGBE_REQUEST_TASK_LSC; + /* External PHY interrupt */ if ((hw->phy.type == ixgbe_phy_x550em_ext_t) && (eicr & IXGBE_EICR_GPI_SDP0_X540))
CVS commit: src
Module Name:src Committed By: msaitoh Date: Mon Nov 30 05:33:32 UTC 2020 Modified Files: src/sys/arch/sh3/sh3: vm_machdep.c src/sys/arch/x86/x86: vm_machdep.c src/sys/dev/usb: ehci.c src/sys/net80211: ieee80211_node.c src/tests/dev/raidframe: t_raid.sh Log Message: s/ we we / we / To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sh3/sh3/vm_machdep.c cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x86/x86/vm_machdep.c cvs rdiff -u -r1.282 -r1.283 src/sys/dev/usb/ehci.c cvs rdiff -u -r1.80 -r1.81 src/sys/net80211/ieee80211_node.c cvs rdiff -u -r1.14 -r1.15 src/tests/dev/raidframe/t_raid.sh 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/sh3/sh3/vm_machdep.c diff -u src/sys/arch/sh3/sh3/vm_machdep.c:1.80 src/sys/arch/sh3/sh3/vm_machdep.c:1.81 --- src/sys/arch/sh3/sh3/vm_machdep.c:1.80 Sat Apr 6 11:54:20 2019 +++ src/sys/arch/sh3/sh3/vm_machdep.c Mon Nov 30 05:33:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.80 2019/04/06 11:54:20 kamil Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.81 2020/11/30 05:33:32 msaitoh Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.80 2019/04/06 11:54:20 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.81 2020/11/30 05:33:32 msaitoh Exp $"); #include "opt_kstack_debug.h" @@ -340,7 +340,7 @@ vmapbuf(struct buf *bp, vsize_t len) * the pmap_extract(). * * no need to flush TLB since we expect nothing to be mapped - * where we we just allocated (TLB will be flushed when our + * where we just allocated (TLB will be flushed when our * mapping is removed). */ upmap = vm_map_pmap(>b_proc->p_vmspace->vm_map); Index: src/sys/arch/x86/x86/vm_machdep.c diff -u src/sys/arch/x86/x86/vm_machdep.c:1.43 src/sys/arch/x86/x86/vm_machdep.c:1.44 --- src/sys/arch/x86/x86/vm_machdep.c:1.43 Fri Jul 3 16:17:24 2020 +++ src/sys/arch/x86/x86/vm_machdep.c Mon Nov 30 05:33:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.43 2020/07/03 16:17:24 maxv Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.44 2020/11/30 05:33:32 msaitoh Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.43 2020/07/03 16:17:24 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.44 2020/11/30 05:33:32 msaitoh Exp $"); #include "opt_mtrr.h" @@ -312,7 +312,7 @@ vmapbuf(struct buf *bp, vsize_t len) * the pmap_extract(). * * no need to flush TLB since we expect nothing to be mapped - * where we we just allocated (TLB will be flushed when our + * where we just allocated (TLB will be flushed when our * mapping is removed). */ while (len) { Index: src/sys/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.282 src/sys/dev/usb/ehci.c:1.283 --- src/sys/dev/usb/ehci.c:1.282 Sun Sep 20 09:08:01 2020 +++ src/sys/dev/usb/ehci.c Mon Nov 30 05:33:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.282 2020/09/20 09:08:01 gson Exp $ */ +/* $NetBSD: ehci.c,v 1.283 2020/11/30 05:33:32 msaitoh Exp $ */ /* * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.282 2020/09/20 09:08:01 gson Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.283 2020/11/30 05:33:32 msaitoh Exp $"); #include "ohci.h" #include "uhci.h" @@ -3770,7 +3770,7 @@ ehci_device_ctrl_close(struct usbd_pipe /* * Some EHCI chips from VIA seem to trigger interrupts before writing back the * qTD status, or miss signalling occasionally under heavy load. If the host - * machine is too fast, we we can miss transaction completion - when we scan + * machine is too fast, we can miss transaction completion - when we scan * the active list the transaction still seems to be active. This generally * exhibits itself as a umass stall that never recovers. * Index: src/sys/net80211/ieee80211_node.c diff -u src/sys/net80211/ieee80211_node.c:1.80 src/sys/net80211/ieee80211_node.c:1.81 --- src/sys/net80211/ieee80211_node.c:1.80 Mon Feb 24 12:20:30 2020 +++ src/sys/net80211/ieee80211_node.c Mon Nov 30 05:33:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_node.c,v 1.80 2020/02/24 12:20:30 rin Exp $ */ +/* $NetBSD: ieee80211_node.c,v 1.81 2020/11/30 05:33:32 msaitoh Exp $ */ /* * Copyright (c) 2001 Atsushi Onoe @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_node.c,v 1.65 2005/08/13 17:50:21 sam Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.80 2020/02/24 12:20:30 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.81 2020/11/30 05:33:32 msaitoh Exp $"); #endif #ifdef _KERNEL_OPT @@ -1381,7 +1381,7 @@ ieee80211_init_neighbor(struct ieee80211 /* * Do node
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Mon Nov 30 05:30:56 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe_vf.c Log Message: s/ we we / we / To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/dev/pci/ixgbe/ixgbe_vf.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/ixgbe/ixgbe_vf.c diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.24 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.25 --- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.24 Wed Jul 22 01:24:40 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_vf.c Mon Nov 30 05:30:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_vf.c,v 1.24 2020/07/22 01:24:40 msaitoh Exp $ */ +/* $NetBSD: ixgbe_vf.c,v 1.25 2020/11/30 05:30:56 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -784,7 +784,7 @@ int ixgbevf_get_queues(struct ixgbe_hw * msg[0] &= ~IXGBE_VT_MSGTYPE_CTS; /* - * if we we didn't get an ACK there must have been + * if we didn't get an ACK there must have been * some sort of mailbox error so we should treat it * as such */
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Mon Nov 30 00:48:35 UTC 2020 Modified Files: src/sys/dev/usb: uhid.c Log Message: uhid(4): Omit needless softint indirection. USB xfer callbacks already run in softint context at IPL_SOFTSERIAL, and I see no reason why the call to psignal must happen instead at the lower priority of IPL_SOFTCLOCK, so let's avoid using up the scarce resource of softints for something that doesn't need 'em. While here, use atomic_store_relaxed to update sc->sc_async and atomic_load_relaxed to optimisitcally test it without acquiring proc_lock. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/dev/usb/uhid.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/uhid.c diff -u src/sys/dev/usb/uhid.c:1.115 src/sys/dev/usb/uhid.c:1.116 --- src/sys/dev/usb/uhid.c:1.115 Sun Nov 29 22:54:51 2020 +++ src/sys/dev/usb/uhid.c Mon Nov 30 00:48:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uhid.c,v 1.115 2020/11/29 22:54:51 riastradh Exp $ */ +/* $NetBSD: uhid.c,v 1.116 2020/11/30 00:48:35 riastradh Exp $ */ /* * Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.115 2020/11/29 22:54:51 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.116 2020/11/30 00:48:35 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -138,7 +138,6 @@ const struct cdevsw uhid_cdevsw = { }; Static void uhid_intr(struct uhidev *, void *, u_int); -Static void uhid_softintr(void *); Static int uhid_do_read(struct uhid_softc *, struct uio *, int); Static int uhid_do_write(struct uhid_softc *, struct uio *, int); @@ -180,7 +179,6 @@ uhid_attach(device_t parent, device_t se sc->sc_hdev.sc_intr = uhid_intr; sc->sc_hdev.sc_parent = uha->parent; sc->sc_hdev.sc_report_id = uha->reportid; - sc->sc_sih = softint_establish(SOFTINT_CLOCK, uhid_softintr, sc); uhidev_get_report_desc(uha->parent, , ); repid = uha->reportid; @@ -277,7 +275,6 @@ uhid_detach(device_t self, int flags) cv_destroy(>sc_detach_cv); mutex_destroy(>sc_lock); seldestroy(>sc_rsel); - softint_disestablish(sc->sc_sih); return 0; } @@ -304,26 +301,18 @@ uhid_intr(struct uhidev *addr, void *dat DPRINTFN(5, ("uhid_intr: waking %p\n", >sc_q)); cv_broadcast(>sc_cv); selnotify(>sc_rsel, 0, NOTE_SUBMIT); - if (sc->sc_async != NULL) { - DPRINTFN(3, ("uhid_intr: sending SIGIO %p\n", sc->sc_async)); - softint_schedule(sc->sc_sih); + if (atomic_load_relaxed(>sc_async) != NULL) { + mutex_enter(_lock); + if (sc->sc_async != NULL) { + DPRINTFN(3, ("uhid_intr: sending SIGIO to %jd\n", +(intmax_t)sc->sc_async->p_pid)); + psignal(sc->sc_async, SIGIO); + } + mutex_exit(_lock); } mutex_exit(>sc_lock); } -void -uhid_softintr(void *cookie) -{ - struct uhid_softc *sc; - - sc = cookie; - - mutex_enter(_lock); - if (sc->sc_async != NULL) - psignal(sc->sc_async, SIGIO); - mutex_exit(_lock); -} - static int uhidopen(dev_t dev, int flag, int mode, struct lwp *l) { @@ -367,7 +356,7 @@ uhidopen(dev_t dev, int flag, int mode, /* Paranoia: reset SIGIO before enabling interrputs. */ mutex_enter(_lock); - sc->sc_async = NULL; + atomic_store_relaxed(>sc_async, NULL); mutex_exit(_lock); /* Open the uhidev -- after this point we can get interrupts. */ @@ -390,7 +379,7 @@ fail2: __unused uhidev_close(>sc_hdev); fail1: selnotify(>sc_rsel, POLLHUP, 0); mutex_enter(_lock); - sc->sc_async = NULL; + atomic_store_relaxed(>sc_async, NULL); mutex_exit(_lock); if (sc->sc_osize > 0) { kmem_free(sc->sc_obuf, sc->sc_osize); @@ -429,7 +418,7 @@ uhidclose(dev_t dev, int flag, int mode, /* Reset SIGIO. */ mutex_enter(_lock); - sc->sc_async = NULL; + atomic_store_relaxed(>sc_async, NULL); mutex_exit(_lock); /* Free the buffer and queue. */ @@ -644,10 +633,10 @@ uhid_do_ioctl(struct uhid_softc *sc, u_l mutex_exit(_lock); return EBUSY; } - sc->sc_async = l->l_proc; + atomic_store_relaxed(>sc_async, l->l_proc); DPRINTF(("uhid_do_ioctl: FIOASYNC %p\n", l->l_proc)); } else - sc->sc_async = NULL; + atomic_store_relaxed(>sc_async, NULL); mutex_exit(_lock); break;
CVS commit: src/lib/libc/sys
Module Name:src Committed By: riastradh Date: Mon Nov 30 00:21:36 UTC 2020 Modified Files: src/lib/libc/sys: open.2 Log Message: Note that open(O_ASYNC) does not work as advertised. This matches Linux, which also advertises the same semantics and fails to implement it, according to: https://man7.org/linux/man-pages/man2/fcntl.2.html (At what point should we collectively stop advertising the semantics that doesn't work and call the bug a feature?) To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/lib/libc/sys/open.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/open.2 diff -u src/lib/libc/sys/open.2:1.62 src/lib/libc/sys/open.2:1.63 --- src/lib/libc/sys/open.2:1.62 Mon Sep 16 04:59:32 2019 +++ src/lib/libc/sys/open.2 Mon Nov 30 00:21:35 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: open.2,v 1.62 2019/09/16 04:59:32 wiz Exp $ +.\" $NetBSD: open.2,v 1.63 2020/11/30 00:21:35 riastradh Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -217,6 +217,13 @@ Enable the signal to be sent to the process group when I/O is possible, e.g., upon availability of data to be read. +.Pp +Note: This is broken in +.Fn open ; +it must be set explicitly with the +.Dv F_SETFL +command to +.Xr fcntl 2 . .\"(This block awaits a decision about the semantics of O_SEARCH) .\" .It Dv O_SEARCH .\" If opening a directory, search permission checks will not be performed on @@ -509,3 +516,13 @@ An .Fn open function call appeared in .At v1 . +.Sh BUGS +.Dv O_ASYNC +doesn't actually work as advertised with +.Nm ; +you must set +.Dv O_ASYNC +explicitly with the +.Dv F_SETFL +command to +.Xr fcntl 2 .
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: msaitoh Date: Mon Nov 30 00:04:03 UTC 2020 Modified Files: src/sys/arch/x86/x86: procfs_machdep.c Log Message: Add sgx, sgx_lc, serialize and tsxldtrk. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/arch/x86/x86/procfs_machdep.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/x86/x86/procfs_machdep.c diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.39 src/sys/arch/x86/x86/procfs_machdep.c:1.40 --- src/sys/arch/x86/x86/procfs_machdep.c:1.39 Sat Apr 25 15:26:18 2020 +++ src/sys/arch/x86/x86/procfs_machdep.c Mon Nov 30 00:04:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_machdep.c,v 1.39 2020/04/25 15:26:18 bouyer Exp $ */ +/* $NetBSD: procfs_machdep.c,v 1.40 2020/11/30 00:04:02 msaitoh Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.39 2020/04/25 15:26:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.40 2020/11/30 00:04:02 msaitoh Exp $"); #include #include @@ -126,7 +126,7 @@ static const char * const x86_features[] NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, { /* (9) Intel-defined: 0007 ebx */ - "fsgsbase", "tsc_adjust", NULL, "bmi1", "hle", "avx2", NULL, "smep", + "fsgsbase", "tsc_adjust", "sgx", "bmi1", "hle", "avx2", NULL, "smep", "bmi2", "erms", "invpcid", "rtm", "cqm", NULL, "mpx", "rdt_a", "avx512f", "avx512dq", "rdseed", "adx", "smap", "avx512ifma", NULL, "clflushopt", @@ -179,7 +179,7 @@ static const char * const x86_features[] "gfni", "vaes", "vpclmulqdq", "avx512_vnni", "avx512_bitalg", "tme", "avx512_vpopcntdq", NULL, "la57", NULL, NULL, NULL, NULL, NULL, "rdpid", NULL, - NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, NULL, NULL}, + NULL, "cldemote", NULL, "movdiri", "movdir64b", NULL, "sgx_lc", NULL}, { /* (17) 0x8007 ebx */ "overflow_recov", "succor", NULL, "smca", NULL, NULL, NULL, NULL, @@ -189,8 +189,8 @@ static const char * const x86_features[] { /* (18) Intel 0x0007 edx */ NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", "fsrm", NULL, NULL, NULL, - "vp2intersect", NULL, "md_clear", NULL, NULL, NULL, NULL, NULL, - NULL, NULL, "pconfig", NULL, NULL, NULL, NULL, NULL, + "vp2intersect", NULL, "md_clear", NULL, NULL, NULL, "serialize", NULL, + "tsxldtrk", NULL, "pconfig", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "flush_l1d", "arch_capabilities", NULL, "ssbd"}, };
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sun Nov 29 22:54:51 UTC 2020 Modified Files: src/sys/dev/usb: uhid.c uhidev.c uhidev.h Log Message: usb: Overhaul uhid(4) and uhidev(4) locking. - uhidev API rules: 1. Call uhidev_open when you want exclusive use of a report id. After it succeeds, you will get interrupts. 2. Call uhidev_close when done with exclusive use of a report id. After it returns, you will no longer get interrupts. => uhidev_open/close do not nest. 3. uhidev_write no longer requires the caller to have exclusive access -- if there is a write in progress, it will block interruptibly until done. This way drivers for individual report ids need not work separately to coordinate their writes. 4. You must uhidev_stop to abort any pending writes on the same report id. (uhidev_stop no longer does anything else -- to ensure no more interrupts, just use uhidev_close.) - Fix uhidev_open/close locking -- uhidev now has an interruptible config lock held only on first open and last close by any report id in the device, to serialize the transition between zero and nonzero numbers of references which requires opening/closing pipes and allocating/freeing buffers. - Make /dev/uhidN selnotify(POLLHUP) when the device is yanked. - Factor uhid device lookup and reference counting and dying detection and so on into uhid_enter/exit. - Nix struct uhid_softc::sc_access_lock. This served no purpose but to confuse me when trying to understand the logic of this beast (and to ensure uhidev_write exclusion, but it was uninterruptible, which is wrong for something that implements userland operations, and didn't actually work because uhidev_write did nothing to coordinate between different report ids). - Fix locking in select/poll. - Use atomics to manage UHID_IMMED to keep it simple. (sc_lock would be fine too but it makes the code more verbose.) - Omit needless UHID_ASLP -- cv_broadcast already has this micro-optimization. With these changes, my Pinebook survives for i in `jot 100`; do echo '###' $i for j in `jot 16`; do usbhidctl -rf /dev/uhid$j >/dev/null & done wait done while plugging and unplugging uhid(4) devices (U2F keys), and the U2F keys still work as U2F keys. ok nick, mrg XXX pullup-9 XXX pullup-8? Note on ABI and pullups: This changes the layout of struct uhidev_softc, but with the sole exception of ucycom(4) -- which at the moment is completely broken and unusable -- the only members that USB HID drivers use are sc_udev and sc_iface, which haven't changed. The layout of struct uhidev, which is allocated by each USB HID driver in its own softc structure, is unchanged. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/dev/usb/uhid.c cvs rdiff -u -r1.78 -r1.79 src/sys/dev/usb/uhidev.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/usb/uhidev.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/dev/usb/uhid.c diff -u src/sys/dev/usb/uhid.c:1.114 src/sys/dev/usb/uhid.c:1.115 --- src/sys/dev/usb/uhid.c:1.114 Sat May 23 23:42:42 2020 +++ src/sys/dev/usb/uhid.c Sun Nov 29 22:54:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uhid.c,v 1.114 2020/05/23 23:42:42 ad Exp $ */ +/* $NetBSD: uhid.c,v 1.115 2020/11/29 22:54:51 riastradh Exp $ */ /* * Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.114 2020/05/23 23:42:42 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.115 2020/11/29 22:54:51 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -43,21 +43,24 @@ __KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.1 #endif #include -#include +#include + +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include #include -#include -#include -#include +#include #include -#include -#include -#include #include -#include -#include -#include #include #include @@ -84,8 +87,7 @@ int uhiddebug = 0; struct uhid_softc { struct uhidev sc_hdev; - kmutex_t sc_access_lock; /* serialises syscall accesses */ - kmutex_t sc_lock; /* protects refcnt, others */ + kmutex_t sc_lock; kcondvar_t sc_cv; kcondvar_t sc_detach_cv; @@ -99,12 +101,12 @@ struct uhid_softc { struct selinfo sc_rsel; proc_t *sc_async; /* process that wants SIGIO */ void *sc_sih; - u_char sc_state; /* driver state */ -#define UHID_ASLP 0x01 /* waiting for device data */ + volatile uint32_t sc_state; /* driver state */ #define UHID_IMMED 0x02 /* return read data immediately */ int sc_refcnt; int sc_raw; + u_char sc_open; u_char sc_dying; }; @@ -192,7 +194,6 @@ uhid_attach(device_t parent, device_t se aprint_normal(": input=%d, output=%d, feature=%d\n",
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 21:50:50 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): initialize global variables in dir.c Calling CachedDir_Assign requires that the variable be initialized. On most systems, NULL is represented as all-zero bits already. This change is only for the few other systems. Add some comments explaining the implementation of Dir_AddDir since that is tricky to read from the code alone. To generate a diff of this commit: cvs rdiff -u -r1.241 -r1.242 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.241 src/usr.bin/make/dir.c:1.242 --- src/usr.bin/make/dir.c:1.241 Sun Nov 29 18:49:36 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 21:50:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.241 2020/11/29 18:49:36 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.242 2020/11/29 21:50:50 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.241 2020/11/29 18:49:36 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.242 2020/11/29 21:50:50 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -269,8 +269,8 @@ static int misses; /* Sad, but not evil static int nearmisses; /* Found under search path */ static int bigmisses; /* Sought by itself */ -static CachedDir *dot; /* contents of current directory */ -static CachedDir *cur; /* contents of current directory, if not dot */ +static CachedDir *dot = NULL; /* contents of current directory */ +static CachedDir *cur = NULL; /* contents of current directory, if not dot */ /* A fake path entry indicating we need to look for '.' last. */ static CachedDir *dotLast = NULL; @@ -1470,11 +1470,8 @@ Dir_UpdateMTime(GNode *gn, Boolean reche } /* - * Read the directory and add it to the cache in openDirs, even if it is - * already there. If a path is given, add the directory to that path as - * well. - * - * XXX: Why is it added to openDirs unconditionally? + * Read the directory and add it to the cache in openDirs. + * If a path is given, add the directory to that path as well. */ static CachedDir * CacheNewDir(const char *name, SearchPath *path) @@ -1526,6 +1523,12 @@ CacheNewDir(const char *name, SearchPath * added, or NULL to only add the directory to openDirs * name The name of the directory to add. * The name is not normalized in any way. + * Output: + * result If no path is given and the directory exists, the + * returned CachedDir has a reference count of 0. It + * must either be assigned to a variable using + * CachedDir_Assign or be appended to a SearchPath using + * Lst_Append and CachedDir_Ref. */ CachedDir * Dir_AddDir(SearchPath *path, const char *name) @@ -1545,6 +1548,7 @@ Dir_AddDir(SearchPath *path, const char } if (path != NULL) { + /* XXX: Why is OpenDirs only checked if path != NULL? */ CachedDir *dir = OpenDirs_Find(, name); if (dir != NULL) { if (Lst_FindDatum(path, dir) == NULL)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 21:31:55 UTC 2020 Modified Files: src/usr.bin/make: meta.c Log Message: make(1): reduce memory allocation in meta_oodate To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 src/usr.bin/make/meta.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/meta.c diff -u src/usr.bin/make/meta.c:1.155 src/usr.bin/make/meta.c:1.156 --- src/usr.bin/make/meta.c:1.155 Sun Nov 29 21:28:06 2020 +++ src/usr.bin/make/meta.c Sun Nov 29 21:31:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.155 2020/11/29 21:28:06 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.156 2020/11/29 21:31:55 rillig Exp $ */ /* * Implement 'meta' mode. @@ -1090,7 +1090,7 @@ meta_oodate(GNode *gn, Boolean oodate) static size_t tmplen = 0; FILE *fp; Boolean needOODATE = FALSE; -StringList *missingFiles; +StringList missingFiles; Boolean have_filemon = FALSE; void *objdir_freeIt; @@ -1105,7 +1105,7 @@ meta_oodate(GNode *gn, Boolean oodate) goto oodate_out; dname = fname3; -missingFiles = Lst_New(); +Lst_Init(); /* * We need to check if the target is out-of-date. This includes @@ -1319,12 +1319,12 @@ meta_oodate(GNode *gn, Boolean oodate) case 'D': /* unlink */ if (*p == '/') { /* remove any missingFiles entries that match p */ - StringListNode *ln = missingFiles->first; + StringListNode *ln = missingFiles.first; while (ln != NULL) { StringListNode *next = ln->next; if (path_starts_with(ln->datum, p)) { free(ln->datum); -Lst_Remove(missingFiles, ln); +Lst_Remove(, ln); } ln = next; } @@ -1390,7 +1390,7 @@ meta_oodate(GNode *gn, Boolean oodate) if ((link_src != NULL && cached_lstat(p, ) < 0) || (link_src == NULL && cached_stat(p, ) < 0)) { if (!meta_ignore(gn, p)) - append_if_new(missingFiles, p); + append_if_new(, p); } break; check_link_src: @@ -1473,7 +1473,7 @@ meta_oodate(GNode *gn, Boolean oodate) * A referenced file outside of CWD is missing. * We cannot catch every eventuality here... */ - append_if_new(missingFiles, p); + append_if_new(, p); } } if (buf[0] == 'E') { @@ -1571,9 +1571,9 @@ meta_oodate(GNode *gn, Boolean oodate) } fclose(fp); - if (!Lst_IsEmpty(missingFiles)) { + if (!Lst_IsEmpty()) { DEBUG2(META, "%s: missing files: %s...\n", - fname, (char *)missingFiles->first->datum); + fname, (char *)missingFiles.first->datum); oodate = TRUE; } if (!oodate && !have_filemon && filemonMissing) { @@ -1598,7 +1598,7 @@ meta_oodate(GNode *gn, Boolean oodate) } } -Lst_Destroy(missingFiles, free); +Lst_DoneCall(, free); if (oodate && needOODATE) { /*
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 21:28:06 UTC 2020 Modified Files: src/usr.bin/make: meta.c Log Message: make(1): reduce memory allocation in meta mode To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/usr.bin/make/meta.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/meta.c diff -u src/usr.bin/make/meta.c:1.154 src/usr.bin/make/meta.c:1.155 --- src/usr.bin/make/meta.c:1.154 Sun Nov 29 09:27:40 2020 +++ src/usr.bin/make/meta.c Sun Nov 29 21:28:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.154 2020/11/29 09:27:40 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.155 2020/11/29 21:28:06 rillig Exp $ */ /* * Implement 'meta' mode. @@ -51,9 +51,9 @@ #endif static BuildMon Mybm; /* for compat */ -static StringList *metaBailiwick; /* our scope of control */ +static StringList metaBailiwick = LST_INIT; /* our scope of control */ static char *metaBailiwickStr; /* string storage for the list */ -static StringList *metaIgnorePaths; /* paths we deliberately ignore */ +static StringList metaIgnorePaths = LST_INIT; /* paths we deliberately ignore */ static char *metaIgnorePathsStr; /* string storage for the list */ #ifndef MAKE_META_IGNORE_PATHS @@ -631,21 +631,19 @@ meta_mode_init(const char *make_mode) /* * We consider ourselves master of all within ${.MAKE.META.BAILIWICK} */ -metaBailiwick = Lst_New(); (void)Var_Subst("${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL, VARE_WANTRES, ); /* TODO: handle errors */ -str2Lst_Append(metaBailiwick, metaBailiwickStr); +str2Lst_Append(, metaBailiwickStr); /* * We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS} */ -metaIgnorePaths = Lst_New(); Var_Append(MAKE_META_IGNORE_PATHS, "/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL); (void)Var_Subst("${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL, VARE_WANTRES, ); /* TODO: handle errors */ -str2Lst_Append(metaIgnorePaths, metaIgnorePathsStr); +str2Lst_Append(, metaIgnorePathsStr); /* * We ignore any paths that match ${.MAKE.META.IGNORE_PATTERNS} @@ -896,11 +894,9 @@ meta_job_finish(Job *job) void meta_finish(void) { -if (metaBailiwick != NULL) - Lst_Free(metaBailiwick); +Lst_Done(); free(metaBailiwickStr); -if (metaIgnorePaths != NULL) - Lst_Free(metaIgnorePaths); +Lst_Done(); free(metaIgnorePathsStr); } @@ -987,7 +983,7 @@ meta_ignore(GNode *gn, const char *p) if (*p == '/') { cached_realpath(p, fname); /* clean it up */ - if (has_any_prefix(fname, metaIgnorePaths)) { + if (has_any_prefix(fname, )) { #ifdef DEBUG_META_MODE DEBUG1(META, "meta_oodate: ignoring path: %s\n", p); #endif @@ -1372,14 +1368,14 @@ meta_oodate(GNode *gn, Boolean oodate) if (*p != '/') break; - if (Lst_IsEmpty(metaBailiwick)) + if (Lst_IsEmpty()) break; /* ignore cwd - normal dependencies handle those */ if (strncmp(p, cwd, cwdlen) == 0) break; - if (!has_any_prefix(p, metaBailiwick)) + if (!has_any_prefix(p, )) break; /* tmpdir might be within */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 21:27:08 UTC 2020 Modified Files: src/usr.bin/make: test-variants.sh Log Message: make(1): add test variant for reference counting logging To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/test-variants.sh 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/test-variants.sh diff -u src/usr.bin/make/test-variants.sh:1.6 src/usr.bin/make/test-variants.sh:1.7 --- src/usr.bin/make/test-variants.sh:1.6 Fri Nov 20 00:24:21 2020 +++ src/usr.bin/make/test-variants.sh Sun Nov 29 21:27:08 2020 @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: test-variants.sh,v 1.6 2020/11/20 00:24:21 rillig Exp $ +# $NetBSD: test-variants.sh,v 1.7 2020/11/29 21:27:08 rillig Exp $ # # Build several variants of make and run the tests on them. # @@ -71,6 +71,8 @@ testcase USE_META="no" testcase USER_CPPFLAGS="-DCLEANUP" +testcase USER_CPPFLAGS="-DDEBUG_REFCNT" + testcase USER_CPPFLAGS="-DDEBUG_HASH_LOOKUP" testcase USER_CPPFLAGS="-DDEBUG_META_MODE"
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 18:49:36 UTC 2020 Modified Files: src/usr.bin/make: dir.c src/usr.bin/make/unit-tests: Makefile Log Message: make(1): clean up memory management for CachedDirs Previously, the reference count for a newly created CacheDir had been set to 1 in CacheNewDir. This was wrong because at that point, the object had not been referenced by any nonlocal variable. The reference count is no longer incremented at this point. All callers of CacheNewDir either append the newly created CachedDir to a SearchPath via Lst_Append and CachedDir_Ref, or they assign it to a global variable via CachedDir_Assign. Since the reference count is no longer wrongly incremented, it does not need to be decremented more than necessary in Dir_End. To keep the code simple and maintainable, all assignments to global variables are now handled by CachedDir_Assign. Adding a CachedDir to a list is still done manually via Lst_Append, and the corresponding code for decrementing is in SearchPath_Clean and SearchPath_Free. These details may be cleaned up in a follow-up commit. As a result, when OpenDirs_Done is called in the unit tests, the list of open directories is empty. It had been non-empty in a single unit test before (dep-wildcards.mk), as a result of calling Dir_Expand. The additional debug logging for the reference counting is not enabled by default since it contains memory addresses, which makes the output dependent on the memory allocator. The function CachedDir_Destroy has been merged into CachedDir_Undef, which had only been used in Dir_End before. The new name emphasizes that it corresponds to CachedDir_Ref. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/usr.bin/make/dir.c cvs rdiff -u -r1.228 -r1.229 src/usr.bin/make/unit-tests/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/dir.c diff -u src/usr.bin/make/dir.c:1.240 src/usr.bin/make/dir.c:1.241 --- src/usr.bin/make/dir.c:1.240 Sun Nov 29 16:37:10 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 18:49:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.240 2020/11/29 16:37:10 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.241 2020/11/29 18:49:36 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.240 2020/11/29 16:37:10 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.241 2020/11/29 18:49:36 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -299,6 +299,10 @@ CachedDir_New(const char *name) dir->hits = 0; HashSet_Init(>files); +#ifdef DEBUG_REFCNT + DEBUG2(DIR, "CachedDir %p new for \"%s\"\n", dir, dir->name); +#endif + return dir; } @@ -306,15 +310,31 @@ static CachedDir * CachedDir_Ref(CachedDir *dir) { dir->refCount++; - DEBUG2(DIR, "CachedDir refCount++ to %d for \"%s\"\n", - dir->refCount, dir->name); + +#ifdef DEBUG_REFCNT + DEBUG3(DIR, "CachedDir %p ++ %d for \"%s\"\n", + dir, dir->refCount, dir->name); +#endif + return dir; } -/* Free a cached directory with reference count 0. */ static void -CachedDir_Free0(CachedDir *dir) +CachedDir_Unref(CachedDir *dir) { + dir->refCount--; + +#ifdef DEBUG_REFCNT + DEBUG3(DIR, "CachedDir %p -- %d for \"%s\"\n", + dir, dir->refCount, dir->name); +#endif + + if (dir->refCount > 0) + return; + +#ifdef DEBUG_REFCNT + DEBUG2(DIR, "CachedDir %p free for \"%s\"\n", dir, dir->name); +#endif OpenDirs_Remove(, dir->name); @@ -323,24 +343,6 @@ CachedDir_Free0(CachedDir *dir) free(dir); } -static void -CachedDir_Unref(CachedDir *dir) -{ - dir->refCount--; - DEBUG2(DIR, "CachedDir refCount-- to %d for \"%s\"\n", - dir->refCount, dir->name); -} - -/* Nuke a directory descriptor, if it is no longer used. */ -static void -CachedDir_Destroy(CachedDir *dir) -{ - CachedDir_Unref(dir); - - if (dir->refCount == 0) - CachedDir_Free0(dir); -} - /* Update the value of the CachedDir variable, updating the reference counts. */ static void CachedDir_Assign(CachedDir **var, CachedDir *dir) @@ -352,7 +354,7 @@ CachedDir_Assign(CachedDir **var, Cached if (dir != NULL) CachedDir_Ref(dir); if (prev != NULL) - CachedDir_Destroy(prev); + CachedDir_Unref(prev); } static void @@ -374,7 +376,7 @@ OpenDirs_Done(OpenDirs *odirs) CachedDir *dir = ln->datum; DIR_DEBUG2("OpenDirs_Done: refCount %d for \"%s\"\n", dir->refCount, dir->name); - CachedDir_Destroy(dir); /* removes the dir from odirs->list */ + CachedDir_Unref(dir); /* removes the dir from odirs->list */ ln = next; } Lst_Done(>list); @@ -502,11 +504,7 @@ Dir_InitCur(const char *cdname) if (dir == NULL) return; - if (cur != NULL && cur != dir) { - CachedDir_Unref(cur); /* XXX: why unref
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 16:37:10 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): fix the reference count of dotLast going negative The memory management for dotLast is quite simple. It is initialized exactly once main_Init > Init_Objdir > Dir_InitDir and freed exactly once in main_CleanUp > Dir_End. Previously, dotLast was not freed at all. The first call to CachedDir_Unref decremented the refCount to 0 but didn't free anything. Next, CachedDir_Destroy was called, which decremented the reference count to -1, therefore skipping the actual freeing. This was probably an implementation mistake. Since Dir_End is called at the very end of main_CleanUp, no code accesses dotLast after it has been freed. To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.239 src/usr.bin/make/dir.c:1.240 --- src/usr.bin/make/dir.c:1.239 Sun Nov 29 16:04:34 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 16:37:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.239 2020/11/29 16:04:34 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.240 2020/11/29 16:37:10 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.239 2020/11/29 16:04:34 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.240 2020/11/29 16:37:10 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -271,8 +271,8 @@ static int bigmisses; /* Sought by itse static CachedDir *dot; /* contents of current directory */ static CachedDir *cur; /* contents of current directory, if not dot */ -static CachedDir *dotLast; /* a fake path entry indicating we need to - * look for . last */ +/* A fake path entry indicating we need to look for '.' last. */ +static CachedDir *dotLast = NULL; /* Results of doing a last-resort stat in Dir_FindFile -- if we have to go to * the system to find the file, we might as well have its mtime on record. @@ -341,6 +341,20 @@ CachedDir_Destroy(CachedDir *dir) CachedDir_Free0(dir); } +/* Update the value of the CachedDir variable, updating the reference counts. */ +static void +CachedDir_Assign(CachedDir **var, CachedDir *dir) +{ + CachedDir *prev; + + prev = *var; + *var = dir; + if (dir != NULL) + CachedDir_Ref(dir); + if (prev != NULL) + CachedDir_Destroy(prev); +} + static void OpenDirs_Init(OpenDirs *odirs) { @@ -466,7 +480,7 @@ Dir_InitDir(const char *cdname) { Dir_InitCur(cdname); - dotLast = CachedDir_Ref(CachedDir_New(".DOTLAST")); + CachedDir_Assign(, CachedDir_New(".DOTLAST")); } /* @@ -537,8 +551,7 @@ Dir_End(void) CachedDir_Unref(cur); /* XXX: why unref twice? */ CachedDir_Destroy(cur); } - CachedDir_Unref(dotLast); /* XXX: why unref twice? */ - CachedDir_Destroy(dotLast); + CachedDir_Assign(, NULL); CachedDir_Unref(dot); /* XXX: why unref twice? */ CachedDir_Destroy(dot); SearchPath_Clear();
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 16:04:34 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): move CachedDir_Destroy up to the related functions To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.238 src/usr.bin/make/dir.c:1.239 --- src/usr.bin/make/dir.c:1.238 Sun Nov 29 15:58:37 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 16:04:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.238 2020/11/29 15:58:37 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.239 2020/11/29 16:04:34 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.238 2020/11/29 15:58:37 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.239 2020/11/29 16:04:34 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -286,7 +286,6 @@ static HashTable mtimes; static HashTable lmtimes; /* same as mtimes but for lstat */ -static void CachedDir_Destroy(CachedDir *); static void OpenDirs_Remove(OpenDirs *, const char *); @@ -332,6 +331,16 @@ CachedDir_Unref(CachedDir *dir) dir->refCount, dir->name); } +/* Nuke a directory descriptor, if it is no longer used. */ +static void +CachedDir_Destroy(CachedDir *dir) +{ + CachedDir_Unref(dir); + + if (dir->refCount == 0) + CachedDir_Free0(dir); +} + static void OpenDirs_Init(OpenDirs *odirs) { @@ -1614,16 +1623,6 @@ SearchPath_ToFlags(const char *flag, Sea return Buf_Destroy(, FALSE); } -/* Nuke a directory descriptor, if it is no longer used. */ -static void -CachedDir_Destroy(CachedDir *dir) -{ - CachedDir_Unref(dir); - - if (dir->refCount == 0) - CachedDir_Free0(dir); -} - /* Free the search path and all directories mentioned in it. */ void SearchPath_Free(SearchPath *path)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 15:58:37 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): extract CachedDir_Free0 from CachedDir_Destroy To generate a diff of this commit: cvs rdiff -u -r1.237 -r1.238 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.237 src/usr.bin/make/dir.c:1.238 --- src/usr.bin/make/dir.c:1.237 Sun Nov 29 15:14:32 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 15:58:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.237 2020/11/29 15:14:32 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.238 2020/11/29 15:58:37 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.237 2020/11/29 15:14:32 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.238 2020/11/29 15:58:37 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -287,6 +287,7 @@ static HashTable lmtimes; /* same as mti static void CachedDir_Destroy(CachedDir *); +static void OpenDirs_Remove(OpenDirs *, const char *); static CachedDir * @@ -311,13 +312,24 @@ CachedDir_Ref(CachedDir *dir) return dir; } -static CachedDir * +/* Free a cached directory with reference count 0. */ +static void +CachedDir_Free0(CachedDir *dir) +{ + + OpenDirs_Remove(, dir->name); + + free(dir->name); + HashSet_Done(>files); + free(dir); +} + +static void CachedDir_Unref(CachedDir *dir) { dir->refCount--; DEBUG2(DIR, "CachedDir refCount-- to %d for \"%s\"\n", dir->refCount, dir->name); - return dir; } static void @@ -1608,13 +1620,8 @@ CachedDir_Destroy(CachedDir *dir) { CachedDir_Unref(dir); - if (dir->refCount == 0) { - OpenDirs_Remove(, dir->name); - - HashSet_Done(>files); - free(dir->name); - free(dir); - } + if (dir->refCount == 0) + CachedDir_Free0(dir); } /* Free the search path and all directories mentioned in it. */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 15:14:33 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): remove wrong comment in Dir_InitCur In a makefile with repeated ".CURDIR=." lines, Dir_AddDir is called with a NULL path, once per line. Since the path is NULL, the search for OpenDirs_Find is skipped and the directory is always read from disk. The freshly read directory has a refCount of 1, and the refCount never raises above 2. In Dir_InitCur, the directory of the previous .CURDIR has a refCount of 2, which is decremented twice and then freed. After this, the new directory is placed in the global 'cur', after incrementing its refCount to 2. It still seems wrong that the refCount of 'cur' is 2 instead of 1, but it works well. To generate a diff of this commit: cvs rdiff -u -r1.236 -r1.237 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.236 src/usr.bin/make/dir.c:1.237 --- src/usr.bin/make/dir.c:1.236 Sun Nov 29 14:29:19 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 15:14:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.236 2020/11/29 14:29:19 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.237 2020/11/29 15:14:32 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.236 2020/11/29 14:29:19 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.237 2020/11/29 15:14:32 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -467,20 +467,11 @@ Dir_InitCur(const char *cdname) if (dir == NULL) return; - /* XXX: Reference counting is wrong here. - * If this function is called repeatedly with the same directory name, - * its reference count increases each time even though the number of - * actual references stays the same. */ - - CachedDir_Ref(dir); /* XXX: This can be expressed clearer. */ if (cur != NULL && cur != dir) { - /* - * We've been here before, clean up. - */ CachedDir_Unref(cur); /* XXX: why unref twice? */ CachedDir_Destroy(cur); } - cur = dir; + cur = CachedDir_Ref(dir); } /* (Re)initialize "dot" (current/object directory) path hash.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 14:29:20 UTC 2020 Modified Files: src/usr.bin/make: dir.c src/usr.bin/make/unit-tests: Makefile Log Message: make(1): add debug logging for OpenDirs_Done To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/usr.bin/make/dir.c cvs rdiff -u -r1.227 -r1.228 src/usr.bin/make/unit-tests/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/dir.c diff -u src/usr.bin/make/dir.c:1.235 src/usr.bin/make/dir.c:1.236 --- src/usr.bin/make/dir.c:1.235 Sun Nov 29 12:30:40 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 14:29:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.235 2020/11/29 12:30:40 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.236 2020/11/29 14:29:19 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.235 2020/11/29 12:30:40 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.236 2020/11/29 14:29:19 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -332,9 +332,13 @@ static void OpenDirs_Done(OpenDirs *odirs) { CachedDirListNode *ln = odirs->list.first; + DIR_DEBUG1("OpenDirs_Done: %u entries to remove\n", + odirs->table.numEntries); while (ln != NULL) { CachedDirListNode *next = ln->next; CachedDir *dir = ln->datum; + DIR_DEBUG2("OpenDirs_Done: refCount %d for \"%s\"\n", + dir->refCount, dir->name); CachedDir_Destroy(dir); /* removes the dir from odirs->list */ ln = next; } Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.227 src/usr.bin/make/unit-tests/Makefile:1.228 --- src/usr.bin/make/unit-tests/Makefile:1.227 Sun Nov 29 10:57:16 2020 +++ src/usr.bin/make/unit-tests/Makefile Sun Nov 29 14:29:19 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.227 2020/11/29 10:57:16 rillig Exp $ +# $NetBSD: Makefile,v 1.228 2020/11/29 14:29:19 rillig Exp $ # # Unit tests for make(1) # @@ -439,6 +439,7 @@ FLAGS.varname-empty= -dv '$${:U}=cmdline # Some tests need extra postprocessing. SED_CMDS.dir= ${:D remove output from -DCLEANUP mode } +SED_CMDS.dir+= -e '/^OpenDirs_Done:/d' SED_CMDS.dir+= -e '/^CachedDir refCount/d' SED_CMDS.export= -e '/^[^=_A-Za-z0-9]*=/d' SED_CMDS.export-all= ${SED_CMDS.export}
CVS commit: src/sys/arch/ofppc/conf
Module Name:src Committed By: phx Date: Sun Nov 29 12:38:44 UTC 2020 Modified Files: src/sys/arch/ofppc/conf: GENERIC Log Message: Message buffer is too small, since timestamps were enforced. To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/sys/arch/ofppc/conf/GENERIC 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/ofppc/conf/GENERIC diff -u src/sys/arch/ofppc/conf/GENERIC:1.173 src/sys/arch/ofppc/conf/GENERIC:1.174 --- src/sys/arch/ofppc/conf/GENERIC:1.173 Sun Sep 27 13:48:53 2020 +++ src/sys/arch/ofppc/conf/GENERIC Sun Nov 29 12:38:44 2020 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.173 2020/09/27 13:48:53 roy Exp $ +# $NetBSD: GENERIC,v 1.174 2020/11/29 12:38:44 phx Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/ofppc/conf/std.ofppc" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.173 $" +#ident "GENERIC-$Revision: 1.174 $" maxusers 32 @@ -60,6 +60,7 @@ options DDB # in-kernel debugger options DDB_HISTORY_SIZE=512 # enable history editing in DDB options DDB_VERBOSE_HELP options TRAP_PANICWAIT +options MSGBUFSIZE=32768 makeoptions DEBUG="-g" # compile full symbol table
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 12:30:40 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): extract CacheNewDir from Dir_AddDir Change the debug output for directories that are not found. To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.234 src/usr.bin/make/dir.c:1.235 --- src/usr.bin/make/dir.c:1.234 Sun Nov 29 11:17:41 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 12:30:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.234 2020/11/29 11:17:41 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.235 2020/11/29 12:30:40 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.234 2020/11/29 11:17:41 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.235 2020/11/29 12:30:40 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -1463,6 +1463,54 @@ Dir_UpdateMTime(GNode *gn, Boolean reche gn->mtime = cst.cst_mtime; } +/* + * Read the directory and add it to the cache in openDirs, even if it is + * already there. If a path is given, add the directory to that path as + * well. + * + * XXX: Why is it added to openDirs unconditionally? + */ +static CachedDir * +CacheNewDir(const char *name, SearchPath *path) +{ + CachedDir *dir = NULL; + DIR *d; + struct dirent *dp; + + if ((d = opendir(name)) == NULL) { + DIR_DEBUG1("Caching %s ... not found\n", name); + return dir; + } + + DIR_DEBUG1("Caching %s ...\n", name); + + dir = CachedDir_New(name); + CachedDir_Ref(dir); /* XXX: why here already? */ + + while ((dp = readdir(d)) != NULL) { + +#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */ + /* + * The sun directory library doesn't check for a 0 inode + * (0-inode slots just take up space), so we have to do + * it ourselves. + */ + if (dp->d_fileno == 0) + continue; +#endif /* sun && d_ino */ + + (void)HashSet_Add(>files, dp->d_name); + } + (void)closedir(d); + + OpenDirs_Add(, dir); + if (path != NULL) + Lst_Append(path, dir); + + DIR_DEBUG1("Caching %s done\n", name); + return dir; +} + /* Read the list of filenames in the directory and store the result * in openDirs. * @@ -1477,9 +1525,6 @@ Dir_UpdateMTime(GNode *gn, Boolean reche CachedDir * Dir_AddDir(SearchPath *path, const char *name) { - CachedDir *dir = NULL; /* the added directory */ - DIR *d; - struct dirent *dp; if (path != NULL && strcmp(name, ".DOTLAST") == 0) { SearchPathNode *ln; @@ -1495,40 +1540,16 @@ Dir_AddDir(SearchPath *path, const char Lst_Prepend(path, dotLast); } - if (path != NULL) - dir = OpenDirs_Find(, name); - if (dir != NULL) { - if (Lst_FindDatum(path, dir) == NULL) - Lst_Append(path, CachedDir_Ref(dir)); - return dir; - } - - DIR_DEBUG1("Caching %s ...\n", name); - - if ((d = opendir(name)) != NULL) { - dir = CachedDir_New(name); - CachedDir_Ref(dir); /* XXX: why here already? */ - - while ((dp = readdir(d)) != NULL) { -#if defined(sun) && defined(d_ino) /* d_ino is a sunos4 #define for d_fileno */ - /* - * The sun directory library doesn't check for a 0 inode - * (0-inode slots just take up space), so we have to do - * it ourselves. - */ - if (dp->d_fileno == 0) -continue; -#endif /* sun && d_ino */ - (void)HashSet_Add(>files, dp->d_name); + if (path != NULL) { + CachedDir *dir = OpenDirs_Find(, name); + if (dir != NULL) { + if (Lst_FindDatum(path, dir) == NULL) +Lst_Append(path, CachedDir_Ref(dir)); + return dir; } - (void)closedir(d); - - OpenDirs_Add(, dir); - if (path != NULL) - Lst_Append(path, dir); } - DIR_DEBUG1("Caching %s done\n", name); - return dir; + + return CacheNewDir(name, path); } /* Return a copy of dirSearchPath, incrementing the reference counts for
CVS commit: [netbsd-9] src/doc
Module Name:src Committed By: martin Date: Sun Nov 29 11:41:49 UTC 2020 Modified Files: src/doc [netbsd-9]: CHANGES-9.2 Log Message: Tickets #1135 - #1138 To generate a diff of this commit: cvs rdiff -u -r1.1.2.15 -r1.1.2.16 src/doc/CHANGES-9.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-9.2 diff -u src/doc/CHANGES-9.2:1.1.2.15 src/doc/CHANGES-9.2:1.1.2.16 --- src/doc/CHANGES-9.2:1.1.2.15 Thu Nov 19 11:26:10 2020 +++ src/doc/CHANGES-9.2 Sun Nov 29 11:41:49 2020 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-9.2,v 1.1.2.15 2020/11/19 11:26:10 martin Exp $ +# $NetBSD: CHANGES-9.2,v 1.1.2.16 2020/11/29 11:41:49 martin Exp $ A complete list of changes from the NetBSD 9.1 release to the NetBSD 9.2 release: @@ -1104,3 +1104,28 @@ libexec/httpd/bozohttpd.c 1.124 Fix httpd serving files greater than 4GB on 32bit archs. [hannken, ticket #1134] +include/arpa/nameser_compat.h 1.8 +lib/libc/net/getaddrinfo.c 1.120 +lib/libc/net/gethnamaddr.c 1.93 + + Don't complain about additional DNAME records received when resolving + A or . + [is, ticket #1135] + +sys/external/bsd/drm2/dist/drm/i915/intel_sprite.c 1.11 + + PR 5: wait without interrupts. + [maya, ticket #1136] + +usr.sbin/sysinst/arch/evbarm/md.c 1.20 + + Make sure the kernel set is selected, even if extracting parts of it + manually. + [jmcneill, ticket #1137] + +external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c 1.19 + + Use vn_close to release the vnodes in the error handling blocks, since + the vnodes were opened for writing. + [yhardy, ticket #1138] +
CVS commit: [netbsd-9] src/external/cddl/osnet/dist/uts/common/fs/zfs
Module Name:src Committed By: martin Date: Sun Nov 29 11:39:45 UTC 2020 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs [netbsd-9]: vdev_disk.c Log Message: Pull up following revision(s) (requested by yhardy in ticket #1138): external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c: revision 1.19 Use vn_close to release the vnodes in the error handling blocks, since the vnodes were opened for writing. Fix proposed on tech-kern and improved by hannken@. To generate a diff of this commit: cvs rdiff -u -r1.11.2.5 -r1.11.2.6 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.11.2.5 src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.11.2.6 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c:1.11.2.5 Tue Jun 30 17:55:35 2020 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c Sun Nov 29 11:39:45 2020 @@ -215,7 +215,11 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi return (SET_ERROR(error)); } if (vp->v_type != VBLK) { +#ifdef __NetBSD__ + vn_close(vp, FREAD|FWRITE, kcred); +#else vrele(vp); +#endif vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED; return (SET_ERROR(EINVAL)); } @@ -247,7 +251,11 @@ vdev_disk_open(vdev_t *vd, uint64_t *psi error = workqueue_create(>vd_wq, "vdevsync", vdev_disk_flush, dvd, PRI_NONE, IPL_NONE, WQ_MPSAFE); if (error != 0) { +#ifdef __NetBSD__ + vn_close(vp, FREAD|FWRITE, kcred); +#else vrele(vp); +#endif return (SET_ERROR(error)); }
CVS commit: [netbsd-9] src/usr.sbin/sysinst/arch/evbarm
Module Name:src Committed By: martin Date: Sun Nov 29 11:36:46 UTC 2020 Modified Files: src/usr.sbin/sysinst/arch/evbarm [netbsd-9]: md.c Log Message: Pull up following revision(s) (requested by jmcneill in ticket #1137): usr.sbin/sysinst/arch/evbarm/md.c: revision 1.20 Make sure the kernel set is selected, even if extracting parts of it manually. To generate a diff of this commit: cvs rdiff -u -r1.8.2.5 -r1.8.2.6 src/usr.sbin/sysinst/arch/evbarm/md.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/sysinst/arch/evbarm/md.c diff -u src/usr.sbin/sysinst/arch/evbarm/md.c:1.8.2.5 src/usr.sbin/sysinst/arch/evbarm/md.c:1.8.2.6 --- src/usr.sbin/sysinst/arch/evbarm/md.c:1.8.2.5 Thu Oct 15 19:36:52 2020 +++ src/usr.sbin/sysinst/arch/evbarm/md.c Sun Nov 29 11:36:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.8.2.5 2020/10/15 19:36:52 bouyer Exp $ */ +/* $NetBSD: md.c,v 1.8.2.6 2020/11/29 11:36:46 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -87,6 +87,7 @@ md_init_set_status(int flags) * manually later, just fetch the kernel set, do not * unpack it. */ + set_kernel_set(SET_KERNEL_1); set_noextract_set(SET_KERNEL_1); }
CVS commit: [netbsd-9] src/sys/external/bsd/drm2/dist/drm/i915
Module Name:src Committed By: martin Date: Sun Nov 29 11:34:04 UTC 2020 Modified Files: src/sys/external/bsd/drm2/dist/drm/i915 [netbsd-9]: intel_sprite.c Log Message: Pull up following revision(s) (requested by maya in ticket #1136): sys/external/bsd/drm2/dist/drm/i915/intel_sprite.c: revision 1.11 Match linux here and wait without interrupts. >From David H. Gutteridge in PR port-amd64/5 There's a second part to the patch, but "make our code behave the way the upstream code does" is very welcome. Also PR kern/54515 and possibly others. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.9.4.1 \ src/sys/external/bsd/drm2/dist/drm/i915/intel_sprite.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/external/bsd/drm2/dist/drm/i915/intel_sprite.c diff -u src/sys/external/bsd/drm2/dist/drm/i915/intel_sprite.c:1.9 src/sys/external/bsd/drm2/dist/drm/i915/intel_sprite.c:1.9.4.1 --- src/sys/external/bsd/drm2/dist/drm/i915/intel_sprite.c:1.9 Mon Aug 27 15:09:35 2018 +++ src/sys/external/bsd/drm2/dist/drm/i915/intel_sprite.c Sun Nov 29 11:34:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: intel_sprite.c,v 1.9 2018/08/27 15:09:35 riastradh Exp $ */ +/* $NetBSD: intel_sprite.c,v 1.9.4.1 2020/11/29 11:34:04 martin Exp $ */ /* * Copyright © 2011 Intel Corporation @@ -32,7 +32,7 @@ * support. */ #include -__KERNEL_RCSID(0, "$NetBSD: intel_sprite.c,v 1.9 2018/08/27 15:09:35 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intel_sprite.c,v 1.9.4.1 2020/11/29 11:34:04 martin Exp $"); #include #include @@ -124,7 +124,7 @@ void intel_pipe_update_start(struct inte trace_i915_pipe_update_start(crtc); #ifdef __NetBSD__ - DRM_SPIN_TIMED_WAIT_UNTIL(ret, wq, >vbl_lock, timeout, + DRM_SPIN_TIMED_WAIT_NOINTR_UNTIL(ret, wq, >vbl_lock, timeout, (scanline = intel_get_crtc_scanline(crtc), scanline < min || scanline > max)); if (ret <= 0)
CVS commit: [netbsd-9] src
Module Name:src Committed By: martin Date: Sun Nov 29 11:25:31 UTC 2020 Modified Files: src/include/arpa [netbsd-9]: nameser_compat.h src/lib/libc/net [netbsd-9]: getaddrinfo.c gethnamaddr.c Log Message: Pull up following revision(s) (requested by is in ticket #1135): lib/libc/net/getaddrinfo.c: revision 1.120 lib/libc/net/gethnamaddr.c: revision 1.93 include/arpa/nameser_compat.h: revision 1.8 Don't complain about additional DNAME records received when resolving A or (like already done for SIG/KEY and CNAME). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.6.18.1 src/include/arpa/nameser_compat.h cvs rdiff -u -r1.119 -r1.119.2.1 src/lib/libc/net/getaddrinfo.c cvs rdiff -u -r1.92 -r1.92.18.1 src/lib/libc/net/gethnamaddr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/include/arpa/nameser_compat.h diff -u src/include/arpa/nameser_compat.h:1.6 src/include/arpa/nameser_compat.h:1.6.18.1 --- src/include/arpa/nameser_compat.h:1.6 Tue Feb 24 17:57:08 2015 +++ src/include/arpa/nameser_compat.h Sun Nov 29 11:25:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nameser_compat.h,v 1.6 2015/02/24 17:57:08 christos Exp $ */ +/* $NetBSD: nameser_compat.h,v 1.6.18.1 2020/11/29 11:25:31 martin Exp $ */ /* Copyright (c) 1983, 1989 *The Regents of the University of California. All rights reserved. @@ -210,6 +210,7 @@ typedef struct { #define T_ATMA ns_t_atma #define T_NAPTR ns_t_naptr #define T_A6 ns_t_a6 +#define T_DNAME ns_t_dname #define T_TSIG ns_t_tsig #define T_IXFR ns_t_ixfr #define T_AXFR ns_t_axfr Index: src/lib/libc/net/getaddrinfo.c diff -u src/lib/libc/net/getaddrinfo.c:1.119 src/lib/libc/net/getaddrinfo.c:1.119.2.1 --- src/lib/libc/net/getaddrinfo.c:1.119 Thu Dec 13 04:41:41 2018 +++ src/lib/libc/net/getaddrinfo.c Sun Nov 29 11:25:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.119 2018/12/13 04:41:41 dholland Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.119.2.1 2020/11/29 11:25:31 martin Exp $ */ /* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */ /* @@ -55,7 +55,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getaddrinfo.c,v 1.119 2018/12/13 04:41:41 dholland Exp $"); +__RCSID("$NetBSD: getaddrinfo.c,v 1.119.2.1 2020/11/29 11:25:31 martin Exp $"); #endif /* LIBC_SCCS and not lint */ #ifndef RUMP_ACTION @@ -1821,7 +1821,7 @@ getanswer(res_state res, const querybuf continue; } } else if (type != qtype) { - if (type != T_KEY && type != T_SIG) { + if (type != T_KEY && type != T_SIG && type != T_DNAME) { struct syslog_data sd = SYSLOG_DATA_INIT; syslog_r(LOG_NOTICE|LOG_AUTH, , "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", Index: src/lib/libc/net/gethnamaddr.c diff -u src/lib/libc/net/gethnamaddr.c:1.92 src/lib/libc/net/gethnamaddr.c:1.92.18.1 --- src/lib/libc/net/gethnamaddr.c:1.92 Tue Sep 22 16:16:02 2015 +++ src/lib/libc/net/gethnamaddr.c Sun Nov 29 11:25:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: gethnamaddr.c,v 1.92 2015/09/22 16:16:02 christos Exp $ */ +/* $NetBSD: gethnamaddr.c,v 1.92.18.1 2020/11/29 11:25:31 martin Exp $ */ /* * ++Copyright++ 1985, 1988, 1993 @@ -57,7 +57,7 @@ static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp "; #else -__RCSID("$NetBSD: gethnamaddr.c,v 1.92 2015/09/22 16:16:02 christos Exp $"); +__RCSID("$NetBSD: gethnamaddr.c,v 1.92.18.1 2020/11/29 11:25:31 martin Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -358,7 +358,7 @@ getanswer(const querybuf *answer, int an continue; } if (type != qtype) { - if (type != T_KEY && type != T_SIG) + if (type != T_KEY && type != T_SIG && type != T_DNAME) syslog(LOG_NOTICE|LOG_AUTH, "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", qname, p_class(C_IN), p_type(qtype),
CVS commit: [netbsd-8] src/doc
Module Name:src Committed By: martin Date: Sun Nov 29 11:20:10 UTC 2020 Modified Files: src/doc [netbsd-8]: CHANGES-8.3 Log Message: Ticket #1625 To generate a diff of this commit: cvs rdiff -u -r1.1.2.51 -r1.1.2.52 src/doc/CHANGES-8.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-8.3 diff -u src/doc/CHANGES-8.3:1.1.2.51 src/doc/CHANGES-8.3:1.1.2.52 --- src/doc/CHANGES-8.3:1.1.2.51 Thu Nov 19 11:28:09 2020 +++ src/doc/CHANGES-8.3 Sun Nov 29 11:20:09 2020 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-8.3,v 1.1.2.51 2020/11/19 11:28:09 martin Exp $ +# $NetBSD: CHANGES-8.3,v 1.1.2.52 2020/11/29 11:20:09 martin Exp $ A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3 release: @@ -1329,3 +1329,11 @@ libexec/httpd/bozohttpd.c 1.124 Fix httpd serving files greater than 4GB on 32bit archs. [hannken, ticket #1624] +include/arpa/nameser_compat.h 1.8 +lib/libc/net/getaddrinfo.c 1.120 +lib/libc/net/gethnamaddr.c 1.93 + + Don't complain about additional DNAME records received when resolving + A or . + [is, ticket #1625] +
CVS commit: [netbsd-8] src
Module Name:src Committed By: martin Date: Sun Nov 29 11:18:54 UTC 2020 Modified Files: src/include/arpa [netbsd-8]: nameser_compat.h src/lib/libc/net [netbsd-8]: getaddrinfo.c gethnamaddr.c Log Message: Pull up following revision(s) (requested by is in ticket #1625): lib/libc/net/getaddrinfo.c: revision 1.120 lib/libc/net/gethnamaddr.c: revision 1.93 include/arpa/nameser_compat.h: revision 1.8 Don't complain about additional DNAME records received when resolving A or (like already done for SIG/KEY and CNAME). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.6.8.1 src/include/arpa/nameser_compat.h cvs rdiff -u -r1.115.6.1 -r1.115.6.2 src/lib/libc/net/getaddrinfo.c cvs rdiff -u -r1.92 -r1.92.8.1 src/lib/libc/net/gethnamaddr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/include/arpa/nameser_compat.h diff -u src/include/arpa/nameser_compat.h:1.6 src/include/arpa/nameser_compat.h:1.6.8.1 --- src/include/arpa/nameser_compat.h:1.6 Tue Feb 24 17:57:08 2015 +++ src/include/arpa/nameser_compat.h Sun Nov 29 11:18:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nameser_compat.h,v 1.6 2015/02/24 17:57:08 christos Exp $ */ +/* $NetBSD: nameser_compat.h,v 1.6.8.1 2020/11/29 11:18:54 martin Exp $ */ /* Copyright (c) 1983, 1989 *The Regents of the University of California. All rights reserved. @@ -210,6 +210,7 @@ typedef struct { #define T_ATMA ns_t_atma #define T_NAPTR ns_t_naptr #define T_A6 ns_t_a6 +#define T_DNAME ns_t_dname #define T_TSIG ns_t_tsig #define T_IXFR ns_t_ixfr #define T_AXFR ns_t_axfr Index: src/lib/libc/net/getaddrinfo.c diff -u src/lib/libc/net/getaddrinfo.c:1.115.6.1 src/lib/libc/net/getaddrinfo.c:1.115.6.2 --- src/lib/libc/net/getaddrinfo.c:1.115.6.1 Wed Oct 25 06:56:41 2017 +++ src/lib/libc/net/getaddrinfo.c Sun Nov 29 11:18:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.115.6.1 2017/10/25 06:56:41 snj Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.115.6.2 2020/11/29 11:18:54 martin Exp $ */ /* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */ /* @@ -55,7 +55,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getaddrinfo.c,v 1.115.6.1 2017/10/25 06:56:41 snj Exp $"); +__RCSID("$NetBSD: getaddrinfo.c,v 1.115.6.2 2020/11/29 11:18:54 martin Exp $"); #endif /* LIBC_SCCS and not lint */ #ifndef RUMP_ACTION @@ -1814,7 +1814,7 @@ getanswer(res_state res, const querybuf continue; } } else if (type != qtype) { - if (type != T_KEY && type != T_SIG) { + if (type != T_KEY && type != T_SIG && type != T_DNAME) { struct syslog_data sd = SYSLOG_DATA_INIT; syslog_r(LOG_NOTICE|LOG_AUTH, , "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", Index: src/lib/libc/net/gethnamaddr.c diff -u src/lib/libc/net/gethnamaddr.c:1.92 src/lib/libc/net/gethnamaddr.c:1.92.8.1 --- src/lib/libc/net/gethnamaddr.c:1.92 Tue Sep 22 16:16:02 2015 +++ src/lib/libc/net/gethnamaddr.c Sun Nov 29 11:18:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: gethnamaddr.c,v 1.92 2015/09/22 16:16:02 christos Exp $ */ +/* $NetBSD: gethnamaddr.c,v 1.92.8.1 2020/11/29 11:18:54 martin Exp $ */ /* * ++Copyright++ 1985, 1988, 1993 @@ -57,7 +57,7 @@ static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp "; #else -__RCSID("$NetBSD: gethnamaddr.c,v 1.92 2015/09/22 16:16:02 christos Exp $"); +__RCSID("$NetBSD: gethnamaddr.c,v 1.92.8.1 2020/11/29 11:18:54 martin Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -358,7 +358,7 @@ getanswer(const querybuf *answer, int an continue; } if (type != qtype) { - if (type != T_KEY && type != T_SIG) + if (type != T_KEY && type != T_SIG && type != T_DNAME) syslog(LOG_NOTICE|LOG_AUTH, "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", qname, p_class(C_IN), p_type(qtype),
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 11:17:41 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): make documentation of CachedDir.refCount more precise To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.233 src/usr.bin/make/dir.c:1.234 --- src/usr.bin/make/dir.c:1.233 Sun Nov 29 10:57:16 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 11:17:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.233 2020/11/29 10:57:16 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.234 2020/11/29 11:17:41 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.233 2020/11/29 10:57:16 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.234 2020/11/29 11:17:41 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -225,6 +225,7 @@ struct CachedDir { /* * The number of SearchPaths that refer to this directory. * Plus the number of global variables that refer to this directory. + * References from openDirs do not count though. * * TODO: Check the reference counting; see Dir_Expand, partPath. */ @@ -1521,6 +1522,7 @@ Dir_AddDir(SearchPath *path, const char (void)HashSet_Add(>files, dp->d_name); } (void)closedir(d); + OpenDirs_Add(, dir); if (path != NULL) Lst_Append(path, dir);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 10:57:16 UTC 2020 Modified Files: src/usr.bin/make: dir.c src/usr.bin/make/unit-tests: Makefile Log Message: make(1): add debug logging for reference counting of CachedDir To generate a diff of this commit: cvs rdiff -u -r1.232 -r1.233 src/usr.bin/make/dir.c cvs rdiff -u -r1.226 -r1.227 src/usr.bin/make/unit-tests/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/dir.c diff -u src/usr.bin/make/dir.c:1.232 src/usr.bin/make/dir.c:1.233 --- src/usr.bin/make/dir.c:1.232 Sun Nov 29 09:51:39 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 10:57:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.232 2020/11/29 09:51:39 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.233 2020/11/29 10:57:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.232 2020/11/29 09:51:39 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.233 2020/11/29 10:57:16 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -223,9 +223,10 @@ struct CachedDir { char *name; /* - * The number of SearchPaths with this directory. + * The number of SearchPaths that refer to this directory. + * Plus the number of global variables that refer to this directory. * - * TODO: Log the reference counting; see Dir_Expand, partPath. + * TODO: Check the reference counting; see Dir_Expand, partPath. */ int refCount; @@ -287,6 +288,37 @@ static HashTable lmtimes; /* same as mti static void CachedDir_Destroy(CachedDir *); +static CachedDir * +CachedDir_New(const char *name) +{ + CachedDir *dir = bmake_malloc(sizeof *dir); + + dir->name = bmake_strdup(name); + dir->refCount = 0; + dir->hits = 0; + HashSet_Init(>files); + + return dir; +} + +static CachedDir * +CachedDir_Ref(CachedDir *dir) +{ + dir->refCount++; + DEBUG2(DIR, "CachedDir refCount++ to %d for \"%s\"\n", + dir->refCount, dir->name); + return dir; +} + +static CachedDir * +CachedDir_Unref(CachedDir *dir) +{ + dir->refCount--; + DEBUG2(DIR, "CachedDir refCount-- to %d for \"%s\"\n", + dir->refCount, dir->name); + return dir; +} + static void OpenDirs_Init(OpenDirs *odirs) { @@ -408,11 +440,7 @@ Dir_InitDir(const char *cdname) { Dir_InitCur(cdname); - dotLast = bmake_malloc(sizeof *dotLast); - dotLast->refCount = 1; - dotLast->hits = 0; - dotLast->name = bmake_strdup(".DOTLAST"); - HashSet_Init(>files); + dotLast = CachedDir_Ref(CachedDir_New(".DOTLAST")); } /* @@ -439,27 +467,29 @@ Dir_InitCur(const char *cdname) * its reference count increases each time even though the number of * actual references stays the same. */ - dir->refCount++; + CachedDir_Ref(dir); /* XXX: This can be expressed clearer. */ if (cur != NULL && cur != dir) { /* * We've been here before, clean up. */ - cur->refCount--; + CachedDir_Unref(cur); /* XXX: why unref twice? */ CachedDir_Destroy(cur); } cur = dir; } /* (Re)initialize "dot" (current/object directory) path hash. - * Some directories may be opened. */ + * Some directories may be cached. */ void Dir_InitDot(void) { if (dot != NULL) { /* Remove old entry from openDirs, but do not destroy. */ + /* XXX: Why not destroy? It's reference-counted after all. */ OpenDirs_Remove(, dot->name); } + /* XXX: Before assigning to the global variable, refCount++. */ dot = Dir_AddDir(NULL, "."); if (dot == NULL) { @@ -471,7 +501,13 @@ Dir_InitDot(void) * We always need to have dot around, so we increment its reference * count to make sure it's not destroyed. */ - dot->refCount++; + /* + * XXX: This is just the normal reference counting. Why is the above + * comment so long? And why doesn't the normal reference counting + * suffice? This sounds like someone misunderstood reference counting + * here. + */ + CachedDir_Ref(dot); Dir_SetPATH(); /* initialize */ } @@ -481,12 +517,12 @@ Dir_End(void) { #ifdef CLEANUP if (cur != NULL) { - cur->refCount--; + CachedDir_Unref(cur); /* XXX: why unref twice? */ CachedDir_Destroy(cur); } - dot->refCount--; - dotLast->refCount--; + CachedDir_Unref(dotLast); /* XXX: why unref twice? */ CachedDir_Destroy(dotLast); + CachedDir_Unref(dot); /* XXX: why unref twice? */ CachedDir_Destroy(dot); SearchPath_Clear(); OpenDirs_Done(); @@ -1454,28 +1490,23 @@ Dir_AddDir(SearchPath *path, const char return pathDir; } - dotLast->refCount++; + CachedDir_Ref(dotLast); Lst_Prepend(path, dotLast); } if (path != NULL) dir = OpenDirs_Find(, name); if (dir != NULL) { - if (Lst_FindDatum(path, dir) == NULL) { - dir->refCount++; - Lst_Append(path, dir); - } + if (Lst_FindDatum(path, dir) == NULL) +
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 09:51:39 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): normalize order of declarations in dir.c To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.231 src/usr.bin/make/dir.c:1.232 --- src/usr.bin/make/dir.c:1.231 Sun Nov 29 09:42:54 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 09:51:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.231 2020/11/29 09:42:54 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.232 2020/11/29 09:51:39 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.231 2020/11/29 09:42:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.232 2020/11/29 09:51:39 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -209,10 +209,6 @@ MAKE_RCSID("$NetBSD: dir.c,v 1.231 2020/ * the mtime in a cache for when Dir_UpdateMTime was actually called. */ -typedef List CachedDirList; -typedef ListNode CachedDirListNode; - -typedef ListNode SearchPathNode; /* A cache for the filenames in a directory. */ struct CachedDir { @@ -240,7 +236,10 @@ struct CachedDir { HashSet files; }; -SearchPath dirSearchPath = LST_INIT; /* main search path */ +typedef List CachedDirList; +typedef ListNode CachedDirListNode; + +typedef ListNode SearchPathNode; /* A list of cached directories, with fast lookup by directory name. */ typedef struct OpenDirs { @@ -248,6 +247,46 @@ typedef struct OpenDirs { HashTable /* of CachedDirListNode */ table; } OpenDirs; +typedef enum CachedStatsFlags { + CST_NONE = 0, + CST_LSTAT = 1 << 0, /* call lstat(2) instead of stat(2) */ + CST_UPDATE = 1 << 1 /* ignore existing cached entry */ +} CachedStatsFlags; + + +SearchPath dirSearchPath = LST_INIT; /* main search path */ + +static OpenDirs openDirs; /* all cached directories */ + +/* + * Variables for gathering statistics on the efficiency of the caching + * mechanism. + */ +static int hits; /* Found in directory cache */ +static int misses; /* Sad, but not evil misses */ +static int nearmisses; /* Found under search path */ +static int bigmisses; /* Sought by itself */ + +static CachedDir *dot; /* contents of current directory */ +static CachedDir *cur; /* contents of current directory, if not dot */ +static CachedDir *dotLast; /* a fake path entry indicating we need to + * look for . last */ + +/* Results of doing a last-resort stat in Dir_FindFile -- if we have to go to + * the system to find the file, we might as well have its mtime on record. + * + * XXX: If this is done way early, there's a chance other rules will have + * already updated the file, in which case we'll update it again. Generally, + * there won't be two rules to update a single file, so this should be ok, + * but... */ +static HashTable mtimes; + +static HashTable lmtimes; /* same as mtimes but for lstat */ + + +static void CachedDir_Destroy(CachedDir *); + + static void OpenDirs_Init(OpenDirs *odirs) { @@ -255,8 +294,6 @@ OpenDirs_Init(OpenDirs *odirs) HashTable_Init(>table); } -static void CachedDir_Destroy(CachedDir *); - #ifdef CLEANUP static void OpenDirs_Done(OpenDirs *odirs) @@ -301,39 +338,6 @@ OpenDirs_Remove(OpenDirs *odirs, const c Lst_Remove(>list, ln); } -static OpenDirs openDirs; /* all cached directories */ - -/* - * Variables for gathering statistics on the efficiency of the caching - * mechanism. - */ -static int hits; /* Found in directory cache */ -static int misses; /* Sad, but not evil misses */ -static int nearmisses; /* Found under search path */ -static int bigmisses; /* Sought by itself */ - -static CachedDir *dot; /* contents of current directory */ -static CachedDir *cur; /* contents of current directory, if not dot */ -static CachedDir *dotLast; /* a fake path entry indicating we need to - * look for . last */ - -/* Results of doing a last-resort stat in Dir_FindFile -- if we have to go to - * the system to find the file, we might as well have its mtime on record. - * - * XXX: If this is done way early, there's a chance other rules will have - * already updated the file, in which case we'll update it again. Generally, - * there won't be two rules to update a single file, so this should be ok, - * but... */ -static HashTable mtimes; - -static HashTable lmtimes; /* same as mtimes but for lstat */ - -typedef enum CachedStatsFlags { - CST_NONE = 0, - CST_LSTAT = 1 << 0, /* call lstat(2) instead of stat(2) */ - CST_UPDATE = 1 << 1 /* ignore existing cached entry */ -} CachedStatsFlags; - /* Returns 0 and the result of stat(2) or lstat(2) in *out_cst, *
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 09:42:54 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): remove comment about returning const The callers modify the reference count of the CachedDir, therefore it must be modifiable. To generate a diff of this commit: cvs rdiff -u -r1.230 -r1.231 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.230 src/usr.bin/make/dir.c:1.231 --- src/usr.bin/make/dir.c:1.230 Sun Nov 29 09:38:04 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 09:42:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.230 2020/11/29 09:38:04 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.231 2020/11/29 09:42:54 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.230 2020/11/29 09:38:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.231 2020/11/29 09:42:54 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -1435,10 +1435,6 @@ Dir_UpdateMTime(GNode *gn, Boolean reche */ CachedDir * Dir_AddDir(SearchPath *path, const char *name) -/* - * XXX: Maybe return const CachedDir, as a hint that the return value must - * not be freed since it is owned by openDirs. - */ { CachedDir *dir = NULL; /* the added directory */ DIR *d; @@ -1554,12 +1550,7 @@ SearchPath_ToFlags(const char *flag, Sea return Buf_Destroy(, FALSE); } -/* Nuke a directory descriptor, if possible. Callback procedure for the - * suffixes module when destroying a search path. - * - * Input: - * dirp The directory descriptor to nuke - */ +/* Nuke a directory descriptor, if it is no longer used. */ static void CachedDir_Destroy(CachedDir *dir) {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 09:38:04 UTC 2020 Modified Files: src/usr.bin/make: dir.c Log Message: make(1): rename Dir_Destroy to CachedDir_Destroy It is no longer exported by the Dir module. To generate a diff of this commit: cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.229 src/usr.bin/make/dir.c:1.230 --- src/usr.bin/make/dir.c:1.229 Sun Nov 29 08:48:24 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 09:38:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.229 2020/11/29 08:48:24 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.230 2020/11/29 09:38:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.229 2020/11/29 08:48:24 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.230 2020/11/29 09:38:04 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -255,7 +255,7 @@ OpenDirs_Init(OpenDirs *odirs) HashTable_Init(>table); } -static void Dir_Destroy(CachedDir *); +static void CachedDir_Destroy(CachedDir *); #ifdef CLEANUP static void @@ -265,7 +265,7 @@ OpenDirs_Done(OpenDirs *odirs) while (ln != NULL) { CachedDirListNode *next = ln->next; CachedDir *dir = ln->datum; - Dir_Destroy(dir); /* removes the dir from odirs->list */ + CachedDir_Destroy(dir); /* removes the dir from odirs->list */ ln = next; } Lst_Done(>list); @@ -441,7 +441,7 @@ Dir_InitCur(const char *cdname) * We've been here before, clean up. */ cur->refCount--; - Dir_Destroy(cur); + CachedDir_Destroy(cur); } cur = dir; } @@ -478,12 +478,12 @@ Dir_End(void) #ifdef CLEANUP if (cur != NULL) { cur->refCount--; - Dir_Destroy(cur); + CachedDir_Destroy(cur); } dot->refCount--; dotLast->refCount--; - Dir_Destroy(dotLast); - Dir_Destroy(dot); + CachedDir_Destroy(dotLast); + CachedDir_Destroy(dot); SearchPath_Clear(); OpenDirs_Done(); HashTable_Done(); @@ -1561,7 +1561,7 @@ SearchPath_ToFlags(const char *flag, Sea * dirp The directory descriptor to nuke */ static void -Dir_Destroy(CachedDir *dir) +CachedDir_Destroy(CachedDir *dir) { dir->refCount--; @@ -1582,7 +1582,7 @@ SearchPath_Free(SearchPath *path) for (ln = path->first; ln != NULL; ln = ln->next) { CachedDir *dir = ln->datum; - Dir_Destroy(dir); + CachedDir_Destroy(dir); } Lst_Free(path); } @@ -1594,7 +1594,7 @@ SearchPath_Clear(SearchPath *path) { while (!Lst_IsEmpty(path)) { CachedDir *dir = Lst_Dequeue(path); - Dir_Destroy(dir); + CachedDir_Destroy(dir); } }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 09:27:40 UTC 2020 Modified Files: src/usr.bin/make: config.h dir.h hash.h job.c job.h make.h meta.c pathnames.h src/usr.bin/make/filemon: filemon.h filemon_dev.c filemon_ktrace.c Log Message: make(1): use space instead of tab for preprocessor directives To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/config.h cvs rdiff -u -r1.38 -r1.39 src/usr.bin/make/dir.h cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/hash.h cvs rdiff -u -r1.333 -r1.334 src/usr.bin/make/job.c cvs rdiff -u -r1.63 -r1.64 src/usr.bin/make/job.h cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/make.h cvs rdiff -u -r1.153 -r1.154 src/usr.bin/make/meta.c cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/pathnames.h cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/filemon/filemon.h cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/filemon/filemon_dev.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/filemon/filemon_ktrace.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/config.h diff -u src/usr.bin/make/config.h:1.25 src/usr.bin/make/config.h:1.26 --- src/usr.bin/make/config.h:1.25 Mon Oct 19 23:43:55 2020 +++ src/usr.bin/make/config.h Sun Nov 29 09:27:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: config.h,v 1.25 2020/10/19 23:43:55 rillig Exp $ */ +/* $NetBSD: config.h,v 1.26 2020/11/29 09:27:40 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -104,7 +104,7 @@ * Is the suffix used to denote libraries and is used by the Suff module * to find the search path on which to seek any -l targets. */ -#define LIBSUFF ".a" +#define LIBSUFF ".a" /* * RECHECK @@ -119,7 +119,7 @@ * On systems that don't have this problem, you should define this. * Under NFS you probably should not, unless you aren't exporting jobs. */ -#define RECHECK +#define RECHECK /* * POSIX Index: src/usr.bin/make/dir.h diff -u src/usr.bin/make/dir.h:1.38 src/usr.bin/make/dir.h:1.39 --- src/usr.bin/make/dir.h:1.38 Sun Nov 29 08:48:24 2020 +++ src/usr.bin/make/dir.h Sun Nov 29 09:27:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.h,v 1.38 2020/11/29 08:48:24 rillig Exp $ */ +/* $NetBSD: dir.h,v 1.39 2020/11/29 09:27:40 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -72,8 +72,8 @@ * from: @(#)dir.h 8.1 (Berkeley) 6/6/93 */ -#ifndef MAKE_DIR_H -#define MAKE_DIR_H +#ifndef MAKE_DIR_H +#define MAKE_DIR_H typedef struct CachedDir CachedDir; @@ -98,8 +98,8 @@ SearchPath *Dir_CopyDirSearchPath(void); /* Stripped-down variant of struct stat. */ struct cached_stat { -time_t cst_mtime; -mode_t cst_mode; + time_t cst_mtime; + mode_t cst_mode; }; int cached_lstat(const char *, struct cached_stat *); Index: src/usr.bin/make/hash.h diff -u src/usr.bin/make/hash.h:1.36 src/usr.bin/make/hash.h:1.37 --- src/usr.bin/make/hash.h:1.36 Mon Nov 23 18:24:05 2020 +++ src/usr.bin/make/hash.h Sun Nov 29 09:27:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.h,v 1.36 2020/11/23 18:24:05 rillig Exp $ */ +/* $NetBSD: hash.h,v 1.37 2020/11/29 09:27:40 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -74,8 +74,8 @@ /* Hash tables with strings as keys and arbitrary pointers as values. */ -#ifndef MAKE_HASH_H -#define MAKE_HASH_H +#ifndef MAKE_HASH_H +#define MAKE_HASH_H /* A single key-value entry in the hash table. */ typedef struct HashEntry { Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.333 src/usr.bin/make/job.c:1.334 --- src/usr.bin/make/job.c:1.333 Sat Nov 28 19:12:28 2020 +++ src/usr.bin/make/job.c Sun Nov 29 09:27:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.333 2020/11/28 19:12:28 rillig Exp $ */ +/* $NetBSD: job.c,v 1.334 2020/11/29 09:27:40 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -143,7 +143,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.333 2020/11/28 19:12:28 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.334 2020/11/29 09:27:40 rillig Exp $"); /* A shell defines how the commands are run. All commands for a target are * written into a single file, which is then given to the shell to execute @@ -395,8 +395,8 @@ static char *targPrefix = NULL; /* What static Job tokenWaitJob; /* token wait pseudo-job */ static Job childExitJob; /* child exit pseudo-job */ -#define CHILD_EXIT "." -#define DO_JOB_RESUME "R" +#define CHILD_EXIT "." +#define DO_JOB_RESUME "R" enum { npseudojobs = 2 }; /* number of pseudo-jobs */ Index: src/usr.bin/make/job.h diff -u src/usr.bin/make/job.h:1.63 src/usr.bin/make/job.h:1.64 --- src/usr.bin/make/job.h:1.63 Sat Nov 14 13:27:01 2020 +++ src/usr.bin/make/job.h Sun Nov 29 09:27:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.h,v
CVS commit: src/share/misc
Module Name:src Committed By: rillig Date: Sun Nov 29 09:15:33 UTC 2020 Modified Files: src/share/misc: style Log Message: style: fix typo To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/share/misc/style Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/misc/style diff -u src/share/misc/style:1.59 src/share/misc/style:1.60 --- src/share/misc/style:1.59 Sun Aug 2 01:36:46 2020 +++ src/share/misc/style Sun Nov 29 09:15:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: style,v 1.59 2020/08/02 01:36:46 riastradh Exp $ */ +/* $NetBSD: style,v 1.60 2020/11/29 09:15:33 rillig Exp $ */ /* * The revision control tag appears first, with a blank line after it. @@ -30,7 +30,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: style,v 1.59 2020/08/02 01:36:46 riastradh Exp $"); +__RCSID("$NetBSD: style,v 1.60 2020/11/29 09:15:33 rillig Exp $"); /* * VERY important single-line comments look like this. @@ -86,7 +86,7 @@ __RCSID("$NetBSD: style,v 1.59 2020/08/0 /* * If it's a network program, put the network include files next. - * Group the includes files by subdirectory. + * Group the include files by subdirectory. */ #include #include
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 29 08:48:24 UTC 2020 Modified Files: src/usr.bin/make: dir.c dir.h Log Message: make(1): unexport CachedDir internals To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/usr.bin/make/dir.c cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/dir.h 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/dir.c diff -u src/usr.bin/make/dir.c:1.228 src/usr.bin/make/dir.c:1.229 --- src/usr.bin/make/dir.c:1.228 Sun Nov 29 01:40:26 2020 +++ src/usr.bin/make/dir.c Sun Nov 29 08:48:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.228 2020/11/29 01:40:26 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.229 2020/11/29 08:48:24 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.228 2020/11/29 01:40:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.229 2020/11/29 08:48:24 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -214,6 +214,32 @@ typedef ListNode CachedDirListNode; typedef ListNode SearchPathNode; +/* A cache for the filenames in a directory. */ +struct CachedDir { + /* + * Name of directory, either absolute or relative to the current + * directory. The name is not normalized in any way, that is, "." + * and "./." are different. + * + * Not sure what happens when .CURDIR is assigned a new value; see + * Parse_DoVar. + */ + char *name; + + /* + * The number of SearchPaths with this directory. + * + * TODO: Log the reference counting; see Dir_Expand, partPath. + */ + int refCount; + + /* The number of times a file in this directory has been found. */ + int hits; + + /* The names of the files in the directory. */ + HashSet files; +}; + SearchPath dirSearchPath = LST_INIT; /* main search path */ /* A list of cached directories, with fast lookup by directory name. */ Index: src/usr.bin/make/dir.h diff -u src/usr.bin/make/dir.h:1.37 src/usr.bin/make/dir.h:1.38 --- src/usr.bin/make/dir.h:1.37 Sat Nov 28 22:56:01 2020 +++ src/usr.bin/make/dir.h Sun Nov 29 08:48:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.h,v 1.37 2020/11/28 22:56:01 rillig Exp $ */ +/* $NetBSD: dir.h,v 1.38 2020/11/29 08:48:24 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -75,21 +75,7 @@ #ifndef MAKE_DIR_H #define MAKE_DIR_H -/* A cache for the filenames in a directory. */ -typedef struct CachedDir { -char *name; /* Name of directory, either absolute or - * relative to the current directory. - * The name is not normalized in any way, - * that is, "." and "./." are different. - * - * Not sure what happens when .CURDIR is - * assigned a new value; see Parse_DoVar. */ -int refCount; /* Number of SearchPaths with this directory */ -/* TODO: Log the reference counting; see Dir_Expand, partPath. */ -int hits; /* The number of times a file in this - * directory has been found */ -HashSet files; /* The files in the directory. */ -} CachedDir; +typedef struct CachedDir CachedDir; void Dir_Init(void); void Dir_InitDir(const char *);