CVS commit: src/usr.bin/units

2022-10-23 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct 24 05:52:48 UTC 2022

Modified Files:
src/usr.bin/units: units.lib

Log Message:
Some more corrections/additions in units.lib:

1. cables; US cables are 720 ft, but international cables are 1/10
nautical mile and UK Admiralty cables are 1/10 of 1853.2 meters
instead of 1852 meters. Make "cable" refer to the international
definition, and add "uscable" and "admiraltycable".

2. rods and chains. US rods and chains and furlongs are defined in
terms of US survey feet, not international feet. Since the US is
apparently working on retiring survey feet, it seems like the best way
forward on this is to define two sets of these units, one prefixed
with "us". Also since this file was inconsistent about using "survey"
vs. "surveyors", fill in more duplicates.

Furthermore, Gunter's rods and chains and links are as best I can tell
the same as the international ones, so since we already have
"gunterschain" add "guntersrod" and "gunterslink".

3. If we're going to make pf a special abbreviation for picofarad,
it's reasonable to make uf a special abbreviation for microfarad, and
if we're going to define "meg" for "megabyte" we should also have
"gig".

4. A "franklin" _is_ a statcoulomb, not an approximation of one.

5. "jewel" has two Es.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/units/units.lib

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/units/units.lib
diff -u src/usr.bin/units/units.lib:1.28 src/usr.bin/units/units.lib:1.29
--- src/usr.bin/units/units.lib:1.28	Mon Oct 24 05:04:50 2022
+++ src/usr.bin/units/units.lib	Mon Oct 24 05:52:48 2022
@@ -1,4 +1,4 @@
-/	$NetBSD: units.lib,v 1.28 2022/10/24 05:04:50 dholland Exp $
+/	$NetBSD: units.lib,v 1.29 2022/10/24 05:52:48 dholland Exp $
 
 / primitive units
 
@@ -104,7 +104,7 @@ radian			.5 / pi
 degree			1|180 pi-radian
 circle			2 pi-radian
 turn			2 pi-radian
-revolution			turn
+revolution		turn
 rev			turn
 grade			.9 degree
 arcdeg			1 degree
@@ -291,33 +291,82 @@ league			3 mi
 mil			1e-3 in
 
 / nautical
+/
 / Historically, the nautical mile was 6080 feet (6080.2 in England)
 / but was changed to 1852 meters (6076 feet and change) in the 20th
 / century with varying dates of adoption around the world.
 / https://en.wikipedia.org/wiki/Nautical_mile
+/
+/ The US cable is 720 feet. The international cable is 1/10 nautical
+/ mile, which is substantially shorter. The UK Admiralty cable is
+/ apparently 1/10 of a historical Admiralty nautical mile, which is
+/ 1853.2 instead of 1852 meters. These definitions date from the 20th
+/ century. Historically, a cable was 100 fathoms, but the fathom
+/ hadn't yet been fixed at 6 feet, so cables weren't a fixed length
+/ either.
+/ https://en.wikipedia.org/wiki/Cable_(unit)
+/
 fathom			6 ft
 nmile			1852 m
 nauticalmile		nmile
 marineleague		3 nmile
-cable			720 ft
+cable			1|10 nmile
+uscable			720 ft
+admiraltycable		185.32 m
 
 / surveying
 /
 / The US survey foot is defined as 1200/3937 meters, as opposed to the
 / ordinary international foot, which is 0.3048 meter (that's exactly
-/ 2.54 cm to the inch as defined above.)
+/ 2.54 cm to the inch as defined above.) These differ slightly.
 / https://en.wikipedia.org/wiki/Foot_(unit)
