Re: CVS commit: src/lib/libutil
On Mon, Apr 08, 2024 at 23:31:16 +0200, Roland Illig wrote: > Am 08.04.2024 um 21:18 schrieb Valery Ushakov: > > "=\017FIFTEEN\0" > > > > with its result a few lines below that has: > > > > BURST=0xf=FIFTEEN > > Thank you for explaining this example. I had a gut feeling that there > would be some hidden correlation between some octal/hexadecimal > combinations, but I couldn't name it. Indeed, if the number base for > output is hexadecimal, the field comparisons should be done in > hexadecimal as well. > > I adjusted the description and examples in the manual page accordingly. Thanks! My unscientific impression is that snprintb(3) was not very popular and its uses sometimes are a bit of a cargo-cult, so existing use cases have to be taken with a grain of salt and don't necessarily represent good style. This is why improving the docs with good examples is important, imho. -uwe
Re: CVS commit: src/lib/libutil
Am 08.04.2024 um 21:18 schrieb Valery Ushakov: > "=\017FIFTEEN\0" > > with its result a few lines below that has: > > BURST=0xf=FIFTEEN Thank you for explaining this example. I had a gut feeling that there would be some hidden correlation between some octal/hexadecimal combinations, but I couldn't name it. Indeed, if the number base for output is hexadecimal, the field comparisons should be done in hexadecimal as well. I adjusted the description and examples in the manual page accordingly. Roland
Re: CVS commit: src/lib/libutil
On Mon, Apr 08, 2024 at 20:21:07 +0200, Roland Illig wrote: > I didn't eradicate _all_ hexadecimal examples, I just made each example > use only one number base, not mix them both. There are both octal and > hexadecimal examples in the manual page. That's not what "prefer octal in examples" conveys. I would also say that source code that says "=\x0f" "FIFTEEN\0" aligns much better than "=\017FIFTEEN\0" with its result a few lines below that has: BURST=0xf=FIFTEEN -uwe
Re: CVS commit: src/lib/libutil
Am 08.04.2024 um 03:24 schrieb Valery Ushakov: > On Sun, Apr 07, 2024 at 14:28:27 +, Roland Illig wrote: > >> Log Message: >> snprintb.3: clean up formatting and wording, prefer octal in examples >> >> Using hexadecimal character escapes requires separate string literals if >> the description starts with one of the letters A-F; octal character >> escapes have at most 3 digits, reducing ambiguity. > > 70s are over, very few people speak octal fluently. If anything, the > man page should highlight the potential snag. Besides, separate > literal for the name is good for readability anyway. When I looked through the NetBSD tree exploring the current usage, I found that a significant majority uses octal instead of hexadecimal. I don't know the exact reasons for this, it might be due to existing practice in the 1990s, to avoid splitting the bit position and the description to separate string literals, to be able to easily split the bit position into the byte and the bit portion mentally, or maybe something entirely different. While your claim that "very few people speak octal fluently" may be true for programmers in general, I expect those using the snprintb function to be more fluent than others. Of course, I saw cases where "\040" was followed by "\039", just as I saw cases of "\x0fFIELD". Lint now warns in both these cases. Regarding the separate literals, I didn't see them in wide use up to now. Existing code seems to focus more on compressing the source code into as few lines as possible rather than making it easily readable. I agree that separate string literals are more readable, and I converted the example that uses hexadecimal escapes to this style. I didn't eradicate _all_ hexadecimal examples, I just made each example use only one number base, not mix them both. There are both octal and hexadecimal examples in the manual page. Roland
Re: CVS commit: src/lib/libutil
On Sun, Apr 07, 2024 at 14:28:27 +, Roland Illig wrote: > Log Message: > snprintb.3: clean up formatting and wording, prefer octal in examples > > Using hexadecimal character escapes requires separate string literals if > the description starts with one of the letters A-F; octal character > escapes have at most 3 digits, reducing ambiguity. 70s are over, very few people speak octal fluently. If anything, the man page should highlight the potential snag. Besides, separate literal for the name is good for readability anyway. Please, revert. -uwe
Re: CVS commit: src/lib/libutil
On Sun, Jan 21, 2024 at 21:31:23 +, Roland Illig wrote: > and also didn't make it clear that a few bits were omitted from > having descriptions. I dislike this part. It's internally inconsistent as it doesn't add the placeholders for the low bits; and in many real-life scenarios there will be *lots* of gaps in the defined bits, so implying in the man page that the placeholders are good style just places the people in a situation where they have to make the sensible thing, but go against the style suggested in the man page. I don't think that's helpful. Please, can we remove the placeholders from this example? -uwe
Re: CVS commit: src/lib/libc/time
Valery Ushakov wrote in : |On Fri, Dec 08, 2023 at 01:32:49 +0300, Valery Ushakov wrote: | |> On Thu, Dec 07, 2023 at 20:13:37 +, Robert Elz wrote: |> |>> While here, consistemntly use minus when minus is meant, rather that |>> just using a hyphen. |> |> One has to be careful with this. | |And to have this on record for refernce: https://lwn.net/Articles/947941/ 'Could be you like that: https://lists.gnu.org/archive/html/groff/2022-09/msg00048.html (or these https://lists.gnu.org/archive/html/groff/2022-09/msg00053.html https://lists.gnu.org/archive/html/groff/2022-09/msg00057.html heck i could vomit all thread long. :-) |-uwe --End of Ciao. --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) | | Only in December: lightful Dubai COP28 Narendra Modi quote: | A small part of humanity has ruthlessly exploited nature. | But the entire humanity is bearing the cost of it, | especially the inhabitants of the Global South. | The selfishness of a few will lead the world into darkness, | not just for themselves but for the entire world.
Re: CVS commit: src/lib/libc/time
On Fri, Dec 08, 2023 at 01:32:49 +0300, Valery Ushakov wrote: > On Thu, Dec 07, 2023 at 20:13:37 +, Robert Elz wrote: > > > While here, consistemntly use minus when minus is meant, rather that > > just using a hyphen. > > One has to be careful with this. And to have this on record for refernce: https://lwn.net/Articles/947941/ -uwe
Re: CVS commit: src/lib/libc/time
On Thu, Dec 07, 2023 at 20:13:37 +, Robert Elz wrote: > While here, consistemntly use minus when minus is meant, rather that > just using a hyphen. One has to be careful with this. In the literal context (Ql, Li, etc) the ascii minus-hyphen in the input is preserved as such. In other contexts you will get a math minus sign in PS/PDF output, or groff UTF-8 text output, which makes man page not copy-pastable. And wide (about the size of en-dash) minus sign looks rather ugly in non math contexts like 02:00 CST (−06) in PS/PDF. -uwe
Re: CVS commit: src/lib/libc/ssp
On Wednesday, November 15, 2023 4:15:28 AM CET you wrote: > Module Name: src > Committed By: christos > Date: Wed Nov 15 03:15:28 UTC 2023 > > Modified Files: > src/lib/libc/ssp: Makefile.inc > Added Files: > src/lib/libc/ssp: ssp_redirect.c > > Log Message: > provide materialized functions for the ssp overriden inlines The functions are supposed to be transparent and they used to be. Can we please just go back to the working state before? IMO wanting to overriding getcwd is absolutely no justification for this. If the prototype (and inline function) is visible from the header, userland should *not* be abled to interpose it. If it is not visible due to standard headers, there was no problem in first place. Joerg
re: CVS commit: src/lib/libc/stdlib
> Minor changes to jemalloc100 (the old one that only vax etc currently uses). thanks. i'm still using this version on a bunch of modern machines. new jemalloc was problematic for a few things for me a number of years ago and i keep meaning to test again, but for now i'm still mostly using this version everwhere. FYI. .mrg.
re: CVS commit: src/lib/libm/src
"Taylor R Campbell" writes: > Module Name: src > Committed By: riastradh > Date: Mon Mar 13 18:18:36 UTC 2023 > > Modified Files: > src/lib/libm/src: ldbl_dummy.c > > Log Message: > libm: Fill in more dummy long double transcendental functions. > > This should cover everything from C99. bump shlib minor? .mrg.
Re: CVS commit: src/lib/libcurses
Hi, r1.125 of refresh.c breaks /usr/bin/vi for me. When scrolling down long file with 'j' key and reaches the bottom line, screen is not scrolled up and new lines are displayed over the previous bottom line. Could you take a look at my problem? Thank you very much. "Brett Lymn" writes: > Module Name: src > Committed By: blymn > Date: Wed Nov 30 06:19:16 UTC 2022 > > Modified Files: > src/lib/libcurses: refresh.c > > Log Message: > When performing a scroll, check the last line of the region is the same > on virtscr and curscr because the indexes past are supposed to be > one *past* the last matching line (they may actually match if the line is > at the bottom of the screen). Iff they don't match reduce the scroll > region size by one so we don't scroll non-matching lines, also check > if the region is then 0 after the decrement and just return if it was. > > > To generate a diff of this commit: > cvs rdiff -u -r1.124 -r1.125 src/lib/libcurses/refresh.c > > Please note that diffs are not public domain; they are subject to the > copyright notices on the relevant files. > > Modified files: > > Index: src/lib/libcurses/refresh.c > diff -u src/lib/libcurses/refresh.c:1.124 src/lib/libcurses/refresh.c:1.125 > --- src/lib/libcurses/refresh.c:1.124 Wed Oct 19 06:09:27 2022 > +++ src/lib/libcurses/refresh.c Wed Nov 30 06:19:15 2022 > @@ -1,4 +1,4 @@ > -/* $NetBSD: refresh.c,v 1.124 2022/10/19 06:09:27 blymn Exp $ */ > +/* $NetBSD: refresh.c,v 1.125 2022/11/30 06:19:15 blymn Exp $ */ > > /* > * Copyright (c) 1981, 1993, 1994 > @@ -34,7 +34,7 @@ > #if 0 > static char sccsid[] = "@(#)refresh.c8.7 (Berkeley) 8/13/94"; > #else > -__RCSID("$NetBSD: refresh.c,v 1.124 2022/10/19 06:09:27 blymn Exp $"); > +__RCSID("$NetBSD: refresh.c,v 1.125 2022/11/30 06:19:15 blymn Exp $"); > #endif > #endif /* not lint */ > > @@ -1852,6 +1852,13 @@ scrolln(int starts, int startw, int curs > ox = curscr->curx; > n = starts - startw; > > + if (!lineeq(__virtscr->alines[startw]->line, > + curscr->alines[starts]->line, (size_t) __virtscr->maxx)) > + n--; > + > + if (n == 0) > + return; > + > /* >* XXX >* The initial tests that set __noqch don't let us reach here unless > -- Ryo ONODERA // r...@tetera.org PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB FD1B F404 27FA C7D1 15F3
Re: CVS commit: src/lib/libc/time
Date:Wed, 26 Oct 2022 10:42:15 -0400 From:Jan Schaumann Message-ID: | New proposal: That looks better (it needs some minor wording changes, there are too many indefinite articles ('a') which aren't needed, and there midnight should be just that, no hyphen or space -- but that's all trivia). kre
Re: CVS commit: src/lib/libc/time
Robert Elz wrote: > Date:Sun, 23 Oct 2022 13:53:01 -0400 > From:Jan Schaumann > Message-ID: > > | Hmm, maybe something like this? > > I think there is still too much there, you don't have > to explain everything (or almost anything), but it is > in the right direction I think. New proposal: --- [...] components are not restricted to their normal ranges and will be normalized, if need be. For example, consider a struct tm initialized with a tm_year = 122, tm_mon = 10, tm_mday = 30, tm_hour = 22, tm_min = 57, and a tm_sec = 0. Incrementing tm_min by 13 and calling mktime() would lead to a tm_hour = 23 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 lead to a tm_mon = 11, tm_mday = 1, tm_hour = 0, and tm_min = 10. Negative values may also be normalized with similar cascading effect such that e.g., a tm_hour of −1 means 1 hour before mid‐ night on the previous day and so on. --- ? -Jan
Re: CVS commit: src/lib/libc/time
Taylor R Campbell wrote in <20221023170035.2542f60...@jupiter.mumble.net>: ... |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. Just to note that the next leap second could be a negative one. --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)
Re: CVS commit: src/lib/libc/time
Date:Sun, 23 Oct 2022 13:53:01 -0400 From:Jan Schaumann Message-ID: | Hmm, maybe something like this? I think there is still too much there, you don't have to explain everything (or almost anything), but it is in the right direction I think. | 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. That last bit (the ISO format spec of the time) isn't really needed, but doesn't hurt either - but I would avoid an example that touches anywhere near midnight Dec 31, UTC, (which this one does later, if not here) as that's exactly where leap seconds start to appear, and (as illustrated in the side-discussion in this thread) that's where things get messy. Best to just avoid that (Avoid June 30 for the same reason.) | Incrementing | tm_min by 13 and calling mktime() would yield a time_t | with value 1672528200, That's irrelevant, the time_t returned isn't what's really interesting here, and its binary value is way too much (useless) information, it is the modification made to the tm that matters. It is already clear enough in the doc (I think) that the result from mktime() is the time_t for the normalised tm. | representing 2022â12â31T23:10:00Z, this, or just give the adjusted tm_min and tm_hour values, there's no need for both, and | as the tm_min = 70 was | normalized to an increment of tm_hour by one and | tm_min = 10. no need for the explanation of how it was done. | 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 That's the adjustment we want to avoid, as it gets right into what happens if we're observing leap seconds, and one was to happen in that period.There's no need to show the year being incremented, showing the month going up would be enough, readers ought to be able to deduce that if the month changes from Dec to Jan then the year would be incremented by one. | the normalization of tm_min incremented tm_hour, This explanation is not needed, but if it were, that would be correct, but | which lead to a normalization of tm_mday, which in | turn caused tm_mon to be normalized, but not those. Those fields (in this example) were already within the appropriate range, they don't need to be normalised, they're simply adjusted, or as in this (or tm_hour above): | which in turn lead to the increment of tm_year. | In addition, That's perhaps poor wording here, "addition" followed immediately by "negative", it could be "Also" which avoids this, but this lead in clause is not really needed at all, just begin like: | 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. Again, too much there, we don't need examples of everything. I still feel though that an example with more than one adjustment to a tm returned by localtime (though how it was originally created is irrelevant) and which would affect Feb 29 were it a leap year, would be worth giving (in both the leap year and non leap year cases) so we get Feb 29 in one case and Mar 1 in the other, from an adjustment that affects months (and days, either directly, or as a flow on from hours, mins, or secs) - like going back a month from Mar 28, then forward to the next day, and sometimes still being in Mar. | The fact that mktime(2) returns a time_t makes the | phrasing even more awkward, Yes, as above. | and I suppose we could | leave out the actual value and say "would yield a | time_t representing..."? No, nothing about the result returned at all, this should all just be about what normalising the tm causes to happen. Those values are not just internal, the tm passed (via ref) is modified if needed before mktime returns. kre
Re: CVS commit: src/lib/libc/time
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
Re: CVS commit: src/lib/libc/time
> 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
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
> 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
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
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 > >
Re: CVS commit: src/lib/libc/time
Date:Sat, 22 Oct 2022 20:17:57 -0600 From:Warner Losh Message-ID: | 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). 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. kre
Re: CVS commit: src/lib/libc/time
Date:Sun, 23 Oct 2022 08:33:18 +0700 From:Robert Elz Message-ID: <7638.1666488...@jacaranda.noi.kre.to> | 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 That is nonsense of course, but I think you get the idea (and being nonsense shows why the examples should be tested ) kre
Re: CVS commit: src/lib/libc/time
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. [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.] 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. | 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. kre
Re: CVS commit: src/lib/libc/time
Robert Elz wrote: > jo...@bec.de said: > | I'd actually weasle out a bit > > Yes, I would too, but A full set of examples strikes me as too much here still, and I do like the idea of weaseling out. Perhaps: This normalization is done in order from tm_sec up to tm_year, 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. Likewise, negative values can lead to decrementing other tm(3) fields. 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. ? -Jan
Re: CVS commit: src/lib/libc/time
Date:Fri, 21 Oct 2022 15:00:41 -0400 From:Jan Schaumann Message-ID: | I believe that it's useful for people to know that | values outside the normal ranges are normalized, Agreed. | as well as what that might look like. The problem with trying to specify that, as we have discovered, is that it is not easy. The problem with only doing half of the job here, is that sometime later someone will read it, see what it says happens, and what it doesn't say, and then expect the code to do that - when it probably doesn't. I'll come back to the rest of your message a bit lower, but first a brief interlude ... jo...@bec.de said: | I'd actually weasle out a bit Yes, I would too, but jo...@bec.de continued: | and just declare that normalisation is best effort and we | don't guarantee behavior for values that are very much outside | the range of the corresponding field. E.g. anything where | numerical overflow can happen in a component. that isn't really the problem. tzcode is very careful with arithmetic to avoid those kinds of problems - if there's anywhere that it isn't (which is still possible) that would be fixed if pointed out. The problem is just the complexity of specifying what does happen, in a way that fits the manual page in a way that is easier to follow that simply reading the source (which isn't all that easy). Now we return to the originally scheduelled e-mail: jscha...@netmeister.org said: | That helps a lot when trying to determine _why_ the | output of mktime(3) [...] | Noting that values may cascade is useful [...] I wonder if rather than attempting to specify what happens, it might be better in this case to give examples of using struct tm alterations, followed by mktime(), to alter the time, and what the results are. I'm not generally much in favour of examples in man pages, I prefer specification, and leave it up to the reader to determine how to use things to achieve the desired result, as while giving an example or two (or three) of what can be done is great for people who want to do one of those exact things (and so can just copy the example) but is useless for someone whose needs are different than any of the examples, and is left trying to guess what will happen. But here a two or three good examples of what happens might just be a sane solution, perhaps two fairly simple ones, but which demonstrate what happens with addition, and subtraction - using just one field modification, but having that result in a cascade through a few of the other fields - perhaps the 180 seconds forward, starting at 23:58 on the last day of some month, and 32 hours backwards starting at 01:15 on the second of a month.Those should both produce entirely reasonable and understandable results. The third should show multiple modifications, in a way that produces, or can do, a surprising result, perhaps 14 days forward, also 2 months forward, and some irrelevant small number of minutes backward (that just to show that multiple fields can be altered, and they don't need to all go in the same direction) starting at 13:27 on Dec 15 - where the result can be Feb 29, or Mar 1 (at something a bit earlier than 13:27, perhaps even make the number of minutes subtracted > 27 in that example) depending upon whether the year is a leap year or not. (Or make it 6 months forward (plus...) starting from August). This one should be one full example, with something like "if the starting year had been then the result would have been" added to show the difference between leap years and others. If this is done, the examples should all be tested to verify the claimed results, but the man page should not need a lot of explanation of why the result shown is achieved, just the input, the modification made, and the result. kre
Re: CVS commit: src/lib/libc/time
Am Fri, Oct 21, 2022 at 02:06:32PM +0700 schrieb Robert Elz: > Date:Fri, 21 Oct 2022 03:05:15 + > From:"Jan Schaumann" > Message-ID: <20221021030515.cdc9df...@cvs.netbsd.org> > > | Note normalizing behavior of mktime(3) using language from FreeBSD. > > If we are going to start specifying what happens (how the struct tm > is normalised) then we really also need to specify in which order > the fields are corrected. It makes a difference. I'd actually weasle out a bit and just declare that normalisation is best effort and we don't guarantee behavior for values that are very much outside the range of the corresponding field. E.g. anything where numerical overflow can happen in a component. Joerg
Re: CVS commit: src/lib/libc/time
Robert Elz wrote: > Date:Fri, 21 Oct 2022 11:54:08 -0400 > From:Jan Schaumann > Message-ID: > > | Right, but all that strikes me as too much to put into > | the manual page here. > > I agree, which is why I wondered if we should be giving any > details about how it is done at all. I believe that it's useful for people to know that values outside the normal ranges are normalized, as well as what that might look like. That helps a lot when trying to determine _why_ the output of mktime(3) with a tm_sec = 180 yields no error and a value of tm_min += 3. I don't think many people would want to go and dig up the sources to make sense of this. Noting that values may cascade is useful (because that, too, is not obvious), but seems to me the limit of detail desired here, while still being useful. -Jan
Re: CVS commit: src/lib/libc/time
Date:Fri, 21 Oct 2022 11:54:08 -0400 From:Jan Schaumann Message-ID: | Right, but all that strikes me as too much to put into | the manual page here. I agree, which is why I wondered if we should be giving any details about how it is done at all. | I think what matters in this context is that there is | an order and that there is a cascading effect. Perhaps, but | "This normalization is done in order from tm_sec to | tm_mon (inclusive), possibly leading to cascading | values." As a generic order, that's backwards. Really we need to go from year (which is always OK) to month (which can always be corrected simply, assuming the Gregorian calendar is in effect, which we assume it is, even for years before that calendar was created). Once we know the year and month, but not before, the day of month can be corrected (which might then affect the month and year, but only once). The code doesn't do it in quite that order, it does the secs mins hours first, but doing it that way ensures that the hours correction cannot affect the day, after it has been corrected, the day(of month) always gets set last (leap seconds excepted). It really is moderately complicated - trying to explain it at all risks being simply wrong, or so vague as to be completely useless.I'm not sure that what was there before (no details at all, just (in other words) "it gets fixed") wasn't as good as is reasonable to expect. kre
Re: CVS commit: src/lib/libc/time
Robert Elz wrote: > Date:Fri, 21 Oct 2022 10:36:23 -0400 > From:Jan Schaumann > Message-ID: > > > | Perhaps like this? > > Like that, yes, but as you wrote it isn't how it is actually > done I believe. > > The order looks to be secs, mins, hours, month, day(of month). > > There's no normalisation of the year (no invalid values to correct) > though the year can be adjusted when the month is adjusted. > > That order is assuming that the system is using posix stretchy seconds, > rather than UTC (with leap seconds), but almost all NetBSD systems > work that way - if UTC is being used, then secs cannot be done first, > as until the rest of the data/time is known, it is unknown whether > the number of seconds permitted is 59 60 or 61. With POSIX seconds > the secs/mins/hours correction order doesn't really matter, as there > are always 0..59 secs, 0..59 mins, and 0..23 hours, the rest of the > fields have no impact at all. Right, but all that strikes me as too much to put into the manual page here. I think what matters in this context is that there is an order and that there is a cascading effect. "This normalization is done in order from tm_sec to tm_mon (inclusive), possibly leading to cascading values." or "This normalization is done in order from tm_sec up to tm_year, possibly leading to cascading values." provides sufficient information, I think? -Jan
Re: CVS commit: src/lib/libc/time
Date:Fri, 21 Oct 2022 10:36:23 -0400 From:Jan Schaumann Message-ID: | Perhaps like this? Like that, yes, but as you wrote it isn't how it is actually done I believe. The order looks to be secs, mins, hours, month, day(of month). There's no normalisation of the year (no invalid values to correct) though the year can be adjusted when the month is adjusted. That order is assuming that the system is using posix stretchy seconds, rather than UTC (with leap seconds), but almost all NetBSD systems work that way - if UTC is being used, then secs cannot be done first, as until the rest of the data/time is known, it is unknown whether the number of seconds permitted is 59 60 or 61. With POSIX seconds the secs/mins/hours correction order doesn't really matter, as there are always 0..59 secs, 0..59 mins, and 0..23 hours, the rest of the fields have no impact at all. kre
Re: CVS commit: src/lib/libc/time
Robert Elz wrote: > Date:Fri, 21 Oct 2022 03:05:15 + > From:"Jan Schaumann" > Message-ID: <20221021030515.cdc9df...@cvs.netbsd.org> > > | Note normalizing behavior of mktime(3) using language from FreeBSD. > > If we are going to start specifying what happens (how the struct tm > is normalised) then we really also need to specify in which order > the fields are corrected. It makes a difference. Perhaps like this? Index: ctime.3 === RCS file: /cvsroot/src/lib/libc/time/ctime.3,v retrieving revision 1.65 diff -u -p -r1.65 ctime.3 --- ctime.3 21 Oct 2022 03:08:29 - 1.65 +++ ctime.3 21 Oct 2022 14:34:39 - @@ -264,6 +264,11 @@ of 0 means the day preceding the current .Fa tm_mon of \-2 means 2 months before January of .Fa tm_year . +This normalization is done in order from +.Fa tm_sec +to +.Fa tm_year , +possibly leading to cascading values. (A positive or zero value for .Fa tm_isdst causes
Re: CVS commit: src/lib/libc/time
Date:Fri, 21 Oct 2022 03:05:15 + From:"Jan Schaumann" Message-ID: <20221021030515.cdc9df...@cvs.netbsd.org> | Note normalizing behavior of mktime(3) using language from FreeBSD. If we are going to start specifying what happens (how the struct tm is normalised) then we really also need to specify in which order the fields are corrected. It makes a difference. kre
Re: CVS commit: src/lib/libc/stdlib
Date:Thu, 29 Sep 2022 08:18:49 -0400 From:Christos Zoulas Message-ID: | Yes, I had forgotten about the need to do this explicitly... | > On Sep 28, 2022, at 10:23 PM, Robert Elz wrote: | > | > Apologies, I did not read the code closely enough, there must be a bug | > in the way the clone file descriptor is created. I think I know the cause now, and it isn't anything specific to /dev/ptmx it would affect all cloning devices. In kern/vfs_syscalls.c do_open() we see the following: if (vp == NULL) { fd_abort(p, fp, indx); error = fd_dupopen(dupfd, dupfd_move, flags, ); if (error) return error; *fd = indx; } else { error = open_setfp(l, fp, vp, indx, flags); if (error) return error; VOP_UNLOCK(vp); *fd = indx; fd_affix(p, fp, indx); } The vp==NULL case is where cloning devices are handled. fd_dupopen() arranges top make the duplicate happen. It attempts to handle O_CLOEXEC thus: error = fd_dup(fp, 0, newp, ff->ff_exclose); where ff_exclose is the close_on_exec bit for the old file descriptor (the one being duplicated) which is just fine for other calls of fd_dupopen(). The vp!=NULL case above is for "normal" opens, and open_setfp() is what handles O_CLOEXEC - that's what (eventually) makes ff_exclose be true (it also handles O_EXLOCK and O_SHLOCK. None of that is being done in the cloning device open case, so those 3 flags simply cannot work, as the code is written currently, for these devices. I'm not about to go playing in this very fiddly piece of code, but I'm kind of hoping that dholland@ might know the right magic sequence to make this issue go away. It probably means a call to open_setfp() with some parameters or other, somewhere in the vp==NULL side of that if statement, though, just what I have not attempted to work out. kre
Re: CVS commit: src/lib/libc/stdlib
Yes, I had forgotten about the need to do this explicitly... christos > On Sep 28, 2022, at 10:23 PM, Robert Elz wrote: > > Apologies, I did not read the code closely enough, there must be a bug > in the way the clone file descriptor is created. > > kre signature.asc Description: Message signed with OpenPGP
Re: CVS commit: src/lib/libc/stdlib
Apologies, I did not read the code closely enough, there must be a bug in the way the clone file descriptor is created. kre
Re: CVS commit: src/lib/libc/stdlib
Date:Wed, 28 Sep 2022 20:48:53 -0400 From:"David H. Gutteridge" Message-ID: <9c9c8e9d9384338320b47dabfdc94...@gutteridge.ca> | (O_CLOEXEC, on the other hand, is ignored, at the moment.) No it isn't, your test is faulty, O_CLOEXEC is a different kind of flag, applies at a different level, and is fetched a different way. That's what dholland@ tried to tell you a few days ago. kre | | $ cat open_test.c | #include | #include | #include | | int main(int argc, char* argv[]) | { | int fd, flags; | | printf("Regular file (read-only) with O_NONBLOCK | O_CLOEXEC.\n"); | if ((fd = open("/etc/release", O_RDONLY | O_NONBLOCK | O_CLOEXEC)) < 0) | printf("Failed to get file handle.\n"); | else { | printf("Descriptor flags: %d\n", flags = fcntl(fd, F_GETFD)); | printf("Status flags: %d\n", flags = fcntl(fd, F_GETFL, 0)); | close(fd); | } | | printf("POSIX pt cloning device with O_NONBLOCK | O_CLOEXEC.\n"); | if ((fd = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK | | O_CLOEXEC)) < 0) | printf("Failed to open /dev/ptmx.\n"); | else { | printf("Descriptor flags: %d\n", flags = fcntl(fd, F_GETFD)); | printf("Status flags: %d\n", flags = fcntl(fd, F_GETFL, 0)); | close(fd); | } | | return 0; | } | | $ ./open_test | Regular file (read-only) with O_NONBLOCK | O_CLOEXEC. | Descriptor flags: 1 | Status flags: 4 | POSIX pt cloning device with O_NONBLOCK | O_CLOEXEC. | Descriptor flags: 0 | Status flags: 6 | | Regards, | | Dave |
Re: CVS commit: src/lib/libc/stdlib
On Wed, 28 Sep 2022, at 15:07:41 - (UTC), Christos Zoulas wrote: In article <20220928003547.D2375FA92%cvs.NetBSD.org@localhost>, David H. Gutteridge wrote: -=-=-=-=-=- Module Name:src Committed By: gutteridge Date: Wed Sep 28 00:35:47 UTC 2022 Modified Files: src/lib/libc/stdlib: posix_openpt.3 Log Message: posix_openpt.3: reflect flag changes from r. 1.44 of tty_ptm.c Some flags are now accepted, others are still ignored. (E.g., other BSDs would return EINVAL if O_RDWR wasn't passed, and we now accept O_NONBLOCK but not O_CLOEXEC.) How so? #define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FDSYNC|FRSYNC|FALTIO|\ ^ FDIRECT|FNOSIGPIPE) /* bits to save after open(2) */ #define FMASK (FREAD|FWRITE|FCNTLFLAGS|FEXEC) ^^ Best, christos Hi Christos, I'm sorry, I don't follow your question? I wrote "we now accept O_NONBLOCK...", which is what I'm reading you're saying too? (O_CLOEXEC, on the other hand, is ignored, at the moment.) $ cat open_test.c #include #include #include int main(int argc, char* argv[]) { int fd, flags; printf("Regular file (read-only) with O_NONBLOCK | O_CLOEXEC.\n"); if ((fd = open("/etc/release", O_RDONLY | O_NONBLOCK | O_CLOEXEC)) < 0) printf("Failed to get file handle.\n"); else { printf("Descriptor flags: %d\n", flags = fcntl(fd, F_GETFD)); printf("Status flags: %d\n", flags = fcntl(fd, F_GETFL, 0)); close(fd); } printf("POSIX pt cloning device with O_NONBLOCK | O_CLOEXEC.\n"); if ((fd = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK | O_CLOEXEC)) < 0) printf("Failed to open /dev/ptmx.\n"); else { printf("Descriptor flags: %d\n", flags = fcntl(fd, F_GETFD)); printf("Status flags: %d\n", flags = fcntl(fd, F_GETFL, 0)); close(fd); } return 0; } $ ./open_test Regular file (read-only) with O_NONBLOCK | O_CLOEXEC. Descriptor flags: 1 Status flags: 4 POSIX pt cloning device with O_NONBLOCK | O_CLOEXEC. Descriptor flags: 0 Status flags: 6 Regards, Dave
Re: CVS commit: src/lib/libc/stdlib
In article <20220928003547.d2375f...@cvs.netbsd.org>, David H. Gutteridge wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: gutteridge >Date: Wed Sep 28 00:35:47 UTC 2022 > >Modified Files: > src/lib/libc/stdlib: posix_openpt.3 > >Log Message: >posix_openpt.3: reflect flag changes from r. 1.44 of tty_ptm.c > >Some flags are now accepted, others are still ignored. (E.g., other >BSDs would return EINVAL if O_RDWR wasn't passed, and we now accept >O_NONBLOCK but not O_CLOEXEC.) How so? #define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FDSYNC|FRSYNC|FALTIO|\ ^ FDIRECT|FNOSIGPIPE) /* bits to save after open(2) */ #define FMASK (FREAD|FWRITE|FCNTLFLAGS|FEXEC) ^^ Best, christos
Re: null-terminated vs. nul-terminated (was: Re: CVS commit: src/lib/libc/gen)
> On Mar 26, 2022, at 9:39 AM, Taylor R Campbell > wrote: > > `C string' is ambiguous because there are also char arrays that > function as strings but which are not guaranteed to be NUL-terminated, > as strncpy is intended for. A non-terminated char array is not a C-string. The term C-string is not ambiguous. This is something that, amazingly, even Internet trolls appear to agree on. However, they do disagree as to the spelling of the terminating character's name, which is why I think it's best to elide it altogether. -- thorpej
Re: null-terminated vs. nul-terminated (was: Re: CVS commit: src/lib/libc/gen)
> On Mar 26, 2022, at 9:09 AM, Warner Losh wrote: > > Since all the 'C' standards[*] use "null-terminated" and "null character", > it's likely best to use that terminology because there is a source of truth > for its definition in case of ambiguity or doubt. Ah, but you're giving up the opportunity to use indirection to solve the problem. By calling it a "C-string", then those who care what the standard calls the terminating character can go look it up! :-) -- thorpej
Re: null-terminated vs. nul-terminated (was: Re: CVS commit: src/lib/libc/gen)
On Sat, Mar 26, 2022 at 9:53 AM Roland Illig wrote: > Am 24.03.2022 um 02:55 schrieb David H. Gutteridge: > > Module Name: src > > Committed By: gutteridge > > Date: Thu Mar 24 01:55:15 UTC 2022 > > > > Modified Files: > > src/lib/libc/gen: popen.3 > > > > Log Message: > > popen.3: minor spelling, grammar, style, and xref tweaks > > > > > > To generate a diff of this commit: > > cvs rdiff -u -r1.22 -r1.23 src/lib/libc/gen/popen.3 > > The term "null-terminated string" is quite common when talking about C. > In contrast, the word "nul" in "nul-terminated" always reminds me of > the character abbreviation in ASCII, which has a narrower scope than C. > I prefer to keep "null-terminated" here. > The standard uses "null-terminated" and "null character" (see Character Sets section 5.2.1 (from the C2x draft, but this term dates back to C89): "A byte with all bits set to 0, called the null character, shall exist in the basic execution character set; it is used to terminate a character string." I couldn't find the definition for null-terminated though. This is different than the NULL #define Not to be confused with the all zeros ASCII charater, whose mnemonic is NUL, which is where some pressure to use NUL terminated comes from. I agree that it's usage is narrower and really only relevant for certain ASCII and ASCII-derived character sets, which is why the standard chose the spelling it did. Since all the 'C' standards[*] use "null-terminated" and "null character", it's likely best to use that terminology because there is a source of truth for its definition in case of ambiguity or doubt. Warner [*] I've not gone the extra mile and checked to see if K used this phrase, to be honest.
Re: null-terminated vs. nul-terminated (was: Re: CVS commit: src/lib/libc/gen)
> Date: Sat, 26 Mar 2022 16:53:19 +0100 > From: Roland Illig > > The term "null-terminated string" is quite common when talking about C. > In contrast, the word "nul" in "nul-terminated" always reminds me of > the character abbreviation in ASCII, which has a narrower scope than C. > I prefer to keep "null-terminated" here. I feel like I've usually seen it as NUL-terminated. I thought it was in /usr/share/misc/style but I must have been thinking of a different style guide. `NUL' is better than `null' or `NULL' here because it's not a null pointer, unlike, e.g., the execve argv terminator. Even if the string isn't US-ASCII, what character encoding calls a nonzero byte `NUL'? `NUL' is better than `zero' or `0' here because it's unambiguously the all-bits-zero byte, not the US-ASCII encoding of `0' (i.e., decimal 48 or 0x30). `C string' is ambiguous because there are also char arrays that function as strings but which are not guaranteed to be NUL-terminated, as strncpy is intended for.
Re: null-terminated vs. nul-terminated (was: Re: CVS commit: src/lib/libc/gen)
> On Mar 26, 2022, at 9:17 AM, Martin Husemann wrote: > When talking about it I prefer "zero terminated", or C-string, in > contrast to C++ std::string (which are objects) or Pascal strings > (which have an explicit length at the beginning). Yes, I also prefer the term “C-string" -- thorpej
Re: null-terminated vs. nul-terminated (was: Re: CVS commit: src/lib/libc/gen)
On Sat, Mar 26, 2022 at 04:53:19PM +0100, Roland Illig wrote: > The term "null-terminated string" is quite common when talking about C. NULL terminated lists/array are quite common, but NULL is a pointer and the string is terminated by a 0 char (sometimes spelled as \0 in a string literal, but implicitly added by the compiler at the end of a literal, and spelled as NUL in the ascii table). > I prefer to keep "null-terminated" here. I think it is a bug. When talking about it I prefer "zero terminated", or C-string, in contrast to C++ std::string (which are objects) or Pascal strings (which have an explicit length at the beginning). Martin
null-terminated vs. nul-terminated (was: Re: CVS commit: src/lib/libc/gen)
Am 24.03.2022 um 02:55 schrieb David H. Gutteridge: Module Name:src Committed By: gutteridge Date: Thu Mar 24 01:55:15 UTC 2022 Modified Files: src/lib/libc/gen: popen.3 Log Message: popen.3: minor spelling, grammar, style, and xref tweaks To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libc/gen/popen.3 The term "null-terminated string" is quite common when talking about C. In contrast, the word "nul" in "nul-terminated" always reminds me of the character abbreviation in ASCII, which has a narrower scope than C. I prefer to keep "null-terminated" here. Roland
Re: CVS commit: src/lib/libc/time
In article <977b81a4-d330-6722-7ce4-cc4e61011...@gmx.de>, Roland Illig wrote: >Am 25.03.2022 um 22:25 schrieb Christos Zoulas: >> In article <20220325183551.0f039f...@cvs.netbsd.org>, >> Roland Illig wrote: >>> -=-=-=-=-=- >>> >>> Module Name:src >>> Committed By: rillig >>> Date: Fri Mar 25 18:35:50 UTC 2022 >>> >>> Modified Files: >>> src/lib/libc/time: localtime.c >>> >>> Log Message: >>> localtime.c: add back storage class 'register' >>> >>> This reduces the differences to the upstream code. >> >> I don't know why you did that. It is as simple to sed -e 's/register //g' >> in upstream when you diff. Adding register is useless; these days it is >> mostly ignored by compilers, except you can't &... > >I thought that having a small diff to the upstream code was more >important than a few saved keywords. If I was wrong, I can of course >revert it. I don't care too much, less clutter without obsolete keywords that do nothing or worse. christos
Re: CVS commit: src/lib/libc/time
Am 26.03.2022 um 00:50 schrieb Tobias Nygren: On Sat, 26 Mar 2022 00:31:45 +0100 Roland Illig wrote: localtime.c: add back storage class 'register' This reduces the differences to the upstream code. I don't know why you did that. It is as simple to sed -e 's/register //g' in upstream when you diff. Adding register is useless; these days it is mostly ignored by compilers, except you can't &... I thought that having a small diff to the upstream code was more important than a few saved keywords. If I was wrong, I can of course revert it. Can we keep it as-is, but #define register to empty at the top of the file? I don't think the compiler's view on the code is the main point of this discussion. At least, GCC generates the same code on x86_64, with or without 'register', so it doesn't seem to care. To me, the more interesting question is how human readers should deal with the code. If this piece of code had originated in the NetBSD tree, I wouldn't have added the 'register' keywords, I would have just indented the code according to KNF. But, most of this code is copied from the tz project, therefore our goal should be to make the diff minimal, in order to benefit from the testing of other projects using the same code. In this case, it means to keep the indentation exactly as inconsistent as upstream and also to keep the keyword 'register'. The remaining diff is still large enough to consume some developer time, containing a few fixes for WARNS=6 and for the lint checks. Roland
Re: CVS commit: src/lib/libc/time
On Sat, 26 Mar 2022 00:31:45 +0100 Roland Illig wrote: > >> localtime.c: add back storage class 'register' > >> > >> This reduces the differences to the upstream code. > > > > I don't know why you did that. It is as simple to sed -e 's/register //g' > > in upstream when you diff. Adding register is useless; these days it is > > mostly ignored by compilers, except you can't &... > > I thought that having a small diff to the upstream code was more > important than a few saved keywords. If I was wrong, I can of course > revert it. Can we keep it as-is, but #define register to empty at the top of the file?
Re: CVS commit: src/lib/libc/time
Am 25.03.2022 um 22:25 schrieb Christos Zoulas: In article <20220325183551.0f039f...@cvs.netbsd.org>, Roland Illig wrote: -=-=-=-=-=- Module Name:src Committed By: rillig Date: Fri Mar 25 18:35:50 UTC 2022 Modified Files: src/lib/libc/time: localtime.c Log Message: localtime.c: add back storage class 'register' This reduces the differences to the upstream code. I don't know why you did that. It is as simple to sed -e 's/register //g' in upstream when you diff. Adding register is useless; these days it is mostly ignored by compilers, except you can't &... I thought that having a small diff to the upstream code was more important than a few saved keywords. If I was wrong, I can of course revert it. Roland
Re: CVS commit: src/lib/libc/time
In article , Roland Illig wrote: > >The mess with the indentation comes from upstream. In our copy it's a >bit worth than upstream, but not much. I've asked upstream to indent consistently in the past. It has not happened. I try to minimize the diffs with upstream so that we can keep patching in our changes. I've also submitted our changes for inclusion to upstream. Some have been accepted, others have not. Best, christos
Re: CVS commit: src/lib/libc/time
In article <20220325183551.0f039f...@cvs.netbsd.org>, Roland Illig wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: rillig >Date: Fri Mar 25 18:35:50 UTC 2022 > >Modified Files: > src/lib/libc/time: localtime.c > >Log Message: >localtime.c: add back storage class 'register' > >This reduces the differences to the upstream code. I don't know why you did that. It is as simple to sed -e 's/register //g' in upstream when you diff. Adding register is useless; these days it is mostly ignored by compilers, except you can't &... christos
Re: CVS commit: src/lib/libc/time
In article <20220325190016.15114f...@cvs.netbsd.org>, Roland Illig wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: rillig >Date: Fri Mar 25 19:00:16 UTC 2022 > >Modified Files: > src/lib/libc/time: localtime.c > >Log Message: >localtime.c: take indentation style from upstream That I am fine with, but remember that some of the indentation changes in upstream were gratuitus (no code changes). christos
Re: CVS commit: src/lib/libc/time
Am 25.03.2022 um 13:59 schrieb Robert Elz: Date:Thu, 24 Mar 2022 23:32:30 +0100 From:Roland Illig Message-ID: <6bb00924-edaf-a4c8-348e-ba1304d57...@gmx.de> | Someone should clean up this mess. No, they probabky shouldn't, in general. That source comes from the tz project (currently from tzcode2022a) with local modifications. When I said "somebody" above, I really meant "somebody at the appropriate position". I already suspected that this would not be NetBSD. Sorry for the brevity. I think upstream mostly uses ts=4 (or more likely the emacs equivalent). we mostky use tab, and view with ts=8 and yes, that can mead to ugly results. The mess with the indentation comes from upstream. In our copy it's a bit worth than upstream, but not much. Roland
Re: CVS commit: src/lib/libc/time
Date:Thu, 24 Mar 2022 23:32:30 +0100 From:Roland Illig Message-ID: <6bb00924-edaf-a4c8-348e-ba1304d57...@gmx.de> | Someone should clean up this mess. No, they probabky shouldn't, in general. That source comes from the tz project (currently from tzcode2022a) with local modifications. I think upstream mostly uses ts=4 (or more likely the emacs equivalent). we mostky use tab, and view with ts=8 and yes, that can mead to ugly results. But to ease merging of future versions, this should be touched as little as possible. kre ps: one way and another we have plenty of localtime testing, not all in tests/libc. At least for general correctness. I don't know if all the various hard casez are as well tested locally, but changes that would affect thise generally come from upstream. Lots of people do lots of tests on the upstream code.
Re: CVS commit: src/lib/libc/time
Am 24.03.2022 um 17:15 schrieb Christos Zoulas: Module Name:src Committed By: christos Date: Thu Mar 24 16:15:05 UTC 2022 Modified Files: src/lib/libc/time: localtime.c Log Message: put back the 2022a changes and fix the misplaced brace. To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 src/lib/libc/time/localtime.c The indentation of this file looks completely random: Line 272 has a comment indented by 2 spaces, the code in that block is indented by 4 spaces instead of the usual tab. Same for line 295. Line 350 is indented differently than line 346. Line 420 has a continuation that is indented by 2 spaces instead of the usual 4. Line 490 is indented by 2 spaces instead of the usual tab. Line 513 is indented by 4 spaces instead of the usual tab. Line 534 is indented by 2 spaces instead of the usual tab. Line 585 is indented by 2 spaces instead of the usual tab. Line 667 is indented by 2 tabs instead of the usual 1 tab. Line 683 is indented by 2 tabs instead of the usual tab. Line 688 is indented by 2 spaces instead of the usual tab. Line 1083 contains unaligned variable declarations. Line 2347 looks as if it were assuming a tab width of 4, but the immediately following line breaks this assumption. Someone should clean up this mess. I don't know how good the test coverage for localtime(3) is, so I'm happy to leave this (and a few possible refactorings to decrease the indentation) to people more familiar with the history and origins of this file. Roland
Re: CVS commit: src/lib/libc/time
On Wed, Mar 23, 2022 at 02:00:29PM +0100, Tobias Nygren wrote: > I think this commit broke something. > date(1) no longer reports a time zone and is stuck at GMT time: > > $ ls -l /etc/localtime > lrwxr-xr-x 1 root wheel 36 Mar 22 08:47 /etc/localtime -> > /usr/share/zoneinfo/Europe/Stockholm > $ date > Wed Mar 23 12:57:40 2022 > $ TZ=CET date > Wed Mar 23 12:57:44 2022 > $ TZ=foo date > Wed Mar 23 12:57:48 GMT 2022 The lib/libc/time tests are failing and e.g. this: zdump -v /usr/share/zoneinfo/US/Eastern gives a suprisingly short output. Martin
Re: CVS commit: src/lib/libc/time
On Tue, 22 Mar 2022 13:48:39 -0400 Christos Zoulas wrote: > Modified Files: > src/lib/libc/time: CONTRIBUTING Makefile NEWS localtime.c private.h > theory.html tz-link.html tzselect.8 tzselect.ksh version zdump.c > zic.c > > Log Message: > welcome to tzcode-2022a Hi, I think this commit broke something. date(1) no longer reports a time zone and is stuck at GMT time: $ ls -l /etc/localtime lrwxr-xr-x 1 root wheel 36 Mar 22 08:47 /etc/localtime -> /usr/share/zoneinfo/Europe/Stockholm $ date Wed Mar 23 12:57:40 2022 $ TZ=CET date Wed Mar 23 12:57:44 2022 $ TZ=foo date Wed Mar 23 12:57:48 GMT 2022 Kind regards, -Tobias
Re: CVS commit: src/lib/libc/stdlib
On Sat, 12 Mar 2022 08:26:01 + Nia Alarie wrote: > Module Name: src > Committed By: nia > Date: Sat Mar 12 08:26:01 UTC 2022 > > Modified Files: > src/lib/libc/stdlib: hcreate.c > > Log Message: > hcreate(3): use reallocarr instead of malloc(x * y) Caution: malloc(0) and reallocarr(, 0, s) have different semantics for the returned pointer value.
Re: CVS commit: src/lib/libc/stdlib
On Sat, Feb 12, 2022, 11:52 AM Taylor R Campbell < campbell+netbsd-source-change...@mumble.net> wrote: > > Date: Sun, 13 Feb 2022 05:44:38 +1100 > > from: matthew green > > > > "Roland Illig" writes: > > > Module Name:src > > > Committed By: rillig > > > Date: Fri Feb 11 21:36:46 UTC 2022 > > > > > > Modified Files: > > > src/lib/libc/stdlib: getenv.c > > > > > > Log Message: > > > libc/getenv: remove trailing whitespace > > > > > > No binary change. > > > > please avoid purely whitespace changes unless you're > > also going to be modifying the code itself. > > > > (don't back out now.) > > I thought we were supposed to _avoid_ mixing whitespace changes and > functional changes? > > (Obviously the solution is to just only ever commit code with perfect > style to begin with so this is never an issue! Speaking of which, > (setq show-trailing-whitespace t) is helpful to avoid this kind of > mistake up front. git diff or git add -p will also flag this kind of > mistake, if you're working in git. /usr/share/misc/NetBSD.el is also > helpful for other KNF style.) > I thought the rule was don't make purely whitespace changes UNLESS you plan on making other changes to (or are fixing an oops you just made). If that's the case, separate the two commits. Warner >
Re: CVS commit: src/lib/libc/stdlib
Am 12.02.2022 um 20:10 schrieb Warner Losh: I thought the rule was don't make purely whitespace changes UNLESS you plan on making other changes to (or are fixing an oops you just made). If that's the case, separate the two commits. That sounds like a useful rule, I'll stick to it. Roland
Re: CVS commit: src/lib/libc/stdlib
> Date: Sun, 13 Feb 2022 05:44:38 +1100 > from: matthew green > > "Roland Illig" writes: > > Module Name:src > > Committed By: rillig > > Date: Fri Feb 11 21:36:46 UTC 2022 > > > > Modified Files: > > src/lib/libc/stdlib: getenv.c > > > > Log Message: > > libc/getenv: remove trailing whitespace > > > > No binary change. > > please avoid purely whitespace changes unless you're > also going to be modifying the code itself. > > (don't back out now.) I thought we were supposed to _avoid_ mixing whitespace changes and functional changes? (Obviously the solution is to just only ever commit code with perfect style to begin with so this is never an issue! Speaking of which, (setq show-trailing-whitespace t) is helpful to avoid this kind of mistake up front. git diff or git add -p will also flag this kind of mistake, if you're working in git. /usr/share/misc/NetBSD.el is also helpful for other KNF style.)
re: CVS commit: src/lib/libc/stdlib
"Roland Illig" writes: > Module Name: src > Committed By: rillig > Date: Fri Feb 11 21:36:46 UTC 2022 > > Modified Files: > src/lib/libc/stdlib: getenv.c > > Log Message: > libc/getenv: remove trailing whitespace > > No binary change. please avoid purely whitespace changes unless you're also going to be modifying the code itself. (don't back out now.) thanks. .mrg.
Re: CVS commit: src/lib/libcurses
On Sun, Jan 16, 2022 at 01:13:04PM +0100, Roland Illig wrote: > I'm not sure what the perfect commit message would look like that > would keep us both unsurprised and how much time we should spend > discussing about this particular case since the code itself can be > reviewed in a few seconds. "Remove two null statements and an unreachable break. NFC." :-} Martin
Re: CVS commit: src/lib/libcurses
16.01.2022 12:44:02 Valery Ushakov : > On Sun, Jan 16, 2022 at 10:30:45 +, Roland Illig wrote: > >> Modified Files: >> src/lib/libcurses: addbytes.c ins_wstr.c >> >> Log Message: >> libcurses: remove unreachable statements > > That summary sounds kinda misleading to me. It's technically true - > the commit removes unreachable *empty* statements - accidentally > doubled semicolons in return foo;; and the like - but it makes it > sound much more ominous by failing to mention that fact. I would have > skipped a change summarized, e.g., as "g/c duplicate semicolons" or > something like that that actually captured the essense of the change > correctly. I felt compelled to go and take a look at something > described as "remove unreachable statements". Please, can you be more > careful in wording those? Actually, I _was_ careful. I not only removed 2 null statements (as the C standard calls them) but also an unreachable break statement. Due to this break statement it would have been misleading (at least to me) to only state "remove empty statements" or even "remove duplicate semicolons". I'm not sure what the perfect commit message would look like that would keep us both unsurprised and how much time we should spend discussing about this particular case since the code itself can be reviewed in a few seconds. Roland
Re: CVS commit: src/lib/libcurses
On Sun, Jan 16, 2022 at 10:30:45 +, Roland Illig wrote: > Modified Files: > src/lib/libcurses: addbytes.c ins_wstr.c > > Log Message: > libcurses: remove unreachable statements That summary sounds kinda misleading to me. It's technically true - the commit removes unreachable *empty* statements - accidentally doubled semicolons in return foo;; and the like - but it makes it sound much more ominous by failing to mention that fact. I would have skipped a change summarized, e.g., as "g/c duplicate semicolons" or something like that that actually captured the essense of the change correctly. I felt compelled to go and take a look at something described as "remove unreachable statements". Please, can you be more careful in wording those? -uwe
Re: CVS commit: src/lib/libcurses
On Thu, Jan 06, 2022 at 06:18:13 +, Brett Lymn wrote: > Module Name: src > Committed By: blymn > Date: Thu Jan 6 06:18:13 UTC 2022 > > Modified Files: > src/lib/libcurses: slk.c > > Log Message: > Properly size and array to hold the larget return from wctomb. I'm not sure this is correct. You are introducing a variable length array here. POSIX says that The header shall define the following macro which shall expand to a positive integer expression with type size_t: {MB_CUR_MAX} Maximum number of bytes in a character specified by the current locale (category LC_CTYPE). the important exegetical fact about this passage is that it says "integer expression", not "integer constant expression". MB_LEN_MAX is maximum MB_CUR_MAX and "shall be suitable for use in #if preprocessing directives". I think this should be reverted. -uwe
Re: CVS commit: src/lib/libc/string
On Fri, Oct 29, 2021 at 10:11:57AM +, Nia Alarie wrote: > Module Name: src > Committed By: nia > Date: Fri Oct 29 10:11:57 UTC 2021 > > Modified Files: > src/lib/libc/string: wcsdup.c > > Log Message: > wcsdup(3): use reallocarr to catch integer overflow Except that no such integer overflow can happen, since the input string already has done the same computation. Joerg
Re: CVS commit: src/lib/libcurses
On Tue, Jul 27, 2021 at 12:22:18AM +0300, Valery Ushakov wrote: > I'm not sure what is the discussion you are referring to, but it's not > a matter of a simple rewording. "It's complicated", as it ties into a > few other things, so ideally it needs a coordinated change to several > man pages. During aiomixer review, someone complained that it wasn't usable and mentioned that their terminal only had A_STANDOUT. I was reluctant to start using A_STANDOUT because of the big warning in the BUGS section of the man page not to use it, which you mentioned is probably bogus. I think you told me that A_STANDOUT should be used for semantic purposes where it makes sense to use. > The two key points from the spec that the BUGS section tries to warn > you about is (emphasis mine): > > A_STANDOUT - Best highlighting mode of the terminal > > The standend() and wstandend() functions turn off ALL attributes of > the current or specified window. > > Roughly speaking "standout" is a kind of higher-level alais and it > works differently than other attributes (standend). Mixing it with > explicit use of other lower-level attributes is not a good idea. With this in mind, I would also change curses_attributes.3 to adequately explain what standout is intended to do rather than just warning against it. Proposed diff attached. Index: curses_attributes.3 === RCS file: /cvsroot/src/lib/libcurses/curses_attributes.3,v retrieving revision 1.9 diff -u -r1.9 curses_attributes.3 --- curses_attributes.3 25 Oct 2018 10:36:56 - 1.9 +++ curses_attributes.3 27 Jul 2021 07:37:27 - @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 25, 2018 +.Dd July 27, 2021 .Dt CURSES_ATTRIBUTES 3 .Os .Sh NAME @@ -102,7 +102,7 @@ .It A_NORMAL no special attributes are applied .It A_STANDOUT -characters are displayed in standout mode +characters are displayed in the "best" highlighting mode of the terminal .It A_UNDERLINE characters are displayed underlined .It A_REVERSE @@ -193,7 +193,7 @@ .Pp .Bl -tag -width "COLOR_PAIR(n)" -compact -offset indent .It WA_STANDOUT -characters are displayed in standout mode +characters are displayed in the "best" highlighting mode of the terminal .It WA_UNDERLINE characters are displayed underlined .It WA_REVERSE @@ -336,7 +336,10 @@ .Sh HISTORY These functions first appeared in .Nx 1.5 . -.Sh BUGS +.Sh CAVEATS Some terminals do not support characters with both color and other attributes set. In this case, the other attribute is displayed instead of the color attribute. +.Pp +The standout attribute is a higher-level alias and should not be mixed with +other attributes. Index: curses_standout.3 === RCS file: /cvsroot/src/lib/libcurses/curses_standout.3,v retrieving revision 1.8 diff -u -r1.8 curses_standout.3 --- curses_standout.3 26 Jul 2021 20:17:09 - 1.8 +++ curses_standout.3 27 Jul 2021 07:37:27 - @@ -25,7 +25,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd July 26, 2021 +.Dd July 27, 2021 .Dt CURSES_STANDOUT 3 .Os .Sh NAME @@ -55,6 +55,9 @@ These functions manipulate the standout attribute on .Dv stdscr or on the specified window. +The standout attribute applies the "best highlighting mode" +supported by the current terminal, which may be an alias of +other attributes. .Pp The .Fn standout @@ -101,3 +104,9 @@ .Sh HISTORY The Curses package appeared in .Bx 4.0 . +.Sh CAVEATS +On some terminals, characters with standout set may have the same appearance +as characters with the reverse video or bold attribute set. +However, on legacy terminals, standout may be the only attribute that can be +used to emphasize characters. +The standout attribute should not be mixed with other attributes.
Re: CVS commit: src/lib/libcurses
On Mon, Jul 26, 2021 at 21:04:37 +, nia wrote: > On Mon, Jul 26, 2021 at 09:01:51PM +, nia wrote: > > On Mon, Jul 26, 2021 at 11:55:24PM +0300, Valery Ushakov wrote: > > > On Mon, Jul 26, 2021 at 20:17:10 +, Nia Alarie wrote: > > > > > > > Module Name:src > > > > Committed By: nia > > > > Date: Mon Jul 26 20:17:10 UTC 2021 > > > > > > > > Modified Files: > > > > src/lib/libcurses: curses_standout.3 > > > > > > > > Log Message: > > > > The BUGS sections is incorrect again for "modern" terminals. > > > > > > > > For example, wscons and xterm both display standout differently to bold. > > > > > > Please, revert. The bugs section need to be changed to caveats (it's > > > not a bug, if it's by design) and fixed, not removed, as the sitution > > > it warns about is still very much pertinent. The fact that xterm > > > chose to use A_REVERSE video instead of A_BOLD is just an irrelevant > > > detail. > > > > > > -uwe > > > > Suggested wording? I was thinking: > > > > "Some modern terminals may display characters with the standout > > attribute set identically to those with the bold or reverse attribute > > set." > > ... A note that some legacy terminals may _only_ support standout > is probably pertinent too, given the discussion that spawned this. I'm not sure what is the discussion you are referring to, but it's not a matter of a simple rewording. "It's complicated", as it ties into a few other things, so ideally it needs a coordinated change to several man pages. Even the official "X/Open Curses, Issue 7" docs are not very good at explaining this and cross-referencing things properly, so you need to do a bit of legwork to find out. The two key points from the spec that the BUGS section tries to warn you about is (emphasis mine): A_STANDOUT - Best highlighting mode of the terminal The standend() and wstandend() functions turn off ALL attributes of the current or specified window. Roughly speaking "standout" is a kind of higher-level alais and it works differently than other attributes (standend). Mixing it with explicit use of other lower-level attributes is not a good idea. -uwe
Re: CVS commit: src/lib/libcurses
On Mon, 26 Jul 2021, nia wrote: "Some modern terminals may display characters with the standout attribute set identically to those with the bold or reverse attribute set." I would remove the word "modern" completely. ++--+--+ | Paul Goyette | PGP Key fingerprint: | E-mail addresses:| | (Retired) | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com| | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org | || | pgoyett...@gmail.com | ++--+--+
Re: CVS commit: src/lib/libcurses
On Mon, Jul 26, 2021 at 09:01:51PM +, nia wrote: > On Mon, Jul 26, 2021 at 11:55:24PM +0300, Valery Ushakov wrote: > > On Mon, Jul 26, 2021 at 20:17:10 +, Nia Alarie wrote: > > > > > Module Name: src > > > Committed By: nia > > > Date: Mon Jul 26 20:17:10 UTC 2021 > > > > > > Modified Files: > > > src/lib/libcurses: curses_standout.3 > > > > > > Log Message: > > > The BUGS sections is incorrect again for "modern" terminals. > > > > > > For example, wscons and xterm both display standout differently to bold. > > > > Please, revert. The bugs section need to be changed to caveats (it's > > not a bug, if it's by design) and fixed, not removed, as the sitution > > it warns about is still very much pertinent. The fact that xterm > > chose to use A_REVERSE video instead of A_BOLD is just an irrelevant > > detail. > > > > -uwe > > Suggested wording? I was thinking: > > "Some modern terminals may display characters with the standout > attribute set identically to those with the bold or reverse attribute > set." ... A note that some legacy terminals may _only_ support standout is probably pertinent too, given the discussion that spawned this.
Re: CVS commit: src/lib/libcurses
On Mon, Jul 26, 2021 at 11:55:24PM +0300, Valery Ushakov wrote: > On Mon, Jul 26, 2021 at 20:17:10 +, Nia Alarie wrote: > > > Module Name:src > > Committed By: nia > > Date: Mon Jul 26 20:17:10 UTC 2021 > > > > Modified Files: > > src/lib/libcurses: curses_standout.3 > > > > Log Message: > > The BUGS sections is incorrect again for "modern" terminals. > > > > For example, wscons and xterm both display standout differently to bold. > > Please, revert. The bugs section need to be changed to caveats (it's > not a bug, if it's by design) and fixed, not removed, as the sitution > it warns about is still very much pertinent. The fact that xterm > chose to use A_REVERSE video instead of A_BOLD is just an irrelevant > detail. > > -uwe Suggested wording? I was thinking: "Some modern terminals may display characters with the standout attribute set identically to those with the bold or reverse attribute set."
Re: CVS commit: src/lib/libcurses
On Mon, Jul 26, 2021 at 20:17:10 +, Nia Alarie wrote: > Module Name: src > Committed By: nia > Date: Mon Jul 26 20:17:10 UTC 2021 > > Modified Files: > src/lib/libcurses: curses_standout.3 > > Log Message: > The BUGS sections is incorrect again for "modern" terminals. > > For example, wscons and xterm both display standout differently to bold. Please, revert. The bugs section need to be changed to caveats (it's not a bug, if it's by design) and fixed, not removed, as the sitution it warns about is still very much pertinent. The fact that xterm chose to use A_REVERSE video instead of A_BOLD is just an irrelevant detail. -uwe
Re: CVS commit: src/lib/libc/arch/powerpc/string
On 2021/07/25 6:32, Joerg Sonnenberger wrote: On Sat, Jul 24, 2021 at 05:27:26AM +, Rin Okuyama wrote: Module Name:src Committed By: rin Date: Sat Jul 24 05:27:26 UTC 2021 Modified Files: src/lib/libc/arch/powerpc/string: Makefile.inc Log Message: For evbppc, use C version of bcopy(3), memcpy(3), memcmp(3), and memmove(3) consistently for debug library (*.go) in order to avoid alignment faults for 403. Why do we want to pessimize all evbppc targets just for issues with the 403 design? Well, for kernel, we can readily switch unaffected machines to assembler versions. For userland, we can provide something like libc_ua.so for machines with capability of unaligned access. Some time, I will benchmark whether it is worth the cost. Thanks, rin
Re: CVS commit: src/lib/libc/arch/powerpc/string
On Sat, Jul 24, 2021 at 05:27:26AM +, Rin Okuyama wrote: > Module Name: src > Committed By: rin > Date: Sat Jul 24 05:27:26 UTC 2021 > > Modified Files: > src/lib/libc/arch/powerpc/string: Makefile.inc > > Log Message: > For evbppc, use C version of bcopy(3), memcpy(3), memcmp(3), and > memmove(3) consistently for debug library (*.go) in order to avoid > alignment faults for 403. Why do we want to pessimize all evbppc targets just for issues with the 403 design? Joerg
Re: CVS commit: src/lib/libc/arch/arm
Oops, this is broken. I will fix shortly... rin On 2021/06/30 8:29, Rin Okuyama wrote: Module Name:src Committed By: rin Date: Tue Jun 29 23:29:12 UTC 2021 Modified Files: src/lib/libc/arch/arm/gen: swapcontext.S src/lib/libc/arch/arm/sys: __clone.S Log Message: Align sp to 8-byte boundary as required by EABI. IIUC, this change only affects libc compiled for ``Thumb-mode userland'', which we've not officially supported yet. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libc/arch/arm/gen/swapcontext.S cvs rdiff -u -r1.9 -r1.10 src/lib/libc/arch/arm/sys/__clone.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/lib/libcurses
On Wed, Jun 23, 2021 at 07:29:30AM +, Martin Husemann wrote: > This (or the series) broke the non-wide char builds. > Easy/quick reproducer: build.sh -m sun2 release /home/builds/ab/HEAD/sun3/202106222020Z-tools/lib/gcc/m68k--netbsdelf/10.3.0/../../../../m68k--netbsdelf/bin/ld: libhack.o: in function `__slk_draw': /usr/src/distrib/utils/libhack/../../../lib/libcurses/slk.c:860: undefined reference to `setcchar' /home/builds/ab/HEAD/sun3/202106222020Z-tools/lib/gcc/m68k--netbsdelf/10.3.0/../../../../m68k--netbsdelf/bin/ld: /usr/src/distrib/utils/libhack/../../../lib/libcurses/slk.c:870: undefined reference to `mvwins_wch' /home/builds/ab/HEAD/sun3/202106222020Z-tools/lib/gcc/m68k--netbsdelf/10.3.0/../../../../m68k--netbsdelf/bin/ld: /usr/src/distrib/utils/libhack/../../../lib/libcurses/slk.c:873: undefined reference to `mvwadd_wch' collect2: error: ld returned 1 exit status See for example: http://releng.netbsd.org/builds/HEAD/202106222020Z/sun3.build.failed Martin
Re: CVS commit: src/lib/libcurses
On Tue, Jun 22, 2021 at 07:49:09AM +, Brett Lymn wrote: > Module Name: src > Committed By: blymn > Date: Tue Jun 22 07:49:09 UTC 2021 > > Modified Files: > src/lib/libcurses: addbytes.c > > Log Message: > Rework the fix for lib/56224. > Move the scroll check to _cursesi_addwchar > Perform the scroll check before updating the cursor location when > processing \n. > > > To generate a diff of this commit: > cvs rdiff -u -r1.56 -r1.57 src/lib/libcurses/addbytes.c This (or the series) broke the non-wide char builds. Easy/quick reproducer: build.sh -m sun2 release Can you please fix? Thanks! Martin
Re: vfork() and posix_spawn() [was: Re: CVS commit: src/lib/libc/sys]
Date:Mon, 14 Jun 2021 03:56:48 +0200 From:Joerg Sonnenberger Message-ID: | This is even more true for multi-threaded applications | (where POSIX explicitly suggests that requirement). Sure, anything with fork() and threads has issues, that's messy. Even I know that, and I know very little about threads. | On the specific topic, I'm somewhat puzzled by the claim that fork is | async-signal-safe That's not what I said, I said it isn't (though the way I phrased that might not have been all that clear - I know I often type too much, and sometimes overcompensate by typing too little). But (from my message): If the "that said" relates to fork() or vfork() not being async signal safe, so a double fork() (when the first is vfork anyway) would not be condoned, was meant to acknowledge that fork() (and vfork()) aren't async signal safe, and so if a requirement that async signal safe functions are all that is permitted after vfork() actually existed, then a if (vfork() == 0) fork(); sequence would not be permitted (not generate defined actions). But for the purposes of whether double fork() option to posix_spawn is useful or not, this restriction doesn't matter, as the above can be (eventually) written if (vfork() == 0) _Fork(); instead, as _Fork() is (to be) async signal safe. Same effect as the (perhaps) undefined version above for this purpose. | since most implementations will require synchronisation for pthread_atfork Yes, which is what _Fork() does not do (_Fork() is to fork() as _exit() is to exit() - in a sense). | It most likely should. The main reason is that much of the system can | and often do depend on things like mutexes to ensure correctness and all | that is essentially UB after vfork(). Actually, it isn't UB, or shouldn't be. The behaviour of vfork() is actually very precisely specified (which doesn't take much, as it is quite simple). There's very little room for UB. What there is is plenty of room for simple errors to screw things (and appear as if it is UB, when it is actually quite well defined broken code). There's no problem using mutexes after a vfork() with two caveats - first anything locked must be unlocked again before the eventual _exit() or exec() (the mutex must be returned to its state at the time of the vfork()) and the child must not need to lock anything which might be already locked in the parent (as that's a guaranteed deadlock). How one makes the latter condition work is for someone else to solve... That said, most of what would require a mutex isn't something that should be being done after a vfork() anyway - most of those operations are likely to be things which change state of the process, and that's what (at least without careful preparation) cannot happen in a child of a vfork() (so no use of stdio, no use of malloc, ...) | That's even ignoring the stronger issue of mutating state. Yes, though if it is intentional, that can actually be OK (sometimes). Our /bin/sh relies upon the ability to modify its parent's state after a vfork() to communicate status back to the parent (more than is possible reliably with exit status - as the parent cannot tell from that whether the status it receives is from its own image running the child after the vfork() or from some other process after an exec() succeeded). A modified volatile variable (in the parent), however, can only have been modified by the vfork() child (we assume here that the parent isn't modifying the variable itself elsewhere, naturally). And yes, that means that on any system that "implements" vfork() using cc -Dvfork=fork (or its equivalent) cannot use vfork() with our sh - we need a "real" vfork, or must simply disable its use and only use fork (which is what the -D implementation does anyway of course, just badly). | vfork use really should die... That sentiment has been around for a long time - almost since vfork() was first created (40+ years ago). But it is still here. Implementing fork() using CoW was supposed to solve all the issues with fork(). It didn't, vfork() is still lots faster. posix_spawn() might allow some uses of vfork()+exec() to be retired, that would be good, but it isn't going to get all of them. | No, it relates to one common pattern for used by or for daemon. Yes, I understood that, but why do we care? Daemons start how often? What percentage of the forks() (vfork is, in practice, never used for this) on your systems are generated by daemons starting? What kind of saving would you expect to see from allowing posix_spawn() to replace that fork();fork() sequence ? Is it really worth even the tiniest extra complexity in that already fairly complex interface to handle this almost irrelevant issue? Do you believe in non-memory managed real time systems there are any daemon processes like that at all? | There are non-trivial uses of fork, yes. There are much less
Re: vfork() and posix_spawn() [was: Re: CVS commit: src/lib/libc/sys]
On Mon, Jun 14, 2021 at 01:33:51AM +0700, Robert Elz wrote: > Date:Sat, 12 Jun 2021 23:13:54 +0200 > From:Joerg Sonnenberger > Message-ID: > > Sorry, missed this message when I was cherry picking messages to read in > a timely fashion. > > | On Wed, Jun 09, 2021 at 01:03:20AM +0700, Robert Elz wrote: > | > after a vfork() the child can do anything > > | This is not true. After vfork(), it is only supposed to call async > | signal safe functions. > > What you said, and what I said are not contradictory. Note I said "can > do" and you said "is only supposed to". > > What is supposed to work and what actually does work (or can be made to > work) are two different things. Sure, but the set of what works reliably has actually been shrinking over time and more bugs in various programs using vfork specifically have been discovered. This is even more true for multi-threaded applications (where POSIX explicitly suggests that requirement). On the specific topic, I'm somewhat puzzled by the claim that fork is async-signal-safe since most implementations will require synchronisation for pthread_atfork and that seems to place quite a burden on the implementation... > I would note though our man page doesn't make that requirement, or not > that I can see anyway, and vfork() is not in POSIX of course - and while > I don't have a copy to check, I'd suspect not in the C standards either), > so while that sounds like a reasonable requirement to impose for safer > operation, I'm not sure that anyone or anything actually does that. It most likely should. The main reason is that much of the system can and often do depend on things like mutexes to ensure correctness and all that is essentially UB after vfork(). That's even ignoring the stronger issue of mutating state. vfork use really should die... > > | That said, a flag for the double fork semantic might be useful. > > If the "that said" relates to fork() or vfork() not being async signal safe, > so a double fork() (when the first is vfork anyway) would not be condoned, > that doesn't matter, there to be an async-signal-safe _Fork() call added to > the next version of POSIX, so even with the "only async signal safe" > requirement for vfork() a: No, it relates to one common pattern for used by or for daemon. > Please don't see posix_spawn() as being (or ever becoming) a panacea that > can replace all fork() (or even just vfork()) calls - even just in the > cases where an exec() follows soon after. It works fine for most simple > cases, but there are lots of not-so-simple situations that it cannot handle, > and burdening the interface with the ability to deal with all of those > would reduce the "efficiently implementable" goal for little real benefit. There are non-trivial uses of fork, yes. There are much less non-trivial uses of vfork as the latter already has quite a few problems with spooky actions otherwise. Supporting something like a double fork flag has very little impact on the complexity of the implementation and even less impact on the efficiency. We certainly are at the point where we can start analyzing the remaining blockers for (v)fork+exec users. > Another example is made obvious by the bug Martin committed a fix for > in the past few days ... the order of operations was incorrect in our > implementation. But that this problem can exist shows that there > are ordering issues - a process that wants to open files using its > current privs, then reset those before (perhaps) opening more files, > and then doing the exec() part cannot do that with posix_spawn(). > Again, this is rare enough that adding the complexity required to allow > it to work just isn't worth it. [In this area also note that the > POSIX_SPAWN_RESETIDS flag causes (effectively) setuid(getuid()), there's > no similar operation to do setuid(geteuid()) ... again too rare to bother.] I quite disagree here, actually. The design-level issue is that POSIX_SPAWN_RESETIDS is a flag and not an action. This means it can't be sequenced and that is the reason for the limitation. There is an obvious parallel with the semantics of the chdir action here--that needs to be that, an action and not just a flag. The separate concern is of course that we need more testing for posix_spawn, but that is hopefully also going to become better as side effect of the non-GSoC project. Joerg
vfork() and posix_spawn() [was: Re: CVS commit: src/lib/libc/sys]
Date:Sat, 12 Jun 2021 23:13:54 +0200 From:Joerg Sonnenberger Message-ID: Sorry, missed this message when I was cherry picking messages to read in a timely fashion. | On Wed, Jun 09, 2021 at 01:03:20AM +0700, Robert Elz wrote: | > after a vfork() the child can do anything | This is not true. After vfork(), it is only supposed to call async | signal safe functions. What you said, and what I said are not contradictory. Note I said "can do" and you said "is only supposed to". What is supposed to work and what actually does work (or can be made to work) are two different things. I would note though our man page doesn't make that requirement, or not that I can see anyway, and vfork() is not in POSIX of course - and while I don't have a copy to check, I'd suspect not in the C standards either), so while that sounds like a reasonable requirement to impose for safer operation, I'm not sure that anyone or anything actually does that. | That said, a flag for the double fork semantic might be useful. If the "that said" relates to fork() or vfork() not being async signal safe, so a double fork() (when the first is vfork anyway) would not be condoned, that doesn't matter, there to be an async-signal-safe _Fork() call added to the next version of POSIX, so even with the "only async signal safe" requirement for vfork() a: if ((child = vfork()) == 0) { if (_Fork())_exit(0); /* do child stuff here */ } else { if (child != -1) waitpid(child, , 0); /* parent continues */ } sequence is possible (will be possible, we don't have _Fork() yet) and fully conforming, apart from vfork() not being in the standard. The child of the vfork() only does _Fork() and _exit(), both of which are permitted. The grandchild process is created by a full fork() so can do anything at all. For what it is worth, the definition of _Fork() is (to be): The _Fork() function shall be equivalent to fork(), except that fork handlers established by means of the pthread_atfork() function shall not be called and _Fork() shall be async-signal-safe. Aside from the prototype line, which is just as you'd expect, that's it. If (or when) we add it, we probably need to decide whether we need _VFork() (or some similar name) as well. Probably. However, an extra posix_spawn attribute to handle double fork is almost certainly not warranted, this kind of thing isn't all that common, and adding the mechanism to the posix_spawn set of functions would really just be bloat (there's also a proposal floating around to add the ability to change a terminal's process group as a posix_spawn action -- that's required for shells to be able to use posix_spawn in general cases, but that most likely won't go anywhere). Remember what the standard says about posix_spawn() (in its rationale, this is not strictly part of the standard)... The posix_spawn( ) function and its close relation posix_spawnp( ) have been introduced to overcome the following perceived difficulties with fork( ): the fork( ) function is difficult or impossible to implement without swapping or dynamic address translation. [...] This view of the role of posix_spawn( ) and posix_spawnp( ) influenced the design of their API. It does not attempt to provide the full functionality of fork( )/exec in which arbitrary user-specified operations of any sort are permitted between the creation of the child process and the execution of the new process image; any attempt to reach that level would need to provide a programming language as parameters. [...] [ It lists some of the known problems with the posix_spawn interface ] [...] The posix_spawn( ) and posix_spawnp( ) functions do not have all the power of fork( )/exec. This is to be expected. The fork( ) function is a wonderfully powerful operation. We do not expect to duplicate its functionality in a simple, fast function with no special hardware requirements. It is worth noting that posix_spawn( ) and posix_spawnp( ) are very similar to the process creation operations on many operating systems that are not UNIX systems. It then goes on to list the requirements they had for posix_spawn()... The requirements for posix_spawn( ) and posix_spawnp( ) are: � They must be implementable without an MMU or unusual hardware. � They must be compatible with existing POSIX standards. Additional goals are: � They should be efficiently implementable. � They should be able to replace at least 50% of typical executions of fork( ). � A system with posix_spawn( ) and posix_spawnp( ) and without fork( ) should be useful, at least for realtime applications. � A
Re: CVS commit: src/lib/libc/sys
On Wed, Jun 09, 2021 at 01:03:20AM +0700, Robert Elz wrote: > It should, when it is workable for the application, make things > faster, while also avoiding the vfork() perils. But only when > it works -- after a vfork() the child can do anything (it should > avoid touching its parent's state, but it can) posix_spawn() isn't > nearly that general, it just handles the most common things apps > are likely to want to do between the fork() and exec(). This is not true. After vfork(), it is only supposed to call async signal safe functions. That said, a flag for the double fork semantic might be useful. Joerg
Re: CVS commit: src/lib/libc/sys
Date:Tue, 8 Jun 2021 16:15:12 + From:"Nia Alarie" Message-ID: <20210608161512.1d7c3f...@cvs.netbsd.org> | vfork.2: recommend posix_spawn instead You might want to reconsider the wording there, posix_spawn() is an alternative to [v]fork() + exec*(). Not just vfork(). It should, when it is workable for the application, make things faster, while also avoiding the vfork() perils. But only when it works -- after a vfork() the child can do anything (it should avoid touching its parent's state, but it can) posix_spawn() isn't nearly that general, it just handles the most common things apps are likely to want to do between the fork() and exec(). Perhaps most notably, it has no notion of (with err checking omitted): if (fork()) { parent_code(/* do a waitpid() first */); } else if (fork()) { exit(0); } else { child_code() /* often ending with execX() */ } when one wants to create an orphan (nothing that cannot be waited upon). kre
Re: CVS commit: src/lib
joerg> Just the libs should be enough and ideally, jk> It appears that we would need to add the 'elftoolchain' subdirectory to jk> "src/external/bsd/Makefile" for the global includes run to work. This should be fixed now. Regards, Joseph Koshy
Re: CVS commit: src/lib
On Thu, Apr 08, 2021 at 05:53:42PM +0100, Joseph Koshy wrote: > On Thu, Apr 08, 2021 at 01:51:30PM +0200, Joerg Sonnenberger wrote: > jk> Redo r1.288: traverse the complete imported Elftoolchain tree during > jk> a build. > > js> Just the libs should be enough and ideally, libelf and libdwarf > js> are folded into the main .WAIT groups. There is a global includes > js> run first. > > It appears that we would need to add the 'elftoolchain' subdirectory to > "src/external/bsd/Makefile" for the global includes run to work. > > Let me try that out - once I get it to work I will revert > 'src/lib/Makefile' to traverse just the imported libraries. Thanks! Joerg
Re: CVS commit: src/lib
On Thu, Apr 08, 2021 at 01:51:30PM +0200, Joerg Sonnenberger wrote: jk> Redo r1.288: traverse the complete imported Elftoolchain tree during jk> a build. js> Just the libs should be enough and ideally, libelf and libdwarf js> are folded into the main .WAIT groups. There is a global includes js> run first. It appears that we would need to add the 'elftoolchain' subdirectory to "src/external/bsd/Makefile" for the global includes run to work. Let me try that out - once I get it to work I will revert 'src/lib/Makefile' to traverse just the imported libraries. Regards, Joseph Koshy
Re: CVS commit: src/lib
On Thu, Apr 08, 2021 at 08:10:30AM +, Joseph Koshy wrote: > Module Name: src > Committed By: jkoshy > Date: Thu Apr 8 08:10:30 UTC 2021 > > Modified Files: > src/lib: Makefile > > Log Message: > Redo r1.288: traverse the complete imported Elftoolchain tree during a build. Just the libs should be enough and ideally, libelf and libdwarf are folded into the main .WAIT groups. There is a global includes run first. Joerg
Re: CVS commit: src/lib/libc/regex
In article <5c9e716-7ec1-9c7d-a7cb-21f08946...@invisible.ca>, Jared McNeill wrote: >Building tools on macOS: > >/Users/jmcneill/netbsd/git-src/tools/compat/../../lib/libc/regex/regcomp.c:1585:8: > >error: implicit declaration of function 'reallocarray' is invalid > in C99 [-Werror,-Wimplicit-function-declaration] > ncs = reallocarray(p->g->sets, p->g->ncsets + 1, sizeof(*ncs)); > ^ >/Users/jmcneill/netbsd/git-src/tools/compat/../../lib/libc/regex/regcomp.c:1585:8: > >note: did you mean 'reallocarr'? >/Users/jmcneill/netbsd/git-src/tools/compat/compat_defs.h:556:5: note: >'reallocarr' declared here >int reallocarr(void *, size_t, size_t); > ^ Fixed, thanks! christos
Re: CVS commit: src/lib/libc/regex
Building tools on macOS: /Users/jmcneill/netbsd/git-src/tools/compat/../../lib/libc/regex/regcomp.c:1585:8: error: implicit declaration of function 'reallocarray' is invalid in C99 [-Werror,-Wimplicit-function-declaration] ncs = reallocarray(p->g->sets, p->g->ncsets + 1, sizeof(*ncs)); ^ /Users/jmcneill/netbsd/git-src/tools/compat/../../lib/libc/regex/regcomp.c:1585:8: note: did you mean 'reallocarr'? /Users/jmcneill/netbsd/git-src/tools/compat/compat_defs.h:556:5: note: 'reallocarr' declared here int reallocarr(void *, size_t, size_t); ^ On Tue, 23 Feb 2021, Christos Zoulas wrote: Module Name:src Committed By: christos Date: Tue Feb 23 22:14:59 UTC 2021 Modified Files: src/lib/libc/regex: cname.h engine.c re_format.7 regcomp.c regerror.c regex.3 regex2.h regexec.c regfree.c utils.h Removed Files: src/lib/libc/regex: cclass.h Log Message: sync with FreeBSD: - NLS support - GNU extensions - bug fixes To generate a diff of this commit: cvs rdiff -u -r1.7 -r0 src/lib/libc/regex/cclass.h cvs rdiff -u -r1.7 -r1.8 src/lib/libc/regex/cname.h cvs rdiff -u -r1.24 -r1.25 src/lib/libc/regex/engine.c cvs rdiff -u -r1.12 -r1.13 src/lib/libc/regex/re_format.7 cvs rdiff -u -r1.38 -r1.39 src/lib/libc/regex/regcomp.c cvs rdiff -u -r1.23 -r1.24 src/lib/libc/regex/regerror.c cvs rdiff -u -r1.26 -r1.27 src/lib/libc/regex/regex.3 cvs rdiff -u -r1.13 -r1.14 src/lib/libc/regex/regex2.h cvs rdiff -u -r1.22 -r1.23 src/lib/libc/regex/regexec.c cvs rdiff -u -r1.15 -r1.16 src/lib/libc/regex/regfree.c cvs rdiff -u -r1.6 -r1.7 src/lib/libc/regex/utils.h 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/gen
On Wed, Feb 17, 2021 at 11:51:04PM +, David A. Holland wrote: > Also, Someone(TM) should check if POSIX permits this or if we ought to > improve the implementation. Unsurprisingly, POSIX is silent. It just says "rewinddir shall also cause the directory stream to refer to the current state of the corresponding directory, as a call to opendir() would have done," basically the same text we had previously. This could be read as _mandating_ reopening it, but that is almost certainly not what they intended, so I think we're ok. https://pubs.opengroup.org/onlinepubs/9699919799/functions/opendir.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/rewinddir.html -- David A. Holland dholl...@netbsd.org
Re: CVS commit: src/lib/libc/locale
On Mon, Feb 15, 2021 at 04:37:15PM +0100, Thomas Klausner wrote: > Hi! > > Thanks for the man pages. > > There is none for uselocale(3), which is heavily referenced from > these, nor do I find a prototype in /usr/include... > so how does one use these? :) We don't support uselocale. You use this functions by passing the locale_t to the *_l functions directly. Joerg
Re: CVS commit: src/lib/libc/locale
Hi! Thanks for the man pages. There is none for uselocale(3), which is heavily referenced from these, nor do I find a prototype in /usr/include... so how does one use these? :) Thomas On Mon, Feb 15, 2021 at 09:35:04AM -0500, Christos Zoulas wrote: > Module Name: src > Committed By: christos > Date: Mon Feb 15 14:35:04 UTC 2021 > > Modified Files: > src/lib/libc/locale: Makefile.inc > Added Files: > src/lib/libc/locale: duplocale.3 freelocale.3 newlocale.3 > > Log Message: > Add missing man pages (from FreeBSD) > > > To generate a diff of this commit: > cvs rdiff -u -r1.64 -r1.65 src/lib/libc/locale/Makefile.inc > cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/duplocale.3 \ > src/lib/libc/locale/freelocale.3 src/lib/libc/locale/newlocale.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/locale/Makefile.inc > diff -u src/lib/libc/locale/Makefile.inc:1.64 > src/lib/libc/locale/Makefile.inc:1.65 > --- src/lib/libc/locale/Makefile.inc:1.64 Sun Aug 18 16:03:48 2013 > +++ src/lib/libc/locale/Makefile.inc Mon Feb 15 09:35:04 2021 > @@ -1,5 +1,5 @@ > #from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91 > -#$NetBSD: Makefile.inc,v 1.64 2013/08/18 20:03:48 joerg Exp $ > +#$NetBSD: Makefile.inc,v 1.65 2021/02/15 14:35:04 christos Exp $ > > # locale sources > .PATH: ${ARCHDIR}/locale ${.CURDIR}/locale > @@ -21,7 +21,7 @@ CPPFLAGS.runetable.c+= -I${LIBCDIR}/cit > CPPFLAGS.multibyte_c90.c+= -I${LIBCDIR}/citrus > CPPFLAGS.multibyte_amd1.c+= -I${LIBCDIR}/citrus > > -MAN+=setlocale.3 nl_langinfo.3 > +MAN+=duplocale.3 freelocale.3 newlocale.3 setlocale.3 nl_langinfo.3 > > MAN+=mbtowc.3 mbstowcs.3 wctomb.3 wcstombs.3 mblen.3 \ > > > Added files: > > Index: src/lib/libc/locale/duplocale.3 > diff -u /dev/null src/lib/libc/locale/duplocale.3:1.1 > --- /dev/null Mon Feb 15 09:35:04 2021 > +++ src/lib/libc/locale/duplocale.3 Mon Feb 15 09:35:04 2021 > @@ -0,0 +1,80 @@ > +.\" $NetBSD: duplocale.3,v 1.1 2021/02/15 14:35:04 christos Exp $ > +.\" Copyright (c) 2011 The FreeBSD Foundation > +.\" All rights reserved. > +.\" > +.\" This documentation was written by David Chisnall under sponsorship from > +.\" the FreeBSD Foundation. > +.\" > +.\" Redistribution and use in source and binary forms, with or without > +.\" modification, are permitted provided that the following conditions > +.\" are met: > +.\" 1. Redistributions of source code must retain the above copyright > +.\"notice, this list of conditions and the following disclaimer. > +.\" 2. Redistributions in binary form must reproduce the above copyright > +.\"notice, this list of conditions and the following disclaimer in the > +.\"documentation and/or other materials provided with the distribution. > +.\" > +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > PURPOSE > +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > CONSEQUENTIAL > +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, > STRICT > +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > +.\" SUCH DAMAGE. > +.\" > +.\" $FreeBSD: head/lib/libc/locale/duplocale.3 281925 2015-04-24 10:17:55Z > theraven $ > +.\" > +.Dd September 17, 2011 > +.Dt DUPLOCALE 3 > +.Os > +.Sh NAME > +.Nm duplocale > +.Nd duplicate an locale > +.Sh LIBRARY > +.Lb libc > +.Sh SYNOPSIS > +.In locale.h > +.Ft locale_t > +.Fn duplocale "locale_t locale" > +.Sh DESCRIPTION > +Duplicates an existing > +.Fa locale_t > +returning a new > +.Fa locale_t > +that refers to the same locale values but has an independent internal state. > +Various functions, such as > +.Xr mblen 3 > +require a persistent state. > +These functions formerly used static variables and calls to them from > multiple > +threads had undefined behavior. > +They now use fields in the > +.Fa locale_t > +associated with the current thread by > +.Xr uselocale 3 . > +These calls are therefore only thread safe on threads with a unique > per-thread > +locale. > +The locale returned by this call must be freed with > +.Xr freelocale 3 . > +.Sh SEE ALSO > +.Xr freelocale 3 , > +.Xr localeconv 3 , > +.Xr newlocale 3 , > +.\" .Xr querylocale 3 , > +.Xr uselocale 3 , > +.\" .Xr xlocale 3 > +.Sh STANDARDS > +This function conforms to > +.St -p1003.1-2008 . > +.Sh BUGS > +Ideally, > +.Xr uselocale 3 > +should make a
Re: CVS commit: src/lib/libc/stdio
Date:Mon, 1 Feb 2021 17:50:54 + From:"Jaromir Dolecek" Message-ID: <20210201175054.112e7f...@cvs.netbsd.org> | FreeBSD has a similar check, but they return EINVAL instead, feel | free to adjust if SUS or other standard mandates specific value Not currently (unless the C standard says something) - but EINVAL would be a better choice, fread() incorporates all errors from fgetc() (and fwrite() from fputc()) and there EOVERFLOW is used to indicate that the file offset exceeds the maximum possible file size, which is quite a different problem. EINVAL is currently unused (at least in POSIX) but makes more sense for this problem (which is am invalid arg combination). FWIW, I submitted a defect report on this issue with the Austin Group (POSIX maintainers) yesterday, though I am expecting they'll simply punt it to the C standards group. kre
Re: CVS commit: src/lib/libc/stdio
Date:Sun, 31 Jan 2021 18:34:22 +0100 From:Joerg Sonnenberger Message-ID: | That makes no sense. Just turn them into a short read, which is | something users have to deal with anyway. I'm not sure I agree with that one. If the user's size * nmemb overflows a size_t then the user is attempting something entirely insane (they cannot possibly have a buffer that big). Reading anything at all is most probably the wrong thing to do, as the args are very likely simply erroneous. EINVAL is not an unreasonable approach, I wouldn't even object to simply abort(). kre
Re: CVS commit: src/lib/libc/stdio
On 31.01.2021 18:34, Joerg Sonnenberger wrote: > On Sun, Jan 31, 2021 at 05:27:28PM +0100, Kamil Rytarowski wrote: >> On 31.01.2021 17:18, Jaromir Dolecek wrote: >>> Module Name:src >>> Committed By: jdolecek >>> Date: Sun Jan 31 16:18:22 UTC 2021 >>> >>> Modified Files: >>> src/lib/libc/stdio: fread.c >>> >>> Log Message: >>> for unbuffered I/O arrange for the destination buffer to be filled in one >>> go, instead of triggering long series of 1 byte read(2)s; this speeds up >>> fread() several order of magnitudes for this case, directly proportional >>> to the size of the supplied buffer >>> >>> change adapted from OpenBSD rev. 1.19 >>> >>> fixes PR lib/55808 by Roland Illig >>> >> >> While there it would be cool to apply FreeBSD and OpenBSD hardening for >> invalid size x nmemb, checking for overflow. I propose to return EINVAL >> in such case. > > That makes no sense. Just turn them into a short read, which is > something users have to deal with anyway. > > Joerg > The purpose of this errno is to catch insage usage of API that in normal circumstances never makes sense. With overflows (that are fine), the error can be unnoticed. Both FreeBSD and OpenBSD found this behavior as useful.
Re: CVS commit: src/lib/libc/stdio
On Sun, Jan 31, 2021 at 05:27:28PM +0100, Kamil Rytarowski wrote: > On 31.01.2021 17:18, Jaromir Dolecek wrote: > > Module Name:src > > Committed By: jdolecek > > Date: Sun Jan 31 16:18:22 UTC 2021 > > > > Modified Files: > > src/lib/libc/stdio: fread.c > > > > Log Message: > > for unbuffered I/O arrange for the destination buffer to be filled in one > > go, instead of triggering long series of 1 byte read(2)s; this speeds up > > fread() several order of magnitudes for this case, directly proportional > > to the size of the supplied buffer > > > > change adapted from OpenBSD rev. 1.19 > > > > fixes PR lib/55808 by Roland Illig > > > > While there it would be cool to apply FreeBSD and OpenBSD hardening for > invalid size x nmemb, checking for overflow. I propose to return EINVAL > in such case. That makes no sense. Just turn them into a short read, which is something users have to deal with anyway. Joerg
Re: CVS commit: src/lib/libc/stdio
On 31.01.2021 17:18, Jaromir Dolecek wrote: > Module Name: src > Committed By: jdolecek > Date: Sun Jan 31 16:18:22 UTC 2021 > > Modified Files: > src/lib/libc/stdio: fread.c > > Log Message: > for unbuffered I/O arrange for the destination buffer to be filled in one > go, instead of triggering long series of 1 byte read(2)s; this speeds up > fread() several order of magnitudes for this case, directly proportional > to the size of the supplied buffer > > change adapted from OpenBSD rev. 1.19 > > fixes PR lib/55808 by Roland Illig > While there it would be cool to apply FreeBSD and OpenBSD hardening for invalid size x nmemb, checking for overflow. I propose to return EINVAL in such case. I planned to submit it a while ago for discussion.