CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 23:16:29 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): replace strcpy with memcpy in Hash_CreateEntry The string length is already known, no need to recalculate it. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/hash.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/hash.c diff -u src/usr.bin/make/hash.c:1.37 src/usr.bin/make/hash.c:1.38 --- src/usr.bin/make/hash.c:1.37 Sat Oct 3 22:33:26 2020 +++ src/usr.bin/make/hash.c Sat Oct 3 23:16:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.37 2020/10/03 22:33:26 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.38 2020/10/03 23:16:28 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -79,7 +79,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.37 2020/10/03 22:33:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.38 2020/10/03 23:16:28 rillig Exp $"); /* * Forward references to local procedures that are used before they're @@ -243,7 +243,7 @@ Hash_CreateEntry(Hash_Table *t, const ch *hp = e; Hash_SetValue(e, NULL); e->namehash = h; - (void)strcpy(e->name, key); + memcpy(e->name, key, keylen + 1); t->numEntries++; if (newPtr != NULL)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 22:33:26 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): remove unnecessary code from Hash_DeleteEntry This function is only called 2 times, and both callers pass valid arguments. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/hash.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/hash.c diff -u src/usr.bin/make/hash.c:1.36 src/usr.bin/make/hash.c:1.37 --- src/usr.bin/make/hash.c:1.36 Sat Oct 3 22:25:04 2020 +++ src/usr.bin/make/hash.c Sat Oct 3 22:33:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.36 2020/10/03 22:25:04 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.37 2020/10/03 22:33:26 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -79,7 +79,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.36 2020/10/03 22:25:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.37 2020/10/03 22:33:26 rillig Exp $"); /* * Forward references to local procedures that are used before they're @@ -257,8 +257,6 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Ent { Hash_Entry **hp, *p; - if (e == NULL) - return; for (hp = >buckets[e->namehash & t->bucketsMask]; (p = *hp) != NULL; hp = >next) { if (p == e) { @@ -268,7 +266,6 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Ent return; } } - (void)write(2, "bad call to Hash_DeleteEntry\n", 29); abort(); }
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Oct 3 22:32:50 UTC 2020 Modified Files: src/sys/dev/ata: ata.c src/sys/kern: subr_autoconf.c src/sys/sys: device.h Log Message: autoconf: Blame devices holding up boot with config_pending. Blame message requires `boot -x' (AB_DEBUG). Fix ata so it doesn't mismatch config_pending_incr/decr devices. To generate a diff of this commit: cvs rdiff -u -r1.159 -r1.160 src/sys/dev/ata/ata.c cvs rdiff -u -r1.273 -r1.274 src/sys/kern/subr_autoconf.c cvs rdiff -u -r1.157 -r1.158 src/sys/sys/device.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/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.159 src/sys/dev/ata/ata.c:1.160 --- src/sys/dev/ata/ata.c:1.159 Mon May 25 19:05:30 2020 +++ src/sys/dev/ata/ata.c Sat Oct 3 22:32:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.159 2020/05/25 19:05:30 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.160 2020/10/03 22:32:50 riastradh Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.159 2020/05/25 19:05:30 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.160 2020/10/03 22:32:50 riastradh Exp $"); #include "opt_ata.h" @@ -298,7 +298,7 @@ atabusconfig(struct atabus_softc *atabus ata_delref(chp); - config_pending_decr(atac->atac_dev); + config_pending_decr(atabus_sc->sc_dev); } /* @@ -424,7 +424,7 @@ atabusconfig_thread(void *arg) ata_delref(chp); - config_pending_decr(atac->atac_dev); + config_pending_decr(atabus_sc->sc_dev); kthread_exit(0); } Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.273 src/sys/kern/subr_autoconf.c:1.274 --- src/sys/kern/subr_autoconf.c:1.273 Sat Aug 1 11:18:26 2020 +++ src/sys/kern/subr_autoconf.c Sat Oct 3 22:32:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.273 2020/08/01 11:18:26 jdolecek Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.274 2020/10/03 22:32:50 riastradh Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.273 2020/08/01 11:18:26 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.274 2020/10/03 22:32:50 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -224,7 +224,8 @@ static int alldevs_nread = 0; static int alldevs_nwrite = 0; static bool alldevs_garbage = false; -static int config_pending; /* semaphore for mountroot */ +static struct devicelist config_pending = +TAILQ_HEAD_INITIALIZER(config_pending); static kmutex_t config_misc_lock; static kcondvar_t config_misc_cv; @@ -2095,9 +2096,12 @@ config_pending_incr(device_t dev) { mutex_enter(_misc_lock); - config_pending++; + KASSERTMSG(dev->dv_pending < INT_MAX, + "%s: excess config_pending_incr", device_xname(dev)); + if (dev->dv_pending++ == 0) + TAILQ_INSERT_TAIL(_pending, dev, dv_pending_list); #ifdef DEBUG_AUTOCONF - printf("%s: %s %d\n", __func__, device_xname(dev), config_pending); + printf("%s: %s %d\n", __func__, device_xname(dev), dev->dv_pending); #endif mutex_exit(_misc_lock); } @@ -2106,13 +2110,15 @@ void config_pending_decr(device_t dev) { - KASSERT(0 < config_pending); mutex_enter(_misc_lock); - config_pending--; + KASSERTMSG(dev->dv_pending > 0, + "%s: excess config_pending_decr", device_xname(dev)); + if (--dev->dv_pending == 0) + TAILQ_REMOVE(_pending, dev, dv_pending_list); #ifdef DEBUG_AUTOCONF - printf("%s: %s %d\n", __func__, device_xname(dev), config_pending); + printf("%s: %s %d\n", __func__, device_xname(dev), dev->dv_pending); #endif - if (config_pending == 0) + if (TAILQ_EMPTY(_pending)) cv_broadcast(_misc_cv); mutex_exit(_misc_lock); } @@ -2165,8 +2171,12 @@ config_finalize(void) * them to finish any deferred autoconfiguration. */ mutex_enter(_misc_lock); - while (config_pending != 0) + while (!TAILQ_EMPTY(_pending)) { + device_t dev; + TAILQ_FOREACH(dev, _pending, dv_pending_list) + aprint_debug_dev(dev, "holding up boot\n"); cv_wait(_misc_cv, _misc_lock); + } mutex_exit(_misc_lock); KERNEL_LOCK(1, NULL); Index: src/sys/sys/device.h diff -u src/sys/sys/device.h:1.157 src/sys/sys/device.h:1.158 --- src/sys/sys/device.h:1.157 Sat Dec 1 01:51:38 2018 +++ src/sys/sys/device.h Sat Oct 3 22:32:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.157 2018/12/01 01:51:38 msaitoh Exp $ */ +/* $NetBSD: device.h,v 1.158 2020/10/03 22:32:50 riastradh Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -165,6 +165,9 @@ struct device { int *dv_locators; /* our actual locators (optional) */ prop_dictionary_t dv_properties;/* properties dictionary */ + int dv_pending; /* config_pending count */ + TAILQ_ENTRY(device) dv_pending_list; + size_t dv_activity_count; void
CVS commit: src/games/factor
Module Name:src Committed By: christos Date: Sat Oct 3 22:27:00 UTC 2020 Modified Files: src/games/factor: factor.6 factor.c Log Message: PR/55693: Andreas Gustafsson: factor(6) lists factors in wrong order Sync with FreeBSD and change their -h (that printed hex) to -x because we were already using -h. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/games/factor/factor.6 cvs rdiff -u -r1.29 -r1.30 src/games/factor/factor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/factor/factor.6 diff -u src/games/factor/factor.6:1.14 src/games/factor/factor.6:1.15 --- src/games/factor/factor.6:1.14 Sat Nov 11 18:48:44 2017 +++ src/games/factor/factor.6 Sat Oct 3 18:27:00 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: factor.6,v 1.14 2017/11/11 23:48:44 rin Exp $ +.\" $NetBSD: factor.6,v 1.15 2020/10/03 22:27:00 christos Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. @@ -35,7 +35,7 @@ .\" .\" By Landon Curt Noll, http://www.isthe.com/chongo/index.html /\oo/\ .\" -.Dd Nov 12, 2017 +.Dd October 3, 2020 .Dt FACTOR 6 .Os .Sh NAME @@ -43,7 +43,7 @@ .Nd factor a number .Sh SYNOPSIS .Nm -.Op Fl h +.Op Fl hx .Op Ar number ... .Sh DESCRIPTION The @@ -98,6 +98,10 @@ If the .Fl h flag is specified, factors will be printed in "human-readable" format. If a factor x divides a value n (>1) times, it will appear as x^n. +.It Fl x +If the +.Fl x +flag is specified, factors will be printed int hexadecimal format. .El .Sh DIAGNOSTICS Out of range or invalid input results in Index: src/games/factor/factor.c diff -u src/games/factor/factor.c:1.29 src/games/factor/factor.c:1.30 --- src/games/factor/factor.c:1.29 Tue Feb 6 11:53:27 2018 +++ src/games/factor/factor.c Sat Oct 3 18:27:00 2020 @@ -1,5 +1,4 @@ -/* $NetBSD: factor.c,v 1.29 2018/02/06 16:53:27 christos Exp $ */ - +/* $NetBSD: factor.c,v 1.30 2020/10/03 22:27:00 christos Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -32,29 +31,34 @@ * SUCH DAMAGE. */ -#include #ifndef lint +#include +#ifdef __COPYRIGHT __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ - The Regents of the University of California. All rights reserved."); -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95"; -#else -__RCSID("$NetBSD: factor.c,v 1.29 2018/02/06 16:53:27 christos Exp $"); + The Regents of the University of California. All rights reserved."); +#endif +#ifdef __SCCSID +__SCCSID("@(#)factor.c 8.4 (Berkeley) 5/4/95"); +#endif +#ifdef __RCSID +__RCSID("$NetBSD: factor.c,v 1.30 2020/10/03 22:27:00 christos Exp $"); +#endif +#ifdef __FBSDID +__FBSDID("$FreeBSD: head/usr.bin/factor/factor.c 35 2020-01-12 20:25:11Z gad $"); #endif #endif /* not lint */ /* * factor - factor a number into primes * - * By Landon Curt Noll, http://www.isthe.com/chongo/index.html /\oo/\ + * By: Landon Curt Noll cho...@toad.com, ...!{sun,tolsoft}!hoptoad!chongo + * + * chongo /\oo/\ * * usage: - * factor [-h] [number] ... + * factor [-hx] [number] ... * - * By Default, the form of the output is: + * The form of the output is: * * number: factor1 factor1 factor2 factor3 factor3 factor3 ... * @@ -63,93 +67,80 @@ __RCSID("$NetBSD: factor.c,v 1.29 2018/0 * If the -h flag is specified, the output is in "human-readable" format. * Duplicate factors are printed in the form of x^n. * + * If the -x flag is specified numbers are printed in hex. + * * If no number args are given, the list of numbers are read from stdin. + * If no args are given, the list of numbers are read from stdin. */ #include #include #include +#include #include +#include #include #include #include -#include + +#include "primes.h" #ifdef HAVE_OPENSSL + #include + +#define PRIME_CHECKS 5 + +static void pollard_pminus1(BIGNUM *, int); /* print factors for big numbers */ + #else + typedef long BIGNUM; typedef u_long BN_ULONG; -static int BN_dec2bn(BIGNUM **a, const char *str); + +#define BN_CTX int +#define BN_CTX_new() NULL #define BN_new() ((BIGNUM *)calloc(sizeof(BIGNUM), 1)) #define BN_is_zero(v) (*(v) == 0) #define BN_is_one(v) (*(v) == 1) #define BN_mod_word(a, b) (*(a) % (b)) -#endif - -#include "primes.h" -/* - * prime[i] is the (i-1)th prime. - * - * We are able to sieve 2^32-1 because this byte table yields all primes - * up to 65537 and 65537^2 > 2^32-1. - */ - -#if 0 /* debugging: limit table use to stress the "pollard" code */ -#define pr_limit [0] -#endif - -#define PRIME_CHECKS 5 - -#ifdef HAVE_OPENSSL -static BN_CTX *ctx; /* just use a global context */ -#endif - -static void pr_fact(BIGNUM *, int); /* print factors of a value */ -static void BN_print_dec_fp(FILE *, const BIGNUM *); -static void usage(void) __dead; -#ifdef
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 22:25:05 UTC 2020 Modified Files: src/usr.bin/make: hash.c Log Message: make(1): clean up hash table implementation Having the hash function potentially redefined is a bit too much flexibility. If actually needed, this should be done using a patch, not using the C preprocessor. Converting the macro to a function made the control flow easier to understand. It also revealed that the variable p was unnecessary in both Hash_FindEntry and Hash_CreateEntry. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/hash.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/hash.c diff -u src/usr.bin/make/hash.c:1.35 src/usr.bin/make/hash.c:1.36 --- src/usr.bin/make/hash.c:1.35 Mon Sep 28 20:46:11 2020 +++ src/usr.bin/make/hash.c Sat Oct 3 22:25:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.35 2020/09/28 20:46:11 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.36 2020/10/03 22:25:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -79,7 +79,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.35 2020/09/28 20:46:11 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.36 2020/10/03 22:25:04 rillig Exp $"); /* * Forward references to local procedures that are used before they're @@ -95,22 +95,20 @@ static void RebuildTable(Hash_Table *); #define rebuildLimit 3 -/* The hash function(s) */ - -#ifndef HASH -/* The default: this one matches Gosling's emacs */ -#define HASH(h, key, p) do { \ - for (h = 0, p = key; *p;) \ - h = (h << 5) - h + (unsigned char)*p++; \ - } while (0) - -#endif +/* This hash function matches Gosling's emacs. */ +static unsigned int +hash(const char *key, size_t *out_keylen) +{ + unsigned h = 0; + const char *p = key; + while (*p != '\0') + h = (h << 5) - h + (unsigned char)*p++; + if (out_keylen != NULL) + *out_keylen = (size_t)(p - key); + return h; +} -/* Sets up the hash table. - * - * Input: - * t Structure to to hold the table. - */ +/* Sets up the hash table. */ void Hash_InitTable(Hash_Table *t) { @@ -164,21 +162,19 @@ Hash_FindEntry(Hash_Table *t, const char { Hash_Entry *e; unsigned h; - const char *p; int chainlen; - if (t == NULL || t->buckets == NULL) { + if (t == NULL || t->buckets == NULL) return NULL; - } - HASH(h, key, p); - p = key; + + h = hash(key, NULL); chainlen = 0; #ifdef DEBUG_HASH_LOOKUP DEBUG4(HASH, "%s: %p h=%x key=%s\n", __func__, t, h, key); #endif for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) { chainlen++; - if (e->namehash == h && strcmp(e->name, p) == 0) + if (e->namehash == h && strcmp(e->name, key) == 0) break; } if (chainlen > t->maxchain) @@ -207,8 +203,7 @@ Hash_CreateEntry(Hash_Table *t, const ch { Hash_Entry *e; unsigned h; - const char *p; - int keylen; + size_t keylen; int chainlen; struct Hash_Entry **hp; @@ -216,16 +211,14 @@ Hash_CreateEntry(Hash_Table *t, const ch * Hash the key. As a side effect, save the length (strlen) of the * key in case we need to create the entry. */ - HASH(h, key, p); - keylen = p - key; - p = key; + h = hash(key, ); chainlen = 0; #ifdef DEBUG_HASH_LOOKUP DEBUG4(HASH, "%s: %p h=%x key=%s\n", __func__, t, h, key); #endif for (e = t->buckets[h & t->bucketsMask]; e != NULL; e = e->next) { chainlen++; - if (e->namehash == h && strcmp(e->name, p) == 0) { + if (e->namehash == h && strcmp(e->name, key) == 0) { if (newPtr != NULL) *newPtr = FALSE; break; @@ -243,13 +236,14 @@ Hash_CreateEntry(Hash_Table *t, const ch */ if (t->numEntries >= rebuildLimit * t->bucketsSize) RebuildTable(t); + e = bmake_malloc(sizeof(*e) + keylen); hp = >buckets[h & t->bucketsMask]; e->next = *hp; *hp = e; Hash_SetValue(e, NULL); e->namehash = h; - (void)strcpy(e->name, p); + (void)strcpy(e->name, key); t->numEntries++; if (newPtr != NULL)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 21:52:51 UTC 2020 Modified Files: src/usr.bin/make: arch.c compat.c dir.c enum.c main.c make_malloc.c parse.c suff.c targ.c trace.c util.c Log Message: make(1): clean up #include sections To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/usr.bin/make/arch.c cvs rdiff -u -r1.161 -r1.162 src/usr.bin/make/compat.c cvs rdiff -u -r1.155 -r1.156 src/usr.bin/make/dir.c cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/enum.c cvs rdiff -u -r1.363 -r1.364 src/usr.bin/make/main.c cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/make_malloc.c cvs rdiff -u -r1.347 -r1.348 src/usr.bin/make/parse.c cvs rdiff -u -r1.173 -r1.174 src/usr.bin/make/suff.c cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/targ.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/trace.c cvs rdiff -u -r1.60 -r1.61 src/usr.bin/make/util.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/arch.c diff -u src/usr.bin/make/arch.c:1.129 src/usr.bin/make/arch.c:1.130 --- src/usr.bin/make/arch.c:1.129 Sat Oct 3 21:19:54 2020 +++ src/usr.bin/make/arch.c Sat Oct 3 21:52:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.129 2020/10/03 21:19:54 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.130 2020/10/03 21:52:50 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -123,18 +123,14 @@ #include #include -#include -#include -#include #include #include"make.h" -#include"hash.h" #include"dir.h" #include"config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.129 2020/10/03 21:19:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.130 2020/10/03 21:52:50 rillig Exp $"); #ifdef TARGET_MACHINE #undef MAKE_MACHINE Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.161 src/usr.bin/make/compat.c:1.162 --- src/usr.bin/make/compat.c:1.161 Thu Oct 1 22:42:00 2020 +++ src/usr.bin/make/compat.c Sat Oct 3 21:52:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.161 2020/10/01 22:42:00 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.162 2020/10/03 21:52:50 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -86,20 +86,17 @@ #include #include -#include #include #include -#include #include"make.h" -#include"hash.h" #include"dir.h" #include"job.h" #include"metachar.h" #include"pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.161 2020/10/01 22:42:00 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.162 2020/10/03 21:52:50 rillig Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.155 src/usr.bin/make/dir.c:1.156 --- src/usr.bin/make/dir.c:1.155 Fri Oct 2 22:20:25 2020 +++ src/usr.bin/make/dir.c Sat Oct 3 21:52:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.155 2020/10/02 22:20:25 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.156 2020/10/03 21:52:50 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -129,14 +129,13 @@ #include #include -#include #include "make.h" #include "dir.h" #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.155 2020/10/02 22:20:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.156 2020/10/03 21:52:50 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) Index: src/usr.bin/make/enum.c diff -u src/usr.bin/make/enum.c:1.9 src/usr.bin/make/enum.c:1.10 --- src/usr.bin/make/enum.c:1.9 Sat Oct 3 06:36:01 2020 +++ src/usr.bin/make/enum.c Sat Oct 3 21:52:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: enum.c,v 1.9 2020/10/03 06:36:01 rillig Exp $ */ +/* $NetBSD: enum.c,v 1.10 2020/10/03 21:52:50 rillig Exp $ */ /* Copyright (c) 2020 Roland Illig @@ -27,13 +27,9 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include - #include "make.h" -MAKE_RCSID("$NetBSD: enum.c,v 1.9 2020/10/03 06:36:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: enum.c,v 1.10 2020/10/03 21:52:50 rillig Exp $"); /* Convert a bitset into a string representation, showing the names of the * individual bits. Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.363 src/usr.bin/make/main.c:1.364 --- src/usr.bin/make/main.c:1.363 Sat Oct 3 13:22:39 2020 +++ src/usr.bin/make/main.c Sat Oct 3 21:52:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.363 2020/10/03 13:22:39 rillig Exp $ */ +/* $NetBSD: main.c,v 1.364 2020/10/03 21:52:50 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -106,16 +106,12 @@ #include #include -#include #include #include #include -#include -#include #include #include "make.h" -#include "hash.h" #include "dir.h"
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 21:43:41 UTC 2020 Modified Files: src/usr.bin/make: parse.c Log Message: make(1): remove dead store in ParseGetLine GCC 5 didn't dare to optimize this by itself. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/usr.bin/make/parse.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/parse.c diff -u src/usr.bin/make/parse.c:1.346 src/usr.bin/make/parse.c:1.347 --- src/usr.bin/make/parse.c:1.346 Sat Oct 3 21:23:42 2020 +++ src/usr.bin/make/parse.c Sat Oct 3 21:43:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.346 2020/10/03 21:23:42 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.347 2020/10/03 21:43:41 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.346 2020/10/03 21:23:42 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.347 2020/10/03 21:43:41 rillig Exp $"); /* types and constants */ @@ -2520,7 +2520,7 @@ ParseEOF(void) #define PARSE_SKIP 2 static char * -ParseGetLine(int flags, int *length) +ParseGetLine(int flags) { IFile *cf = curFile; char *ptr; @@ -2612,7 +2612,6 @@ ParseGetLine(int flags, int *length) if (flags & PARSE_RAW) { /* Leave '\' (etc) in line buffer (eg 'for' lines) */ - *length = line_end - line; return line; } @@ -2632,10 +2631,8 @@ ParseGetLine(int flags, int *length) } /* If we didn't see a '\\' then the in-situ data is fine */ -if (escaped == NULL) { - *length = line_end - line; +if (escaped == NULL) return line; -} /* Remove escapes from '\n' and '#' */ tp = ptr = escaped; @@ -2678,7 +2675,6 @@ ParseGetLine(int flags, int *length) tp--; *tp = 0; -*length = tp - line; return line; } @@ -2694,12 +2690,11 @@ static char * ParseReadLine(void) { char *line; /* Result */ -int lineLength; /* Length of result */ int lineno; /* Saved line # */ int rval; for (;;) { - line = ParseGetLine(0, ); + line = ParseGetLine(0); if (line == NULL) return NULL; @@ -2714,7 +2709,7 @@ ParseReadLine(void) case COND_SKIP: /* Skip to next conditional that evaluates to COND_PARSE. */ do { - line = ParseGetLine(PARSE_SKIP, ); + line = ParseGetLine(PARSE_SKIP); } while (line && Cond_EvalLine(line) != COND_PARSE); if (line == NULL) break; @@ -2734,7 +2729,7 @@ ParseReadLine(void) lineno = curFile->lineno; /* Accumulate loop lines until matching .endfor */ do { - line = ParseGetLine(PARSE_RAW, ); + line = ParseGetLine(PARSE_RAW); if (line == NULL) { Parse_Error(PARSE_FATAL, "Unexpected end of file in for loop.");
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 21:23:42 UTC 2020 Modified Files: src/usr.bin/make: parse.c Log Message: make(1): inline macro ISEQOPERATOR The name of the macro was wrong. These characters are not used in an equality operator, it's an assignment operator. To generate a diff of this commit: cvs rdiff -u -r1.345 -r1.346 src/usr.bin/make/parse.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/parse.c diff -u src/usr.bin/make/parse.c:1.345 src/usr.bin/make/parse.c:1.346 --- src/usr.bin/make/parse.c:1.345 Sat Oct 3 21:19:54 2020 +++ src/usr.bin/make/parse.c Sat Oct 3 21:23:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.345 2020/10/03 21:19:54 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.346 2020/10/03 21:23:42 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.345 2020/10/03 21:19:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.346 2020/10/03 21:23:42 rillig Exp $"); /* types and constants */ @@ -1690,12 +1690,8 @@ Parse_IsVar(const char *line) Boolean wasSpace = FALSE; /* set TRUE if found a space */ char ch; int level = 0; -#define ISEQOPERATOR(c) \ - (((c) == '+') || ((c) == ':') || ((c) == '?') || ((c) == '!')) -/* - * Skip to variable name - */ +/* Skip to variable name */ while (*line == ' ' || *line == '\t') line++; @@ -1723,7 +1719,7 @@ Parse_IsVar(const char *line) #endif if (ch == '=') return TRUE; - if (*line == '=' && ISEQOPERATOR(ch)) + if (*line == '=' && (ch == '+' || ch == ':' || ch == '?' || ch == '!')) return TRUE; if (wasSpace) return FALSE;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 21:19:54 UTC 2020 Modified Files: src/usr.bin/make: arch.c cond.c for.c job.c make.h parse.c var.c Log Message: make(1): use consistent pattern for parsing whitespace The pp and cpp in the function names stand for "parsing position" and "const parsing position". To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 src/usr.bin/make/arch.c cvs rdiff -u -r1.156 -r1.157 src/usr.bin/make/cond.c cvs rdiff -u -r1.89 -r1.90 src/usr.bin/make/for.c cvs rdiff -u -r1.256 -r1.257 src/usr.bin/make/job.c cvs rdiff -u -r1.151 -r1.152 src/usr.bin/make/make.h cvs rdiff -u -r1.344 -r1.345 src/usr.bin/make/parse.c cvs rdiff -u -r1.563 -r1.564 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.128 src/usr.bin/make/arch.c:1.129 --- src/usr.bin/make/arch.c:1.128 Sat Oct 3 10:04:34 2020 +++ src/usr.bin/make/arch.c Sat Oct 3 21:19:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.128 2020/10/03 10:04:34 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.129 2020/10/03 21:19:54 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -134,7 +134,7 @@ #include"config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.128 2020/10/03 10:04:34 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.129 2020/10/03 21:19:54 rillig Exp $"); #ifdef TARGET_MACHINE #undef MAKE_MACHINE @@ -413,15 +413,9 @@ Arch_ParseArchive(char **linePtr, GNodeL free(libName); } -/* - * We promised the pointer would be set up at the next non-space, so - * we must advance cp there before setting *linePtr... (note that on - * entrance to the loop, cp is guaranteed to point at a ')') - */ -do { - cp++; -} while (*cp != '\0' && ch_isspace(*cp)); - +cp++; /* skip the ')' */ +/* We promised that linePtr would be set up at the next non-space. */ +pp_skip_whitespace(); *linePtr = cp; return TRUE; } Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.156 src/usr.bin/make/cond.c:1.157 --- src/usr.bin/make/cond.c:1.156 Thu Oct 1 22:42:00 2020 +++ src/usr.bin/make/cond.c Sat Oct 3 21:19:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.156 2020/10/01 22:42:00 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.157 2020/10/03 21:19:54 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -93,7 +93,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.156 2020/10/01 22:42:00 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.157 2020/10/03 21:19:54 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -186,8 +186,7 @@ CondParser_PushBack(CondParser *par, Tok static void CondParser_SkipWhitespace(CondParser *par) { -while (ch_isspace(par->p[0])) - par->p++; +cpp_skip_whitespace(>p); } /* Parse the argument of a built-in function. @@ -697,8 +696,7 @@ ParseEmptyArg(const char **linePtr, Bool } /* A variable is empty when it just contains spaces... 4/15/92, christos */ -while (ch_isspace(val[0])) - val++; +cpp_skip_whitespace(); /* * For consistency with the other functions we can't generate the @@ -745,8 +743,7 @@ CondParser_Func(CondParser *par, Boolean continue; cp += fn_def->fn_name_len; /* There can only be whitespace before the '(' */ - while (ch_isspace(*cp)) - cp++; + cpp_skip_whitespace(); if (*cp != '(') break; @@ -776,8 +773,8 @@ CondParser_Func(CondParser *par, Boolean * expression. */ arglen = ParseFuncArg(, doEval, NULL, ); -for (cp1 = cp; ch_isspace(*cp1); cp1++) - continue; +cp1 = cp; +cpp_skip_whitespace(); if (*cp1 == '=' || *cp1 == '!') return CondParser_Comparison(par, doEval); par->p = cp; Index: src/usr.bin/make/for.c diff -u src/usr.bin/make/for.c:1.89 src/usr.bin/make/for.c:1.90 --- src/usr.bin/make/for.c:1.89 Mon Sep 28 20:46:11 2020 +++ src/usr.bin/make/for.c Sat Oct 3 21:19:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.89 2020/09/28 20:46:11 rillig Exp $ */ +/* $NetBSD: for.c,v 1.90 2020/10/03 21:19:54 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -61,7 +61,7 @@ #include"strlist.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.89 2020/09/28 20:46:11 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.90 2020/10/03 21:19:54 rillig Exp $"); typedef enum { FOR_SUB_ESCAPE_CHAR = 0x0001, @@ -119,8 +119,8 @@ For_Eval(const char *line) Words words; /* Skip the '.' and any following whitespace */ -for (ptr = line + 1; ch_isspace(*ptr); ptr++) - continue; +ptr = line + 1; +cpp_skip_whitespace(); /* * If we are not in a for loop quickly
CVS commit: src/distrib/sets/lists/tests
Module Name:src Committed By: rillig Date: Sat Oct 3 20:34:06 UTC 2020 Modified Files: src/distrib/sets/lists/tests: mi Log Message: make(1): add unit test for the Towers of Hanoi puzzle To generate a diff of this commit: cvs rdiff -u -r1.936 -r1.937 src/distrib/sets/lists/tests/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.936 src/distrib/sets/lists/tests/mi:1.937 --- src/distrib/sets/lists/tests/mi:1.936 Sat Oct 3 14:39:36 2020 +++ src/distrib/sets/lists/tests/mi Sat Oct 3 20:34:06 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.936 2020/10/03 14:39:36 rillig Exp $ +# $NetBSD: mi,v 1.937 2020/10/03 20:34:06 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4813,6 +4813,8 @@ ./usr/tests/usr.bin/make/unit-tests/forloop.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/forsubst.exptests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/forsubst.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/hanoi-include.exptests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/hanoi-include.mktests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/hash.exp tests-obsolete obsolete ./usr/tests/usr.bin/make/unit-tests/hash.mk tests-obsolete obsolete ./usr/tests/usr.bin/make/unit-tests/impsrc.exp tests-usr.bin-tests compattestfile,atf
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Sat Oct 3 18:54:18 UTC 2020 Modified Files: src/usr.sbin/sysinst: bsddisklabel.c disklabel.c gpt.c label.c mbr.c part_edit.c partitions.h Log Message: PR 55384: detangle pm->ptstart from the "install" flag (selecting a target partition). Instead introduce a new PTI_INSTALL_TARGET per partition flag and deal with it in the partitioning backends. Honour pm->ptstart when allocating new partitions - it is supposed to be the first sector usable by NetBSD. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/sysinst/bsddisklabel.c cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/sysinst/disklabel.c cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/sysinst/gpt.c cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/sysinst/label.c cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/sysinst/mbr.c cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/sysinst/part_edit.c cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/sysinst/partitions.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.sbin/sysinst/bsddisklabel.c diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.45 src/usr.sbin/sysinst/bsddisklabel.c:1.46 --- src/usr.sbin/sysinst/bsddisklabel.c:1.45 Tue Sep 29 15:29:17 2020 +++ src/usr.sbin/sysinst/bsddisklabel.c Sat Oct 3 18:54:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bsddisklabel.c,v 1.45 2020/09/29 15:29:17 martin Exp $ */ +/* $NetBSD: bsddisklabel.c,v 1.46 2020/10/03 18:54:18 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -1431,7 +1431,7 @@ apply_settings_to_partitions(struct pm_d } } - from = -1; + from = p->ptstart > 0 ? pm->ptstart : -1; /* * First add all outer partitions - we need to align those exactly * with the inner counterpart later. Index: src/usr.sbin/sysinst/disklabel.c diff -u src/usr.sbin/sysinst/disklabel.c:1.39 src/usr.sbin/sysinst/disklabel.c:1.40 --- src/usr.sbin/sysinst/disklabel.c:1.39 Tue Sep 29 15:29:17 2020 +++ src/usr.sbin/sysinst/disklabel.c Sat Oct 3 18:54:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.c,v 1.39 2020/09/29 15:29:17 martin Exp $ */ +/* $NetBSD: disklabel.c,v 1.40 2020/10/03 18:54:18 martin Exp $ */ /* * Copyright 2018 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ const struct disk_partitioning_scheme di struct disklabel_disk_partitions { struct disk_partitions dp; struct disklabel l; - daddr_t ptn_alignment; + daddr_t ptn_alignment, install_target; char last_mounted[MAXPARTITIONS][MOUNTLEN]; uint fs_sub_type[MAXPARTITIONS]; }; @@ -150,6 +150,7 @@ disklabel_parts_new(const char *dev, dad if (parts == NULL) return NULL; + parts->install_target = -1; total_size = geo.dg_secperunit; if (len*(geo.dg_secsize/512) > disklabel_parts.size_limit) len = disklabel_parts.size_limit/(geo.dg_secsize/512); @@ -213,6 +214,7 @@ disklabel_parts_read(const char *disk, d struct disklabel_disk_partitions *parts = calloc(1, sizeof(*parts)); if (parts == NULL) return NULL; + parts->install_target = -1; fd = opendisk(disk, O_RDONLY, diskpath, sizeof(diskpath), 0); if (fd == -1) { @@ -272,8 +274,12 @@ disklabel_parts_read(const char *disk, d flags = 0; if (parts->l.d_partitions[part].p_fstype == FS_MSDOS) flags = GLM_MAYBE_FAT32; - else if (parts->l.d_partitions[part].p_fstype == FS_BSDFFS) + else if (parts->l.d_partitions[part].p_fstype == FS_BSDFFS) { flags = GLM_LIKELY_FFS; + if (parts->install_target < 0) +parts->install_target = +parts->l.d_partitions[part].p_offset; + } if (flags != 0) { uint fs_type, fs_sub_type; const char *lm = get_last_mounted(fd, @@ -511,6 +517,9 @@ disklabel_delete(struct disk_partitions MSG_part_not_deletable); return false; } + if (parts->install_target == + parts->l.d_partitions[part].p_offset) +parts->install_target = -1; parts->l.d_partitions[part].p_size = 0; parts->l.d_partitions[part].p_offset = 0; parts->l.d_partitions[part].p_fstype = FS_UNUSED; @@ -552,6 +561,8 @@ disklabel_delete_range(struct disk_parti if ((start >= r_start && start <= r_start+r_size) || (end >= r_start && end <= r_start+r_size)) { + if (start == parts->install_target) +parts->install_target = -1; if (parts->dp.num_part > 1) parts->dp.num_part--; parts->dp.free_space += @@ -765,6 +776,8 @@ disklabel_get_part_info(const struct dis parts->l.d_partitions[part].p_fstype == FS_UNUSED) info->flags |= PTI_PSCHEME_INTERNAL|PTI_RAW_PART; + if (info->start == parts->install_target) +info->flags |= PTI_INSTALL_TARGET; #if RAW_PART == 3 if (part == (RAW_PART-1) && parts->dp.parent != NULL && parts->l.d_partitions[part].p_fstype == FS_UNUSED) @@ -789,6 +802,7 @@ disklabel_set_part_info(struct disk_part struct disklabel_disk_partitions *parts = (struct disklabel_disk_partitions*)arg; part_id ndx; + bool was_inst_target;
CVS commit: src/sbin/mount_nfs
Module Name:src Committed By: christos Date: Sat Oct 3 18:42:20 UTC 2020 Modified Files: src/sbin/mount_nfs: mount_nfs.c Log Message: - centralize number parsing code - enable -g - KNF To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sbin/mount_nfs/mount_nfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/mount_nfs/mount_nfs.c diff -u src/sbin/mount_nfs/mount_nfs.c:1.73 src/sbin/mount_nfs/mount_nfs.c:1.74 --- src/sbin/mount_nfs/mount_nfs.c:1.73 Sat Oct 3 14:06:37 2020 +++ src/sbin/mount_nfs/mount_nfs.c Sat Oct 3 14:42:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mount_nfs.c,v 1.73 2020/10/03 18:06:37 christos Exp $ */ +/* $NetBSD: mount_nfs.c,v 1.74 2020/10/03 18:42:20 christos Exp $ */ /* * Copyright (c) 1992, 1993, 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19 #if 0 static char sccsid[] = "@(#)mount_nfs.c 8.11 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: mount_nfs.c,v 1.73 2020/10/03 18:06:37 christos Exp $"); +__RCSID("$NetBSD: mount_nfs.c,v 1.74 2020/10/03 18:42:20 christos Exp $"); #endif #endif /* not lint */ @@ -52,7 +52,8 @@ __RCSID("$NetBSD: mount_nfs.c,v 1.73 202 #include #include -#include +#include +#include /* XXX: redefines enums */ #include #include #include @@ -181,21 +182,36 @@ mount_nfs_dogetargs(struct nfs_args *nfs nfsargsp->addrlen = sizeof(sa); } else { if ((tspec = strdup(spec)) == NULL) { - err(1, "strdup"); + err(EXIT_FAILURE, "strdup"); } if (!getnfsargs(tspec, nfsargsp)) { - exit(1); + exit(EXIT_FAILURE); } free(tspec); } } +static int +getnum(const char *s, int c) +{ + char *es; + long num = strtol(s, , 10); + if (*es || num <= 0 || num > INT_MAX) + errx(EXIT_FAILURE, "Illegal value `%s' for option -%c", s, c); + return (int)num; +} + +static __dead void +conflicting(void) +{ + errx(EXIT_FAILURE, "Conflicting version options"); +} + void mount_nfs_parseargs(int argc, char *argv[], struct nfs_args *nfsargsp, int *mntflags, char *spec, char *name) { - char *p; int altflags, num; int c; mntoptparse_t mp; @@ -210,12 +226,12 @@ mount_nfs_parseargs(int argc, char *argv case '3': case 'q': if (force2) -errx(1, "conflicting version options"); +conflicting(); force3 = 1; break; case '2': if (force3) -errx(1, "conflicting version options"); +conflicting(); force2 = 1; nfsargsp->flags &= ~NFSMNT_NFSV3; break; @@ -223,10 +239,7 @@ mount_nfs_parseargs(int argc, char *argv nfsargsp->flags |= NFSMNT_NOAC; break; case 'a': - num = strtol(optarg, , 10); - if (*p || num < 0) -errx(1, "illegal -a value -- %s", optarg); - nfsargsp->readahead = num; + nfsargsp->readahead = getnum(optarg, c); nfsargsp->flags |= NFSMNT_READAHEAD; break; case 'b': @@ -239,30 +252,20 @@ mount_nfs_parseargs(int argc, char *argv nfsargsp->flags &= ~NFSMNT_NOCONN; break; case 'D': - num = strtol(optarg, , 10); - if (*p || num <= 0) -errx(1, "illegal -D value -- %s", optarg); - nfsargsp->deadthresh = num; + nfsargsp->deadthresh = getnum(optarg, c); nfsargsp->flags |= NFSMNT_DEADTHRESH; break; case 'd': nfsargsp->flags |= NFSMNT_DUMBTIMR; break; -#if 0 /* */ case 'g': - num = strtol(optarg, , 10); - if (*p || num <= 0) -errx(1, "illegal -g value -- %s", optarg); + num = getnum(optarg, c); set_rpc_maxgrouplist(num); nfsargsp->maxgrouplist = num; nfsargsp->flags |= NFSMNT_MAXGRPS; break; -#endif case 'I': - num = strtol(optarg, , 10); - if (*p || num <= 0) -errx(1, "illegal -I value -- %s", optarg); - nfsargsp->readdirsize = num; + nfsargsp->readdirsize = getnum(optarg, c); nfsargsp->flags |= NFSMNT_READDIRSIZE; break; case 'i': @@ -277,7 +280,7 @@ mount_nfs_parseargs(int argc, char *argv case 'o': mp = getmntopts(optarg, mopts, mntflags, ); if (mp == NULL) -err(1, "getmntopts"); +err(EXIT_FAILURE, "getmntopts"); if (altflags & ALTF_BG) opflags |= BGRND; if (altflags & ALTF_CONN) @@ -290,12 +293,12 @@ mount_nfs_parseargs(int argc, char *argv nfsargsp->flags |= NFSMNT_NOAC; if (altflags & (ALTF_NFSV3|ALTF_NQNFS)) { if (force2) - errx(1, "conflicting version options"); + conflicting(); force3 = 1; } if (altflags & ALTF_NFSV2) { if (force3) - errx(1, "conflicting version options"); + conflicting(); force2 = 1; nfsargsp->flags &= ~NFSMNT_NFSV3; } @@ -318,7 +321,7 @@ mount_nfs_parseargs(int argc, char *argv nfsargsp->sotype = SOCK_STREAM; } if (altflags & ALTF_PORT) { -port = getmntoptnum(mp, "port"); +port = (int)getmntoptnum(mp, "port"); } if (altflags & ALTF_RSIZE) { nfsargsp->rsize = @@ -378,16 +381,10 @@ mount_nfs_parseargs(int argc, char *argv nfsargsp->flags &= ~NFSMNT_RESVPORT;
CVS commit: src/distrib/sets/lists
Module Name:src Committed By: christos Date: Sat Oct 3 18:35:21 UTC 2020 Modified Files: src/distrib/sets/lists/base: shl.mi src/distrib/sets/lists/debug: shl.mi Log Message: bump libc for set_rpc_maxgrouplist To generate a diff of this commit: cvs rdiff -u -r1.907 -r1.908 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.266 -r1.267 src/distrib/sets/lists/debug/shl.mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/base/shl.mi diff -u src/distrib/sets/lists/base/shl.mi:1.907 src/distrib/sets/lists/base/shl.mi:1.908 --- src/distrib/sets/lists/base/shl.mi:1.907 Tue Sep 29 14:33:22 2020 +++ src/distrib/sets/lists/base/shl.mi Sat Oct 3 14:35:21 2020 @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.907 2020/09/29 18:33:22 roy Exp $ +# $NetBSD: shl.mi,v 1.908 2020/10/03 18:35:21 christos Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -24,7 +24,7 @@ ./lib/libblocklist.so.0.0 base-sys-shlib dynamicroot ./lib/libc.so base-sys-shlib dynamicroot ./lib/libc.so.12base-sys-shlib dynamicroot -./lib/libc.so.12.217base-sys-shlib dynamicroot +./lib/libc.so.12.218base-sys-shlib dynamicroot ./lib/libcrypt.sobase-sys-shlib dynamicroot ./lib/libcrypt.so.1base-sys-shlib dynamicroot ./lib/libcrypt.so.1.0base-sys-shlib dynamicroot @@ -257,7 +257,7 @@ ./usr/lib/libc++.so.1.0base-sys-shlib compatfile,libcxx ./usr/lib/libc.sobase-sys-shlib compatfile ./usr/lib/libc.so.12base-sys-shlib compatfile -./usr/lib/libc.so.12.217 base-sys-shlib compatfile +./usr/lib/libc.so.12.218 base-sys-shlib compatfile ./usr/lib/libcbor.sobase-sys-shlib compatfile ./usr/lib/libcbor.so.0base-sys-shlib compatfile ./usr/lib/libcbor.so.0.5 base-sys-shlib compatfile Index: src/distrib/sets/lists/debug/shl.mi diff -u src/distrib/sets/lists/debug/shl.mi:1.266 src/distrib/sets/lists/debug/shl.mi:1.267 --- src/distrib/sets/lists/debug/shl.mi:1.266 Tue Sep 29 14:33:23 2020 +++ src/distrib/sets/lists/debug/shl.mi Sat Oct 3 14:35:21 2020 @@ -1,10 +1,10 @@ -# $NetBSD: shl.mi,v 1.266 2020/09/29 18:33:23 roy Exp $ +# $NetBSD: shl.mi,v 1.267 2020/10/03 18:35:21 christos Exp $ ./usr/lib/libbfd_g.a comp-c-debuglib debuglib,compatfile,binutils ./usr/libdata/debug/lib base-sys-usr debug,dynamicroot,compatdir ./usr/libdata/debug/lib/libavl.so.0.0.debug comp-zfs-debug debug,dynamicroot,zfs ./usr/libdata/debug/lib/libblacklist.so.0.0.debug comp-obsolete obsolete,compatfile ./usr/libdata/debug/lib/libblocklist.so.0.0.debug comp-sys-debug debug,dynamicroot -./usr/libdata/debug/lib/libc.so.12.217.debug comp-sys-debug debug,dynamicroot +./usr/libdata/debug/lib/libc.so.12.218.debug comp-sys-debug debug,dynamicroot ./usr/libdata/debug/lib/libcrypt.so.1.0.debug comp-sys-debug debug,dynamicroot ./usr/libdata/debug/lib/libcrypto.so.12.0.debug comp-sys-debug debug,dynamicroot,openssl=10 ./usr/libdata/debug/lib/libcrypto.so.14.0.debug comp-sys-debug debug,dynamicroot,openssl=11 @@ -85,7 +85,7 @@ ./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compatfile ./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug comp-sys-debug debug,compatfile ./usr/libdata/debug/usr/lib/libc++.so.1.0.debug comp-sys-debug debug,compatfile,libcxx -./usr/libdata/debug/usr/lib/libc.so.12.217.debug comp-sys-debug debug,compatfile +./usr/libdata/debug/usr/lib/libc.so.12.218.debug comp-sys-debug debug,compatfile ./usr/libdata/debug/usr/lib/libcbor.so.0.5.debug comp-sys-debug debug,compatfile ./usr/libdata/debug/usr/lib/libcom_err.so.8.0.debug comp-krb5-debug debug,compatfile,kerberos ./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug comp-sys-debug debug,compatfile
CVS commit: src/lib/libc
Module Name:src Committed By: christos Date: Sat Oct 3 18:34:15 UTC 2020 Modified Files: src/lib/libc: shlib_version Log Message: bump for set_rpc_maxgrouplist To generate a diff of this commit: cvs rdiff -u -r1.289 -r1.290 src/lib/libc/shlib_version 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/shlib_version diff -u src/lib/libc/shlib_version:1.289 src/lib/libc/shlib_version:1.290 --- src/lib/libc/shlib_version:1.289 Tue Jun 2 09:56:30 2020 +++ src/lib/libc/shlib_version Sat Oct 3 14:34:15 2020 @@ -1,4 +1,4 @@ -# $NetBSD: shlib_version,v 1.289 2020/06/02 13:56:30 nia Exp $ +# $NetBSD: shlib_version,v 1.290 2020/10/03 18:34:15 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # # things we wish to do on next major version bump: @@ -53,4 +53,4 @@ # - move statfs() to libcompat since we have statvfs() # - the syscall stubs for the (obsolete) lfs syscalls should be removed major=12 -minor=217 +minor=218
CVS commit: src/distrib/sets/lists/comp
Module Name:src Committed By: christos Date: Sat Oct 3 18:33:52 UTC 2020 Modified Files: src/distrib/sets/lists/comp: mi Log Message: add set_rpc_maxgrouplist To generate a diff of this commit: cvs rdiff -u -r1.2360 -r1.2361 src/distrib/sets/lists/comp/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2360 src/distrib/sets/lists/comp/mi:1.2361 --- src/distrib/sets/lists/comp/mi:1.2360 Tue Sep 29 14:33:22 2020 +++ src/distrib/sets/lists/comp/mi Sat Oct 3 14:33:52 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2360 2020/09/29 18:33:22 roy Exp $ +# $NetBSD: mi,v 1.2361 2020/10/03 18:33:52 christos Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -9886,6 +9886,7 @@ ./usr/share/man/cat3/set_menu_win.0 comp-c-catman .cat ./usr/share/man/cat3/set_new_page.0 comp-c-catman .cat ./usr/share/man/cat3/set_panel_userptr.0 comp-c-catman .cat +./usr/share/man/cat3/set_rpc_maxgrouplist.0 comp-c-catman .cat ./usr/share/man/cat3/set_tabsize.0 comp-c-catman .cat ./usr/share/man/cat3/set_term.0 comp-c-catman .cat ./usr/share/man/cat3/set_top_row.0 comp-c-catman .cat @@ -18116,6 +18117,7 @@ ./usr/share/man/html3/set_menu_win.html comp-c-htmlman html ./usr/share/man/html3/set_new_page.html comp-c-htmlman html ./usr/share/man/html3/set_panel_userptr.html comp-c-htmlman html +./usr/share/man/html3/set_rpc_maxgrouplist.html comp-c-htmlman html ./usr/share/man/html3/set_tabsize.html comp-c-htmlman html ./usr/share/man/html3/set_term.html comp-c-htmlman html ./usr/share/man/html3/set_top_row.html comp-c-htmlman html @@ -26351,6 +26353,7 @@ ./usr/share/man/man3/set_menu_win.3 comp-c-man .man ./usr/share/man/man3/set_new_page.3 comp-c-man .man ./usr/share/man/man3/set_panel_userptr.3 comp-c-man .man +./usr/share/man/man3/set_rpc_maxgrouplist.3 comp-c-man .man ./usr/share/man/man3/set_tabsize.3 comp-c-man .man ./usr/share/man/man3/set_term.3 comp-c-man .man ./usr/share/man/man3/set_top_row.3 comp-c-man .man
CVS commit: src/lib/libc/rpc
Module Name:src Committed By: christos Date: Sat Oct 3 18:31:29 UTC 2020 Modified Files: src/lib/libc/rpc: Makefile.inc auth_unix.c rpc_clnt_auth.3 Log Message: Add set_rpc_maxgrouplist To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libc/rpc/Makefile.inc \ src/lib/libc/rpc/auth_unix.c cvs rdiff -u -r1.6 -r1.7 src/lib/libc/rpc/rpc_clnt_auth.3 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/rpc/Makefile.inc diff -u src/lib/libc/rpc/Makefile.inc:1.26 src/lib/libc/rpc/Makefile.inc:1.27 --- src/lib/libc/rpc/Makefile.inc:1.26 Sun Oct 13 03:28:10 2019 +++ src/lib/libc/rpc/Makefile.inc Sat Oct 3 14:31:29 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.26 2019/10/13 07:28:10 mrg Exp $ +# $NetBSD: Makefile.inc,v 1.27 2020/10/03 18:31:29 christos Exp $ # librpc sources .PATH: ${.CURDIR}/rpc @@ -38,6 +38,7 @@ MLINKS+= bindresvport.3 bindresvport_sa. rpc_clnt_auth.3 authnone_create.3 \ rpc_clnt_auth.3 authsys_create.3 \ rpc_clnt_auth.3 authsys_create_default.3 \ + rpc_clnt_auth.3 set_rpc_maxgrouplist.3 \ rpc_clnt_calls.3 clnt_call.3 \ rpc_clnt_calls.3 clnt_perrno.3 \ rpc_clnt_calls.3 clnt_perror.3 \ Index: src/lib/libc/rpc/auth_unix.c diff -u src/lib/libc/rpc/auth_unix.c:1.26 src/lib/libc/rpc/auth_unix.c:1.27 --- src/lib/libc/rpc/auth_unix.c:1.26 Sat Oct 18 04:33:23 2014 +++ src/lib/libc/rpc/auth_unix.c Sat Oct 3 14:31:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: auth_unix.c,v 1.26 2014/10/18 08:33:23 snj Exp $ */ +/* $NetBSD: auth_unix.c,v 1.27 2020/10/03 18:31:29 christos Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -37,7 +37,7 @@ static char *sccsid = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC"; #else -__RCSID("$NetBSD: auth_unix.c,v 1.26 2014/10/18 08:33:23 snj Exp $"); +__RCSID("$NetBSD: auth_unix.c,v 1.27 2020/10/03 18:31:29 christos Exp $"); #endif #endif @@ -183,6 +183,20 @@ authunix_create(char *machname, int uid, } /* + * Some servers will refuse mounts if the group list is larger + * than it expects (like 8). This allows the application to set + * the maximum size of the group list that will be sent. + */ +static int maxgrplist = NGROUPS; + +void +set_rpc_maxgrouplist(int num) +{ + if (num < NGROUPS) + maxgrplist = num; +} + +/* * Returns an auth handle with parameters determined by doing lots of * syscalls. */ @@ -202,6 +216,8 @@ authunix_create_default(void) gid = getegid(); if ((len = getgroups(NGRPS, gids)) < 0) abort(); + if (len > maxgrplist) + len = maxgrplist; /* XXX: interface problem; those should all have been unsigned */ return (authunix_create(machname, (int)uid, (int)gid, len, (int *)gids)); Index: src/lib/libc/rpc/rpc_clnt_auth.3 diff -u src/lib/libc/rpc/rpc_clnt_auth.3:1.6 src/lib/libc/rpc/rpc_clnt_auth.3:1.7 --- src/lib/libc/rpc/rpc_clnt_auth.3:1.6 Wed Apr 16 09:34:43 2003 +++ src/lib/libc/rpc/rpc_clnt_auth.3 Sat Oct 3 14:31:29 2020 @@ -2,15 +2,16 @@ .\" Copyright 1989 AT .\" @(#)rpc_clnt_auth 1.4 89/07/20 SMI; .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. -.\" $NetBSD: rpc_clnt_auth.3,v 1.6 2003/04/16 13:34:43 wiz Exp $ -.Dd May 7, 1993 +.\" $NetBSD: rpc_clnt_auth.3,v 1.7 2020/10/03 18:31:29 christos Exp $ +.Dd October 3, 2020 .Dt RPC_CLNT_AUTH 3 .Os .Sh NAME .Nm auth_destroy , .Nm authnone_create , .Nm authsys_create , -.Nm authsys_create_default +.Nm authsys_create_default , +.Nm set_rpc_maxgrouplist .Nd library routines for client side remote procedure call authentication .Sh LIBRARY .Lb libc @@ -24,6 +25,8 @@ .Fn authsys_create "const char *host" "const uid_t uid" "const gid_t gid" "const int len" "const gid_t *aup_gids" .Ft "AUTH *" .Fn authsys_create_default "void" +.Ft "void" +.Fn set_rpc_maxgrouplist "int num" .Sh DESCRIPTION These routines are part of the RPC library that allows C language programs to make procedure @@ -90,6 +93,14 @@ refer to a counted array of groups to wh Call .Fn authsys_create with the appropriate parameters. +.Pp +.It Fn set_rpc_maxgrouplist +Allow the application to set the maximum size of the group list +that will be used in +.Fn authunix_create_default to +.Fa num . +Some servers will refuse mounts if the group list is larger than it expects +(like 8). .El .Sh SEE ALSO .Xr rpc 3 ,
CVS commit: src/include/rpc
Module Name:src Committed By: christos Date: Sat Oct 3 18:30:39 UTC 2020 Modified Files: src/include/rpc: auth.h Log Message: add set_rpc_maxgrouplist(3) To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/include/rpc/auth.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/include/rpc/auth.h diff -u src/include/rpc/auth.h:1.19 src/include/rpc/auth.h:1.20 --- src/include/rpc/auth.h:1.19 Fri Jan 22 21:34:09 2016 +++ src/include/rpc/auth.h Sat Oct 3 14:30:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: auth.h,v 1.19 2016/01/23 02:34:09 dholland Exp $ */ +/* $NetBSD: auth.h,v 1.20 2020/10/03 18:30:39 christos Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -172,6 +172,7 @@ extern AUTH *authnone_create (void); extern AUTH *authdes_create (char *, unsigned int, struct sockaddr_in *, des_block *); extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); +extern void set_rpc_maxgrouplist (int); #define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip)) #define authsys_create_default() authunix_create_default()
CVS commit: src/sbin/mount_nfs
Module Name:src Committed By: wiz Date: Sat Oct 3 18:29:02 UTC 2020 Modified Files: src/sbin/mount_nfs: mount_nfs.8 Log Message: New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sbin/mount_nfs/mount_nfs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/mount_nfs/mount_nfs.8 diff -u src/sbin/mount_nfs/mount_nfs.8:1.49 src/sbin/mount_nfs/mount_nfs.8:1.50 --- src/sbin/mount_nfs/mount_nfs.8:1.49 Sat Oct 3 18:06:37 2020 +++ src/sbin/mount_nfs/mount_nfs.8 Sat Oct 3 18:29:02 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: mount_nfs.8,v 1.49 2020/10/03 18:06:37 christos Exp $ +.\" $NetBSD: mount_nfs.8,v 1.50 2020/10/03 18:29:02 wiz Exp $ .\" .\" Copyright (c) 1992, 1993, 1994, 1995 .\" The Regents of the University of California. All rights reserved. @@ -79,13 +79,14 @@ fall back to version 2 if the mount fail Disable the attribute cache in the client, making it consult the server for the current version of a given file's attributes every time the file is accessed. - +.Pp By default the attribute cache is enabled, making the client only consult -the server every handful of seconds. This improves performance, however -at the cost of the risk of a mid-air collision when changes are made -simultaneously by different NFS clients and/or locally on the NFS server -that affect the same file. In that case changes made elsewhere may be -missed, leading to consistency issues. +the server every handful of seconds. +This improves performance, however at the cost of the risk of a +mid-air collision when changes are made simultaneously by different +NFS clients and/or locally on the NFS server that affect the same file. +In that case changes made elsewhere may be missed, leading to +consistency issues. .It Fl a Ar maxreadahead Set the read-ahead count to the specified value. This may be in the range of 0 - 4, and determines how many blocks
CVS commit: src/sbin/mount_nfs
Module Name:src Committed By: christos Date: Sat Oct 3 18:06:37 UTC 2020 Modified Files: src/sbin/mount_nfs: mount_nfs.8 mount_nfs.c Log Message: Add -A (noac) option to turn off the attribute cache. (Maciej W. Rozycki) To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sbin/mount_nfs/mount_nfs.8 cvs rdiff -u -r1.72 -r1.73 src/sbin/mount_nfs/mount_nfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/mount_nfs/mount_nfs.8 diff -u src/sbin/mount_nfs/mount_nfs.8:1.48 src/sbin/mount_nfs/mount_nfs.8:1.49 --- src/sbin/mount_nfs/mount_nfs.8:1.48 Thu May 17 02:37:06 2018 +++ src/sbin/mount_nfs/mount_nfs.8 Sat Oct 3 14:06:37 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: mount_nfs.8,v 1.48 2018/05/17 06:37:06 wiz Exp $ +.\" $NetBSD: mount_nfs.8,v 1.49 2020/10/03 18:06:37 christos Exp $ .\" .\" Copyright (c) 1992, 1993, 1994, 1995 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)mount_nfs.8 8.3 (Berkeley) 3/29/95 .\" -.Dd September 12, 2016 +.Dd October 3, 2020 .Dt MOUNT_NFS 8 .Os .Sh NAME @@ -37,7 +37,7 @@ .Nd mount NFS file systems .Sh SYNOPSIS .Nm -.Op Fl 23bCcdilPpqsTUuX +.Op Fl 23AbCcdilPpqsTUuX .Op Fl a Ar maxreadahead .Op Fl D Ar deadthresh .Op Fl g Ar maxgroups @@ -75,6 +75,17 @@ Use the NFS Version 2 protocol. Use the NFS Version 3 protocol. The default is to try version 3 first, and fall back to version 2 if the mount fails. +.It Fl A +Disable the attribute cache in the client, making it consult the server +for the current version of a given file's attributes every time the file +is accessed. + +By default the attribute cache is enabled, making the client only consult +the server every handful of seconds. This improves performance, however +at the cost of the risk of a mid-air collision when changes are made +simultaneously by different NFS clients and/or locally on the NFS server +that affect the same file. In that case changes made elsewhere may be +missed, leading to consistency issues. .It Fl a Ar maxreadahead Set the read-ahead count to the specified value. This may be in the range of 0 - 4, and determines how many blocks @@ -186,6 +197,9 @@ Same as .It Cm nfsv3 Same as .Fl 3 . +.It Cm noac +Same as +.Fl A . .It Cm noresport Same as .Fl p . Index: src/sbin/mount_nfs/mount_nfs.c diff -u src/sbin/mount_nfs/mount_nfs.c:1.72 src/sbin/mount_nfs/mount_nfs.c:1.73 --- src/sbin/mount_nfs/mount_nfs.c:1.72 Wed May 16 22:34:31 2018 +++ src/sbin/mount_nfs/mount_nfs.c Sat Oct 3 14:06:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mount_nfs.c,v 1.72 2018/05/17 02:34:31 thorpej Exp $ */ +/* $NetBSD: mount_nfs.c,v 1.73 2020/10/03 18:06:37 christos Exp $ */ /* * Copyright (c) 1992, 1993, 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19 #if 0 static char sccsid[] = "@(#)mount_nfs.c 8.11 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: mount_nfs.c,v 1.72 2018/05/17 02:34:31 thorpej Exp $"); +__RCSID("$NetBSD: mount_nfs.c,v 1.73 2020/10/03 18:06:37 christos Exp $"); #endif #endif /* not lint */ @@ -79,6 +79,7 @@ __RCSID("$NetBSD: mount_nfs.c,v 1.72 201 #define ALTF_CONN 0x0002 #define ALTF_DUMBTIMR 0x0004 #define ALTF_INTR 0x0008 +#define ALTF_NOAC 0x0010 #define ALTF_NFSV3 0x0020 #define ALTF_RDIRPLUS 0x0040 #define ALTF_MNTUDP 0x0080 @@ -109,6 +110,7 @@ static const struct mntopt mopts[] = { { "conn", 0, ALTF_CONN, 1 }, { "dumbtimer", 0, ALTF_DUMBTIMR, 1 }, { "intr", 0, ALTF_INTR, 1 }, + { "ac", 1, ALTF_NOAC, 1 }, { "nfsv3", 0, ALTF_NFSV3, 1 }, { "rdirplus", 0, ALTF_RDIRPLUS, 1 }, { "mntudp", 0, ALTF_MNTUDP, 1 }, @@ -217,6 +219,9 @@ mount_nfs_parseargs(int argc, char *argv force2 = 1; nfsargsp->flags &= ~NFSMNT_NFSV3; break; + case 'A': + nfsargsp->flags |= NFSMNT_NOAC; + break; case 'a': num = strtol(optarg, , 10); if (*p || num < 0) @@ -281,6 +286,8 @@ mount_nfs_parseargs(int argc, char *argv nfsargsp->flags |= NFSMNT_DUMBTIMR; if (altflags & ALTF_INTR) nfsargsp->flags |= NFSMNT_INT; + if (altflags & ALTF_NOAC) +nfsargsp->flags |= NFSMNT_NOAC; if (altflags & (ALTF_NFSV3|ALTF_NQNFS)) { if (force2) errx(1, "conflicting version options");
CVS commit: src/sys/arch/alpha/include
Module Name:src Committed By: thorpej Date: Sat Oct 3 17:33:23 UTC 2020 Modified Files: src/sys/arch/alpha/include: rpb.h Log Message: Add a comment describing the rpb::rpb_vptb field. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/arch/alpha/include/rpb.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/alpha/include/rpb.h diff -u src/sys/arch/alpha/include/rpb.h:1.43 src/sys/arch/alpha/include/rpb.h:1.44 --- src/sys/arch/alpha/include/rpb.h:1.43 Mon Apr 8 00:47:21 2019 +++ src/sys/arch/alpha/include/rpb.h Sat Oct 3 17:33:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rpb.h,v 1.43 2019/04/08 00:47:21 thorpej Exp $ */ +/* $NetBSD: rpb.h,v 1.44 2020/10/03 17:33:23 thorpej Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -190,7 +190,7 @@ struct rpb { char rpb_revision[8]; /* 60; only first 4 valid */ uint64_t rpb_intr_freq; /* 68; scaled by 4096 */ uint64_t rpb_cc_freq; /* 70: cycle cntr frequency */ - u_long rpb_vptb; /* 78: */ + u_long rpb_vptb; /* 78: virtual page tbl base */ uint64_t rpb_reserved_arch; /* 80: */ u_long rpb_tbhint_off; /* 88: */ uint64_t rpb_pcs_cnt; /* 90: */
CVS commit: src/sys/arch/alpha/alpha
Module Name:src Committed By: thorpej Date: Sat Oct 3 17:32:49 UTC 2020 Modified Files: src/sys/arch/alpha/alpha: qemu.c Log Message: Provide an alternate delay function that uses the Qemu get-time hypercall. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/alpha/alpha/qemu.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/alpha/alpha/qemu.c diff -u src/sys/arch/alpha/alpha/qemu.c:1.2 src/sys/arch/alpha/alpha/qemu.c:1.3 --- src/sys/arch/alpha/alpha/qemu.c:1.2 Tue Sep 29 01:33:00 2020 +++ src/sys/arch/alpha/alpha/qemu.c Sat Oct 3 17:32:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: qemu.c,v 1.2 2020/09/29 01:33:00 thorpej Exp $ */ +/* $NetBSD: qemu.c,v 1.3 2020/10/03 17:32:49 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -56,8 +56,10 @@ struct qemu_softc { struct timecounter sc_tc; }; -static u_int -qemu_get_timecount(struct timecounter * const tc __unused) +static unsigned long qemu_nsec_per_tick __read_mostly = (unsigned long)-1; + +static inline unsigned long +qemu_get_vmtime(void) { register unsigned long v0 __asm("$0"); register unsigned long a0 __asm("$16") = 7; /* Qemu get-time */ @@ -67,7 +69,41 @@ qemu_get_timecount(struct timecounter * : "i"(PAL_cserve) : "$17", "$18", "$19", "$20", "$21"); - return (u_int)v0; + return v0; +} + +static void +qemu_delay(unsigned long usec) +{ + /* Get starting point. */ + const unsigned long base = qemu_get_vmtime(); + + /* convert request from usec to nsec */ + const unsigned long nsec = usec * 1000; + KASSERT(nsec > usec); + + /* Figure out finish line. */ + const unsigned long finished = base + nsec; + KASSERT(finished > base); + + unsigned long now; + + /* Spin until we're finished. */ + while ((now = qemu_get_vmtime()) < finished) { + /* + * If we have more than one clock tick worth of spinning + * to do, when use WTINT to wait at a low power state. + */ + if (finished - now > qemu_nsec_per_tick) { + alpha_pal_wtint(0); + } + } +} + +static u_int +qemu_get_timecount(struct timecounter * const tc __unused) +{ + return (u_int)qemu_get_vmtime(); } static inline void @@ -82,8 +118,6 @@ qemu_set_alarm_relative(unsigned long ns : "$0", "$18", "$19", "$20", "$21"); } -static unsigned long qemu_nsec_per_tick __read_mostly; - static void qemu_hardclock(struct clockframe * const framep) { @@ -102,7 +136,7 @@ static void qemu_clock_init(void * const v __unused) { /* First-time initialization... */ - if (qemu_nsec_per_tick == 0) { + if (qemu_nsec_per_tick == (unsigned long)-1) { KASSERT(CPU_IS_PRIMARY(curcpu())); qemu_nsec_per_tick = 10UL / hz; @@ -175,6 +209,11 @@ qemu_attach(device_t parent, device_t se * Qemu's PALcode implements WTINT; use it to save host cycles. */ cpu_idle_fn = cpu_idle_wtint; + + /* + * Use Qemu's "VM time" hypercall to implement delay(). + */ + alpha_delay_fn = qemu_delay; } CFATTACH_DECL_NEW(qemu, sizeof(struct qemu_softc),
CVS commit: src/sys/arch/alpha
Module Name:src Committed By: thorpej Date: Sat Oct 3 17:31:46 UTC 2020 Modified Files: src/sys/arch/alpha/alpha: autoconf.c machdep.c prom.c src/sys/arch/alpha/include: alpha.h prom.h Log Message: Qemu loads the kernel directly, and so there's no bootloader to provide a "bootinfo" structure for us. Qemu does, however, place a Linux kernel parameter block at kernel_text[] - 0x6000 that contains Linux-style kernel command line arguments. So, add a prom_qemu_getenv() that allows us to look for specific things passed along to the kernel from there, and use them as follows: - Support specifying the root device in the forms "root=/dev/wd0a", "root=wd0a", or "rootdev=wd0". - Support SRM-like -flags ... in the form of "flags=AD". In the case of Qemu, we also assume that no flags=... is the same as "flags=A", i.e. perform an auto-boot. Also allow an alternate delay() function to be specified, if the platform wishes to provide one. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/arch/alpha/alpha/autoconf.c cvs rdiff -u -r1.365 -r1.366 src/sys/arch/alpha/alpha/machdep.c cvs rdiff -u -r1.57 -r1.58 src/sys/arch/alpha/alpha/prom.c cvs rdiff -u -r1.41 -r1.42 src/sys/arch/alpha/include/alpha.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/alpha/include/prom.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/alpha/alpha/autoconf.c diff -u src/sys/arch/alpha/alpha/autoconf.c:1.54 src/sys/arch/alpha/alpha/autoconf.c:1.55 --- src/sys/arch/alpha/alpha/autoconf.c:1.54 Mon Sep 3 16:29:22 2018 +++ src/sys/arch/alpha/alpha/autoconf.c Sat Oct 3 17:31:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.54 2018/09/03 16:29:22 riastradh Exp $ */ +/* $NetBSD: autoconf.c,v 1.55 2020/10/03 17:31:46 thorpej Exp $ */ /* * Copyright (c) 1992, 1993 @@ -42,7 +42,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.54 2018/09/03 16:29:22 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.55 2020/10/03 17:31:46 thorpej Exp $"); #include "pci.h" @@ -97,13 +97,64 @@ cpu_configure(void) hwrpb_restart_setup(); } +static void +qemu_find_rootdev(void) +{ + char buf[32]; + + /* + * Check for "rootdev=wd0". + */ + if (prom_qemu_getenv("rootdev", buf, sizeof(buf))) { + snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev), + "rootdev=%s", buf); + booted_device = device_find_by_xname(buf); + return; + } + + /* + * Check for "root=/dev/wd0a", "root=/dev/hda1", etc. + */ + if (prom_qemu_getenv("root", buf, sizeof(buf))) { + const size_t devlen = strlen("/dev/"); + const char *cp = buf; + char *ecp = [sizeof(buf) - 1]; + + snprintf(bootinfo.booted_dev, sizeof(bootinfo.booted_dev), + "root=%s", buf); + + /* Find the start of the device xname. */ + if (strlen(cp) > devlen && strncmp(cp, "/dev/", devlen) == 0) { + cp += devlen; + } + + /* Now strip any partition letter off the end. */ + while (ecp != cp) { + if (*ecp >= '0' && *ecp <= '9') { +break; + } + *ecp-- = '\0'; + } + + booted_device = device_find_by_xname(cp); + return; + } + + printf("WARNING: no rootdev= or root= arguments provided by Qemu\n"); +} + void cpu_rootconf(void) { - if (booted_device == NULL) + if (booted_device == NULL && alpha_is_qemu) { + qemu_find_rootdev(); + } + + if (booted_device == NULL) { printf("WARNING: can't figure what device matches \"%s\"\n", bootinfo.booted_dev); + } rootconf(); } Index: src/sys/arch/alpha/alpha/machdep.c diff -u src/sys/arch/alpha/alpha/machdep.c:1.365 src/sys/arch/alpha/alpha/machdep.c:1.366 --- src/sys/arch/alpha/alpha/machdep.c:1.365 Sun Sep 27 23:16:10 2020 +++ src/sys/arch/alpha/alpha/machdep.c Sat Oct 3 17:31:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.365 2020/09/27 23:16:10 thorpej Exp $ */ +/* $NetBSD: machdep.c,v 1.366 2020/10/03 17:31:46 thorpej Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2019 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.365 2020/09/27 23:16:10 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.366 2020/10/03 17:31:46 thorpej Exp $"); #include #include @@ -320,12 +320,24 @@ nobootinfo: bootinfo.hwrpb_phys = ((struct rpb *)HWRPB_ADDR)->rpb_phys; bootinfo.hwrpb_size = ((struct rpb *)HWRPB_ADDR)->rpb_size; init_prom_interface(ptb, (struct rpb *)HWRPB_ADDR); - prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo.boot_flags, - sizeof bootinfo.boot_flags); - prom_getenv(PROM_E_BOOTED_FILE, bootinfo.booted_kernel, - sizeof bootinfo.booted_kernel); - prom_getenv(PROM_E_BOOTED_DEV, bootinfo.booted_dev, - sizeof bootinfo.booted_dev); + if (alpha_is_qemu) { + /* + * Grab boot flags from kernel command line. + * Assume autoboot if not supplied. + */ + if (!
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 17:30:54 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: hanoi-include.exp hanoi-include.mk Log Message: make(1): add test demonstrating the Towers of Hanoi puzzle It's not the primary task of make to handle procedure calls with parameters, combined with lexical scoping, therefore the code does not look as straight-forward or clean as in other programming languages. It feels more like squeezing a programming problem from the imperative world into the world of declarative dependencies. A more idiomatic way of implementing this puzzle should be as a dependency graph since that's both the natural structure of the puzzle and the primary domain of make. Something like having a main target "hanoi-5" that depends on intermediate targets of the form "move-1.2.3.4.5-_._._._._-_._._._._", each representing a single configuration of the stacks. These targets could be generated dynamically. A benefit of this implementation would be that the puzzle could be resumed from an arbitrary configuration, just just from the initial configuration. To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/hanoi-include.exp \ src/usr.bin/make/unit-tests/hanoi-include.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.158 src/usr.bin/make/unit-tests/Makefile:1.159 --- src/usr.bin/make/unit-tests/Makefile:1.158 Sat Oct 3 14:39:36 2020 +++ src/usr.bin/make/unit-tests/Makefile Sat Oct 3 17:30:54 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.158 2020/10/03 14:39:36 rillig Exp $ +# $NetBSD: Makefile,v 1.159 2020/10/03 17:30:54 rillig Exp $ # # Unit tests for make(1) # @@ -168,6 +168,7 @@ TESTS+= export-env TESTS+= export-variants TESTS+= forloop TESTS+= forsubst +TESTS+= hanoi-include TESTS+= impsrc TESTS+= include-main TESTS+= job-output-long-lines Added files: Index: src/usr.bin/make/unit-tests/hanoi-include.exp diff -u /dev/null src/usr.bin/make/unit-tests/hanoi-include.exp:1.1 --- /dev/null Sat Oct 3 17:30:54 2020 +++ src/usr.bin/make/unit-tests/hanoi-include.exp Sat Oct 3 17:30:54 2020 @@ -0,0 +1,32 @@ +Move the upper disk from stack A to stack C. +Move the upper disk from stack A to stack B. +Move the upper disk from stack C to stack B. +Move the upper disk from stack A to stack C. +Move the upper disk from stack B to stack A. +Move the upper disk from stack B to stack C. +Move the upper disk from stack A to stack C. +Move the upper disk from stack A to stack B. +Move the upper disk from stack C to stack B. +Move the upper disk from stack C to stack A. +Move the upper disk from stack B to stack A. +Move the upper disk from stack C to stack B. +Move the upper disk from stack A to stack C. +Move the upper disk from stack A to stack B. +Move the upper disk from stack C to stack B. +Move the upper disk from stack A to stack C. +Move the upper disk from stack B to stack A. +Move the upper disk from stack B to stack C. +Move the upper disk from stack A to stack C. +Move the upper disk from stack B to stack A. +Move the upper disk from stack C to stack B. +Move the upper disk from stack C to stack A. +Move the upper disk from stack B to stack A. +Move the upper disk from stack B to stack C. +Move the upper disk from stack A to stack C. +Move the upper disk from stack A to stack B. +Move the upper disk from stack C to stack B. +Move the upper disk from stack A to stack C. +Move the upper disk from stack B to stack A. +Move the upper disk from stack B to stack C. +Move the upper disk from stack A to stack C. +exit status 0 Index: src/usr.bin/make/unit-tests/hanoi-include.mk diff -u /dev/null src/usr.bin/make/unit-tests/hanoi-include.mk:1.1 --- /dev/null Sat Oct 3 17:30:54 2020 +++ src/usr.bin/make/unit-tests/hanoi-include.mk Sat Oct 3 17:30:54 2020 @@ -0,0 +1,41 @@ +# $NetBSD: hanoi-include.mk,v 1.1 2020/10/03 17:30:54 rillig Exp $ +# +# Implements the Towers of Hanoi puzzle, thereby demonstrating a bunch of +# useful programming techniques: +# +# * default assignment using the ?= assignment operator +# * including the same file recursively +# * extracting the current value of a variable using the .for loop +# * using shell commands for calculations since make is a text processor +# * using the :: dependency operator for adding commands to a target +# * on-the-fly variable assignment expressions using the ::= modifier +# +# usage: +# env N=3 make -f hanoi-include.mk +# endless loop: +# make -f hanoi-include.mk N=3 + +N?= 5 # Move this number of disks ... +FROM?= A # ... from this stack ... +VIA?= B # ... via this stack ... +TO?= C # ... to this stack. + +.if $N == 1 +. for from to in
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 15:38:13 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: shell-csh.exp shell-csh.mk Log Message: make(1): demonstrate naive output filtering with csh in parallel mode To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/shell-csh.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/shell-csh.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/shell-csh.exp diff -u src/usr.bin/make/unit-tests/shell-csh.exp:1.4 src/usr.bin/make/unit-tests/shell-csh.exp:1.5 --- src/usr.bin/make/unit-tests/shell-csh.exp:1.4 Sat Oct 3 15:28:37 2020 +++ src/usr.bin/make/unit-tests/shell-csh.exp Sat Oct 3 15:38:13 2020 @@ -5,4 +5,5 @@ echo always always echo ignore errors ignore errors +They chatted in the sy. exit status 0 Index: src/usr.bin/make/unit-tests/shell-csh.mk diff -u src/usr.bin/make/unit-tests/shell-csh.mk:1.3 src/usr.bin/make/unit-tests/shell-csh.mk:1.4 --- src/usr.bin/make/unit-tests/shell-csh.mk:1.3 Sat Oct 3 15:23:42 2020 +++ src/usr.bin/make/unit-tests/shell-csh.mk Sat Oct 3 15:38:13 2020 @@ -1,12 +1,17 @@ -# $NetBSD: shell-csh.mk,v 1.3 2020/10/03 15:23:42 rillig Exp $ +# $NetBSD: shell-csh.mk,v 1.4 2020/10/03 15:38:13 rillig Exp $ # # Tests for using a C shell for running the commands. +# The shell path must be an absolute path. +# This is only obvious in parallel mode since in compat mode, +# simple commands are executed via execve directly. .SHELL: name="csh" path="${:!which csh!}" -# The -j option is needed to cover the code in JobOutput. +# In parallel mode, the commandShell->noPrint command is filtered from +# the output, rather naively (in JobOutput). # -# FIXME: The "se " does not belong in the output. +# Until 2020-10-03, the output in parallel mode was garbled because +# the definition of the csh had been wrong since 1993 at least. .MAKEFLAGS: -j1 all: @@ -21,3 +26,7 @@ all: # This command is both printed and executed. -echo ignore errors + + # In the C shell, "unset verbose" is set as the noPrint command. + # Therefore it is filtered from the output, rather naively. + @echo 'They chatted in the sunset verbosely.'
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 15:28:37 UTC 2020 Modified Files: src/usr.bin/make: job.c src/usr.bin/make/unit-tests: shell-csh.exp Log Message: make(1): fix shell definition for csh The bug has been there since at least 1993-03-21. This is strong evidence that nobody has ever used the csh in parallel mode. To generate a diff of this commit: cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/job.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/shell-csh.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.255 src/usr.bin/make/job.c:1.256 --- src/usr.bin/make/job.c:1.255 Sat Oct 3 15:00:57 2020 +++ src/usr.bin/make/job.c Sat Oct 3 15:28:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.255 2020/10/03 15:00:57 rillig Exp $ */ +/* $NetBSD: job.c,v 1.256 2020/10/03 15:28:37 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.255 2020/10/03 15:00:57 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.256 2020/10/03 15:28:37 rillig Exp $"); # define STATIC static @@ -264,7 +264,7 @@ static Shellshells[] = { */ { "csh", -TRUE, "unset verbose", "set verbose", "unset verbose", 10, +TRUE, "unset verbose", "set verbose", "unset verbose", 13, FALSE, "echo \"%s\"\n", "csh -c \"%s || exit 0\"\n", "", "'\\\n'", '#', "v", "e", }, Index: src/usr.bin/make/unit-tests/shell-csh.exp diff -u src/usr.bin/make/unit-tests/shell-csh.exp:1.3 src/usr.bin/make/unit-tests/shell-csh.exp:1.4 --- src/usr.bin/make/unit-tests/shell-csh.exp:1.3 Sat Oct 3 15:23:42 2020 +++ src/usr.bin/make/unit-tests/shell-csh.exp Sat Oct 3 15:28:37 2020 @@ -1,10 +1,8 @@ echo normal normal -se hidden echo always always -se echo ignore errors ignore errors exit status 0
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 15:23:42 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: shell-csh.exp shell-csh.mk Log Message: make(1): demonstrate wrong output when using csh in parallel mode To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/shell-csh.exp \ src/usr.bin/make/unit-tests/shell-csh.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/shell-csh.exp diff -u src/usr.bin/make/unit-tests/shell-csh.exp:1.2 src/usr.bin/make/unit-tests/shell-csh.exp:1.3 --- src/usr.bin/make/unit-tests/shell-csh.exp:1.2 Sat Oct 3 15:21:12 2020 +++ src/usr.bin/make/unit-tests/shell-csh.exp Sat Oct 3 15:23:42 2020 @@ -1,8 +1,10 @@ echo normal normal +se hidden echo always always +se echo ignore errors ignore errors exit status 0 Index: src/usr.bin/make/unit-tests/shell-csh.mk diff -u src/usr.bin/make/unit-tests/shell-csh.mk:1.2 src/usr.bin/make/unit-tests/shell-csh.mk:1.3 --- src/usr.bin/make/unit-tests/shell-csh.mk:1.2 Sat Oct 3 15:21:12 2020 +++ src/usr.bin/make/unit-tests/shell-csh.mk Sat Oct 3 15:23:42 2020 @@ -1,8 +1,13 @@ -# $NetBSD: shell-csh.mk,v 1.2 2020/10/03 15:21:12 rillig Exp $ +# $NetBSD: shell-csh.mk,v 1.3 2020/10/03 15:23:42 rillig Exp $ # # Tests for using a C shell for running the commands. -.SHELL: name="csh" path="csh" +.SHELL: name="csh" path="${:!which csh!}" + +# The -j option is needed to cover the code in JobOutput. +# +# FIXME: The "se " does not belong in the output. +.MAKEFLAGS: -j1 all: # This command is both printed and executed.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 15:21:13 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: shell-csh.exp shell-csh.mk Log Message: make(1): refine test for printing commands using csh To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/shell-csh.exp \ src/usr.bin/make/unit-tests/shell-csh.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/shell-csh.exp diff -u src/usr.bin/make/unit-tests/shell-csh.exp:1.1 src/usr.bin/make/unit-tests/shell-csh.exp:1.2 --- src/usr.bin/make/unit-tests/shell-csh.exp:1.1 Sat Oct 3 14:39:36 2020 +++ src/usr.bin/make/unit-tests/shell-csh.exp Sat Oct 3 15:21:12 2020 @@ -1,4 +1,8 @@ -true normal -true always -true ignore errors +echo normal +normal +hidden +echo always +always +echo ignore errors +ignore errors exit status 0 Index: src/usr.bin/make/unit-tests/shell-csh.mk diff -u src/usr.bin/make/unit-tests/shell-csh.mk:1.1 src/usr.bin/make/unit-tests/shell-csh.mk:1.2 --- src/usr.bin/make/unit-tests/shell-csh.mk:1.1 Sat Oct 3 14:39:36 2020 +++ src/usr.bin/make/unit-tests/shell-csh.mk Sat Oct 3 15:21:12 2020 @@ -1,13 +1,18 @@ -# $NetBSD: shell-csh.mk,v 1.1 2020/10/03 14:39:36 rillig Exp $ +# $NetBSD: shell-csh.mk,v 1.2 2020/10/03 15:21:12 rillig Exp $ # # Tests for using a C shell for running the commands. .SHELL: name="csh" path="csh" -# Contrary to sh and ksh, the csh does not know the ':' command. -# Therefore this test uses 'true' instead. all: - true normal - @true hidden - +true always - -true ignore errors + # This command is both printed and executed. + echo normal + + # This command is only executed. + @echo hidden + + # This command is both printed and executed. + +echo always + + # This command is both printed and executed. + -echo ignore errors
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 15:00:57 UTC 2020 Modified Files: src/usr.bin/make: job.c nonints.h str.c Log Message: make(1): inline Str_FindSubstring in JobOutput To generate a diff of this commit: cvs rdiff -u -r1.254 -r1.255 src/usr.bin/make/job.c cvs rdiff -u -r1.133 -r1.134 src/usr.bin/make/nonints.h cvs rdiff -u -r1.65 -r1.66 src/usr.bin/make/str.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/job.c diff -u src/usr.bin/make/job.c:1.254 src/usr.bin/make/job.c:1.255 --- src/usr.bin/make/job.c:1.254 Thu Oct 1 22:42:00 2020 +++ src/usr.bin/make/job.c Sat Oct 3 15:00:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.254 2020/10/01 22:42:00 rillig Exp $ */ +/* $NetBSD: job.c,v 1.255 2020/10/03 15:00:57 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.254 2020/10/01 22:42:00 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.255 2020/10/03 15:00:57 rillig Exp $"); # define STATIC static @@ -1580,9 +1580,8 @@ JobOutput(Job *job, char *cp, char *endp { char *ecp; -if (commandShell->noPrint) { - ecp = Str_FindSubstring(cp, commandShell->noPrint); - while (ecp != NULL) { +if (commandShell->noPrint && commandShell->noPrint[0] != '\0') { + while ((ecp = strstr(cp, commandShell->noPrint)) != NULL) { if (cp != ecp) { *ecp = '\0'; if (!beSilent && msg && job->node != lastNode) { @@ -1609,7 +1608,6 @@ JobOutput(Job *job, char *cp, char *endp while (*cp == ' ' || *cp == '\t' || *cp == '\n') { cp++; } - ecp = Str_FindSubstring(cp, commandShell->noPrint); } else { return cp; } Index: src/usr.bin/make/nonints.h diff -u src/usr.bin/make/nonints.h:1.133 src/usr.bin/make/nonints.h:1.134 --- src/usr.bin/make/nonints.h:1.133 Thu Oct 1 23:44:36 2020 +++ src/usr.bin/make/nonints.h Sat Oct 3 15:00:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nonints.h,v 1.133 2020/10/01 23:44:36 rillig Exp $ */ +/* $NetBSD: nonints.h,v 1.134 2020/10/03 15:00:57 rillig Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -147,7 +147,6 @@ Words_Free(Words w) { char *str_concat2(const char *, const char *); char *str_concat3(const char *, const char *, const char *); char *str_concat4(const char *, const char *, const char *, const char *); -char *Str_FindSubstring(const char *, const char *); Boolean Str_Match(const char *, const char *); /* suff.c */ Index: src/usr.bin/make/str.c diff -u src/usr.bin/make/str.c:1.65 src/usr.bin/make/str.c:1.66 --- src/usr.bin/make/str.c:1.65 Sun Sep 13 15:15:51 2020 +++ src/usr.bin/make/str.c Sat Oct 3 15:00:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.65 2020/09/13 15:15:51 rillig Exp $ */ +/* $NetBSD: str.c,v 1.66 2020/10/03 15:00:57 rillig Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -71,7 +71,7 @@ #include "make.h" /* "@(#)str.c 5.8 (Berkeley) 6/1/90" */ -MAKE_RCSID("$NetBSD: str.c,v 1.65 2020/09/13 15:15:51 rillig Exp $"); +MAKE_RCSID("$NetBSD: str.c,v 1.66 2020/10/03 15:00:57 rillig Exp $"); /* Return the concatenation of s1 and s2, freshly allocated. */ char * @@ -269,46 +269,6 @@ done: } /* - * Str_FindSubstring -- See if a string contains a particular substring. - * - * Input: - * string String to search. - * substring Substring to find in string. - * - * Results: If string contains substring, the return value is the location of - * the first matching instance of substring in string. If string doesn't - * contain substring, the return value is NULL. Matching is done on an exact - * character-for-character basis with no wildcards or special characters. - * - * Side effects: None. - */ -char * -Str_FindSubstring(const char *string, const char *substring) -{ - const char *a, *b; - - /* - * First scan quickly through the two strings looking for a single- - * character match. When it's found, then compare the rest of the - * substring. - */ - - for (b = substring; *string != 0; string++) { - if (*string != *b) - continue; - a = string; - for (;;) { - if (*b == 0) -return UNCONST(string); - if (*a++ != *b++) -break; - } - b = substring; - } - return NULL; -} - -/* * Str_Match -- Test if a string matches a pattern like "*.[ch]". * * XXX this function does not detect or report malformed patterns.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 14:41:20 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): inline Str_FindSubstring in ModifyWord_Subst To generate a diff of this commit: cvs rdiff -u -r1.562 -r1.563 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.562 src/usr.bin/make/var.c:1.563 --- src/usr.bin/make/var.c:1.562 Sat Oct 3 12:51:49 2020 +++ src/usr.bin/make/var.c Sat Oct 3 14:41:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.562 2020/10/03 12:51:49 rillig Exp $ */ +/* $NetBSD: var.c,v 1.563 2020/10/03 14:41:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.562 2020/10/03 12:51:49 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.563 2020/10/03 14:41:20 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -1292,8 +1292,11 @@ ModifyWord_Subst(const char *word, SepBu return; } +if (args->lhs[0] == '\0') + goto nosub; + /* unanchored case, may match more than once */ -while ((match = Str_FindSubstring(word, args->lhs)) != NULL) { +while ((match = strstr(word, args->lhs)) != NULL) { SepBuf_AddBytesBetween(buf, word, match); SepBuf_AddBytes(buf, args->rhs, args->rhsLen); args->matched = TRUE;
CVS commit: src
Module Name:src Committed By: rillig Date: Sat Oct 3 14:39:36 UTC 2020 Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: shell-csh.exp shell-csh.mk shell-custom.exp shell-custom.mk shell-ksh.exp shell-ksh.mk shell-sh.exp shell-sh.mk Log Message: make(1): add tests for the various supported shells To generate a diff of this commit: cvs rdiff -u -r1.935 -r1.936 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.157 -r1.158 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/shell-csh.exp \ src/usr.bin/make/unit-tests/shell-csh.mk \ src/usr.bin/make/unit-tests/shell-custom.exp \ src/usr.bin/make/unit-tests/shell-custom.mk \ src/usr.bin/make/unit-tests/shell-ksh.exp \ src/usr.bin/make/unit-tests/shell-ksh.mk \ src/usr.bin/make/unit-tests/shell-sh.exp \ src/usr.bin/make/unit-tests/shell-sh.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.935 src/distrib/sets/lists/tests/mi:1.936 --- src/distrib/sets/lists/tests/mi:1.935 Fri Oct 2 20:34:59 2020 +++ src/distrib/sets/lists/tests/mi Sat Oct 3 14:39:36 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.935 2020/10/02 20:34:59 rillig Exp $ +# $NetBSD: mi,v 1.936 2020/10/03 14:39:36 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4973,6 +4973,14 @@ ./usr/tests/usr.bin/make/unit-tests/sh-single-line.mktests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/sh.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/sh.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/shell-csh.exptests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/shell-csh.mktests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/shell-custom.exptests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/shell-custom.mktests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/shell-ksh.exptests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/shell-ksh.mktests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/shell-sh.exptests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/shell-sh.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/suff-rebuild.exptests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/suff-rebuild.mktests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/suffixes.exptests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.157 src/usr.bin/make/unit-tests/Makefile:1.158 --- src/usr.bin/make/unit-tests/Makefile:1.157 Sat Oct 3 08:16:53 2020 +++ src/usr.bin/make/unit-tests/Makefile Sat Oct 3 14:39:36 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.157 2020/10/03 08:16:53 rillig Exp $ +# $NetBSD: Makefile,v 1.158 2020/10/03 14:39:36 rillig Exp $ # # Unit tests for make(1) # @@ -244,6 +244,10 @@ TESTS+= sh-leading-plus TESTS+= sh-meta-chars TESTS+= sh-multi-line TESTS+= sh-single-line +TESTS+= shell-csh +TESTS+= shell-custom +TESTS+= shell-ksh +TESTS+= shell-sh TESTS+= # suffixes # runs into an endless loop (try -dA) TESTS+= suff-rebuild TESTS+= sunshcmd Added files: Index: src/usr.bin/make/unit-tests/shell-csh.exp diff -u /dev/null src/usr.bin/make/unit-tests/shell-csh.exp:1.1 --- /dev/null Sat Oct 3 14:39:36 2020 +++ src/usr.bin/make/unit-tests/shell-csh.exp Sat Oct 3 14:39:36 2020 @@ -0,0 +1,4 @@ +true normal +true always +true ignore errors +exit status 0 Index: src/usr.bin/make/unit-tests/shell-csh.mk diff -u /dev/null src/usr.bin/make/unit-tests/shell-csh.mk:1.1 --- /dev/null Sat Oct 3 14:39:36 2020 +++ src/usr.bin/make/unit-tests/shell-csh.mk Sat Oct 3 14:39:36 2020 @@ -0,0 +1,13 @@ +# $NetBSD: shell-csh.mk,v 1.1 2020/10/03 14:39:36 rillig Exp $ +# +# Tests for using a C shell for running the commands. + +.SHELL: name="csh" path="csh" + +# Contrary to sh and ksh, the csh does not know the ':' command. +# Therefore this test uses 'true' instead. +all: + true normal + @true hidden + +true always + -true ignore errors Index: src/usr.bin/make/unit-tests/shell-custom.exp diff -u /dev/null src/usr.bin/make/unit-tests/shell-custom.exp:1.1 --- /dev/null Sat Oct 3 14:39:36 2020 +++ src/usr.bin/make/unit-tests/shell-custom.exp Sat Oct 3 14:39:36 2020 @@ -0,0 +1,8 @@ +: normal +-c : normal +-c : hidden +: always +-c : always +: ignore errors +-c : ignore errors +exit status 0 Index: src/usr.bin/make/unit-tests/shell-custom.mk diff -u /dev/null
CVS commit: src/usr.sbin/pstat
Module Name:src Committed By: christos Date: Sat Oct 3 14:01:16 UTC 2020 Modified Files: src/usr.sbin/pstat: pstat.c Log Message: Filter out the VUSECOUNT_GATE bit To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/usr.sbin/pstat/pstat.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/pstat/pstat.c diff -u src/usr.sbin/pstat/pstat.c:1.130 src/usr.sbin/pstat/pstat.c:1.131 --- src/usr.sbin/pstat/pstat.c:1.130 Wed Dec 11 14:51:36 2019 +++ src/usr.sbin/pstat/pstat.c Sat Oct 3 10:01:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pstat.c,v 1.130 2019/12/11 19:51:36 ad Exp $ */ +/* $NetBSD: pstat.c,v 1.131 2020/10/03 14:01:16 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95"; #else -__RCSID("$NetBSD: pstat.c,v 1.130 2019/12/11 19:51:36 ad Exp $"); +__RCSID("$NetBSD: pstat.c,v 1.131 2020/10/03 14:01:16 christos Exp $"); #endif #endif /* not lint */ @@ -444,8 +444,9 @@ vnode_print(struct vnode *avnode, struct PRWORD(ovflw, "%*lx", PTRSTRWIDTH, 0, (long)avnode); PRWORD(ovflw, " %*s", 4, 1, type); PRWORD(ovflw, " %*s", 6, 1, flags); - PRWORD(ovflw, " %*ld", 5, 1, (long)vp->v_usecount); - PRWORD(ovflw, " %*ld", 5, 1, (long)vp->v_holdcnt); +#define VUSECOUNT_MASK 0x7fff /* XXX: kernel private */ + PRWORD(ovflw, " %*d", 5, 1, vp->v_usecount & VUSECOUNT_MASK); + PRWORD(ovflw, " %*d", 5, 1, vp->v_holdcnt); PRWORD(ovflw, " %*d", 4, 1, vp->v_tag); PRWORD(ovflw, " %*d", 6, 1, vp->v_uobj.uo_npages); return (ovflw);
CVS commit: src/sys/dev/virtio
Module Name:src Committed By: jmcneill Date: Sat Oct 3 13:51:34 UTC 2020 Modified Files: src/sys/dev/virtio: virtio_mmio.c Log Message: MMIO configuration space is in guest byte order. AArch64 BE is special, as the guest starts in LE and we switch to BE after the kernel starts. For this case, we need to byte swap all config space accesses. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/virtio/virtio_mmio.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/virtio/virtio_mmio.c diff -u src/sys/dev/virtio/virtio_mmio.c:1.2 src/sys/dev/virtio/virtio_mmio.c:1.3 --- src/sys/dev/virtio/virtio_mmio.c:1.2 Fri Jun 15 17:13:43 2018 +++ src/sys/dev/virtio/virtio_mmio.c Sat Oct 3 13:51:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_mmio.c,v 1.2 2018/06/15 17:13:43 jakllsch Exp $ */ +/* $NetBSD: virtio_mmio.c,v 1.3 2020/10/03 13:51:34 jmcneill Exp $ */ /* $OpenBSD: virtio_mmio.c,v 1.2 2017/02/24 17:12:31 patrick Exp $ */ /* @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: virtio_mmio.c,v 1.2 2018/06/15 17:13:43 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_mmio.c,v 1.3 2020/10/03 13:51:34 jmcneill Exp $"); #include #include @@ -66,6 +66,27 @@ __KERNEL_RCSID(0, "$NetBSD: virtio_mmio. #define VIRTIO_MMIO_INT_CONFIG (1 << 1) /* + * MMIO configuration space is in guest byte order. AArch64 BE is special, + * as the guest starts in LE and we switch to BE after the kernel starts. + * For this case, we need to byte swap all config space accesses. + */ +#if defined(__aarch64__) && BYTE_ORDER == BIG_ENDIAN +#define VIO16TOH(x) le16toh(x) +#define VIO32TOH(x) le32toh(x) +#define VIO64TOH(x) le64toh(x) +#define HTOVIO16(x) htole16(x) +#define HTOVIO32(x) htole32(x) +#define HTOVIO64(x) htole64(x) +#else +#define VIO16TOH(x) (x) +#define VIO32TOH(x) (x) +#define VIO64TOH(x) (x) +#define HTOVIO16(x) (x) +#define HTOVIO32(x) (x) +#define HTOVIO64(x) (x) +#endif + +/* * XXX: Before being used on big endian arches, the access to config registers * XXX: needs to be reviewed/fixed. The non-device specific registers are * XXX: PCI-endian while the device specific registers are native endian. @@ -242,16 +263,16 @@ static uint16_t virtio_mmio_read_device_config_2(struct virtio_softc *vsc, int index) { struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)vsc; - return bus_space_read_2(sc->sc_iot, sc->sc_ioh, -VIRTIO_MMIO_CONFIG + index); + return VIO16TOH(bus_space_read_2(sc->sc_iot, sc->sc_ioh, + VIRTIO_MMIO_CONFIG + index)); } static uint32_t virtio_mmio_read_device_config_4(struct virtio_softc *vsc, int index) { struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)vsc; - return bus_space_read_4(sc->sc_iot, sc->sc_ioh, -VIRTIO_MMIO_CONFIG + index); + return VIO32TOH(bus_space_read_4(sc->sc_iot, sc->sc_ioh, + VIRTIO_MMIO_CONFIG + index)); } static uint64_t @@ -265,7 +286,7 @@ virtio_mmio_read_device_config_8(struct r <<= 32; r += bus_space_read_4(sc->sc_iot, sc->sc_ioh, VIRTIO_MMIO_CONFIG + index); - return r; + return VIO64TOH(r); } static void @@ -283,7 +304,7 @@ virtio_mmio_write_device_config_2(struct { struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)vsc; bus_space_write_2(sc->sc_iot, sc->sc_ioh, - VIRTIO_MMIO_CONFIG + index, value); + VIRTIO_MMIO_CONFIG + index, HTOVIO16(value)); } static void @@ -292,7 +313,7 @@ virtio_mmio_write_device_config_4(struct { struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)vsc; bus_space_write_4(sc->sc_iot, sc->sc_ioh, - VIRTIO_MMIO_CONFIG + index, value); + VIRTIO_MMIO_CONFIG + index, HTOVIO32(value)); } static void @@ -302,10 +323,10 @@ virtio_mmio_write_device_config_8(struct struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)vsc; bus_space_write_4(sc->sc_iot, sc->sc_ioh, VIRTIO_MMIO_CONFIG + index, - value & 0x); + HTOVIO64(value) & 0x); bus_space_write_4(sc->sc_iot, sc->sc_ioh, VIRTIO_MMIO_CONFIG + index + sizeof(uint32_t), - value >> 32); + HTOVIO64(value) >> 32); } /*
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 13:22:39 UTC 2020 Modified Files: src/usr.bin/make: main.c Log Message: make(1): replace backslash-newline with ordinary string literals The character sequence backslash-newline is not mentioned in ISO C99. To generate a diff of this commit: cvs rdiff -u -r1.362 -r1.363 src/usr.bin/make/main.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/main.c diff -u src/usr.bin/make/main.c:1.362 src/usr.bin/make/main.c:1.363 --- src/usr.bin/make/main.c:1.362 Sat Oct 3 13:06:56 2020 +++ src/usr.bin/make/main.c Sat Oct 3 13:22:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.362 2020/10/03 13:06:56 rillig Exp $ */ +/* $NetBSD: main.c,v 1.363 2020/10/03 13:22:39 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,10 +126,11 @@ #endif /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.362 2020/10/03 13:06:56 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.363 2020/10/03 13:22:39 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) -__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ - The Regents of the University of California. All rights reserved."); +__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " + "The Regents of the University of California. " + "All rights reserved."); #endif #ifndef DEFMAXLOCAL
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 13:06:56 UTC 2020 Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: opt-debug.exp opt-debug.mk Log Message: make(1): allow to disable debug logging options This is only intended for the unit tests, to selectively enable and disable debug logging as needed. Previously the tests for debug logging required complicated postprocessing that was not obvious when looking at the test .mk file alone, but was specified externally in unit-tests/Makefile. This is the simplest possible implementation. Another variant would have been to selectively disable individual debug logging options, but that would have made the code more complicated. The -dL option is not affected by -d0 since that is not really a debug option, even if it is implemented as one. To generate a diff of this commit: cvs rdiff -u -r1.361 -r1.362 src/usr.bin/make/main.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-debug.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.361 src/usr.bin/make/main.c:1.362 --- src/usr.bin/make/main.c:1.361 Thu Oct 1 23:52:51 2020 +++ src/usr.bin/make/main.c Sat Oct 3 13:06:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.361 2020/10/01 23:52:51 rillig Exp $ */ +/* $NetBSD: main.c,v 1.362 2020/10/03 13:06:56 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,7 +126,7 @@ #endif /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.361 2020/10/01 23:52:51 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.362 2020/10/03 13:06:56 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ The Regents of the University of California. All rights reserved."); @@ -270,6 +270,9 @@ parse_debug_options(const char *argvalue for (modules = argvalue; *modules; ++modules) { switch (*modules) { + case '0': /* undocumented, only intended for tests */ + debug &= DEBUG_LINT; + break; case 'A': debug = ~(0|DEBUG_LINT); break; Index: src/usr.bin/make/unit-tests/opt-debug.exp diff -u src/usr.bin/make/unit-tests/opt-debug.exp:1.1 src/usr.bin/make/unit-tests/opt-debug.exp:1.2 --- src/usr.bin/make/unit-tests/opt-debug.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/opt-debug.exp Sat Oct 3 13:06:56 2020 @@ -1 +1,4 @@ +Global:VAR = value +Global:.MAKEFLAGS = -r -k -d v -d +Global:.MAKEFLAGS = -r -k -d v -d 0 exit status 0 Index: src/usr.bin/make/unit-tests/opt-debug.mk diff -u src/usr.bin/make/unit-tests/opt-debug.mk:1.2 src/usr.bin/make/unit-tests/opt-debug.mk:1.3 --- src/usr.bin/make/unit-tests/opt-debug.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/opt-debug.mk Sat Oct 3 13:06:56 2020 @@ -1,8 +1,14 @@ -# $NetBSD: opt-debug.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: opt-debug.mk,v 1.3 2020/10/03 13:06:56 rillig Exp $ # -# Tests for the -d command line option. +# Tests for the -d command line option, which controls debug logging. -# TODO: Implementation +# Enable debug logging for the variables (var.c). +.MAKEFLAGS: -dv + +VAR= value + +# Disable all debug logging again. +.MAKEFLAGS: -d0 # -d0 is available since 2020-10-03 all: @:;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 12:51:49 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): extract ApplyModifier_Literal into separate function To generate a diff of this commit: cvs rdiff -u -r1.561 -r1.562 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.561 src/usr.bin/make/var.c:1.562 --- src/usr.bin/make/var.c:1.561 Sat Oct 3 12:46:52 2020 +++ src/usr.bin/make/var.c Sat Oct 3 12:51:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.561 2020/10/03 12:46:52 rillig Exp $ */ +/* $NetBSD: var.c,v 1.562 2020/10/03 12:51:49 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.561 2020/10/03 12:46:52 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.562 2020/10/03 12:51:49 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -2065,6 +2065,16 @@ ApplyModifier_Defined(const char **pp, A return AMR_OK; } +/* :L */ +static ApplyModifierResult +ApplyModifier_Literal(const char **pp, ApplyModifiersState *st) +{ +ApplyModifiersState_Define(st); +st->newVal = bmake_strdup(st->v->name); +(*pp)++; +return AMR_OK; +} + /* :gmtime */ static ApplyModifierResult ApplyModifier_Gmtime(const char **pp, ApplyModifiersState *st) @@ -3076,10 +3086,7 @@ ApplyModifier(const char **pp, ApplyModi case 'U': return ApplyModifier_Defined(pp, st); case 'L': - ApplyModifiersState_Define(st); - st->newVal = bmake_strdup(st->v->name); - (*pp)++; - return AMR_OK; +return ApplyModifier_Literal(pp, st); case 'P': return ApplyModifier_Path(pp, st); case '!':
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 12:46:52 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): extract ApplyModifier_Unique into separate function To generate a diff of this commit: cvs rdiff -u -r1.560 -r1.561 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.560 src/usr.bin/make/var.c:1.561 --- src/usr.bin/make/var.c:1.560 Sat Oct 3 12:30:17 2020 +++ src/usr.bin/make/var.c Sat Oct 3 12:46:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.560 2020/10/03 12:30:17 rillig Exp $ */ +/* $NetBSD: var.c,v 1.561 2020/10/03 12:46:52 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.560 2020/10/03 12:30:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.561 2020/10/03 12:46:52 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -2927,6 +2927,17 @@ ApplyModifier_WordFunc(const char **pp, return AMR_OK; } +static ApplyModifierResult +ApplyModifier_Unique(const char **pp, ApplyModifiersState *st) +{ +if ((*pp)[1] == st->endc || (*pp)[1] == ':') { + st->newVal = VarUniq(st->val); + (*pp)++; + return AMR_OK; +} else + return AMR_UNKNOWN; +} + #ifdef SYSVVARSUB /* :from=to */ static ApplyModifierResult @@ -3110,12 +3121,7 @@ ApplyModifier(const char **pp, ApplyModi case 'O': return ApplyModifier_Order(pp, st); case 'u': - if ((*pp)[1] == st->endc || (*pp)[1] == ':') { - st->newVal = VarUniq(st->val); - (*pp)++; - return AMR_OK; - } else - return AMR_UNKNOWN; +return ApplyModifier_Unique(pp, st); #ifdef SUNSHCMD case 's': return ApplyModifier_SunShell(pp, st);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 12:30:17 UTC 2020 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: opt-debug-lint.exp Log Message: make(1): in lint mode, reject modifiers without delimiter The expression ${VAR:LPL} must now be written as ${VAR:L:P:L}. The manual page has never documented that some modifiers don't need to be delimited by ':' and others need to. That would have been unnecessarily confusing anyway. To generate a diff of this commit: cvs rdiff -u -r1.559 -r1.560 src/usr.bin/make/var.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/opt-debug-lint.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.559 src/usr.bin/make/var.c:1.560 --- src/usr.bin/make/var.c:1.559 Sat Oct 3 10:42:08 2020 +++ src/usr.bin/make/var.c Sat Oct 3 12:30:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.559 2020/10/03 10:42:08 rillig Exp $ */ +/* $NetBSD: var.c,v 1.560 2020/10/03 12:30:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.559 2020/10/03 10:42:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.560 2020/10/03 12:30:17 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -3169,13 +3169,21 @@ ApplyModifiers( /* TODO: handle errors */ /* - * If we have not parsed up to st.endc or ':', - * we are not interested. + * If we have not parsed up to st.endc or ':', we are not + * interested. This means the expression ${VAR:${M_1}${M_2}} + * is not accepted, but ${VAR:${M_1}:${M_2}} is. */ if (rval[0] != '\0' && (c = *nested_p) != '\0' && c != ':' && c != st.endc) { + if (DEBUG(LINT)) + Parse_Error(PARSE_FATAL, +"Missing delimiter ':' after indirect modifier \"%.*s\"", +(int)(nested_p - p), p); + free(freeIt); /* XXX: apply_mods doesn't sound like "not interested". */ + /* XXX: Why is the indirect modifier parsed again by + * apply_mods? If any, p should be advanced to nested_p. */ goto apply_mods; } @@ -3196,6 +3204,7 @@ ApplyModifiers( } } free(freeIt); + if (*p == ':') p++; else if (*p == '\0' && endc != '\0') { @@ -3252,6 +3261,10 @@ ApplyModifiers( st.endc, st.v->name, st.val, *mod); } else if (*p == ':') { p++; + } else if (DEBUG(LINT) && *p != '\0' && *p != endc) { + Parse_Error(PARSE_FATAL, + "Missing delimiter ':' after modifier \"%.*s\"", + (int)(p - mod), mod); } } out: Index: src/usr.bin/make/unit-tests/opt-debug-lint.exp diff -u src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.8 src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.9 --- src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.8 Sat Oct 3 12:26:11 2020 +++ src/usr.bin/make/unit-tests/opt-debug-lint.exp Sat Oct 3 12:30:17 2020 @@ -1,5 +1,8 @@ make: "opt-debug-lint.mk" line 19: Variable "X" is undefined make: "opt-debug-lint.mk" line 41: Variable "UNDEF" is undefined +make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "L" +make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "P" +make: "opt-debug-lint.mk" line 67: Missing delimiter ':' after indirect modifier "${:UL}" make: Unknown modifier '$' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 12:26:11 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: opt-debug-lint.exp opt-debug-lint.mk Log Message: make(1): add test for variable modifiers without delimiter To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt-debug-lint.exp \ src/usr.bin/make/unit-tests/opt-debug-lint.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/opt-debug-lint.exp diff -u src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.7 src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.8 --- src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.7 Mon Sep 14 21:55:53 2020 +++ src/usr.bin/make/unit-tests/opt-debug-lint.exp Sat Oct 3 12:26:11 2020 @@ -1,5 +1,6 @@ make: "opt-debug-lint.mk" line 19: Variable "X" is undefined make: "opt-debug-lint.mk" line 41: Variable "UNDEF" is undefined +make: Unknown modifier '$' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/opt-debug-lint.mk diff -u src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.7 src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.8 --- src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.7 Mon Sep 14 21:55:53 2020 +++ src/usr.bin/make/unit-tests/opt-debug-lint.mk Sat Oct 3 12:26:11 2020 @@ -1,4 +1,4 @@ -# $NetBSD: opt-debug-lint.mk,v 1.7 2020/09/14 21:55:53 rillig Exp $ +# $NetBSD: opt-debug-lint.mk,v 1.8 2020/10/03 12:26:11 rillig Exp $ # # Tests for the -dL command line option, which runs additional checks # to catch common mistakes, such as unclosed variable expressions. @@ -56,5 +56,17 @@ ${UNDEF}: ${UNDEF} . error .endif +# Since 2020-10-03, in lint mode the variable modifier must be separated +# by colons. See varparse-mod.mk. +.if ${value:LPL} != "value" +. error +.endif + +# Since 2020-10-03, in lint mode the variable modifier must be separated +# by colons. See varparse-mod.mk. +.if ${value:${:UL}PL} != "LPL}" # FIXME: "LPL}" is unexpected here. +. error ${value:${:UL}PL} +.endif + all: @:;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 10:42:09 UTC 2020 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: make-exported.mk Log Message: make(1): ignore -env and -literal in assignments to .MAKE.EXPORTED Previously, assigning the string "-env" to the variable .MAKE.EXPORTED had the same effect as the .export-env directive. This was only due to a sloppy implementation, not by design. For the string "-literal" and the directive .export-literal, the situation was even worse since the actually executed code was a wild mixture between .export and .export-literal that in the end exported the expanded form of the variable. Therefore there was no practical use case of this implementation flaw. To generate a diff of this commit: cvs rdiff -u -r1.558 -r1.559 src/usr.bin/make/var.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/make-exported.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.558 src/usr.bin/make/var.c:1.559 --- src/usr.bin/make/var.c:1.558 Sat Oct 3 10:31:05 2020 +++ src/usr.bin/make/var.c Sat Oct 3 10:42:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.558 2020/10/03 10:31:05 rillig Exp $ */ +/* $NetBSD: var.c,v 1.559 2020/10/03 10:42:08 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.558 2020/10/03 10:31:05 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.559 2020/10/03 10:42:08 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -603,10 +603,10 @@ Var_Export(const char *str, Boolean isEx return; } -if (strncmp(str, "-env", 4) == 0) { +if (isExport && strncmp(str, "-env", 4) == 0) { str += 4; flags = 0; -} else if (strncmp(str, "-literal", 8) == 0) { +} else if (isExport && strncmp(str, "-literal", 8) == 0) { str += 8; flags = VAR_EXPORT_LITERAL; } else { Index: src/usr.bin/make/unit-tests/make-exported.mk diff -u src/usr.bin/make/unit-tests/make-exported.mk:1.3 src/usr.bin/make/unit-tests/make-exported.mk:1.4 --- src/usr.bin/make/unit-tests/make-exported.mk:1.3 Sat Oct 3 10:31:05 2020 +++ src/usr.bin/make/unit-tests/make-exported.mk Sat Oct 3 10:42:09 2020 @@ -1,4 +1,4 @@ -# $NetBSD: make-exported.mk,v 1.3 2020/10/03 10:31:05 rillig Exp $ +# $NetBSD: make-exported.mk,v 1.4 2020/10/03 10:42:09 rillig Exp $ # # As of 2020-08-09, the code in Var_Export is shared between the .export # directive and the .MAKE.EXPORTED variable. This leads to non-obvious @@ -8,23 +8,17 @@ -literal= make-exported-value-literal UT_VAR= ${UNEXPANDED} -# The following behavior is probably not intended. -.MAKE.EXPORTED= -env # behaves like .export-env +# Before 2020-10-03, the following line took the code path of .export-env, +# which was surprising behavior. Since 2020-10-03 this line tries to +# export the variable named "-env", but that is rejected because the +# variable name starts with a hyphen. +.MAKE.EXPORTED= -env -# If the value of .MAKE.EXPORTED starts with "-literal", make behaves like -# a mixture of .export-literal and a regular .export. -# XXX: This is due to a sloppy implementation, reusing code in places where -# it is not appropriate. +# Before 2020-10-03, if the value of .MAKE.EXPORTED started with "-literal", +# make behaved like a mixture of .export-literal and a regular .export. # -# In Parse_DoVar, the code path for MAKE_EXPORTED is taken, calling Var_Export -# in turn. There, the code path for .export-literal is taken, and the -# environment variable UT_VAR is set to ${UNEXPANDED}, as expected. -# Later, in Compat_RunCommand, in the child process after vfork, -# Var_ExportVars is called, which treats "-literal" as an ordinary variable -# name, therefore exports it and also overwrites the previously exported -# UT_VAR with the expanded value. -# -# Since 2020-10-03, the "variable" named "-literal" is not exported anymore. +# Since 2020-10-03, the "variable" named "-literal" is not exported anymore, +# it is just ignored since its name starts with '-'. .MAKE.EXPORTED= -literal UT_VAR all:
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 10:31:05 UTC 2020 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: make-exported.exp make-exported.mk Log Message: make(1): do not export variable names starting with '-' By convention, names of environment variables consist of uppercase letters and underscores. Most of them start with an uppercase letter. In a few cases, the names also contain lowercase letters, such as in http_proxy. Variable names starting with a hyphen are confusing and might be mistaken as command line options. Therefore don't export these. This also affects a few edge cases that don't occur in practice, such as setting .MAKE.EXPORTED=-env or .MAKE.EXPORTED=-literal. These had not worked as expected anyway. To generate a diff of this commit: cvs rdiff -u -r1.557 -r1.558 src/usr.bin/make/var.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/make-exported.exp \ src/usr.bin/make/unit-tests/make-exported.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.557 src/usr.bin/make/var.c:1.558 --- src/usr.bin/make/var.c:1.557 Sat Oct 3 10:13:39 2020 +++ src/usr.bin/make/var.c Sat Oct 3 10:31:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.557 2020/10/03 10:13:39 rillig Exp $ */ +/* $NetBSD: var.c,v 1.558 2020/10/03 10:31:05 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.557 2020/10/03 10:13:39 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.558 2020/10/03 10:31:05 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -470,6 +470,8 @@ Var_Export1(const char *name, VarExportF if (name[0] == '.') return FALSE; /* skip internals */ +if (name[0] == '-') + return FALSE; /* skip misnamed variables */ if (name[1] == '\0') { /* * A single char. Index: src/usr.bin/make/unit-tests/make-exported.exp diff -u src/usr.bin/make/unit-tests/make-exported.exp:1.2 src/usr.bin/make/unit-tests/make-exported.exp:1.3 --- src/usr.bin/make/unit-tests/make-exported.exp:1.2 Sat Oct 3 09:48:40 2020 +++ src/usr.bin/make/unit-tests/make-exported.exp Sat Oct 3 10:31:05 2020 @@ -1,3 +1,2 @@ --literal=make-exported-value-literal UT_VAR= exit status 0 Index: src/usr.bin/make/unit-tests/make-exported.mk diff -u src/usr.bin/make/unit-tests/make-exported.mk:1.2 src/usr.bin/make/unit-tests/make-exported.mk:1.3 --- src/usr.bin/make/unit-tests/make-exported.mk:1.2 Sat Oct 3 09:48:40 2020 +++ src/usr.bin/make/unit-tests/make-exported.mk Sat Oct 3 10:31:05 2020 @@ -1,4 +1,4 @@ -# $NetBSD: make-exported.mk,v 1.2 2020/10/03 09:48:40 rillig Exp $ +# $NetBSD: make-exported.mk,v 1.3 2020/10/03 10:31:05 rillig Exp $ # # As of 2020-08-09, the code in Var_Export is shared between the .export # directive and the .MAKE.EXPORTED variable. This leads to non-obvious @@ -23,6 +23,8 @@ UT_VAR= ${UNEXPANDED} # Var_ExportVars is called, which treats "-literal" as an ordinary variable # name, therefore exports it and also overwrites the previously exported # UT_VAR with the expanded value. +# +# Since 2020-10-03, the "variable" named "-literal" is not exported anymore. .MAKE.EXPORTED= -literal UT_VAR all:
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 10:13:39 UTC 2020 Modified Files: src/usr.bin/make: var.c Log Message: make(1): clean up confusing code in Var_Export The generated code stays exactly the same. To generate a diff of this commit: cvs rdiff -u -r1.556 -r1.557 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.556 src/usr.bin/make/var.c:1.557 --- src/usr.bin/make/var.c:1.556 Fri Oct 2 17:42:33 2020 +++ src/usr.bin/make/var.c Sat Oct 3 10:13:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.556 2020/10/02 17:42:33 rillig Exp $ */ +/* $NetBSD: var.c,v 1.557 2020/10/03 10:13:39 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -121,7 +121,7 @@ #include"metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.556 2020/10/02 17:42:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.557 2020/10/03 10:13:39 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -601,14 +601,14 @@ Var_Export(const char *str, Boolean isEx return; } -flags = 0; if (strncmp(str, "-env", 4) == 0) { str += 4; + flags = 0; } else if (strncmp(str, "-literal", 8) == 0) { str += 8; - flags |= VAR_EXPORT_LITERAL; + flags = VAR_EXPORT_LITERAL; } else { - flags |= VAR_EXPORT_PARENT; + flags = VAR_EXPORT_PARENT; } (void)Var_Subst(str, VAR_GLOBAL, VARE_WANTRES, );
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 10:04:34 UTC 2020 Modified Files: src/usr.bin/make: arch.c Log Message: make(1): format code in arch.c To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/usr.bin/make/arch.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/arch.c diff -u src/usr.bin/make/arch.c:1.127 src/usr.bin/make/arch.c:1.128 --- src/usr.bin/make/arch.c:1.127 Thu Oct 1 22:42:00 2020 +++ src/usr.bin/make/arch.c Sat Oct 3 10:04:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.127 2020/10/01 22:42:00 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.128 2020/10/03 10:04:34 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -134,7 +134,7 @@ #include"config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.127 2020/10/01 22:42:00 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.128 2020/10/03 10:04:34 rillig Exp $"); #ifdef TARGET_MACHINE #undef MAKE_MACHINE @@ -151,11 +151,11 @@ typedef struct ListNode ArchListNode; static ArchList *archives; /* The archives we've already examined */ typedef struct Arch { -char *name; /* Name of archive */ -Hash_Table members;/* All the members of the archive described - * by key/value pairs */ -char *fnametab; /* Extended name table strings */ -size_t fnamesize; /* Size of the string table */ +char *name; /* Name of archive */ +Hash_Table members; /* All the members of the archive described + * by key/value pairs */ +char *fnametab; /* Extended name table strings */ +size_t fnamesize; /* Size of the string table */ } Arch; static FILE *ArchFindMember(const char *, const char *, @@ -170,8 +170,8 @@ static void ArchFree(void *ap) { Arch *a = (Arch *)ap; -Hash_Search search; -Hash_Entry *entry; +Hash_Search search; +Hash_Entry *entry; /* Free memory from hash entries */ for (entry = Hash_EnumFirst(>members, ); @@ -258,7 +258,7 @@ Arch_ParseArchive(char **linePtr, GNodeL * place and skip to the end of it (either white-space or * a close paren). */ - Boolean doSubst = FALSE; /* TRUE if need to substitute in memName */ + Boolean doSubst = FALSE; /* TRUE if need to substitute in memName */ while (*cp != '\0' && *cp != ')' && ch_isspace(*cp)) { cp++; @@ -270,7 +270,7 @@ Arch_ParseArchive(char **linePtr, GNodeL * Variable spec, so call the Var module to parse the puppy * so we can safely advance beyond it... */ - void *freeIt; + void *freeIt; const char *result; Boolean isError; const char *nested_p = cp; @@ -324,11 +324,11 @@ Arch_ParseArchive(char **linePtr, GNodeL * later. */ if (doSubst) { - char*buf; - char*sacrifice; - char*oldMemName = memName; + char *buf; + char *sacrifice; + char *oldMemName = memName; - (void)Var_Subst(memName, ctxt, VARE_UNDEFERR | VARE_WANTRES, + (void)Var_Subst(memName, ctxt, VARE_UNDEFERR|VARE_WANTRES, ); /* TODO: handle errors */ @@ -449,15 +449,15 @@ Arch_ParseArchive(char **linePtr, GNodeL static struct ar_hdr * ArchStatMember(const char *archive, const char *member, Boolean hash) { -#define AR_MAX_NAME_LEN (sizeof(arh.ar_name)-1) -FILE * arch; /* Stream to archive */ -size_t size; /* Size of archive member */ -char magic[SARMAG]; +#define AR_MAX_NAME_LEN (sizeof(arh.ar_name) - 1) +FILE *arch; /* Stream to archive */ +size_t size; /* Size of archive member */ +char magic[SARMAG]; ArchListNode *ln; -Arch *ar; /* Archive descriptor */ -struct ar_hdr arh;/* archive-member header for reading archive */ -char memName[MAXPATHLEN+1]; - /* Current member name while hashing. */ +Arch *ar; /* Archive descriptor */ +struct ar_hdr arh; /* archive-member header for reading archive */ +char memName[MAXPATHLEN + 1]; +/* Current member name while hashing. */ /* * Because of space constraints and similar things, files are archived @@ -486,7 +486,7 @@ ArchStatMember(const char *archive, cons { /* Try truncated name */ - char copy[AR_MAX_NAME_LEN+1]; + char copy[AR_MAX_NAME_LEN + 1]; size_t len = strlen(member); if (len > AR_MAX_NAME_LEN) { @@ -506,11 +506,11 @@ ArchStatMember(const char *archive, cons * no need to allocate extra room for the header we're returning, * so just declare it static. */ - static struct ar_hdr sarh; + static struct ar_hdr sarh; - arch = ArchFindMember(archive, member, , "r"); + arch = ArchFindMember(archive, member, , "r"); - if (arch == NULL) { + if (arch == NULL) { return NULL; } else { fclose(arch); @@ -533,8 +533,8 @@ ArchStatMember(const char *archive, cons */ if ((fread(magic, SARMAG, 1, arch) != 1)
CVS commit: src/sys/arch/mips/include
Module Name:src Committed By: martin Date: Sat Oct 3 09:56:00 UTC 2020 Modified Files: src/sys/arch/mips/include: mcontext.h Log Message: Add missing __BEGIN_DECLS/__END_DECLS to force function declarations into the "C" namespace. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/mips/include/mcontext.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/mips/include/mcontext.h diff -u src/sys/arch/mips/include/mcontext.h:1.23 src/sys/arch/mips/include/mcontext.h:1.24 --- src/sys/arch/mips/include/mcontext.h:1.23 Sun Jul 26 08:08:41 2020 +++ src/sys/arch/mips/include/mcontext.h Sat Oct 3 09:56:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.23 2020/07/26 08:08:41 simonb Exp $ */ +/* $NetBSD: mcontext.h,v 1.24 2020/10/03 09:56:00 martin Exp $ */ /*- * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. @@ -196,6 +196,8 @@ typedef struct { __CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000); __CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0); +__BEGIN_DECLS + static __inline struct tls_tcb * __lwp_gettcb_fast(void) { @@ -233,6 +235,7 @@ __lwp_settcb(struct tls_tcb *__tcb) __tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1; _lwp_setprivate(__tcb); } +__END_DECLS #endif #endif /* _MIPS_MCONTEXT_H_ */
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 09:48:40 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: make-exported.exp make-exported.mk Log Message: make(1): explain the purpose of the test make-exported To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/make-exported.exp \ src/usr.bin/make/unit-tests/make-exported.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/make-exported.exp diff -u src/usr.bin/make/unit-tests/make-exported.exp:1.1 src/usr.bin/make/unit-tests/make-exported.exp:1.2 --- src/usr.bin/make/unit-tests/make-exported.exp:1.1 Sun Aug 9 12:59:16 2020 +++ src/usr.bin/make/unit-tests/make-exported.exp Sat Oct 3 09:48:40 2020 @@ -1,3 +1,3 @@ --literal=make-exported-value +-literal=make-exported-value-literal UT_VAR= exit status 0 Index: src/usr.bin/make/unit-tests/make-exported.mk diff -u src/usr.bin/make/unit-tests/make-exported.mk:1.1 src/usr.bin/make/unit-tests/make-exported.mk:1.2 --- src/usr.bin/make/unit-tests/make-exported.mk:1.1 Sun Aug 9 12:59:16 2020 +++ src/usr.bin/make/unit-tests/make-exported.mk Sat Oct 3 09:48:40 2020 @@ -1,16 +1,29 @@ -# $NetBSD: make-exported.mk,v 1.1 2020/08/09 12:59:16 rillig Exp $ +# $NetBSD: make-exported.mk,v 1.2 2020/10/03 09:48:40 rillig Exp $ # # As of 2020-08-09, the code in Var_Export is shared between the .export # directive and the .MAKE.EXPORTED variable. This leads to non-obvious # behavior for certain variable assignments. --env= make-exported-value --literal= make-exported-value +-env= make-exported-value-env +-literal= make-exported-value-literal UT_VAR= ${UNEXPANDED} # The following behavior is probably not intended. -.MAKE.EXPORTED= -env # like .export-env -.MAKE.EXPORTED= -literal UT_VAR # like .export-literal PATH +.MAKE.EXPORTED= -env # behaves like .export-env + +# If the value of .MAKE.EXPORTED starts with "-literal", make behaves like +# a mixture of .export-literal and a regular .export. +# XXX: This is due to a sloppy implementation, reusing code in places where +# it is not appropriate. +# +# In Parse_DoVar, the code path for MAKE_EXPORTED is taken, calling Var_Export +# in turn. There, the code path for .export-literal is taken, and the +# environment variable UT_VAR is set to ${UNEXPANDED}, as expected. +# Later, in Compat_RunCommand, in the child process after vfork, +# Var_ExportVars is called, which treats "-literal" as an ordinary variable +# name, therefore exports it and also overwrites the previously exported +# UT_VAR with the expanded value. +.MAKE.EXPORTED= -literal UT_VAR all: @env | sort | grep -E '^UT_|make-exported-value' || true
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 09:37:04 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: directive-export-literal.exp directive-export-literal.mk Log Message: make(1): add test for .export-literal To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/usr.bin/make/unit-tests/directive-export-literal.exp cvs rdiff -u -r1.2 -r1.3 \ src/usr.bin/make/unit-tests/directive-export-literal.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/directive-export-literal.exp diff -u src/usr.bin/make/unit-tests/directive-export-literal.exp:1.1 src/usr.bin/make/unit-tests/directive-export-literal.exp:1.2 --- src/usr.bin/make/unit-tests/directive-export-literal.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/directive-export-literal.exp Sat Oct 3 09:37:04 2020 @@ -1 +1,2 @@ +value with ${UNEXPANDED} expression exit status 0 Index: src/usr.bin/make/unit-tests/directive-export-literal.mk diff -u src/usr.bin/make/unit-tests/directive-export-literal.mk:1.2 src/usr.bin/make/unit-tests/directive-export-literal.mk:1.3 --- src/usr.bin/make/unit-tests/directive-export-literal.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/directive-export-literal.mk Sat Oct 3 09:37:04 2020 @@ -1,8 +1,11 @@ -# $NetBSD: directive-export-literal.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: directive-export-literal.mk,v 1.3 2020/10/03 09:37:04 rillig Exp $ # -# Tests for the .export-literal directive. +# Tests for the .export-literal directive, which exports a variable value +# without expanding it. -# TODO: Implementation +UT_VAR= value with ${UNEXPANDED} expression + +.export-literal UT_VAR all: - @:; + @echo "$$UT_VAR"
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 09:10:26 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: opt-debug-file.mk Log Message: make(1): add test for the -dF option To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-file.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/opt-debug-file.mk diff -u src/usr.bin/make/unit-tests/opt-debug-file.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-file.mk:1.2 --- src/usr.bin/make/unit-tests/opt-debug-file.mk:1.1 Sat Sep 5 06:20:51 2020 +++ src/usr.bin/make/unit-tests/opt-debug-file.mk Sat Oct 3 09:10:26 2020 @@ -1,9 +1,37 @@ -# $NetBSD: opt-debug-file.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $ +# $NetBSD: opt-debug-file.mk,v 1.2 2020/10/03 09:10:26 rillig Exp $ # # Tests for the -dF command line option, which redirects the debug log # to a file instead of writing it to stderr. -# TODO: Implementation +# Enable debug logging for variable assignments and evaluation (-dv) +# and redirect the debug logging to the given file. +.MAKEFLAGS: -dvFopt-debug-file.debuglog + +# This output goes to the debug log file. +VAR= value ${:Uexpanded} + +# Hide the logging output for the remaining actions. +# As of 2020-10-03, it is not possible to disable debug logging again. +.MAKEFLAGS: -dF/dev/null + +# Make sure that the debug logging file contains some logging. +DEBUG_OUTPUT:= ${:!cat opt-debug-file.debuglog!} +# Grmbl. Because of the := operator in the above line, the variable +# value contains ${:Uexpanded}. This variable expression is expanded +# upon further processing. Therefore, don't read from untrusted input. +#.MAKEFLAGS: -dc -dFstderr +.if !${DEBUG_OUTPUT:tW:M*VAR = value expanded*} +. error ${DEBUG_OUTPUT} +.endif + +# To get the unexpanded text that was actually written to the debug log +# file, the content of that log file must not be stored in a variable. +# XXX: In the :M modifier, a dollar is escaped as '$$', not '\$'. +.if !${:!cat opt-debug-file.debuglog!:tW:M*VAR = value $${:Uexpanded}*} +. error +.endif + +_!= rm opt-debug-file.debuglog all: @:;
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 08:29:32 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: opt-debug-for.exp opt-debug-for.mk Log Message: make(1): add test for the -df debug option To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-for.exp \ src/usr.bin/make/unit-tests/opt-debug-for.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/opt-debug-for.exp diff -u src/usr.bin/make/unit-tests/opt-debug-for.exp:1.1 src/usr.bin/make/unit-tests/opt-debug-for.exp:1.2 --- src/usr.bin/make/unit-tests/opt-debug-for.exp:1.1 Sat Sep 5 06:20:51 2020 +++ src/usr.bin/make/unit-tests/opt-debug-for.exp Sat Oct 3 08:29:32 2020 @@ -1 +1,22 @@ +For: new loop 2 +For: end for 2 +For: end for 1 +For: loop body: +. for inner in 1 2 +VAR.${:Ua}${inner}= value +. endfor +For: end for 1 +For: loop body: +VAR.${:Ua}${:U1}= value +For: loop body: +VAR.${:Ua}${:U2}= value +For: loop body: +. for inner in 1 2 +VAR.${:Ub}${inner}= value +. endfor +For: end for 1 +For: loop body: +VAR.${:Ub}${:U1}= value +For: loop body: +VAR.${:Ub}${:U2}= value exit status 0 Index: src/usr.bin/make/unit-tests/opt-debug-for.mk diff -u src/usr.bin/make/unit-tests/opt-debug-for.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-for.mk:1.2 --- src/usr.bin/make/unit-tests/opt-debug-for.mk:1.1 Sat Sep 5 06:20:51 2020 +++ src/usr.bin/make/unit-tests/opt-debug-for.mk Sat Oct 3 08:29:32 2020 @@ -1,9 +1,26 @@ -# $NetBSD: opt-debug-for.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $ +# $NetBSD: opt-debug-for.mk,v 1.2 2020/10/03 08:29:32 rillig Exp $ # # Tests for the -df command line option, which adds debug logging for # parsing and evaluating .for loops. -# TODO: Implementation +.MAKEFLAGS: -df + +# XXX: In the debug log, the "new loop 2" appears out of context. +# There should be a "begin loop 1" before, and all these messages should +# contain line number information. +# +# XXX: The "loop body" should print the nesting level as well. +# +# XXX: It is hard to extract any information from the debug log since +# the "begin" and "end" events are not balanced and the nesting level +# is not printed consistently. It would also be helpful to mention the +# actual substitutions, such as "For 1: outer=b". +# +.for outer in a b +. for inner in 1 2 +VAR.${outer}${inner}= value +. endfor +.endfor all: @:;
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 08:16:53 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: Makefile opt-debug-jobs.exp opt-debug-jobs.mk Log Message: make(1): add test for the -dj debug option To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-jobs.exp \ src/usr.bin/make/unit-tests/opt-debug-jobs.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.156 src/usr.bin/make/unit-tests/Makefile:1.157 --- src/usr.bin/make/unit-tests/Makefile:1.156 Fri Oct 2 20:34:59 2020 +++ src/usr.bin/make/unit-tests/Makefile Sat Oct 3 08:16:53 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.156 2020/10/02 20:34:59 rillig Exp $ +# $NetBSD: Makefile,v 1.157 2020/10/03 08:16:53 rillig Exp $ # # Unit tests for make(1) # @@ -403,6 +403,10 @@ SED_CMDS.opt-debug-graph1= \ SED_CMDS.opt-debug-graph1+= \ -e '/Global Variables:/,/Suffixes:/d' SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,,' +SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(),' +SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid ,' +SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process ,' +SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: ,' SED_CMDS.varmod-subst-regex+= \ -e 's,\(Regex compilation error:\).*,\1 (details omitted),' SED_CMDS.varmod-edge+= -e 's, line [0-9]*:, line omitted:,' Index: src/usr.bin/make/unit-tests/opt-debug-jobs.exp diff -u src/usr.bin/make/unit-tests/opt-debug-jobs.exp:1.1 src/usr.bin/make/unit-tests/opt-debug-jobs.exp:1.2 --- src/usr.bin/make/unit-tests/opt-debug-jobs.exp:1.1 Sat Sep 5 06:20:51 2020 +++ src/usr.bin/make/unit-tests/opt-debug-jobs.exp Sat Oct 3 08:16:53 2020 @@ -1 +1,25 @@ +job_pipe -1 -1, maxjobs 1, tokens 1, compat 0 +Job_TokenWithdraw(): aborting 0, running 0 +() withdrew token +echo ": expanded expression" +{ : expanded expression +} || exit $? +echo ": variable" +{ : variable +} || exit $? +echo ": 'single' and \"double\" quotes" +{ : 'single' and "double" quotes +} || exit $? +Running all locally + Command: sh -q +JobExec(all): pid added to jobs table +job table @ job started +job 0, status 3, flags 0, pid +: expanded expression +: variable +: 'single' and "double" quotes +Process exited/stopped status 0. +JobFinish: [all], status 0 +Job_TokenWithdraw(): aborting 0, running 0 +() withdrew token exit status 0 Index: src/usr.bin/make/unit-tests/opt-debug-jobs.mk diff -u src/usr.bin/make/unit-tests/opt-debug-jobs.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-jobs.mk:1.2 --- src/usr.bin/make/unit-tests/opt-debug-jobs.mk:1.1 Sat Sep 5 06:20:51 2020 +++ src/usr.bin/make/unit-tests/opt-debug-jobs.mk Sat Oct 3 08:16:53 2020 @@ -1,9 +1,26 @@ -# $NetBSD: opt-debug-jobs.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $ +# $NetBSD: opt-debug-jobs.mk,v 1.2 2020/10/03 08:16:53 rillig Exp $ # -# Tests for the -da command line option, which adds debug logging about +# Tests for the -dj command line option, which adds debug logging about # running jobs in multiple shells. -# TODO: Implementation +.MAKEFLAGS: -dj + +# Run in parallel mode since the debug logging is more interesting there +# than in compat mode. +.MAKEFLAGS: -j1 all: - @:; + # Only the actual command is logged. + # To see the evaluation of the variable expressions, use -dv. + : ${:Uexpanded} expression + + # Undefined variables expand to empty strings. + # Multiple spaces are preserved in the command, as they might be + # significant. + : ${UNDEF} variable + + # In the debug output, single quotes are not escaped, even though + # the whole command is enclosed in single quotes as well. + # This allows to copy and paste the whole command, without having + # to unescape anything. + : 'single' and "double" quotes
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Oct 3 07:52:30 UTC 2020 Modified Files: src/usr.bin/make/unit-tests: opt-debug-loud.exp opt-debug-loud.mk Log Message: make(1): add test for the -dl command line option To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-loud.exp \ src/usr.bin/make/unit-tests/opt-debug-loud.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/opt-debug-loud.exp diff -u src/usr.bin/make/unit-tests/opt-debug-loud.exp:1.1 src/usr.bin/make/unit-tests/opt-debug-loud.exp:1.2 --- src/usr.bin/make/unit-tests/opt-debug-loud.exp:1.1 Sat Sep 5 06:20:51 2020 +++ src/usr.bin/make/unit-tests/opt-debug-loud.exp Sat Oct 3 07:52:30 2020 @@ -1 +1,3 @@ +echo all-word +all-word exit status 0 Index: src/usr.bin/make/unit-tests/opt-debug-loud.mk diff -u src/usr.bin/make/unit-tests/opt-debug-loud.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-loud.mk:1.2 --- src/usr.bin/make/unit-tests/opt-debug-loud.mk:1.1 Sat Sep 5 06:20:51 2020 +++ src/usr.bin/make/unit-tests/opt-debug-loud.mk Sat Oct 3 07:52:30 2020 @@ -1,13 +1,22 @@ -# $NetBSD: opt-debug-loud.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $ +# $NetBSD: opt-debug-loud.mk,v 1.2 2020/10/03 07:52:30 rillig Exp $ # # Tests for the -dl command line option, which prints the commands before # running them, ignoring the command line option for silent mode (-s) as # well as the .SILENT special source and target, as well as the '@' prefix # for shell commands. -# TODO: Implementation +.MAKEFLAGS: -dl -s +.SILENT: -# TODO: What about ${:!cmd!}? +# The -dl command line option does not affect commands that are run during +# variable expansion, such as :!cmd! or :sh. +.if ${:!echo word!} != "word" +. error +.endif -all: - @:; +all: .SILENT + # Even though the command line option -s is given, .SILENT is set + # for all targets and for this target in particular, the command + # is still printed. The -dl debugging option is stronger than all + # of these. + @echo all-word
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Oct 3 06:36:01 UTC 2020 Modified Files: src/usr.bin/make: enum.c Log Message: make(1): fix indentation of code for printing enum values To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/enum.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/enum.c diff -u src/usr.bin/make/enum.c:1.8 src/usr.bin/make/enum.c:1.9 --- src/usr.bin/make/enum.c:1.8 Sun Sep 13 15:15:51 2020 +++ src/usr.bin/make/enum.c Sat Oct 3 06:36:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: enum.c,v 1.8 2020/09/13 15:15:51 rillig Exp $ */ +/* $NetBSD: enum.c,v 1.9 2020/10/03 06:36:01 rillig Exp $ */ /* Copyright (c) 2020 Roland Illig @@ -33,7 +33,7 @@ #include "make.h" -MAKE_RCSID("$NetBSD: enum.c,v 1.8 2020/09/13 15:15:51 rillig Exp $"); +MAKE_RCSID("$NetBSD: enum.c,v 1.9 2020/10/03 06:36:01 rillig Exp $"); /* Convert a bitset into a string representation, showing the names of the * individual bits. @@ -52,7 +52,7 @@ Enum_FlagsToString(char *buf, size_t buf size_t name_len; if ((value & spec->es_value) != spec->es_value) - continue; + continue; value &= ~spec->es_value; assert(buf_size >= sep_len + 1); @@ -86,8 +86,8 @@ const char * Enum_ValueToString(int value, const EnumToStringSpec *spec) { for (; spec->es_name[0] != '\0'; spec++) { - if (value == spec->es_value) - return spec->es_name; + if (value == spec->es_value) + return spec->es_name; } abort(/* unknown enum value */); }