-rod			5.5 yd
-rd			rod
-perch			rd
-pole			rd
-chain			66 ft
-link			66|100 ft
-furlong			220 yd
+/
+/ In the US, rods, chains, and furlongs are defined in terms of survey
+/ feet, though the Wikipedia page on furlongs claims without citation
+/ that some states use one definition and some the other. However, it
+/ appears that as of 2022 this definition is on the way out, and other
+/ jurisdictions define these units (to the extent they're used at all)
+/ in terms of the international foot.
+/ https://en.wikipedia.org/wiki/Rod_(unit)
+/ https://en.wikipedia.org/wiki/Furlong_(unit)
+/
+/ Consequently we'll make two sets of definitions and prefix the
+/ variant US ones with "us".
+/
+/ Since historically this file defined "surveyfoot" and "surveyyard"
+/ but "surveyorschain" and "surveyorslink", we will now end up with
+/ several sets for consistency.
+/
 surveyfoot		1200|3937 meter
 surveyyard		3 surveyfoot
-surveyorschain		66 ft
-surveyorslink		66|100 ft
+
+rod			5.5 yard
+rd			rod
+perch			rod
+pole			rod
+chain			66 foot
+link			1|100 chain
+furlong			220 yard
+
+usrod			5.5 surveyyard
+usperch			usrod
+uspole			usrod
+uschain			66 surveyfoot
+uslink			1|100 uschain
+usfurlong		220 surveyyard
+
+surveyorsfoot		surveyfoot
+surveyorsyard		surveyyard
+surveyorsrod		usrod
+surveyorschain		uschain
+surveyorslink		uslink
+
+/ These are the same as the basic ones based on the international foot.
+/ https://en.wikipedia.org/wiki/Gunter's_chain
+/ https://en.wikipedia.org/wiki/Imperial_units
+guntersrod		rod
+gunterschain		chain
+gunterslink		link
 
 / typographical
 pica			1|6 in
@@ -363,7 

CVS commit: src/usr.bin/units

2022-10-23 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct 24 05:52:48 UTC 2022

Modified Files:
src/usr.bin/units: units.lib

Log Message:
Some more corrections/additions in units.lib:

1. cables; US cables are 720 ft, but international cables are 1/10
nautical mile and UK Admiralty cables are 1/10 of 1853.2 meters
instead of 1852 meters. Make "cable" refer to the international
definition, and add "uscable" and "admiraltycable".

2. rods and chains. US rods and chains and furlongs are defined in
terms of US survey feet, not international feet. Since the US is
apparently working on retiring survey feet, it seems like the best way
forward on this is to define two sets of these units, one prefixed
with "us". Also since this file was inconsistent about using "survey"
vs. "surveyors", fill in more duplicates.

Furthermore, Gunter's rods and chains and links are as best I can tell
the same as the international ones, so since we already have
"gunterschain" add "guntersrod" and "gunterslink".

3. If we're going to make pf a special abbreviation for picofarad,
it's reasonable to make uf a special abbreviation for microfarad, and
if we're going to define "meg" for "megabyte" we should also have
"gig".

4. A "franklin" _is_ a statcoulomb, not an approximation of one.

5. "jewel" has two Es.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/units/units.lib

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/units

2022-10-23 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct 24 05:04:51 UTC 2022

Modified Files:
src/usr.bin/units: units.lib

Log Message:
units.lib: fix "surveyfoot" and kill off "british".

The US survey foot is defined as 1200/3937 of a meter, whereas the
ordinary international foot is 0.3048 meter. These are almost, but
not quite the same.

Define the survey foot this way instead of defining an adjective unit
for the conversion, which is much less confusing even if the adjective
unit had a reasonable name. For the time being the fact that it was
called "british" remains thoroughly obscure.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/units/units.lib

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/units/units.lib
diff -u src/usr.bin/units/units.lib:1.27 src/usr.bin/units/units.lib:1.28
--- src/usr.bin/units/units.lib:1.27	Mon Oct 24 04:55:19 2022
+++ src/usr.bin/units/units.lib	Mon Oct 24 05:04:50 2022
@@ -1,4 +1,4 @@
-/	$NetBSD: units.lib,v 1.27 2022/10/24 04:55:19 dholland Exp $
+/	$NetBSD: units.lib,v 1.28 2022/10/24 05:04:50 dholland Exp $
 
 / primitive units
 
@@ -290,8 +290,6 @@ mi			mile
 league			3 mi
 mil			1e-3 in
 
-british			1200|3937 m/ft
-
 / nautical
 / Historically, the nautical mile was 6080 feet (6080.2 in England)
 / but was changed to 1852 meters (6076 feet and change) in the 20th
@@ -304,6 +302,11 @@ marineleague		3 nmile
 cable			720 ft
 
 / surveying
+/
+/ The US survey foot is defined as 1200/3937 meters, as opposed to the
+/ ordinary international foot, which is 0.3048 meter (that's exactly
+/ 2.54 cm to the inch as defined above.)
+/ https://en.wikipedia.org/wiki/Foot_(unit)
 rod			5.5 yd
 rd			rod
 perch			rd
@@ -311,7 +314,7 @@ pole			rd
 chain			66 ft
 link			66|100 ft
 furlong			220 yd
-surveyfoot		british-ft
+surveyfoot		1200|3937 meter
 surveyyard		3 surveyfoot
 surveyorschain		66 ft
 surveyorslink		66|100 ft
@@ -356,7 +359,7 @@ englishell		45 inch
 rood			1.21e+3 yd
 
 / other
-geodeticfoot		british-ft
+geodeticfoot		surveyfoot
 geographicalmile	1852 m
 engineerschain		100 ft
 engineerslink		100|100 ft



CVS commit: src/usr.bin/units

2022-10-23 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct 24 05:04:51 UTC 2022

Modified Files:
src/usr.bin/units: units.lib

Log Message:
units.lib: fix "surveyfoot" and kill off "british".

The US survey foot is defined as 1200/3937 of a meter, whereas the
ordinary international foot is 0.3048 meter. These are almost, but
not quite the same.

Define the survey foot this way instead of defining an adjective unit
for the conversion, which is much less confusing even if the adjective
unit had a reasonable name. For the time being the fact that it was
called "british" remains thoroughly obscure.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/units/units.lib

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libc/time

2022-10-23 Thread Warner Losh
On Sun, Oct 23, 2022 at 11:00 AM Taylor R Campbell <
campbell+netbsd-source-change...@mumble.net> wrote:

> > Date: Sun, 23 Oct 2022 07:39:25 -0600
> > From: Warner Losh 
> >
> > I guess a more accurate way of saying this is that leap seconds simply
> > aren't reliable, cannot be made reliable, and this affects normalization
> > in ways too numerous to mention due to the details of the tz files, bugs
> > in the system, and lack of others to implement them correctly.
>
> I think you mean `POSIX clocks simply aren't reliable'.  They _could_
> be made reliable, though, by fixing the the calendar arithmetic
> formula in POSIX for mapping time_t to and from UTC -- just like POSIX
> already fixed the bug in its Gregorian leap year formula.
>

Except they can't, at least not practically enough to be a standard. The
Gregorian Leap Year formula is a mathematical formula that needs no
further data other than the broken down time to compute. It's not an
observational calendar, but a computational or arithmetic one. UTC is an
observational calendar. We barely know if there's going to be a leap
second in the coming months, and have nothing more than a vague notion
of when the one after that might be. You must have a table of all past
leap seconds to do any kind of sensible mapping. And you also must
have some way to keep that up to date, even when machines are
powered off, or installed from not really that old media (anything older
than 6 months can't possibly have the right leap table, except by
chance). And then the question becomes how do you get it, do you
assume connectivity, some standard media format, some standard file
format, etc. All of these details means POSIX can't really fix this. And
even if they do, the current formula has been around so long there's a
lot of dusty decks of code that will likely silently break. You can
ameliorate
that somewhat by inventing new interfaces, but issues like the one you go
into below will still persist.


> > > The code works with either set of tzdata files, POSIX stretchy secs,
> > > or UTC with leap secs - claiming that one doesn't happen, or cannot
> > > happen, isn't really correct.
> >
> > Yea, and even 'posix stretchy sec' is really a misnomer. POSIX simply
> > counts time without leap seconds. Each second is the same length,
>
> Not at all.
>
> If you use a monotonic timer to sample the POSIX clock before and
> after a leap second, the POSIX clock will appear to have taken twice
> as long as it should to pass the leap second.
>
> Of course, it's worse.  If sampled at _subsecond_ intervals, a POSIX
> clock behaves _erratically_: it spontaneously rewinds itself!
>
> Suppose we have a machine with a monotonic clock that counts SI
> seconds as well as a POSIX clock:
>
> SI monotonicPOSIX
> 123.25  1483228799.00
> 123.50  1483228799.25
> 123.75  1483228799.50  # t0 = boottime + 123.75
> 124.00  1483228799.75
> 124.25  1483228800.00  # leap second begins at 2016-12-31T23:59:60Z
> 124.50  1483228800.25
> 124.75  1483228800.50
> 125.00  1483228800.75  # t1 = boottime + 125.00
> 125.25  1483228800.00  # POSIX clock rewinds at
> 2017-01-01T00:00:00Z!
> 125.50  1483228800.25
> 125.75  1483228800.50  # t2 = boottime + 125.75
> 126.00  1483228800.75
>
> At supersecond resolution, t2 - t0 is a duration of 2 SI seconds, but
> a POSIX clock reports a time difference POSIX(t2) - POSIX(t0) of 1, so
> `POSIX seconds' are not always SI seconds -- it is not the case that
> `each [POSIX] second is the same length', even ignoring physical clock
> sampling error.
>

Right. Except during that brief interval around a leap second, all the
seconds
are the same size. They aren't expanded or contracted by running the clock
at a different frequency that was done between approx 1960-1972 which is
often referred to as the rubber leap second era. It was more on that basis
that
I was objecting to the turn of phrase because that sort of thing isn't
happening.


> And, of course, at subsecond resolution, the POSIX clock rewinds.  The
> monotonic clock correctly has t1 < t2, but POSIX(t1) > POSIX(t2).  And
> this erratic behaviour is much worse than a typical NTP-driven clock
> adjustment at random times, because by design this erratic behaviour
> happens on ~every computer on the planet simultaneously!
>

Yea, if NTP knows about the leap, it can deal with it. The problem as you
say comes in when the stratum 1 servers don't announce the leap second
far enough in advance for the implementations to cope. It then devolves to
the 'when, exactly, do you step the time back' problem since there's a
couple
of choices, unless you have the 'leap smear' ntp servers which do it over
a few hours.


> There's no need for this nonsense except insistence on the formula
> that says every UTC day is counted by 86400 `POSIX seconds'.  POSIX
> could be revised to fix this bug in the clock by just not doing civil
> calendar 

CVS commit: src/usr.bin/units

2022-10-23 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct 24 04:55:19 UTC 2022

Modified Files:
src/usr.bin/units: units.lib

Log Message:
Reorganize units.lib.

It's all very well to file miscellaneous old units under "trivia" but
it's more useful to sort first by type and then by creakiness.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/units/units.lib

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/units/units.lib
diff -u src/usr.bin/units/units.lib:1.26 src/usr.bin/units/units.lib:1.27
--- src/usr.bin/units/units.lib:1.26	Tue Feb 15 16:21:35 2022
+++ src/usr.bin/units/units.lib	Mon Oct 24 04:55:19 2022
@@ -1,4 +1,4 @@
-/	$NetBSD: units.lib,v 1.26 2022/02/15 16:21:35 jakllsch Exp $
+/	$NetBSD: units.lib,v 1.27 2022/10/24 04:55:19 dholland Exp $
 
 / primitive units
 
@@ -58,21 +58,47 @@ a-			atto
 z-			zopto
 y-			yocto
 
+/ 
 / constants
 
 fuzz			1
+
 pi			3.14159265358979323846
 c			2.99792458e+8 m/sec fuzz
-g			9.80665 m/sec2
-au			1.49597871e+11 m fuzz
-mole			6.022169e+23 fuzz
 e			1.6021917e-19 coul fuzz
+k			1.38047e-16 erg/degC
+planck			6.626e-34 joule-sec
+hbar			1.055e-34 joule-sec
+mole			6.022169e+23 fuzz
+
+g			9.80665 m/sec2
+
+/ conversion factors used as adjectives
 energy			c2
 force			g
 mercury			1.33322e+5 kg/m2-sec2
 hg			mercury
 
-/ dimensionless
+/ standard ratios
+%			1|100
+percent			%
+/ proof is specific to alcohol concentration
+proof			1|200
+
+/ 
+/ counts
+
+dozen			12
+bakersdozen		13
+score			20
+gross			144
+
+/ quire and ream are specific to counting sheets of paper
+quire			25
+ream			500
+
+/ 
+/ angles
 
 radian			.5 / pi
 degree			1|180 pi-radian
@@ -83,17 +109,32 @@ rev			turn
 grade			.9 degree
 arcdeg			1 degree
 arcmin			1|60 arcdeg
-ccs			1|36 erlang
 arcsec			1|60 arcmin
 
+centesimalminute	1e-2 grade
+centesimalsecond	1e-4 grade
+
+/ 
+/ solid angles
+
 steradian		radian2
 sphere			4 pi-steradian
 sr			steradian
+spat			4 pi sr
 
+/ 
 / Time
 
+/ SI unit
 second			sec
 s			sec
+
+/ special-case abbreviations
+ms			millisec
+ns			nanosec
+us			microsec
+
+/ civil timekeeping
 minute			60 sec
 min			minute
 hour			60 min
@@ -101,53 +142,142 @@ hr			hour
 day			24 hr
 da			day
 week			7 day
+fortnight		14 da
+month			1|12 year
+mo			month
 year			365.24219879 day fuzz
 yr			year
-month			1|12 year
-ms			millisec
-us			microsec
+decade			10 yr
+century			100 year
+millennium		1000 year
+
+/ astronomical details
+siderealyear		365.256360417 day
+siderealday		23.934469444 hour
+siderealhour		1|24 siderealday
+lunarmonth		29.530 day
+synodicmonth		lunarmonth
+siderealmonth		27.32152777 day
+tropicalyear		year
+solaryear		year
+lunaryear		12 lunarmonth
+
+/ misc
+sigma			microsec
+
+/ 
+/ Frequency
+
+hertz			/sec
+Hz			hertz
+hz			/sec
+khz			1e+3 /sec
+mhz			1e+6 /sec
+rpm			rev/minute
+rps			rev/sec
+
+fresnel			1e12 hertz
+pulsatance		2 pi/sec
 
-/ Mass
+/ 
+/ Mass and weight
 
 gram			millikg
+gramme			gram
 gm			gram
 mg			milligram
 metricton		kilokg
+tonne			1e+6 gm
+
+atomicmassunit		1.66044e-27 kg fuzz
+amu			atomicmassunit
+dalton			amu
+
+electronmass		9.1095e-31 kg
+protonmass		1.6726e-27 kg
+neutronmass		1.6606e-27 kg
+
+carat			205 mg
+metriccarat		200 mg
+quintal			100 kg
 
-/ Avoirdupois
+/ Avoirdupois weight
 
 lb			.45359237 kg
 pound			lb
-lbf			lb g
 ounce			1|16 lb
 oz			ounce
 dram			1|16 oz
 dr			dram
 grain			1|7000 lb
 gr			grain
+stone			14 lb
 shortton		2000 lb
 ton			shortton
 longton			2240 lb
 
-/ Apothecary
+bag			94 lb
+cental			100 lb
+longhundredweight	112 lb
+longquarter		28 lb
+pennyweight		1|20 oz
+pwt			pennyweight
+shorthundredweight	100 lb
+shortquarter		25 lb
+weymass			252 lb
+
+/ Related mass units
+/
+/ According to Wikipedia there are two definitions for hyl, one using
+/ grams and one using kilograms. beware
+
+hyl			gm force sec2/m
+slug			lb-g-sec2/ft
+
+/ Apothecary weight
 
 scruple			20 grain
 apdram			60 grain
+drachm			60 grain
 apounce			480 grain
 appound			5760 grain
 troypound		appound
 troyounce		1|12 troypound
 
+/ Thai weight
+
+salueng			3.75 gm
+baht			4 salueng
+tamlueng		4 baht
+chang			20 tamlueng
+hap			50 chang
+
+/ 
 / Length
 
+/ SI unit
 meter			m
+metre			meter
+
+/ special-case abbreviations
 cm			centimeter
 mm			millimeter
 km			kilometer
 nm			nanometer
-micron			micrometer
+
+/ other metric units
 angstrom		decinanometer
+fermi			

CVS commit: src/usr.bin/units

2022-10-23 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct 24 04:55:19 UTC 2022

Modified Files:
src/usr.bin/units: units.lib

Log Message:
Reorganize units.lib.

It's all very well to file miscellaneous old units under "trivia" but
it's more useful to sort first by type and then by creakiness.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/units/units.lib

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2022-10-23 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 24 01:54:19 UTC 2022

Modified Files:
src/share/man/man7: sysctl.7
src/sys/netinet6: in6.c in6_proto.c ip6_input.c ip6_var.h

Log Message:
Fix PR kern/57037

Be able to change the behavior sending parameter changing routing messages.
When set net.inet6.ip6.param_rt_msg=0, don't send parameter changing
routing messages.
When set net.inet6.ip6.param_rt_msg=1(default), send parameter changing
routing messages by RTM_NEWADDR.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/share/man/man7/sysctl.7
cvs rdiff -u -r1.286 -r1.287 src/sys/netinet6/in6.c
cvs rdiff -u -r1.129 -r1.130 src/sys/netinet6/in6_proto.c
cvs rdiff -u -r1.225 -r1.226 src/sys/netinet6/ip6_input.c
cvs rdiff -u -r1.91 -r1.92 src/sys/netinet6/ip6_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man7/sysctl.7
diff -u src/share/man/man7/sysctl.7:1.161 src/share/man/man7/sysctl.7:1.162
--- src/share/man/man7/sysctl.7:1.161	Mon Aug 29 09:14:02 2022
+++ src/share/man/man7/sysctl.7	Mon Oct 24 01:54:19 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysctl.7,v 1.161 2022/08/29 09:14:02 knakahara Exp $
+.\"	$NetBSD: sysctl.7,v 1.162 2022/10/24 01:54:19 knakahara Exp $
 .\"
 .\" Copyright (c) 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
 .\"
-.Dd August 29, 2022
+.Dd October 24, 2022
 .Dt SYSCTL 7
 .Os
 .Sh NAME
@@ -1888,6 +1888,7 @@ The currently defined protocols and name
 .It ip6	maxfragpackets	integer	yes
 .It ip6	maxfrags	integer	yes
 .It ip6	neighborgcthresh	integer	yes
+.It ip6	param_rt_msg	integer	yes
 .It ip6	redirect	integer	yes
 .It ip6	rr_prune	integer	yes
 .It ip6	use_deprecated	integer	yes
@@ -2023,6 +2024,10 @@ The flag is provided basically for avoid
 Maximum number of entries in neighbor cache per interface.
 Set to negative to disable.
 The default value is 2048.
+.It Li ip6.param_rt_msg
+If set to 0, parameter changing routing message is suppressed.
+If set to 1, parameter changing routing message is sent by RTM_NEWADDR.
+Other values are undefined yet.
 .It Li ip6.redirect
 If set to 1, ICMPv6 redirects may be sent by the node.
 This option is ignored unless the node is routing IP packets,

Index: src/sys/netinet6/in6.c
diff -u src/sys/netinet6/in6.c:1.286 src/sys/netinet6/in6.c:1.287
--- src/sys/netinet6/in6.c:1.286	Tue Sep 20 02:23:37 2022
+++ src/sys/netinet6/in6.c	Mon Oct 24 01:54:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6.c,v 1.286 2022/09/20 02:23:37 knakahara Exp $	*/
+/*	$NetBSD: in6.c,v 1.287 2022/10/24 01:54:19 knakahara Exp $	*/
 /*	$KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.286 2022/09/20 02:23:37 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.287 2022/10/24 01:54:19 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1065,6 +1065,9 @@ in6_update_ifa1(struct ifnet *ifp, struc
 	int dad_delay, was_tentative;
 	struct in6_ifaddr *ia = iap ? *iap : NULL;
 	char ip6buf[INET6_ADDRSTRLEN];
+	bool addrmaskNotChanged = false;
+	bool send_rtm_newaddr = (ip6_param_rt_msg == 1);
+	int saved_flags;
 
 	KASSERT((iap == NULL && psref == NULL) ||
 	(iap != NULL && psref != NULL));
@@ -1186,6 +1189,21 @@ in6_update_ifa1(struct ifnet *ifp, struc
 			return 0; /* there's nothing to do */
 	}
 
+#define sin6eq(a, b) \
+	((a)->sin6_len == sizeof(struct sockaddr_in6) && \
+	 (b)->sin6_len == sizeof(struct sockaddr_in6) && \
+	 IN6_ARE_ADDR_EQUAL(&(a)->sin6_addr, &(b)->sin6_addr))
+
+	if (!send_rtm_newaddr) {
+		if (ia != NULL &&
+		sin6eq(>ifra_addr, >ia_addr) &&
+		sin6eq(>ifra_prefixmask, >ia_prefixmask)) {
+			addrmaskNotChanged = true;
+			saved_flags = ia->ia6_flags;  /* check it later */
+		}
+	}
+#undef sin6eq
+
 	/*
 	 * If this is a new address, allocate a new ifaddr and link it
 	 * into chains.
@@ -1291,6 +1309,17 @@ in6_update_ifa1(struct ifnet *ifp, struc
 		ia->ia6_lifetime.ia6t_preferred = time_uptime;
 	}
 
+	if (!send_rtm_newaddr) {
+		/*
+		 * We will not send RTM_NEWADDR if the only difference between
+		 * ia and ifra is preferred/valid lifetimes, because it is not
+		 * very useful for userland programs to be notified of that
+		 * changes.
+		 */
+		if (addrmaskNotChanged && ia->ia6_flags == saved_flags)
+			return 0;
+	}
+
 	if (hostIsNew) {
 		/*
 		 * We need a reference to ia before calling in6_ifinit.

Index: src/sys/netinet6/in6_proto.c
diff -u src/sys/netinet6/in6_proto.c:1.129 src/sys/netinet6/in6_proto.c:1.130
--- src/sys/netinet6/in6_proto.c:1.129	Sat Sep  3 02:53:18 2022
+++ src/sys/netinet6/in6_proto.c	Mon Oct 24 01:54:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_proto.c,v 1.129 2022/09/03 02:53:18 thorpej Exp $	*/
+/*	$NetBSD: in6_proto.c,v 1.130 2022/10/24 01:54:19 knakahara Exp $	*/
 /*	

CVS commit: src

2022-10-23 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 24 01:54:19 UTC 2022

Modified Files:
src/share/man/man7: sysctl.7
src/sys/netinet6: in6.c in6_proto.c ip6_input.c ip6_var.h

Log Message:
Fix PR kern/57037

Be able to change the behavior sending parameter changing routing messages.
When set net.inet6.ip6.param_rt_msg=0, don't send parameter changing
routing messages.
When set net.inet6.ip6.param_rt_msg=1(default), send parameter changing
routing messages by RTM_NEWADDR.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/share/man/man7/sysctl.7
cvs rdiff -u -r1.286 -r1.287 src/sys/netinet6/in6.c
cvs rdiff -u -r1.129 -r1.130 src/sys/netinet6/in6_proto.c
cvs rdiff -u -r1.225 -r1.226 src/sys/netinet6/ip6_input.c
cvs rdiff -u -r1.91 -r1.92 src/sys/netinet6/ip6_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2022-10-23 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Oct 23 23:30:31 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Remove extraneous "d" in a printf format string in UVM history dump
(leftover int format specifier from conversion to FMTd32?).


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/vmstat/vmstat.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/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.255 src/usr.bin/vmstat/vmstat.c:1.256
--- src/usr.bin/vmstat/vmstat.c:1.255	Sat Jul 16 10:36:19 2022
+++ src/usr.bin/vmstat/vmstat.c	Sun Oct 23 23:30:31 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.255 2022/07/16 10:36:19 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.256 2022/10/23 23:30:31 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.255 2022/07/16 10:36:19 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.256 2022/10/23 23:30:31 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -2299,7 +2299,7 @@ hist_dodump(struct kern_history *histp)
 			bintime2timeval(>bt, );
 			(void)printf("%06ld.%06ld ", (long int)tv.tv_sec,
 			(long int)tv.tv_usec);
-			(void)printf("%s#%" PRId32 "@%" PRId32 "d: ",
+			(void)printf("%s#%" PRId32 "@%" PRId32 ": ",
 			fn, e->call, e->cpunum);
 			(void)printf(fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
 			(void)putchar('\n');



CVS commit: src/usr.bin/vmstat

2022-10-23 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Oct 23 23:30:31 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Remove extraneous "d" in a printf format string in UVM history dump
(leftover int format specifier from conversion to FMTd32?).


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 23:03:30 UTC 2022

Modified Files:
src/sys/dev: midi.c

Log Message:
midi(4): No need to take lock just for callout_halt.

Lock is relevant only if we're doing something _else_ under the lock
that must be serialized with the callout's own action.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/midi.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/midi.c
diff -u src/sys/dev/midi.c:1.100 src/sys/dev/midi.c:1.101
--- src/sys/dev/midi.c:1.100	Sun Oct 23 23:03:13 2022
+++ src/sys/dev/midi.c	Sun Oct 23 23:03:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: midi.c,v 1.100 2022/10/23 23:03:13 riastradh Exp $	*/
+/*	$NetBSD: midi.c,v 1.101 2022/10/23 23:03:30 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.100 2022/10/23 23:03:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.101 2022/10/23 23:03:30 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "midi.h"
@@ -246,10 +246,8 @@ mididetach(device_t self, int flags)
 		sc->sih = NULL;
 	}
 
-	mutex_enter(sc->lock);
-	callout_halt(>xmt_asense_co, sc->lock);
-	callout_halt(>rcv_asense_co, sc->lock);
-	mutex_exit(sc->lock);
+	callout_halt(>xmt_asense_co, NULL);
+	callout_halt(>rcv_asense_co, NULL);
 
 	callout_destroy(>xmt_asense_co);
 	callout_destroy(>rcv_asense_co);



CVS commit: src/sys/dev

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 23:03:30 UTC 2022

Modified Files:
src/sys/dev: midi.c

Log Message:
midi(4): No need to take lock just for callout_halt.

Lock is relevant only if we're doing something _else_ under the lock
that must be serialized with the callout's own action.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/midi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 23:03:13 UTC 2022

Modified Files:
src/sys/dev: midi.c

Log Message:
midi(4): Explain what's about to happen when refcnt drain fails.

This should really be an unconditional cv_wait loop, but for now
let's just give fair warning when the driver is about to puke its
guts out in case the I/O paths I haven't audited yet are buggy.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/midi.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/midi.c
diff -u src/sys/dev/midi.c:1.99 src/sys/dev/midi.c:1.100
--- src/sys/dev/midi.c:1.99	Sun Oct 23 23:02:50 2022
+++ src/sys/dev/midi.c	Sun Oct 23 23:03:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: midi.c,v 1.99 2022/10/23 23:02:50 riastradh Exp $	*/
+/*	$NetBSD: midi.c,v 1.100 2022/10/23 23:03:13 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.99 2022/10/23 23:02:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.100 2022/10/23 23:03:13 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "midi.h"
@@ -211,6 +211,10 @@ mididetach(device_t self, int flags)
 
 	if (--sc->refcnt >= 0) {
 		(void)cv_timedwait(>detach_cv, sc->lock, hz * 60);
+		if (sc->refcnt >= 0) {
+			aprint_error_dev(self, "refcnt failed to drain,"
+			" bashing my brains out anyway\n");
+		}
 	}
 	mutex_exit(sc->lock);
 



CVS commit: src/sys/dev

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 23:03:13 UTC 2022

Modified Files:
src/sys/dev: midi.c

Log Message:
midi(4): Explain what's about to happen when refcnt drain fails.

This should really be an unconditional cv_wait loop, but for now
let's just give fair warning when the driver is about to puke its
guts out in case the I/O paths I haven't audited yet are buggy.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/midi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 23:02:50 UTC 2022

Modified Files:
src/sys/dev: midi.c

Log Message:
midi(4): Wake waiters _before_ waiting for them.

Otherwise we may deadlock waiting for them to give up while they're
waiting for I/O, not knowing they need to give up.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/midi.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/midi.c
diff -u src/sys/dev/midi.c:1.98 src/sys/dev/midi.c:1.99
--- src/sys/dev/midi.c:1.98	Sat Jun  4 03:31:10 2022
+++ src/sys/dev/midi.c	Sun Oct 23 23:02:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: midi.c,v 1.98 2022/06/04 03:31:10 pgoyette Exp $	*/
+/*	$NetBSD: midi.c,v 1.99 2022/10/23 23:02:50 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.98 2022/06/04 03:31:10 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.99 2022/10/23 23:02:50 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "midi.h"
@@ -206,13 +206,12 @@ mididetach(device_t self, int flags)
 
 	mutex_enter(sc->lock);
 	sc->dying = 1;
+	cv_broadcast(>wchan);
+	cv_broadcast(>rchan);
 
 	if (--sc->refcnt >= 0) {
-		/* Wake anything? */
 		(void)cv_timedwait(>detach_cv, sc->lock, hz * 60);
 	}
-	cv_broadcast(>wchan);
-	cv_broadcast(>rchan);
 	mutex_exit(sc->lock);
 
 	/* locate the major number */



CVS commit: src/sys/dev

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 23:02:50 UTC 2022

Modified Files:
src/sys/dev: midi.c

Log Message:
midi(4): Wake waiters _before_ waiting for them.

Otherwise we may deadlock waiting for them to give up while they're
waiting for I/O, not knowing they need to give up.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/midi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libc/time

2022-10-23 Thread Taylor R Campbell
> Date: Sun, 23 Oct 2022 12:19:37 -0600
> From: Warner Losh 
> 
>  You must have a table of all past
> leap seconds to do any kind of sensible mapping. And you also must
> have some way to keep that up to date, [...]

It's the same for all civil calendar matters with political changes
around summer time, but at a smaller scale: with an outdated tzdb,
where localtime might be off for an hour, mktime might be off by a few
seconds.

> > And, of course, at subsecond resolution, the POSIX clock rewinds.  The
> > monotonic clock correctly has t1 < t2, but POSIX(t1) > POSIX(t2).  And
> > this erratic behaviour is much worse than a typical NTP-driven clock
> > adjustment at random times, because by design this erratic behaviour
> > happens on ~every computer on the planet simultaneously!
> 
> Yea, if NTP knows about the leap, it can deal with it. The problem as you
> say comes in when the stratum 1 servers don't announce the leap second
> far enough in advance for the implementations to cope. It then devolves to
> the 'when, exactly, do you step the time back' problem since there's a
> couple
> of choices, unless you have the 'leap smear' ntp servers which do it over
> a few hours.

I mentioned NTP-driven clock adjustments as an example of _other_
times that a POSIX clock might rewind.  Such adjustments arise from
local clock drift and so occur randomly, in contrast to the rewinding
on leap seconds that is globally coordinated as a deliberate design
decision of POSIX leading to simultaneous worldwide computer system
failures.

NTP doesn't have to know about leap seconds at all, nor does POSIX.
They could both just report the number of SI seconds (averaged in the
usual TAI way) since an appropriate epoch, and all the leap second
adjustment logic could be ripped out and moved to tzdb and mktime just
like time zones and summer time.

The fundamental problem with a POSIX clock -- and to a lesser extent
NTP, although NTP at least transmits additional information to work
around it during a leap second transition unlike POSIX programs -- is
that it goes out of its way to step back the _internal concept of
timecounting_ (tick-tick-tick, counting what everyone expects to be SI
seconds) just to deal with an _external civil calendar presentation_,
like the summer time change.  And it makes sure to do so
simultaneously on all computers worldwide.  That's a spectacularly bad
design leading to tremendously costly mistakes.  Leap seconds aren't a
big deal; the erratic design of POSIX clocks is.


Re: CVS commit: src/lib/libc/time

2022-10-23 Thread Jan Schaumann
Robert Elz  wrote:
> Date:Sat, 22 Oct 2022 13:42:54 -0400
> From:Jan Schaumann 
> Message-ID:  
> 
>   | A full set of examples strikes me as too much here
> 
> A full set would be yes, but I think we could handle 3.

Hmm, maybe something like this?


...and will be normalized, if need be.

For example, consider a struct tm initialized with a
tm_year = 122, tm_mon = 11, tm_mday = 30, tm_hour =
22, tm_min = 57, and a tm_sec = 0, using UTC,
representing 2022‐12‐31T22:57:00Z.  Incrementing
tm_min by 13 and calling mktime() would yield a time_t
with value 1672528200, representing
2022‐12‐31T23:10:00Z, as the tm_min = 70 was
normalized to an increment of tm_hour by one and
tm_min = 10.

This normalizing can lead to cascading changes: Again
using a struct tm initialized as in the above example
but with a tm_hour = 23, the same change would yield a
time_t with value 1672531800, representing
2023‐01‐01T00:10:00Z: the normalization of tm_min
incremented tm_hour, which lead to a normalization
of tm_mday, which in turn caused tm_mon to be
normalized, which in turn lead to the increment of
tm_year.

In addition, negative values may also be normalized,
such that e.g., a tm_hour of −1 means 1 hour before
midnight, tm_mday of 0 means the day preceding the
current month, and tm_mon of −2 means 2 months before
January of tm_year.
---

The fact that mktime(2) returns a time_t makes the
phrasing even more awkward, and I suppose we could
leave out the actual value and say "would yield a
time_t representing..."?

Other ideas to improve this?

-Jan


Re: CVS commit: src/lib/libc/time

2022-10-23 Thread Taylor R Campbell
> Date: Sun, 23 Oct 2022 07:39:25 -0600
> From: Warner Losh 
> 
> I guess a more accurate way of saying this is that leap seconds simply
> aren't reliable, cannot be made reliable, and this affects normalization
> in ways too numerous to mention due to the details of the tz files, bugs
> in the system, and lack of others to implement them correctly.

I think you mean `POSIX clocks simply aren't reliable'.  They _could_
be made reliable, though, by fixing the the calendar arithmetic
formula in POSIX for mapping time_t to and from UTC -- just like POSIX
already fixed the bug in its Gregorian leap year formula.

> > The code works with either set of tzdata files, POSIX stretchy secs,
> > or UTC with leap secs - claiming that one doesn't happen, or cannot
> > happen, isn't really correct.
> 
> Yea, and even 'posix stretchy sec' is really a misnomer. POSIX simply
> counts time without leap seconds. Each second is the same length,

Not at all.

If you use a monotonic timer to sample the POSIX clock before and
after a leap second, the POSIX clock will appear to have taken twice
as long as it should to pass the leap second.

Of course, it's worse.  If sampled at _subsecond_ intervals, a POSIX
clock behaves _erratically_: it spontaneously rewinds itself!

Suppose we have a machine with a monotonic clock that counts SI
seconds as well as a POSIX clock:

SI monotonicPOSIX
123.25  1483228799.00
123.50  1483228799.25
123.75  1483228799.50  # t0 = boottime + 123.75
124.00  1483228799.75
124.25  1483228800.00  # leap second begins at 2016-12-31T23:59:60Z
124.50  1483228800.25
124.75  1483228800.50
125.00  1483228800.75  # t1 = boottime + 125.00
125.25  1483228800.00  # POSIX clock rewinds at 2017-01-01T00:00:00Z!
125.50  1483228800.25
125.75  1483228800.50  # t2 = boottime + 125.75
126.00  1483228800.75

At supersecond resolution, t2 - t0 is a duration of 2 SI seconds, but
a POSIX clock reports a time difference POSIX(t2) - POSIX(t0) of 1, so
`POSIX seconds' are not always SI seconds -- it is not the case that
`each [POSIX] second is the same length', even ignoring physical clock
sampling error.

And, of course, at subsecond resolution, the POSIX clock rewinds.  The
monotonic clock correctly has t1 < t2, but POSIX(t1) > POSIX(t2).  And
this erratic behaviour is much worse than a typical NTP-driven clock
adjustment at random times, because by design this erratic behaviour
happens on ~every computer on the planet simultaneously!

There's no need for this nonsense except insistence on the formula
that says every UTC day is counted by 86400 `POSIX seconds'.  POSIX
could be revised to fix this bug in the clock by just not doing civil
calendar adjustments in the basic clock that goes tick-tick-tick for
counting what most people think are going to be SI seconds.  For the
time_t<->UTC conversion in libc, machines with out-of-date tzdb would
just be off by a few seconds sometimes, no worse than being off by an
hour in the time_t<->localtime conversion with an out-of-date tzdb
across an updated summer time change.


Re: CVS commit: src/lib/libc/time

2022-10-23 Thread Warner Losh
On Sat, Oct 22, 2022 at 10:55 PM Robert Elz  wrote:

> Date:Sat, 22 Oct 2022 20:17:57 -0600
> From:Warner Losh 
> Message-ID:  <
> canczdfqhkz0xs7lf6lmjveontc5dgsonons_ug6fzsf30og...@mail.gmail.com>
>
>
>   | On the other hand, adding a caveat that leap seconds don't exist in a
> POSIX
>   | time_t and that's necessarily reflected in the normalization wouldn't
> be
>   | bad.
>
> The problem with doing that is that while we don't install it this
> way, it is possible to install tzdata such that leap seconds do occur
> (despite that not being posix) either unconditionally, or installing
> both and leaving it up to the user by their choice of timezone to use
> (which makes rather a mess).
>

That's true. In the default "UTC system time" clock, leap seconds simply
do no work at all. With the tzdata with leap seconds, they work for a
limited
subset of things, but not quite everything because you can't completely
close the gap due to time_t not having an encoding for them. Having tried
to deploy systems that needed to present a pedantically-correct UTC
time to the outside world shows many hole (most of which self correct
and are mostly right not near leap seconds).

I guess a more accurate way of saying this is that leap seconds simply
aren't reliable, cannot be made reliable, and this affects normalization
in ways too numerous to mention due to the details of the tz files, bugs
in the system, and lack of others to implement them correctly.


> The code works with either set of tzdata files, POSIX stretchy secs,
> or UTC with leap secs - claiming that one doesn't happen, or cannot
> happen, isn't really correct.
>

Yea, and even 'posix stretchy sec' is really a misnomer. POSIX simply
counts time without leap seconds. Each second is the same length,
and it doesn't make them longer or shorter. It just assumes some
ad-hoc, beyond the standard method for synchronization. The quality
of these ad-hoc methods ranges from terrible to halfway-decent, but
none are perfect.

OK. I've got my annual leap seconds rant out of the way. Even 15 years
after shipping these systems, the almost (but not completely) right nature
of how computers implement them still has my knee jerking just a little
too much...

Warner


Re: CVS commit: src/lib/libc/time

2022-10-23 Thread Warner Losh
On Sat, Oct 22, 2022, 8:05 PM Robert Elz  wrote:

> Date:Sat, 22 Oct 2022 13:42:54 -0400
> From:Jan Schaumann 
> Message-ID:  
>
>   | A full set of examples strikes me as too much here
>
> A full set would be yes, but I think we could handle 3.
> They don't need to be C code examples, just something
> like
> if tm_year==2022 tm_mon==10 tm_mday==19
>tm_hour==23 tm_min==58 tm_sec==17 and tm_dst==-1
>
> and tm_min was incremented as tm_min+=180, and then
> mktime() called upon the result, the struct tm would
> now have tm_min==1 tm_hour==24 and tm_mday==20, with
> tm_isdst 0 or 1 depending upon the local time zone.
> The other fields shown would not be altered in this
> example, the fields of struct tm not show here would
> (tm_wday, ...) would be filled in with appropriate values.
>

That sounds like a good idea...

[Using tm_min rather than tm_sec to avoid needing to include
> caveats about possible leap seconds, which, at least currently,
> could never happen in November, but all of that is too much
> to bother with.]
>

On the other hand, adding a caveat that leap seconds don't exist in a POSIX
time_t and that's necessarily reflected in the normalization wouldn't be
bad. It's a quite common misconception that somehow they do because they
exist in UTC... while you can encode any valid UTC time, they are always
normalized away.

The other examples could be even shorter, no need to repeat
> the final sentence about the other field changes or otherwise.
>
>   | Perhaps:
>   |
>   | This normalization is done in order from tm_sec up to
>   | tm_year,
>
> No, that is what you cannot say, because it is wrong.
>
> We do not always start from tm_sec, and tm_mon is *always*
> normalised (with its possible flow on to tm_year) before
> tm_mday - nothing else makes sense.   tm_year isn't
> "normalized" at all, though it might be adjusted.
>
> But all of this is what we already agreed is too much
> to explain.   And no matter how simple it makes things,
> the man pages cannot (deliberately) lie.
>

Agreed. These nuances are important.

  | possibly leading to cascading values.  That
>   | is, a tm_sec value of e.g., 185 with a tm_min value of
>   | 58 could lead to an increment of tm_min by three, and
>   | thus further incrementing tm_hour by one, and so on.
>
> This is more explaining how it works, which if we do at all,
> we need to do correctly.   That's where a few examples can
> be better, they allow the reader to deduce what probably
> happens, the weird one is there to show that the results
> will not always be what is expected at first glance, but
> that they always are correct.
>
>   | As with most things relating to
>   | time, dates, and calendars, the full details of these
>   | side effects are often non‐obvious, and it may be best
>   | to avoid such scenarios.
>
> And that part is just useless, unless you mean that non-normalised
> values should never be used, perhaps just in some fields (and it
> isn't that anyway, a big enough increment of tm_sec is the same
> as an increment of tm_mday or tm_mon) in which case we should just
> say that.   If not that, then hinting that it is sometimes odd,
> and those cases, which ones we refuse to tell you, should be
> avoided is a complete waste of time.   Which scenarios should be
> avoided?   The answer really is none of them, the answer is
> always correct, it just might not be what the user expected.
>


All good points.

Warner

> kre
>
>


CVS commit: src

2022-10-23 Thread Jan Schaumann
Module Name:src
Committed By:   jschauma
Date:   Sun Oct 23 15:43:40 UTC 2022

Modified Files:
src/include: time.h
src/share/man/man3: tm.3

Log Message:
correct tm_sec range to be [0-60]

The previous range introduced in time.h rev1.14 was supposed to account
for a mystical "double leap second", which ultimately never could exist
and was a mistaken interpretation from an early ISO C standard whereby
the possibility of two leap seconds within a year was erroneously
interpreted to mean that two leap seconds could occur at once.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/include/time.h
cvs rdiff -u -r1.4 -r1.5 src/share/man/man3/tm.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/include/time.h
diff -u src/include/time.h:1.47 src/include/time.h:1.48
--- src/include/time.h:1.47	Tue Oct  4 09:41:41 2016
+++ src/include/time.h	Sun Oct 23 15:43:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: time.h,v 1.47 2016/10/04 09:41:41 kamil Exp $	*/
+/*	$NetBSD: time.h,v 1.48 2022/10/23 15:43:40 jschauma Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -73,7 +73,7 @@ typedef	_BSD_TIMER_T_	timer_t;
 #define CLOCKS_PER_SEC	100
 
 struct tm {
-	int	tm_sec;		/* seconds after the minute [0-61] */
+	int	tm_sec;		/* seconds after the minute [0-60] */
 	int	tm_min;		/* minutes after the hour [0-59] */
 	int	tm_hour;	/* hours since midnight [0-23] */
 	int	tm_mday;	/* day of the month [1-31] */

Index: src/share/man/man3/tm.3
diff -u src/share/man/man3/tm.3:1.4 src/share/man/man3/tm.3:1.5
--- src/share/man/man3/tm.3:1.4	Thu Apr 14 05:45:34 2011
+++ src/share/man/man3/tm.3	Sun Oct 23 15:43:40 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: tm.3,v 1.4 2011/04/14 05:45:34 jruoho Exp $
+.\" $NetBSD: tm.3,v 1.5 2022/10/23 15:43:40 jschauma Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen 
 .\" All rights reserved.
@@ -42,7 +42,7 @@ The following standards-compliant fields
 .Bl -column -offset indent \
 "Type" "Field  " "Months since January 1 "  "Range "
 .It Sy Type Ta Sy Field Ta Sy Represents Ta Sy Range
-.It Vt int Ta Va tm_sec Ta Seconds Ta [0, 61]
+.It Vt int Ta Va tm_sec Ta Seconds Ta [0, 60]
 .It Vt int Ta Va tm_min Ta Minutes Ta [0, 59]
 .It Vt int Ta Va tm_hour Ta Hours since midnight Ta [0, 23]
 .It Vt int Ta Va tm_mday Ta Day of the month Ta [1, 31]



CVS commit: src

2022-10-23 Thread Jan Schaumann
Module Name:src
Committed By:   jschauma
Date:   Sun Oct 23 15:43:40 UTC 2022

Modified Files:
src/include: time.h
src/share/man/man3: tm.3

Log Message:
correct tm_sec range to be [0-60]

The previous range introduced in time.h rev1.14 was supposed to account
for a mystical "double leap second", which ultimately never could exist
and was a mistaken interpretation from an early ISO C standard whereby
the possibility of two leap seconds within a year was erroneously
interpreted to mean that two leap seconds could occur at once.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/include/time.h
cvs rdiff -u -r1.4 -r1.5 src/share/man/man3/tm.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 11:06:37 UTC 2022

Modified Files:
src/sys/dev/usb: ugen.c

Log Message:
ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/dev/usb/ugen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ugen.c
diff -u src/sys/dev/usb/ugen.c:1.170 src/sys/dev/usb/ugen.c:1.171
--- src/sys/dev/usb/ugen.c:1.170	Sun Oct 23 06:27:26 2022
+++ src/sys/dev/usb/ugen.c	Sun Oct 23 11:06:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ugen.c,v 1.170 2022/10/23 06:27:26 skrll Exp $	*/
+/*	$NetBSD: ugen.c,v 1.171 2022/10/23 11:06:37 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.170 2022/10/23 06:27:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.171 2022/10/23 11:06:37 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -562,7 +562,7 @@ ugenopen(dev_t dev, int flag, int mode, 
 	struct usbd_xfer *xfer;
 	int i, j;
 	int error;
-	int opened;
+	int opened = 0;
 
 	UGENHIST_FUNC(); UGENHIST_CALLED();
 



CVS commit: src/sys/dev/usb

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 11:06:37 UTC 2022

Modified Files:
src/sys/dev/usb: ugen.c

Log Message:
ugen(4): Make sure opened is initialized in ugenopen.

Otherwise the error branch is based on garbage.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/dev/usb/ugen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/sys

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 08:38:21 UTC 2022

Modified Files:
src/sys/sys: workqueue.h

Log Message:
sys/workqueue.h: Need sys/types.h for pri_t.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/sys/workqueue.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/sys

2022-10-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Oct 23 08:38:21 UTC 2022

Modified Files:
src/sys/sys: workqueue.h

Log Message:
sys/workqueue.h: Need sys/types.h for pri_t.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/sys/workqueue.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/sys/workqueue.h
diff -u src/sys/sys/workqueue.h:1.11 src/sys/sys/workqueue.h:1.12
--- src/sys/sys/workqueue.h:1.11	Sat Aug  1 02:14:43 2020
+++ src/sys/sys/workqueue.h	Sun Oct 23 08:38:21 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: workqueue.h,v 1.11 2020/08/01 02:14:43 riastradh Exp $	*/
+/*	$NetBSD: workqueue.h,v 1.12 2022/10/23 08:38:21 riastradh Exp $	*/
 
 /*-
  * Copyright (c)2002, 2005 YAMAMOTO Takashi,
@@ -29,6 +29,8 @@
 #ifndef _SYS_WORKQUEUE_H_
 #define	_SYS_WORKQUEUE_H_
 
+#include 
+
 struct cpu_info;
 
 /*



CVS commit: src/sys/arch/aarch64/aarch64

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:14:12 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: db_interface.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/aarch64/db_interface.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/db_interface.c
diff -u src/sys/arch/aarch64/aarch64/db_interface.c:1.20 src/sys/arch/aarch64/aarch64/db_interface.c:1.21
--- src/sys/arch/aarch64/aarch64/db_interface.c:1.20	Sat Oct 15 11:07:38 2022
+++ src/sys/arch/aarch64/aarch64/db_interface.c	Sun Oct 23 07:14:12 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.20 2022/10/15 11:07:38 jmcneill Exp $ */
+/* $NetBSD: db_interface.c,v 1.21 2022/10/23 07:14:12 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.20 2022/10/15 11:07:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.21 2022/10/23 07:14:12 skrll Exp $");
 
 #include 
 #include 
@@ -170,7 +170,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * will stop...
 		 */
 		/* old pte is returned by pmap_kvattr */
-		pte = pmap_kvattr(ptep, VM_PROT_EXECUTE|VM_PROT_READ|VM_PROT_WRITE);
+		pte = pmap_kvattr(ptep, VM_PROT_EXECUTE | VM_PROT_READ | VM_PROT_WRITE);
 		aarch64_tlbi_all();
 
 		s = size;



CVS commit: src/sys/arch/aarch64/aarch64

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:14:12 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: db_interface.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/aarch64/db_interface.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/include

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:13:07 UTC 2022

Modified Files:
src/sys/arch/aarch64/include: pmap.h

Log Message:
KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/aarch64/include/pmap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/include/pmap.h
diff -u src/sys/arch/aarch64/include/pmap.h:1.54 src/sys/arch/aarch64/include/pmap.h:1.55
--- src/sys/arch/aarch64/include/pmap.h:1.54	Sun Oct 23 07:11:26 2022
+++ src/sys/arch/aarch64/include/pmap.h	Sun Oct 23 07:13:07 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.54 2022/10/23 07:11:26 skrll Exp $ */
+/* $NetBSD: pmap.h,v 1.55 2022/10/23 07:13:07 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -176,7 +176,7 @@ struct vm_page_md {
 #define LX_BLKPAG_OS_WRITE		LX_BLKPAG_OS_1
 #define LX_BLKPAG_OS_WIRED		LX_BLKPAG_OS_2
 #define LX_BLKPAG_OS_BOOT		LX_BLKPAG_OS_3
-#define LX_BLKPAG_OS_RWMASK		(LX_BLKPAG_OS_WRITE|LX_BLKPAG_OS_READ)
+#define LX_BLKPAG_OS_RWMASK		(LX_BLKPAG_OS_WRITE | LX_BLKPAG_OS_READ)
 
 #define PMAP_PTE_OS0	"read"
 #define PMAP_PTE_OS1	"write"
@@ -215,7 +215,7 @@ struct vm_page_md {
 (((pde) & ((user) ? LX_BLKPAG_UXN : LX_BLKPAG_PXN)) == 0)
 #define l3pte_readable(pde)	((pde) & LX_BLKPAG_AF)
 #define l3pte_writable(pde)	\
-(((pde) & (LX_BLKPAG_AF|LX_BLKPAG_AP)) == (LX_BLKPAG_AF|LX_BLKPAG_AP_RW))
+(((pde) & (LX_BLKPAG_AF | LX_BLKPAG_AP)) == (LX_BLKPAG_AF | LX_BLKPAG_AP_RW))
 #define l3pte_index(v)		(((vaddr_t)(v) & L3_ADDR_BITS) >> L3_SHIFT)
 #define l3pte_valid(pde)	lxpde_valid(pde)
 #define l3pte_is_page(pde)	(((pde) & LX_TYPE) == L3_TYPE_PAG)
@@ -251,16 +251,16 @@ pmap_kvattr(pt_entry_t *ptep, vm_prot_t 
 	pt_entry_t pte = *ptep;
 	const pt_entry_t opte = pte;
 
-	pte &= ~(LX_BLKPAG_AF|LX_BLKPAG_AP);
-	switch (prot & (VM_PROT_READ|VM_PROT_WRITE)) {
+	pte &= ~(LX_BLKPAG_AF | LX_BLKPAG_AP);
+	switch (prot & (VM_PROT_READ | VM_PROT_WRITE)) {
 	case 0:
 		break;
 	case VM_PROT_READ:
-		pte |= (LX_BLKPAG_AF|LX_BLKPAG_AP_RO);
+		pte |= (LX_BLKPAG_AF | LX_BLKPAG_AP_RO);
 		break;
 	case VM_PROT_WRITE:
 	case VM_PROT_READ|VM_PROT_WRITE:
-		pte |= (LX_BLKPAG_AF|LX_BLKPAG_AP_RW);
+		pte |= (LX_BLKPAG_AF | LX_BLKPAG_AP_RW);
 		break;
 	}
 
@@ -320,7 +320,7 @@ paddr_t pmap_devmap_vtophys(paddr_t);
 		.pd_va = DEVMAP_ALIGN(va),			\
 		.pd_pa = DEVMAP_ALIGN(pa),			\
 		.pd_size = DEVMAP_SIZE(sz),			\
-		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,		\
+		.pd_prot = VM_PROT_READ | VM_PROT_WRITE,	\
 		.pd_flags = PMAP_DEV\
 	}
 #define	DEVMAP_ENTRY_END	{ 0 }



CVS commit: src/sys/arch/aarch64/include

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:13:07 UTC 2022

Modified Files:
src/sys/arch/aarch64/include: pmap.h

Log Message:
KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/aarch64/include/pmap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/include

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:11:27 UTC 2022

Modified Files:
src/sys/arch/aarch64/include: pmap.h

Log Message:
Line continuation alignment whitespace. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/aarch64/include/pmap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/include/pmap.h
diff -u src/sys/arch/aarch64/include/pmap.h:1.53 src/sys/arch/aarch64/include/pmap.h:1.54
--- src/sys/arch/aarch64/include/pmap.h:1.53	Sat Oct 15 11:07:38 2022
+++ src/sys/arch/aarch64/include/pmap.h	Sun Oct 23 07:11:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.53 2022/10/15 11:07:38 jmcneill Exp $ */
+/* $NetBSD: pmap.h,v 1.54 2022/10/23 07:11:26 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -315,13 +315,13 @@ paddr_t pmap_devmap_vtophys(paddr_t);
 #define DEVMAP_ALIGN(x)		L3_TRUNC_BLOCK((x))
 #define DEVMAP_SIZE(x)		L3_ROUND_BLOCK((x))
 
-#define	DEVMAP_ENTRY(va, pa, sz)			\
-	{		\
-		.pd_va = DEVMAP_ALIGN(va),		\
-		.pd_pa = DEVMAP_ALIGN(pa),		\
+#define	DEVMAP_ENTRY(va, pa, sz)\
+	{			\
+		.pd_va = DEVMAP_ALIGN(va),			\
+		.pd_pa = DEVMAP_ALIGN(pa),			\
 		.pd_size = DEVMAP_SIZE(sz),			\
-		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,	\
-		.pd_flags = PMAP_DEV			\
+		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,		\
+		.pd_flags = PMAP_DEV\
 	}
 #define	DEVMAP_ENTRY_END	{ 0 }
 



CVS commit: src/sys/arch/aarch64/include

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:11:27 UTC 2022

Modified Files:
src/sys/arch/aarch64/include: pmap.h

Log Message:
Line continuation alignment whitespace. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/aarch64/include/pmap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:04:44 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Use UVMHIST_CALLARGS in pmap_bootstrap


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.142 src/sys/arch/aarch64/aarch64/pmap.c:1.143
--- src/sys/arch/aarch64/aarch64/pmap.c:1.142	Sun Oct 23 07:02:26 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Oct 23 07:04:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.142 2022/10/23 07:02:26 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.143 2022/10/23 07:04:44 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.142 2022/10/23 07:02:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.143 2022/10/23 07:04:44 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -472,7 +472,8 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	PMAP_HIST_INIT();	/* init once */
 
 	UVMHIST_FUNC(__func__);
-	UVMHIST_CALLED(pmaphist);
+	UVMHIST_CALLARGS(pmaphist, "vstart=%#jx vend=%#jx", (uintptr_t)vstart,
+	(uintptr_t)vend, 0, 0);
 
 	uvmexp.ncolors = aarch64_cache_vindexsize / PAGE_SIZE;
 



CVS commit: src/sys/arch/aarch64/aarch64

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:04:44 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Use UVMHIST_CALLARGS in pmap_bootstrap


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:02:27 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Only define the EFI variable if EFI_RUNTIME


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.141 src/sys/arch/aarch64/aarch64/pmap.c:1.142
--- src/sys/arch/aarch64/aarch64/pmap.c:1.141	Thu Oct 20 06:47:29 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Oct 23 07:02:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.141 2022/10/20 06:47:29 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.142 2022/10/23 07:02:26 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.141 2022/10/20 06:47:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.142 2022/10/23 07:02:26 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -199,15 +199,18 @@ static int _pmap_get_pdp(struct pmap *, 
 struct vm_page **);
 
 static struct pmap kernel_pmap __cacheline_aligned;
-static struct pmap efirt_pmap __cacheline_aligned;
 
 struct pmap * const kernel_pmap_ptr = _pmap;
 
+#if defined(EFI_RUNTIME)
+static struct pmap efirt_pmap __cacheline_aligned;
+
 pmap_t
 pmap_efirt(void)
 {
 	return _pmap;
 }
+#endif
 
 static vaddr_t pmap_maxkvaddr;
 



CVS commit: src/sys/arch/aarch64/aarch64

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 07:02:27 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Only define the EFI variable if EFI_RUNTIME


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/uvm/pmap

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 06:37:15 UTC 2022

Modified Files:
src/sys/uvm/pmap: pmap.c

Log Message:
Correct the pmap_kstart_segtab entry in pmap_kern_segtab


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/uvm/pmap/pmap.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/uvm/pmap/pmap.c
diff -u src/sys/uvm/pmap/pmap.c:1.67 src/sys/uvm/pmap/pmap.c:1.68
--- src/sys/uvm/pmap/pmap.c:1.67	Thu Sep 15 06:44:18 2022
+++ src/sys/uvm/pmap/pmap.c	Sun Oct 23 06:37:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.67 2022/09/15 06:44:18 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.68 2022/10/23 06:37:15 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.67 2022/09/15 06:44:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.68 2022/10/23 06:37:15 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -202,7 +202,7 @@ pmap_segtab_t	pmap_kstart_segtab PMAP_SE
 #endif
 pmap_segtab_t	pmap_kern_segtab PMAP_SEGTAB_ALIGN = { /* top level segtab for kernel */
 #ifdef _LP64
-	.seg_seg[(VM_MIN_KERNEL_ADDRESS & XSEGOFSET) >> SEGSHIFT] = _kstart_segtab,
+	.seg_seg[(VM_MIN_KERNEL_ADDRESS >> XSEGSHIFT) & (NSEGPG - 1)] = _kstart_segtab,
 #endif
 };
 



CVS commit: src/sys/uvm/pmap

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 06:37:15 UTC 2022

Modified Files:
src/sys/uvm/pmap: pmap.c

Log Message:
Correct the pmap_kstart_segtab entry in pmap_kern_segtab


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/uvm/pmap/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/mips/adm5120/dev

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 06:29:01 UTC 2022

Modified Files:
src/sys/arch/mips/adm5120/dev: ahci.c

Log Message:
Fix build from previous


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mips/adm5120/dev/ahci.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/mips/adm5120/dev/ahci.c
diff -u src/sys/arch/mips/adm5120/dev/ahci.c:1.31 src/sys/arch/mips/adm5120/dev/ahci.c:1.32
--- src/sys/arch/mips/adm5120/dev/ahci.c:1.31	Wed Mar  9 22:17:41 2022
+++ src/sys/arch/mips/adm5120/dev/ahci.c	Sun Oct 23 06:29:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahci.c,v 1.31 2022/03/09 22:17:41 riastradh Exp $	*/
+/*	$NetBSD: ahci.c,v 1.32 2022/10/23 06:29:01 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.31 2022/03/09 22:17:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.32 2022/10/23 06:29:01 skrll Exp $");
 
 #include 
 #include 
@@ -743,7 +743,7 @@ ahci_root_intr_start(struct usbd_xfer *x
 
 	DPRINTF(D_TRACE, ("SLRIstart "));
 
-	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock);
+	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
 
 	KASSERT(sc->sc_intr_xfer == NULL);
 	sc->sc_interval = MS_TO_TICKS(xfer->ux_pipe->up_endpoint->ue_edesc->bInterval);
@@ -834,7 +834,7 @@ ahci_device_ctrl_start(struct usbd_xfer 
 	struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 	int len, isread;
 
-	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock);
+	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
 
 #if 0
 	struct ahci_pipe *apipe = (struct ahci_pipe *)xfer->ux_pipe;
@@ -1011,7 +1011,7 @@ ahci_device_intr_start(struct usbd_xfer 
 
 	DPRINTF(D_TRACE, ("INTRstart "));
 
-	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock);
+	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
 
 	sx = kmem_intr_alloc(sizeof(*sx), KM_NOSLEEP);
 	if (sx == NULL)
@@ -1158,7 +1158,7 @@ ahci_device_bulk_start(struct usbd_xfer 
 #define KSEG1ADDR(x) (0xa000 | (((uint32_t)x) & 0x1fff))
 	DPRINTF(D_TRACE, ("st "));
 
-	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock);
+	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
 
 #ifdef DIAGNOSTIC
 	if (xfer->ux_rqflags & URQ_REQUEST) {



CVS commit: src/sys/arch/mips/adm5120/dev

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 06:29:01 UTC 2022

Modified Files:
src/sys/arch/mips/adm5120/dev: ahci.c

Log Message:
Fix build from previous


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mips/adm5120/dev/ahci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/usb

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 06:27:26 UTC 2022

Modified Files:
src/sys/dev/usb: ugen.c

Log Message:
Fix USBDEBUG build on ILP32


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/dev/usb/ugen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/ugen.c
diff -u src/sys/dev/usb/ugen.c:1.169 src/sys/dev/usb/ugen.c:1.170
--- src/sys/dev/usb/ugen.c:1.169	Fri Oct 21 04:55:11 2022
+++ src/sys/dev/usb/ugen.c	Sun Oct 23 06:27:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ugen.c,v 1.169 2022/10/21 04:55:11 mrg Exp $	*/
+/*	$NetBSD: ugen.c,v 1.170 2022/10/23 06:27:26 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.169 2022/10/21 04:55:11 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.170 2022/10/23 06:27:26 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -473,8 +473,8 @@ ugen_set_config(struct ugen_softc *sc, i
 
 	UGENHIST_FUNC(); UGENHIST_CALLED();
 
-	DPRINTFN(1, "ugen%jd: %s to configno %jd, sc=%jx",
-		device_unit(sc->sc_dev), configno, sc, 0);
+	DPRINTFN(1, "ugen%jd: to configno %jd, sc=%jx",
+		device_unit(sc->sc_dev), configno, (uintptr_t)sc, 0);
 
 	KASSERT(KERNEL_LOCKED_P()); /* sc_is_open */
 
@@ -486,8 +486,8 @@ ugen_set_config(struct ugen_softc *sc, i
 		for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++)
 			if (sc->sc_is_open[endptno]) {
 DPRINTFN(1,
- "%s - endpoint %d is open",
-  endptno, 0, 0, 0);
+ "ugen%jd - endpoint %d is open",
+  device_unit(sc->sc_dev), endptno, 0, 0);
 return USBD_IN_USE;
 			}
 
@@ -607,7 +607,7 @@ ugenopen(dev_t dev, int flag, int mode, 
 		sce->state = 0;
 		sce->timeout = USBD_NO_TIMEOUT;
 		DPRINTFN(5, "sc=%jx, endpt=%jd, dir=%jd, sce=%jp",
-			 sc, endpt, dir, sce);
+			 (uintptr_t)sc, endpt, dir, (uintptr_t)sce);
 		edesc = sce->edesc;
 		switch (edesc->bmAttributes & UE_XFERTYPE) {
 		case UE_INTERRUPT:
@@ -754,7 +754,7 @@ ugen_do_close(struct ugen_softc *sc, int
 		if (sce->pipeh == NULL)
 			continue;
 		DPRINTFN(5, "endpt=%jd dir=%jd sce=%jx",
-			 endpt, dir, sce, 0);
+			 endpt, dir, (uintptr_t)sce, 0);
 
 		usbd_abort_pipe(sce->pipeh);
 
@@ -856,7 +856,7 @@ ugen_do_read(struct ugen_softc *sc, int 
 mutex_exit(>sc_lock);
 return EWOULDBLOCK;
 			}
-			DPRINTFN(5, "sleep on %jx", sce, 0, 0, 0);
+			DPRINTFN(5, "sleep on %jx", (uintptr_t)sce, 0, 0, 0);
 			/* "ugenri" */
 			error = cv_timedwait_sig(>cv, >sc_lock,
 			mstohz(sce->timeout));
@@ -899,7 +899,7 @@ ugen_do_read(struct ugen_softc *sc, int 
 			while (uio->uio_resid > 0 && !error) {
 while (sce->ra_wb_used == 0) {
 	DPRINTFN(5, "sleep on %jx",
-		sce, 0, 0, 0);
+		(uintptr_t)sce, 0, 0, 0);
 	/* "ugenrb" */
 	error = cv_timedwait_sig(>cv,
 	>sc_lock, mstohz(sce->timeout));
@@ -987,7 +987,7 @@ ugen_do_read(struct ugen_softc *sc, int 
 return EWOULDBLOCK;
 			}
 			/* "ugenri" */
-			DPRINTFN(5, "sleep on %jx", sce, 0, 0, 0);
+			DPRINTFN(5, "sleep on %jx", (uintptr_t)sce, 0, 0, 0);
 			error = cv_timedwait_sig(>cv, >sc_lock,
 			mstohz(sce->timeout));
 			DPRINTFN(5, "woke, error=%jd", error, 0, 0, 0);
@@ -1076,8 +1076,8 @@ ugen_do_write(struct ugen_softc *sc, int
 			while (uio->uio_resid > 0 && !error) {
 while (sce->ra_wb_used ==
    sce->limit - sce->ibuf) {
-	DPRINTFN(5, "sleep on %p",
-		 sce, 0, 0, 0);
+	DPRINTFN(5, "sleep on %#jx",
+		 (uintptr_t)sce, 0, 0, 0);
 	/* "ugenwb" */
 	error = cv_timedwait_sig(>cv,
 	>sc_lock, mstohz(sce->timeout));
@@ -1231,7 +1231,7 @@ ugen_detach(device_t self, int flags)
 
 	UGENHIST_FUNC(); UGENHIST_CALLED();
 
-	DPRINTF("sc=%ju flags=%ju", sc, flags, 0, 0);
+	DPRINTF("sc=%ju flags=%ju", (uintptr_t)sc, flags, 0, 0);
 
 	KASSERT(KERNEL_LOCKED_P()); /* sc_is_open */
 
@@ -1340,8 +1340,8 @@ ugenintr(struct usbd_xfer *xfer, void *a
 	usbd_get_xfer_status(xfer, NULL, NULL, , NULL);
 	ibuf = sce->ibuf;
 
-	DPRINTFN(5, "xfer=%p status=%d count=%d",
-		 xfer, status, count, 0);
+	DPRINTFN(5, "xfer=%#jx status=%d count=%d",
+		 (uintptr_t)xfer, status, count, 0);
 	DPRINTFN(5, "  data = %02x %02x %02x",
 		 ibuf[0], ibuf[1], ibuf[2], 0);
 



CVS commit: src/sys/dev/usb

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 06:27:26 UTC 2022

Modified Files:
src/sys/dev/usb: ugen.c

Log Message:
Fix USBDEBUG build on ILP32


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/sys/dev/usb/ugen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/mips/mips

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 06:10:09 UTC 2022

Modified Files:
src/sys/arch/mips/mips: mips_machdep.c

Log Message:
Trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.303 -r1.304 src/sys/arch/mips/mips/mips_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/mips/mips

2022-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 23 06:10:09 UTC 2022

Modified Files:
src/sys/arch/mips/mips: mips_machdep.c

Log Message:
Trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.303 -r1.304 src/sys/arch/mips/mips/mips_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/mips/mips_machdep.c
diff -u src/sys/arch/mips/mips/mips_machdep.c:1.303 src/sys/arch/mips/mips/mips_machdep.c:1.304
--- src/sys/arch/mips/mips/mips_machdep.c:1.303	Mon Aug  9 21:38:04 2021
+++ src/sys/arch/mips/mips/mips_machdep.c	Sun Oct 23 06:10:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mips_machdep.c,v 1.303 2021/08/09 21:38:04 andvar Exp $	*/
+/*	$NetBSD: mips_machdep.c,v 1.304 2022/10/23 06:10:09 skrll Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -111,7 +111,7 @@
  */
 
 #include 			/* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.303 2021/08/09 21:38:04 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.304 2022/10/23 06:10:09 skrll Exp $");
 
 #define __INTR_PRIVATE
 #include "opt_cputype.h"
@@ -2092,14 +2092,14 @@ mips_init_msgbuf(void)
 
 	paddr_t start = uvm_physseg_get_start(bank);
 	paddr_t end = uvm_physseg_get_end(bank);
-	
+
 	/* shrink so that it'll fit in the last segment */
 	if ((end - start) < atop(sz))
 		sz = ptoa(end - start);
 
 	end -= atop(sz);
 	uvm_physseg_unplug(end, atop(sz));
-	
+
 #ifdef _LP64
 	msgbufaddr = (void *) MIPS_PHYS_TO_XKPHYS_CACHED(ptoa(end));
 #else