Commit graph

10052 commits

Author SHA1 Message Date
R. Christian McDonald 6e5b1ff71e libc: enable initial-exec (IE) as default thread-local storage model on arm
As suggested by jrtc27@ in https://reviews.freebsd.org/D42415, this
patch enables IE as default thread-local storage model in libc on arm.

Reviewed by:	kib
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42445
2023-11-09 21:24:23 +01:00
Ed Maste 4e0e01bf65 fflush: correct buffer handling in __sflush
Two additional stdio changes followed 86a16ada1e and need to be
reverted as part of the fflush fix.

This reverts commit 6e13794fbe.
This reverts commit bafaa70b6f.

Fixes: d09a3bf72c ("fflush: correct buffer handling in __sflush")
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42491
2023-11-07 11:03:34 -05:00
Ed Maste 418f026bd5 libc: remove unused errno.h include
errno.h was added in 44cf1e5eb4, which has been reverted.

Fixes: d09a3bf72c ("fflush: correct buffer handling in __sflush")
Sponsored by: The FreeBSD Foundation
2023-11-07 10:23:20 -05:00
Dag-Erling Smørgrav b8dbfb0a6c fflush: Add test for buffer handling in __sflush
Sponsored by:	Klara, Inc.
2023-11-07 08:21:12 -05:00
Dag-Erling Smørgrav d09a3bf72c fflush: correct buffer handling in __sflush
This fixes CVE-2014-8611 correctly.

The commit that purported to fix CVE-2014-8611 (805288c2f0) only hid
it behind another bug.  Two later commits, 86a16ada1e and
44cf1e5eb4, attempted to address this new bug but mostly just confused
the issue.  This commit rolls back the three previous changes and fixes
CVE-2014-8611 correctly.

The key to understanding the bug (and the fix) is that `_w` has
different meanings for different stream modes.  If the stream is
unbuffered, it is always zero.  If the stream is fully buffered, it is
the amount of space remaining in the buffer (equal to the buffer size
when the buffer is empty and zero when the buffer is full).  If the
stream is line-buffered, it is a negative number reflecting the amount
of data in the buffer (zero when the buffer is empty and negative buffer
size when the buffer is full).

At the heart of `fflush()`, we call the stream's write function in a
loop, where `t` represents the return value from the last call and `n`
the amount of data that remains to be written.  When the write function
fails, we need to move the unwritten data to the top of the buffer
(unless nothing was written) and adjust `_p` (which points to the next
free location in the buffer) and `_w` accordingly.  These variables have
already been set to the values they should have after a successful
flush, so instead of adjusting them down to reflect what was written,
we're adjusting them up to reflect what remains.

The bug was that while `_p` was always adjusted, we only adjusted `_w`
if the stream was fully buffered.  The fix is to also adjust `_w` for
line-buffered streams.  Everything else is just noise.

Fixes: 805288c2f0
Fixes: 86a16ada1e
Fixes: 44cf1e5eb4
Sponsored by:	Klara, Inc.
2023-11-07 08:21:12 -05:00
Dag-Erling Smørgrav 1f90b4edff fflush: Split a temporary variable in two.
It is clearer to avoid reusing temporary variables for different
purposes.

Sponsored by:	Klara, Inc.
2023-11-03 13:38:12 -04:00
Warner Losh 559a218c9b libc: Purge unneeded cdefs.h
These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42385
2023-11-01 16:44:30 -06:00
Warner Losh 0527c9bdc7 ino64: Remove 'forward compat' code for this
Forward compatibility code was added for running newer ino64 binaries on
older kernels as a transition aide. Now that ino64 has been in the tree
6 years, this code is no longer useful and should have been removed long
ago.  Remove it now. Should be no user-visible changes at this point as
all the 'upgrade' scenarios it was intended for are long since past.

Also need to remove this stuff from rtld since the _foo versions
no longer exist.

Sponsored by:		Netflix
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D42382
2023-10-31 15:26:44 -06:00
Jessica Clarke 1c1f229e91 libc: Strip plentiful trailing whitespace from aarch64+arm makecontext.c 2023-10-28 02:45:06 +01:00
Warner Losh 314542de6d clock_gettime: Minor clarification
Add a note saying that the CLOCK_BOOTTIME is unrelated to FreeBSD's
kern.boottime sysctl. Make a minor tweak to markup.

Feedback from:		pauammu
Sponsored by:		Netflix
Differential Revsion:	https://reviews.freebsd.org/D36037
2023-10-27 11:20:28 -06:00
Warner Losh 5e50a0f39f strlcpy/strlcat: Remove references to snprintf
While strlcpy and snprintf are somewhat similar, there's big differences
between strlcat and snprintf which leads to confusion. Remove the
comparison, since it's ultimately not that useful: the snprintf man page
has similar language to strlcpy, so it doesn't provide a better
reference. The two implementations are otherwise unrelated.

Reviewed by:		bcr
Sponsored by:		Netflix
Differential Revision:  https://reviews.freebsd.org/D27228
2023-10-27 10:13:50 -06:00
Brooks Davis 4894205482 procctl.2: improve phrasing for ASLR disable
Reported by:	jrtc27
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D42364
2023-10-26 18:40:08 +01:00
Dag-Erling Smørgrav ca57a343e8 libc: More missing MLINKS.
Differential Revision:	https://reviews.freebsd.org/D42292
2023-10-20 12:29:40 +02:00
Dag-Erling Smørgrav dc41de36ab libc: Fix missing or misspelled MLINKS.
Differential Revision:	https://reviews.freebsd.org/D42192
2023-10-18 16:07:46 +02:00
Dag-Erling Smørgrav a66d27e22f memory(3): Mention more functions.
Differential Revision:	https://reviews.freebsd.org/D42191
2023-10-18 16:07:46 +02:00
Dag-Erling Smørgrav 64fc8a936c hesiod: Modernize.
Reviewed by:	zlei
Differential Revision:	https://reviews.freebsd.org/D42190
2023-10-18 16:05:55 +02:00
Robert Clausecker 5048c1b855 lib/libc/amd64/string: add timingsafe_memcmp() assembly implementation
Conceptually very similar to timingsafe_bcmp(), but with comparison
logic inspired by Elijah Stone's fancy memcmp. A baseline (SSE)
implementation was omitted this time as I was not able to get it to
perform adequately.  Best I got was 8% over the scalar version for
long inputs, but slower for short inputs.

Sponsored by:	The FreeBSD Foundation
Approved by:	security (cperciva)
Inspired by:	https://github.com/moon-chilled/fancy-memcmp
Differential Revision:	https://reviews.freebsd.org/D41696
2023-10-15 15:25:53 -04:00
Robert Clausecker 76c2b331bc lib/libc/amd64/string: add timingsafe_bcmp(3) scalar, baseline implementations
Very straightforward and similar to memcmp(3). The code has
been written to use only instructions specified as having
data operand independent timing by Intel.

Sponsored by:	The FreeBSD Foundation
Approved by:	security (cperciva)
Differential Revision:	https://reviews.freebsd.org/D41673
2023-10-15 15:19:04 -04:00
Ed Maste a5ed6a815e ptsname.3: accommodate upcoming POSIX Issue 8 ptsname_r
POSIX has accepted a proposal[1] to add glibc-compatible ptsname_r.  It
indicates an error by returning the error number, rather than returning
-1 and setting errno.  Update RETURN VALUES in ptsname_r's man page now
to encourage folks to test that the return value != 0 rather than == -1.

[1] https://www.austingroupbugs.net/bug_view_page.php?bug_id=508

Reported by:	Collin Funk
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42204
2023-10-13 22:10:21 -04:00
Ed Maste a572dfa1bf ktrace.2: correct kern.ktrace.genio_size sysctl name
The man page had `kern.ktrace.geniosize` but the sysctl node contains an
underscore.

PR:		274274
Reported by:	Ivan Rozhuk
Sponsored by:	The FreeBSD Foundation
2023-10-10 21:23:02 -04:00
Robert Clausecker c6cc06d465 lib/libc/tests/string: expand memcmp test to bcmp, timingsafe_{b,mem}cmp
The four functions more or less perform the same operation.
Reuse the same unit test with slight changes so we can cover
them all.  Constant-time operation is not verified for the
timingsafe_* functions.

Sponsored by:	The FreeBSD Foundation
Approved by:	ngie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41528
2023-10-02 15:25:31 -04:00
Robert Clausecker b166580681 lib/libc/tests/string/memcmp_test.c: extend test to support custom memcmp function
Extend the tests to permit loading an external memcmp function
and testing it over using the libc version. This was added by the
example of other tests in the test suite doing the same thing and
helped tremendously in development.

This change was originally part of D41442 but was taken out to
permit separate review as extrapolated from @ngie's request in
D41349.

Sponsored by:	FreeBSD Foundation
Approved by:	ngie
Differential Revision:	https://reviews.freebsd.org/D41528
2023-10-02 15:25:21 -04:00
Olivier Certner d952820105 ptrace(2): Disabling: Describe influence of security.bsd.see_jail_proc
Reviewed by:            mhorne, emaste, pauamma_gundo.com
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41109
2023-09-28 12:05:47 -03:00
Dag-Erling Smørgrav c7dd4601ae libc: Add a rudimentary test for quick_exit(3).
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41937
2023-09-26 22:07:10 +02:00
Dag-Erling Smørgrav 1dc3abb052 libc: Rewrite quick_exit() and at_quick_exit() using C11 atomics.
Compiler memory barriers do not prevent the CPU from executing the code
out of order.  Switch to C11 atomics.  This also lets us get rid of the
mutex; instead, loop until the compare_exchange succeeds.

While here, change the return value of at_quick_exit() on failure to
the more traditional -1, matching atexit().

Sponsored by:	Klara, Inc.
Reviewed by:	Olivier Certner, kevans, kib
Differential Revision:	https://reviews.freebsd.org/D41936
2023-09-26 22:07:10 +02:00
Jens Schweikhardt e8a7cee673 Add paragraph about kern.mqueue sysctls and their defaults. 2023-09-26 21:41:29 +02:00
Christos Zoulas 3fb80f1476 regcomp: use unsigned char when testing for escapes
- cast GETNEXT to unsigned where it is being promoted to int to prevent
  sign-extension (really it would have been better for PEEK*() and
  GETNEXT() to return unsigned char; this would have removed a ton of
  (uch) casts, but it is too intrusive for now).
- fix an isalpha that should have been iswalpha

PR:		264275, 274032
Reviewed by:	kevans, eugen (previous version)
Obtained from:	NetBSD
Differential Revision:	https://reviews.freebsd.org/D41947
2023-09-26 00:49:14 +02:00
John Baldwin eba230afba Purge more stray embedded $FreeBSD$ strings
These do not use __FBSDID but instead use bare char arrays.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41957
2023-09-25 07:54:56 -07:00
John Baldwin 16837d353c Remove a few more stray __FBSDID uses
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41954
2023-09-25 07:49:52 -07:00
Yuri Pankov 95a4709b2c Create namespace for the symbols added during 15-CURRENT cycle
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41935
2023-09-22 10:16:29 +02:00
Dag-Erling Smørgrav c34fce8a03 Fix typos in acl_get_entry(3) manual page.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41924
2023-09-22 09:43:19 +02:00
Dag-Erling Smørgrav b653faaa19 Remove mention of defunct mailing list from acl / mac man pages.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41923
2023-09-22 09:43:19 +02:00
Ed Maste b15f640037 swapon.2: correct FreeBSD release that introduced swapoff
It was introduced in 92da00bb24, after 5.0 and beforen 5.1.  Reported
in https://github.com/ziglang/zig/issues/16590.
2023-09-18 10:01:38 +01:00
Robert Clausecker 601fd768cf lib/libc/tests/string/strcspn_test.c: extend tests to catch previous bug
This extends the strcspn() unit tests to catch mistakes in the
implementation that only appear when a mismatch occurs in a certain
position of the string against a certain position of the set.

See also:	52d4a4d4e0
Sponsored by:	The FreeBSD Foundation
Approved by:	imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41821
2023-09-16 20:40:13 -04:00
Robert Clausecker 953b93cf24 lib/libc/amd64/string/memcmp.S: harden against phony buffer lengths
When memcmp(a, b, len) (or equally, bcmp) is called with a phony length
such that a + len < a, the code would malfunction and not compare the
two buffers correctly.  While such arguments are illegal (buffers do not
wrap around the end of the address space), it is neverthless conceivable
that people try things like memcmp(a, b, SIZE_MAX) to compare a and b
until the first mismatch, in the knowledge that such a mismatch exists,
expecting memcmp() to stop comparing somewhere around the mismatch.
While memcmp() is usually written to confirm to this assumption, no
version of ISO/IEC 9899 guarantees this behaviour (in contrast to
memchr() for which it is).

Neverthless it appears sensible to at least not grossly misbehave on
phony lengths.  This change hardens memcmp() against this case by
comparing at least until the end of the address space if a + len
overflows a 64 bit integer.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg (blanket, via IRC)
See also:	b2618b651b
MFC after:	1 week
2023-09-16 00:20:32 -04:00
Robert Clausecker 52d4a4d4e0 lib/libc/amd64/string/strcspn.S: fix behaviour with sets of 17--32
When a string is matched against a set of 17--32 characters, each chunk
of the string is matched first against the first 16 characters of the
set and then against the remaining characters.  We also check at the
same time if the string has a nul byte in the current chunk, terminating
the search if it does.

Due to misconceived logic, the order of checks was "first half of set,
nul byte, second half of set", meaning that a match with the second half
of the set was ignored when the string ended in the same 16 bytes.
Reverse the order of checks to fix this problem.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg (blanket, via IRC)
MFC after:	1 week
MFC to:		stable/14
2023-09-11 22:58:43 -04:00
Dag-Erling Smørgrav 88a9b6e1ed libc: Don't assume signed char.
MFC after:	3 days
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D41814
2023-09-11 13:18:25 +00:00
Robert Clausecker b2618b651b lib/libc/amd64/string/memchr.S: fix behaviour with overly long buffers
When memchr(buf, c, len) is called with a phony len (say, SIZE_MAX),
buf + len overflows and we have buf + len < buf.  This confuses the
implementation and makes it return incorrect results.  Neverthless we
must support this case as memchr() is guaranteed to work even with
phony buffer lengths, as long as a match is found before the buffer
actually ends.

Sponsored by:	The FreeBSD Foundation
Reported by:	yuri, des
Tested by:	des
Approved by:	mjg (blanket, via IRC)
MFC after:	1 week
MFC to:		stable/14
PR:		273652
2023-09-10 08:52:59 -04:00
Robert Clausecker 331737281c lib/libc/amd64/string: implement strnlen(3) trough memchr(3)
Now that we have an optimised memchr(3), we can use it to implement
strnlen(3) with better perofrmance.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41598
2023-09-08 17:22:31 -04:00
Robert Clausecker de12a689fa lib/libc/amd64/string: add memchr(3) scalar, baseline implementation
This is conceptually similar to strchr(3), but there are
slight changes to account for the buffer having an explicit
buffer length.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41598
2023-09-08 17:22:20 -04:00
Robert Clausecker 7084133cde lib/libc/amd64/string: add strspn(3) scalar, x86-64-v2 implementation
This is conceptually very similar to the strcspn(3) implementations
from D41557, but we can't do the fast paths the same way.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41567
2023-09-08 17:21:59 -04:00
Robert Clausecker 468adddd75 lib/libc/tests/string: derive strspn(3) tests from strcspn(3) tests
To cover the new optimised amd64 strspn(3) SIMD implementation, extend
the previously written strcspn(3) unit test to also cover strspn(3).

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41567
2023-09-08 17:21:59 -04:00
Robert Clausecker 35a5359406 lib/libc/tests/string: add unit tests for strcspn(3)
We currently use the NetBSD test suite to cover strcspn(3).  It only
contains a very rudimentary test of this function.  This all new set
of unit tests for the FreeBSD test suite should cover many more edge
cases relating to alignment issues.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision: https://reviews.freebsd.org/D41557
2023-09-08 17:21:31 -04:00
Robert Clausecker 474408bb79 lib/libc/amd64/string: add strcspn(3) scalar, x86-64-v2 implementation
This changeset adds both a scalar and an x86-64-v2 implementation
of the strcspn(3) function to libc. A baseline implementation does not
appear to be feasible given the requirements of the function.

The scalar implementation is similar to the generic libc implementation,
but expands the bit set into a byte set to reduce latency, improving
performance. This approach could probably be backported to the generic
C version to benefit other platforms.

The x86-64-v2 implementation is built around the infamous pcmpistri
instruction. An alternative implementation based on the Muła/Langdale
algorithm [1] was prototyped, but performed worse than the pcmpistri
approach except for sets of more than 16 characters with long input
strings.

All implementations provide special cases for the empty set (reduces to
strlen as well as single-character sets (reduces to strchr). The
x86-64-v2 kernel falls back to the scalar implementation for sets of
more than 32 characters. This limit could be raised by additional
multiples of 16 through the use of additional pcmpistri code paths, but
I consider this case to be too rare to be of importance.

[1]: http://0x80.pl/articles/simd-byte-lookup.html

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41557
2023-09-08 17:20:19 -04:00
Li-Wen Hsu 604f6bf022
powerpcspe: Fix build
Copy _fpmath.h from powerpc, which is the same as the one in powerpc64.

Sponsored by:	The FreeBSD Foundation
2023-09-09 04:46:25 +08:00
Dag-Erling Smørgrav 12b1c1e3fb libc: Add test cases for N2680.
This adds test cases for %wN and %wfN to the printf(3) and scanf(3) tests.

While here, fix a few nits in the N2630 test cases.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D41743
2023-09-07 06:40:14 +00:00
Dag-Erling Smørgrav bce0bef3c6 libc: Implement N2680.
This adds specific width length modifiers in the form of wN and wfN (where N is 8, 16, 32, or 64) which allow printing intN_t and int_fastN_t without resorting to casts or PRI macros.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41725
2023-09-07 06:40:14 +00:00
Dag-Erling Smørgrav 294bd2827e libc: Suppress format checks on printf() / scanf() tests.
Reviewed by:	jrtc27, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D41727
2023-09-07 06:40:14 +00:00
Dag-Erling Smørgrav 4ec9ee9912 libc: Add a wide version of snprintf_test.
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41726
2023-09-07 06:40:14 +00:00
Warner Losh b19d8afe4d msun: LIBCSRCDIR is too fragile, use ${SRCTOP}/lib/libc instead
LIBCSRCDIR is defined in bsd.libnames.mk, which is read in later in the
Makefile than the line:

.if exists(${LIBCSRCDIR}/${MACHINE_ARCH})

so we test to see if /${MARCHIN_ARCH} exists which it usually doesn't
(but did for me since I mounted 13.2R SD image there).  Move to defining
our own LIBC_SRCTOP in terms of SRCTOP to treat these uniformily.

Sponsored by:		Netflix
Reviewed by:		sjg
Differential Revision:	https://reviews.freebsd.org/D41661
2023-09-05 16:08:02 -06:00
Mateusz Piotrowski 5b7a776f48 getdirentries.2: Reference dir(5)
As a note, parts of manual pages getdirentries(2) and dir(5) should
probably be consolidated.

MFC after:	3 days
2023-09-05 15:50:45 +02:00
Mateusz Piotrowski 52d374a067 getdirentries.2: Improve readability of dirent members
MFC after:	3 days
2023-09-05 15:50:45 +02:00
Robert Clausecker d41afb8146 */string.3,arch.7,environ.7: add cross-references to simd(7)
With the new simd-dispatch framework documented in simd(7),
add cross-references to the new man pages to appropriate places.

Sponsored by:	The FreeBSD Foundation
Approved by:	emaste
MFC to:		stable/14
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D41697
2023-09-05 09:33:12 -04:00
Mateusz Piotrowski 3a02df5e27 getdirentries.2: Reference directory(3)
MFC after:	3 days
2023-09-05 11:39:39 +02:00
Dag-Erling Smørgrav c9f5889d05 libc: Further nit in fopen(3) man page.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41687
2023-09-01 22:53:35 +00:00
Trond Endrestøl b7000cadfb scandir.3: Fix several typos
PR:		273480
Reviewed by:	markj
MFC after:	1 week
2023-09-01 16:57:03 -04:00
Dag-Erling Smørgrav 5a57401e71 libc: Fix fmemopen(3) prototype in fopen(3) man page.
While here, also update a mention of ANSI C.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans, markj
Differential Revision:	https://reviews.freebsd.org/D41686
2023-09-01 20:56:26 +00:00
Brooks Davis 09e32b2fdd libc: add LIBC_MALLOC option
This will enable alternative mallocs to be included in the tree and
selected by setting LIBC_MALLOC.  As there is only one today (jemalloc)
this option does nothing, but we expect to add other implementations
in the future.  This will also reduce diffs to CheriBSD.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D41660
2023-09-01 17:54:23 +01:00
Mina Galić 09ec5e67a7 libc: fix history for strverscmp(3) and versionsort(3)
strverscmp(3) and versionsort(3) where first released in 13.2

PR:		273401
Reviewed by:	kib
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41617
2023-08-31 14:52:31 +03:00
Dag-Erling Smørgrav aca3bd1602 libc: Fix fixed-width case in the new integer parser.
Fixes:		d9dc1603d6
Differential Revision:	https://reviews.freebsd.org/D41622
2023-08-28 23:38:19 +00:00
Li-Wen Hsu e0752f431b
Revert "libc/locale tests: temporarily skip lib.libc.locale.c16rtomb_test.c16rtomb_utf_8_test"
This reverts commit b80572fe3b.

This has been fixed in e2030ca246.

PR:		265871
2023-08-29 01:18:42 +08:00
Dag-Erling Smørgrav 76edfabbec libc: Document support for binary integers.
Reviewed by:	debdrup, emaste
Differential Revision:	https://reviews.freebsd.org/D41522
2023-08-28 15:34:17 +00:00
Dag-Erling Smørgrav b9385720f3 libc: Add unit tests for N2630 and possible collateral damage.
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41512
2023-08-28 15:34:05 +00:00
Dag-Erling Smørgrav d9dc1603d6 libc: Implement N2630.
This adds formatted input/output of binary integer numbers to the printf(), scanf(), and strtol() families, including their wide-character counterparts.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41511
2023-08-28 15:33:51 +00:00
Robert Clausecker 3d8ef251aa lib/libc/amd64/string/strchrnul.S: fix edge case in scalar code
When the buffer is immediately preceeded by the character we
are looking for and begins with one higher than that character,
and the buffer is misaligned, a match was errorneously detected
in the first character.  Fix this by changing the way we prevent
matches before the buffer from being detected: instead of
removing the corresponding bit from the 0x80..80 mask, set the
LSB of bytes before the buffer after xoring with the character we
look for.

The bug only affects amd64 with ARCHLEVEL=scalar (cf. simd(7)).
The change comes at a 2% performance impact for short strings
if ARCHLEVEL is set to scalar.  The default configuration is not
affected.

os: FreeBSD
arch: amd64
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
        │ strchrnul.scalar.0.out │       strchrnul.scalar.2.out       │
        │         sec/op         │   sec/op     vs base               │
Short                57.89µ ± 2%   59.08µ ± 1%  +2.07% (p=0.030 n=20)
Mid                  19.24µ ± 0%   19.73µ ± 0%  +2.53% (p=0.000 n=20)
Long                 11.03µ ± 0%   11.03µ ± 0%       ~ (p=0.547 n=20)
geomean              23.07µ        23.43µ       +1.53%

        │ strchrnul.scalar.0.out │       strchrnul.scalar.2.out        │
        │          B/s           │     B/s       vs base               │
Short               2.011Gi ± 2%   1.970Gi ± 1%  -2.02% (p=0.030 n=20)
Mid                 6.049Gi ± 0%   5.900Gi ± 0%  -2.47% (p=0.000 n=20)
Long                10.56Gi ± 0%   10.56Gi ± 0%       ~ (p=0.547 n=20)
geomean             5.045Gi        4.969Gi       -1.50%

MFC to:		stable/14
MFC after:	3 days
Approved by:	mjg (blanket, via IRC)
Sponsored by:	The FreeBSD Foundation
2023-08-25 21:21:54 +02:00
Dag-Erling Smørgrav 9b5d724cad libc: Add timespec_getres(3) as per C23.
This also adds support for TIME_MONOTONIC to timespec_get(3).

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D41524
2023-08-24 21:31:54 +00:00
Dag-Erling Smørgrav b8b6bef43f libc: Fix parsing of hexadecimal numbers in strtol() family.
This had previously been partly fixed in 2571c7f720.

MFC after:	1 week
Reviewed by:	imp, allanjude, emaste
Differential Revision:	https://reviews.freebsd.org/D41510
2023-08-24 21:31:54 +00:00
Jake Freeland 8544651dc5 timerfd: Add manual page.
This manual page accompanies the timerfd system calls.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D40218
2023-08-24 14:29:06 -06:00
Jake Freeland af93fea710 timerfd: Move implementation from linux compat to sys/kern
Move the timerfd impelemntation from linux compat code to sys/kern. Use
it to implement the new system calls for timerfd. Add a hook to kern_tc
to allow timerfd to know when the system time has stepped. Add kqueue
support to timerfd. Adjust a few names to be less Linux centric.

RelNotes: YES
Reviewed by: markj (on irc), imp, kib (with reservations), jhb (slack)
Differential Revision: https://reviews.freebsd.org/D38459
2023-08-24 14:28:56 -06:00
Kyle Evans 939199a2b5 libc: iconv: zero out cv_shared on allocation
Right now we have to zero-initialize most fields in the varius callers,
but this is a little error prone.  Simplify it by zeroing it out upon
allocation instead, drop the other redundant initialization.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D41546
2023-08-22 22:40:45 -05:00
Kyle Evans e2030ca246 libc: fix c*rtomb/mbrtoc*
In 693f88c9da ("iconv_std: complete the //IGNORE support"), we
more completely implemented //IGNORE, which changed the semantics of
ci_discard_ilseq. DISCARD_ILSEQ semantics are supposed to match
//IGNORE, so we really can't do much about that particular
incompatibility.  This broke c*rtomb and mbrtoc* handling of invalid
sequences, but it turns out they don't want DISCARD_ILSEQ semantics at
all; they really want the subset that we call
_CITRUS_ICONV_F_HIDE_INVALID.

This restores the exact flow in iconv_std to precisely how it happened
prior to 693f88c9da.

PR:	265871
Fixes:	693f88c9da ("iconv_std: complete the //IGNORE support")
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D41513
2023-08-22 22:40:45 -05:00
Konstantin Belousov 4a69fc16a5 Add membarrier(2)
This is an attempt at clean-room implementation of the Linux'
membarrier(2) syscall.  For documentation, you would need to read
both membarrier(2) Linux man page, the comments in Linux
kernel/sched/membarrier.c implementation and possibly look at
actual uses.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32360
2023-08-23 03:02:21 +03:00
David E. O'Brien 4d004ccce2 Document strnstr()'s history. 2023-08-21 23:40:46 -07:00
Robert Clausecker 8803f01e93 lib/libc/amd64/string/memcmp.S: add baseline implementation
This changeset adds a baseline implementation of memcmp and bcmp
for amd64. The same code is used for both functions with conditional
code were the behaviour differs (we need more precise output for the
memcmp case).

FreeBSD documents that memcmp returns the difference between the
mismatching characters. Slightly faster code would be possible could
we relax this requirement to the ISO/IEC 9899:1999 requirement of
merely returning a negative/positive integer or zero.

Performance is better than bionic and glibc, except for long strings
were the two are 13% faster. This could be because they use SSE4
ptest which we cannot use in a baseline kernel.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
Differential Revision:	https://reviews.freebsd.org/D41442
2023-08-21 21:19:46 +02:00
Robert Clausecker 9fbea87028 lib/libc/amd64/string/stpcpy.S: add baseline implementation
This commit adds a baseline implementation of stpcpy(3) for amd64.
It performs quite well in comparison to the previous scalar implementation
as well as agains bionic and glibc (though glibc is faster for very long
strings).  Fiddle with the Makefile to also have strcpy(3) call into the
optimised stpcpy(3) code, fixing an oversight from D9841.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp ngie emaste
Approved by:	mjg kib
Fixes:		D9841
Differential Revision:	https://reviews.freebsd.org/D41349
2023-08-21 20:59:38 +02:00
Konstantin Belousov 89e17c6ea0 libc/gen/_pthread_stubs.c: Remove stray whitespaces
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-08-21 01:44:18 +03:00
Minsoo Choo 0dc52b7210 libc: export pthread_getname_np stub
pthread_getname_np needs to be provided by libc in order to import
jemalloc 5.3.0.

A stub implementation for libc pthread_getname_np() is added for
_pthread_stubs.c, which always reports empty name for the main thread.

Internal _pthread_getname_np() is not exported, but provided for libc
own use.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41461
2023-08-21 01:44:17 +03:00
John Baldwin ece58eaf50 Restore blank line after #include 2023-08-17 11:32:32 -07:00
Brooks Davis c5f49ece16 libc: regoranize malloc build
Create a stdlib/malloc to hold the definition of the malloc interface
(e.g., the Symbol.map file) and make jemalloc a subdirectory.  This will
make it easier to integrate alternative allocators such as snmalloc
while making it clear that the current jemalloc symbols are the FreeBSD
API/ABI (for better or worse).

Suggested by:	jrtc27
Reviewed by:	jrtc27, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D41457
2023-08-16 19:16:51 +01:00
Brooks Davis 075c716558 jemalloc: drop unused .PATH
All jemalloc sources are in contrib so don't look for them in the
jemalloc subdirectory.

Reviewed by:	jrtc27, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D41481
2023-08-16 19:16:43 +01:00
Brooks Davis 4c757938e4 libc: include malloc via stdlib/Makefile.inc
There's a hierarchy here and we should use it.

Improves: cbeacb7c46

Reviewed by:	jrtc27, jhb, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D41456
2023-08-16 19:16:26 +01:00
Warner Losh 401ab69cff Remove $FreeBSD$: one-line ps tag
Remove /^%\s*RCSID:\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:39 -06:00
Warner Losh ae992a336e Remove $FreeBSD$: one-line catalog
Remove /^\s*\$\s*\$FreeBSD\$$\n/
2023-08-16 11:55:26 -06:00
Warner Losh 05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh b1cfcffa89 Remove $FreeBSD$: one-line .S pattern
Remove /^\s\.(asciz|ident)\s+\"\$FreeBSD\$\".*\n/
2023-08-16 11:54:57 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Warner Losh c251557621 glob.h: Remove $FreeBSD$
This likely documented where this file was copied, but the $FreeBSD$
tag was lost as soon as it was committed. Just remove it. Also remove
the one that looked like it was intended to track versions. That will
simplify the MFC.

Sponsored by:		Netflix
2023-08-16 01:46:21 -06:00
Warner Losh be6151e43c mpool: Remove $FreeBSD$ comment
Remove non-standard $FreeBSD$ comment. It's not useful

Sponsored by:		Netflix
2023-08-16 01:37:16 -06:00
Dmitry Chagin f3e11927dc vm: Allow MAP_32BIT for all architectures
Reviewed by:		alc, kib, markj
Differential revision:	https://reviews.freebsd.org/D41435
2023-08-14 20:20:20 +03:00
Michal Meloun e59b6e48f4 gdtoa: Regenerate configuration headers for 32-bit arm.
These configuration headers were only guessed, but unfortunately not exactly
correctly. Therefore, re-generate them on real HW.

Generated on CA15, verified on CA9, CA7(with VFP lite) and on 32-bit ARMv9.

PR:	272229
Reported by:	Robert Clausecker <fuz@FreeBSD.org>
MFC after:	2 weeks
2023-08-13 09:35:48 +02:00
Konstantin Belousov 41acfee690 libc vdso time functions: correctly convert errors into errnos
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-08-13 01:34:08 +03:00
Konstantin Belousov 21a52f9944 libc dlfcn.c: make dl_iterate_phdr() from libc more useful
Apparently there are applications that resolve dl_iterate_phdr from libc
and try to call the symbol. Our libc only provides stubs for dl* to
satisfy static linker or statically linked binaries, and is not prepared
to this situation.

Add a code to dso libc to find real dl_iterate_phdr and redirect the
call to it.

Reported by:	yuri
PR:	272992
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-08-09 08:07:05 +03:00
Robert Clausecker d7302cabc0 lib/libc/amd64/string/strchrnul.S: fix wrong indentation
Uses spaces instead of tabs for this line by accident.

Reported by:	jrtc27, kib
Approved by:	kib
2023-08-07 14:03:28 +02:00
Robert Clausecker 61f4c4d3dd lib/libc/amd64/string: add strchrnul implementations (scalar, baseline)
A lot better than the generic (pre) implementaion.  We do not beat glibc
for long strings, likely due to glibc switching to AVX once the input is
sufficiently long.  X86-64-v3 and v4 implementations may be added at a
future time.

os: FreeBSD
arch: amd64
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
        │ strchrnul_pre.out │         strchrnul_scalar.out         │       strchrnul_baseline.out        │
        │      sec/op       │    sec/op     vs base                │   sec/op     vs base                │
Short          129.68µ ± 3%    59.91µ ± 1%  -53.80% (p=0.000 n=20)   44.37µ ± 1%  -65.79% (p=0.000 n=20)
Mid             21.15µ ± 0%    19.30µ ± 0%   -8.76% (p=0.000 n=20)   12.30µ ± 0%  -41.85% (p=0.000 n=20)
Long           13.772µ ± 0%   11.028µ ± 0%  -19.92% (p=0.000 n=20)   3.285µ ± 0%  -76.15% (p=0.000 n=20)
geomean         33.55µ         23.36µ       -30.37%                  12.15µ       -63.80%

        │ strchrnul_pre.out │          strchrnul_scalar.out          │         strchrnul_baseline.out         │
        │        B/s        │      B/s       vs base                 │      B/s       vs base                 │
Short          919.3Mi ± 3%   1989.7Mi ± 1%  +116.45% (p=0.000 n=20)   2686.8Mi ± 1%  +192.28% (p=0.000 n=20)
Mid            5.505Gi ± 0%    6.033Gi ± 0%    +9.60% (p=0.000 n=20)    9.466Gi ± 0%   +71.97% (p=0.000 n=20)
Long           8.453Gi ± 0%   10.557Gi ± 0%   +24.88% (p=0.000 n=20)   35.441Gi ± 0%  +319.26% (p=0.000 n=20)
geomean        3.470Gi         4.983Gi        +43.62%                   9.584Gi       +176.22%

For comparison, glibc on the same machine:

        │ strchrnul_glibc.out │
        │       sec/op        │
Short             49.73µ ± 0%
Mid               14.60µ ± 0%
Long              1.237µ ± 0%
geomean           9.646µ

        │ strchrnul_glibc.out │
        │         B/s         │
Short            2.341Gi ± 0%
Mid              7.976Gi ± 0%
Long             94.14Gi ± 0%
geomean          12.07Gi

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
Differential Revision: https://reviews.freebsd.org/D41333
2023-08-06 15:58:27 +02:00
Ed Maste dedc71fd38 libc: unsplit log message to to make it greppable in src
Also use __func__ rather than hardcoding the function name.  This code
now fits in 80 columns without splitting the log message.

Reviewed by:	zlei
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39619
2023-08-04 20:59:30 -04:00
Robert Clausecker d8385768fb lib/libc/amd64/string/strlen.S: add amd64 baseline kernel
This performs very well.  x86-64-v3 and x86-64-v4 kernels were written,
too, but performed worse than the baseline kernel on short strings.
These may be added at a future point in time if the performance issues
can be fixed.

os: FreeBSD
arch: amd64
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
        │ strlen_scalar.out │          strlen_baseline.out          │
        │        B/s        │     B/s       vs base                 │
Short          1.667Gi ± 1%   2.676Gi ± 1%   +60.55% (p=0.000 n=20)
Mid            5.459Gi ± 1%   8.756Gi ± 1%   +60.39% (p=0.000 n=20)
Long           15.34Gi ± 0%   52.27Gi ± 0%  +240.64% (p=0.000 n=20)
geomean        5.188Gi        10.70Gi       +106.24%

Sponsored by:	The FreeBSD Foundation
Approved by:	kib
Reviewed by:	mjg jrtc27
Differential Revision:	https://reviews.freebsd.org/D40693
2023-08-04 01:54:23 +03:00
Robert Clausecker ad2fac552c lib/libc/amd64: add archlevel-based simd dispatch framework
Add a framework for selecting from one of multiple implementations
of a function based on amd64 architecture level (cf. amd64 SysV
ABI supplement).

Sponsored by:	The FreeBSD Foundation
Approved by:	kib
Reviewed by:	jrtc27
Differential Revision:	https://reviews.freebsd.org/D40693
2023-08-04 01:53:43 +03:00
Ed Maste 89c762c815 inet.3: remove mention of VAX endianness
Machine endianness is not very important in understanding the inet*
functions; the endianness of the VAX is especially so.

PR:		272728
Sponsored by:	The FreeBSD Foundation
2023-08-01 13:23:42 -04:00
Dmitry Chagin 03eab865aa man: Link _Fork(2) man page
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D41221
MFC after:		1 week
2023-07-28 11:54:20 +03:00
Andrew Turner 835927fd8e arm: Remove swi.h
It has been unneeded since moving to the Arm EABI

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41136
2023-07-24 17:58:14 +01:00
Dmitry Chagin 241a55b461 libc/csu: Do not compile the finalizer() for PIC build
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D41148
2023-07-22 11:56:06 +03:00
Kyle Evans b744861818 libc: locale: flesh out an incomplete comment
Extrapolate from the context what the intention for the rest of the
comment probably was -- that the C/POSIX (and now C.UTF-8) locales may
avoid an allocation and reuse a global table.

Reviewed by:	bapt
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D41087
2023-07-20 23:27:24 -05:00
Robert Clausecker 4da7282a18 lib/libc/string/bcmp.c: fix integer overflow bug
bcmp() returned the number of remaining bytes when the main loop exits.
In case of a match, this is zero, else a positive integer.  On systems
where SIZE_MAX > INT_MAX, the implicit conversion from size_t to int in
the return value may cause the number of remaining bytes to overflow,
becoming zero and falsely indicating a successful comparison.

Fix the bug by always returning 0 on equality, 1 otherwise.

PR:		272474
Approved by:	emaste
Reviewed by:	imp
MFC After:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41011
2023-07-16 20:36:17 +03:00
Robert Clausecker 3f5788e0ed lib/libc/string/ffs*.c: work around gcc warning
Gcc warns of infinite recursion if we use __builtin_ffs*() to
implement ffs*().  This is because gcc uses ffs() to implement
these on some platforms.  Sidestep the warning by using
__builtin_ctz*() for these.

Sponsored by:	FreeBSD Foundation
Reported by:	jlduran@gmail.com, jhb
Fixes:		ee8b0c43 (D40730)
Reviewed by:	jhb, mhorne
Approved by:	jhb
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D40966
2023-07-14 22:26:43 +02:00
Jessica Clarke 0fbb77c3ef libc: Build all i386 sources for amd64 lib32
Having the symbols exported by libc differ between i386 and amd64 lib32
is questionable. Since these files build just fine today, stop guarding
them with !defined(COMPAT_32BIT). Whether or not they work at run time
is a different matter, but an i386 jail would be similarly affected if
not, so that's not a problem with lib32.

Reviewed by:	kib, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D40937
2023-07-09 18:46:03 +01:00
Jens Schweikhardt 7a949a0f1c Correct grammo. 2023-07-08 14:25:44 +02:00
Dmitry Chagin acfd261524 libc: Improve setjmp comments
Reviewed by:		imp, kib
Differential Revision:	https://reviews.freebsd.org/D40879
2023-07-06 20:21:54 +03:00
Robert Clausecker ee8b0c436d lib/libc/string: replace ffs/fls implementations with clang builtins
Most architectures we support (except for riscv64) have instructions
to compute these functions very quickly.  Replace old code with the
ffs and clz builtin functions, allowing clang to generate good code
for all architectures.

As a consequence, toss out arm and i386 ffs() implementations.

Sponsored by:	FreeBSD Foundation
Approved by:	mhorne
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D40730
2023-07-03 22:18:27 +02:00
Robert Clausecker 49390697b9 lib/libc/tests/string: add unit tests for ffs, ffsl, ffsll, fls, flsl, and flsll
Also supply CFLAGS+=-fno-builtin to ensure our unit tests
actually test libc functions and not clang's builtins.

Sponsored by:	FreeBSD Foundation
Approved by:	kevans
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D40729
2023-07-03 22:18:27 +02:00
Eugene Grosbein 5aee3e14d4 syslog.3: document ident[N] format
When libc switched to generation of logs as per RFC 5424,
that change broke application ability to insert specific process id
using ident[N] format, the feature existed for decades.
Some processes rely on it (including logger and syslogd).

Later the regression was fixed but the feature remained undocumented.
This change documents it.

MFC after:	1 week
2023-07-03 19:46:40 +07:00
Yuri Pankov 24ec316c13 Correctly spell illumos (all lowercase) in man pages
From illumos FAQ:

    "illumos (pronounced i-llu-MOS and written in lowercase)"
2023-06-29 13:14:45 +02:00
Piotr Kubaj fd774e065c gdtoa: fix endianness issue on powerpc64le
The current code assumes running on big-endian, which causes issues with
e.g. strtod() as reported on https://github.com/ocaml/ocaml/pull/10837#issuecomment-1605346422
This is probably a leftover from when powerpc64le was introduced.

Approved by:	jhibbits (on IRC)
2023-06-29 01:45:50 +02:00
Konstantin Belousov 42ceab3ea1 libc.a: implement _rtld_addr_phdr()
to make __cxa_thread_call_dtors() operational for statically linked
binaries.

Noted by:	andrew
Reviewed by:	emaste, dim
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40748
2023-06-25 21:27:25 +03:00
Gordon Bergling 8f79b07564 nameser: Fix a typo in a source code comment
-s /unknwon/unknown/

MFC after:	3 days
2023-06-19 13:49:23 +02:00
Kyle Evans 0e96337b11 acl_is_trivial_np(3): minor fixes
- Correct the document title
- This function has an _np suffix
- acl_strip_np has a manpage, xref it
- RETURN VALUES should describe acl_is_trivial_np, not acl_get_tag_type

Sponsored by:	Klara, Inc.
2023-06-19 00:47:04 -05:00
Gordon Bergling 85604f7008 xdr(3): Fix a typo in a source code comment
- s/curren/current/

MFC after: 3 days
2023-06-17 10:49:40 +02:00
David E. O'Brien 2a3493b93b Correct man page URI formatting.
Don't format URL's embedding a ',' where one doesn't exist; so that
one may copy-n-paste the displayed URL into a browser.
2023-06-09 20:49:51 -07:00
Konstantin Belousov 1fc174cba6 open(2): fix typo
__aLC_aclcheck_fd -> acl_aclcheck_fd

Reported by:	Peter Eriksson  <pen@lysator.liu.se>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-05-30 12:18:25 +03:00
Konstantin Belousov 7a292504ba __acl_get_fd(2), __acl_aclcheck_fd(2): enable for O_PATH filedescriptors
PR:	271704
Reported by:	Peter Eriksson  <pen@lysator.liu.se>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40318
2023-05-30 08:53:56 +03:00
Kyle Evans e15da6b10a libc: locale: fix collation file size validation
At a minimum, we need enough for the colllation format version string +
locale definition version string and a full collate_info definition,
rather than just the first two and a pointer.

Sponsored by:	Klara, Inc.
2023-05-28 12:54:24 -05:00
Peter Wemm e829181c65
libc: Update copyright text to match current templates. 2023-05-18 11:30:10 -07:00
Warner Losh b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Kyle Evans 20c61a7c51 acl(3): improve discoverability of acl_get_perm_np(3)
- Mention it in acl(3) as an available function, xref
- Mention it in acl_get_permset(3), as acl_get_perm_np(3) is a natural
    follow-up to acl_get_permset(3)

Sponsored by:	Klara, Inc.
2023-05-08 22:45:12 -05:00
Mariusz Zaborski 95950880ad libc: document when the namespace was created
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39989
2023-05-07 11:45:13 +02:00
Ed Maste 5f2e84015d bsd.lib.mk: decouple lib*_pic.a from TOOLCHAIN build knob
A user may use a tool chain from a package or just use an existing
tool chain from a previous installation.  There is no reason for this
to disable the installation of lib${LIB}_pic.a.

This also means we don't need to force MK_TOOLCHAIN=yes in lib/libc.

This reverts part of commit c0f5aeb032.

Reviewed by:	jrtc27
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39917
2023-05-01 16:46:39 -04:00
Tom Hukins 9c353fa4a9 libc: Fix a documentation spelling mistake
Pull Request:	https://github.com/freebsd/freebsd-src/pull/704
2023-05-01 10:30:15 -04:00
Eugene Grosbein 4824d78872 listen(2): improve administrator control over logging
As documented in listen.2 manual page, the kernel emits a LOG_DEBUG
syslog message if a socket listen queue overflows. For some appliances,
it may be desirable to change the priority to some higher value
like LOG_INFO while keeping other debugging suppressed.

OTOH there are cases when such overflows are normal and expected.
Then it may be desirable to suppress overflow logging altogether,
so that dmesg buffer is not flooded over long run.

In addition to existing sysctl kern.ipc.sooverinterval,
introduce new sysctl kern.ipc.sooverprio that defaults to 7 (LOG_DEBUG)
to preserve current behavior. It may be changed to any value
in a range of 0..7 for corresponding priority or to -1 to suppress logging.
Document it in the listen.2 manual page.

MFC after:	1 month
2023-05-01 03:26:44 +07:00
Dag-Erling Smørgrav 6f3c2f41b1 tzcode: Clean up the ctime(3) manual page.
MFC after:	3 weeks
Sponsored by:	Klara, Inc.
Reviewed by:	pauamma_gundo.com
Differential Revision:	https://reviews.freebsd.org/D39714
2023-04-26 11:46:41 +02:00
Dag-Erling Smørgrav 75411d1572 Update tzcode to 2023c.
MFC after:      3 weeks
Sponsored by:   Klara, Inc.
Reviewed by:    philip
Differential Revision:  https://reviews.freebsd.org/D39712
2023-04-26 11:46:21 +02:00
John Baldwin 47e888f836 Remove a few more references to riscv64sf.
Fixes:		1ca12bd927 Remove the riscv64sf architecture.
2023-04-20 11:00:46 -07:00
Hans Petter Selasky bb8e8e230d Revert "libc: Implement bsort(3) a bitonic type of sorting algorithm."
Some points for the future:
 - libc is not the right place for sorting algorithms.
   Probably libutil is better suited for this purpose or
   a dedicated libsort. Should move all sorting algorithms
   away from libc eventually.
 - CheriBSD uses capabilities for memory access, and could
   benefit from a standard memswap() function.
 - Do something about qsort() in FreeBSD's libc like:
   - Mark it deprecated on FreeBSD, as a first step,
     due to missing limits on CPU time.
   - Audit the use of qsort() in the FreeBSD base system
     and consider swapping to other existing sorting
     algorithms.

Discussed with:	brooks@

Differential Revision:	https://reviews.freebsd.org/D36493

This reverts commit a7469c9c0a.
This reverts commit 7d65a450cd.
This reverts commit 8dcf3a82c5.
2023-04-20 19:16:14 +02:00
Hans Petter Selasky ecb2ce3a51 libc: Sorting is not needed when there are less than two elements
If there are less than two elements avoid executing the first
sorting loop. No functional change intended.

Reviewed by:	kib@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
Differential Revision:	https://reviews.freebsd.org/D39691
2023-04-19 17:17:33 +02:00
Hans Petter Selasky 27bb0d337c libc: Add missing object size check to qsort_s(3)
When sorting, both the C11 standard (ISO/IEC 9899:2011, K.3.6.3.2) and
the ISO/IEC JTC1 SC22 WG14 N1172 standard, does not define objects of
zero size as undefined behaviour. However Microsoft's cpp-docs does.

Add proper checks for this. Found while working on bsort(3).

Reviewed by:	kib@ and emaste@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
Differential Revision:	https://reviews.freebsd.org/D39687
2023-04-19 15:35:14 +02:00
Hans Petter Selasky 7d65a450cd bsort.3: Fix warnings as reported by mandoc -W warning
Reported by:	Yuri <yuri@aetern.org>
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2023-04-19 15:34:00 +02:00
Hans Petter Selasky 8dcf3a82c5 libc: Implement bsort(3) a bitonic type of sorting algorithm.
The bsort(3) algorithm works by swapping objects, similarly to qsort(3),
and does not require any significant amount of additional memory.

The bsort(3) algorithm doesn't suffer from the processing time issues
known the plague the qsort(3) family of algorithms, and is bounded by
a complexity of O(log2(N) * log2(N) * N), where N is the number of
elements in the sorting array. The additional complexity compared to
mergesort(3) is a fair tradeoff in situations where no memory may
be allocated.

The bsort(3) APIs are identical to those of qsort(3), allowing for
easy drop-in and testing.

The design of the bsort(3) algorithm allows for future parallell CPU
execution when sorting arrays. The current version of the bsort(3)
algorithm is single threaded. This is possible because fixed areas
of the sorting data is compared at a time, and can easily be divided
among different CPU's to sort large arrays faster.

Reviewed by:	gbe@, delphij@, pauamma_gundo.com (manpages)
Sponsored by:	NVIDIA Networking
Differential Revision:	https://reviews.freebsd.org/D36493
2023-04-19 14:04:22 +02:00
Konstantin Belousov 93ca6ff295 umtx: allow to configure minimal timeout (in nanoseconds)
PR:	270785
Reviewed by:	markj, mav
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39584
2023-04-19 02:22:28 +03:00
Val Packett 77f0e198d9 procctl: add state flags to PROC_REAP_GETPIDS reports
For a process supervisor using the reaper API to track process subtrees,
it is very useful to know the state of the processes on the list.

Sponsored by:   https://www.patreon.com/valpackett
Reviewed by:    kib
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D39585
2023-04-16 13:48:20 +03:00
Konstantin Belousov dcc19c6701 pkru.3: fix markup
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-04-15 02:53:59 +03:00
Konstantin Belousov 54579376c0 Change kqueue1() to be compatible with NetBSD
by making it accept some open(2) flags.  More precisely, only
O_CLOEXEC is supported, the flag is translated into the KQUEUE_CLOEXEC flag
for kqueuex(2), and O_NONBLOCK is silently ignored.

Reported and tested by:	vishwin
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39377
2023-04-05 06:29:49 +03:00
Ed Maste 20c9c3be5a kqueue: add close() calls to man page example
There is no real need to close descriptors before a process exits, but
these close calls demonstrate by example that kqueue descriptors occupy
the same namespace as other file descriptors.

Reviewed by:	fernape, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39376
2023-04-04 09:29:53 -04:00
Konstantin Belousov dac3102488 Rename kqueue1(2) to kqueuex(2) to avoid compat issues with NetBSD
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39377
2023-04-04 16:19:08 +03:00
Ed Maste d860991a72 kqueue: tidy up indentation in man page example
Fixes: e07b0c12ba ("[patch][doc] Fix EXAMPLE in kqueue(2)")
Sponsored by:	The FreeBSD Foundation
2023-03-31 14:48:39 -04:00
Ed Maste 30da840c62 memmem: add a note about other systems which have memmem
memmem started as a GNU extension but is now widely available.

Reviewed by:	mhorne (slightly earlier version)
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39337
2023-03-30 12:14:26 -04:00
Stefan Eßer 9d33a9d96f Fix typo in statfs man page
There are FAT12 and FAT16 file systems, but FAT13 of was an
unintentional invention of mine ...

Reported by:	Ravi Pokala <rpokala@freebsd.org>
MFC after:	1 month
2023-03-29 10:11:19 +02:00
Stefan Eßer c33db74b53 fs/msdosfs: add tracking of free root directory entries
This update implements tallying of free directory entries during
create, delete,	or rename operations on FAT12 and FAT16 file systems.

Prior to this change, the total number of root directory entries
was reported as number of inodes, but 0 as the number of free
inodes, causing system health monitoring software to warn about
a suspected disk full issue.

The FAT12 and FAT16 file systems provide a limited number of
root directory entries, e.g. 512 on typical hard disk formats.
The valid range of values is 1 to 65535, but the msdosfs code
will effectively round up "odd" values to the next multiple of 16
(e.g. 513 would allow for 528 root directory entries).

This update implements tracking of directory entries during create,
delete, or rename operations, with initial values determined by
scanning the directory when the file system is mounted.

Total and free directory entries are reported in the f_files and
f_ffree elements of struct statfs, despite differences in semantics
of these values:

- There is no limit on the number of files and directories that can
  be created on a FAT file system. Only the root directory of FAT12
  and FAT16 file systems is limited, any number of files can still be
  created in sub-directories, even when 0 free "inodes" are reported.

- A single file can require 1 to 21 directory entries, depending on
  the character set, structure, and length of the name. The DOS 8.3
  style file name takes up 1 entry, and if the name does not comply
  with the syntax of a DOS 8.3 file name, 1 additional entry is used
  for each 13 characters of the file name. Since all these entries
  have to be contiguous, it is possible that a file or directory with
  a long name can not be created, despite a sufficient total number of
  free directory entries.

- Renaming a file can require more directory entries than currently
  allocated to store its long name, which may prevent an in-place
  update of the name if more entries are needed. This may cause a
  rename operation to fail if no contiguous range of free entries for
  the new name can be found.

- The volume label is stored in a directory entry. An empty FAT file
  system with a volume label will therefore show 1 used "inode" in
  df.

- The perceentage of free inodes shown in df or monitoring tools does
  only represent the state of the root directory of a FAT12 or FAT16
  file system. Neither does a reported value of 0% free inodes does
  prevent files from being created in sub-directories, nor does a
  value of 50% free inodes guarantee that even a single file with
  a "long" name can be created in the root directory (if every other
  directory entry is occupied and there are no 2 contiguous entries).

The statfs(2) and df(1) man pages have been updated with a notice
regarding the possibly different semantics of values reported as
total and free inodes for non-Unix file systems.

PR:		270053
Reported by:	Ben Woods <woodsb02@freebsd.org>
Approved by:	mckusick
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D38987
2023-03-29 08:46:01 +02:00
Yuri Pankov 269dea90d6 libc: use separate collate objects for C, POSIX, and C.UTF-8
Fix newlocale() overwriting the locale name in collate object
when same instance was used for those locales, and querylocale()
reporting unexpected value for LC_COLLATE_MASK.

PR:		255646, 269375
Reviewed by:	markj, bapt (previous version)
Differential Revision:	https://reviews.freebsd.org/D30146
2023-03-28 17:16:30 +02:00
Konstantin Belousov f2ec444be5 kqueue1(2): document
Reviewed by:	emaste, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39271
2023-03-28 02:39:26 +03:00
Konstantin Belousov 375732cc6e kqueue1(2): export the symbol from libc
Reviewed by:	emaste, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39271
2023-03-28 02:39:26 +03:00
Mark Johnston 68ca8363c7 libc: Use secure_getenv(3) where appropriate
No functional change intended.

Reviewed by:	mjg, imp, kib
Differential Revision:	https://reviews.freebsd.org/D39278
2023-03-27 08:56:22 -04:00
Warner Losh d5df268584 secure_getenv: Improve documentation wording
Improve the documentation wording to be more consistent with FreeBSD
manual pages.

Suggested by:		mjg (though reworded)
Sponsored by:		Netflix
2023-03-25 11:06:13 -06:00
Warner Losh 72f501d07a secure_getenv: Add () around return values
Style only change, no functional change intended.

Sponsored by:		Netflix
2023-03-25 11:06:13 -06:00
Val Packett f9c7fb7cae arpa: garbage collect ns_newmsg/ns_rdata decls
These were brought in by the libbind import, but these functions were
never actually implemented anywhere, only header declarations and symbol
map entries were imported.

Fixes: 046c3635cd ("Bring final version of libbind:")
Fixes: e45764721a ("Update our stub resolver to final version of ...")
Reported by:	ld.lld 16 being --no-undefined-version by default
Sponsored by:	https://www.patreon.com/valpackett
Reviewed by:	emaste
Pull request:	https://github.com/freebsd/freebsd-src/pull/700
Differential Revision: https://reviews.freebsd.org/D38407
2023-03-22 14:58:23 -04:00
Mitchell Horne d55c187738 kern_reboot(9): some updates
- This function no longer disables interrupts
 - MLINK to reboot.9
 - The mentions of autoconfiguration is more about shutdown_nice(),
   coming in the next commit.
 - Describe the RB_* flags relevant to this function
 - Describe behaviour when shutdown hooks fail the reset
 - Describe expected execution contexts
 - Add FF copyright
 - xref panic(9)
 - xref this page in reboot(2)

Reviewed by:	markj
Discussed with:	rpokala, Pau Amma <pauamma@gundo.com>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39133
2023-03-20 17:12:12 -03:00
Mateusz Guzik 62a573d953 vfs: retire KERN_VNODE
It got disabled in 2003:

commit acb18acfec
Author: Poul-Henning Kamp <phk@FreeBSD.org>
Date:   Sun Feb 23 18:09:05 2003 +0000

    Bracket the kern.vnode sysctl in #ifdef notyet because it results
    in massive locking issues on diskless systems.

    It is also not clear that this sysctl is non-dangerous in its
    requirements for locked down memory on large RAM systems.

There does not seem to be practical use for it and the disabled routine
does not work anyway.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39127
2023-03-17 16:21:45 +00:00
Mateusz Guzik ba5070ab44 libc/yp: sort out warnings
.. in least-effort manner

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-16 18:56:47 +00:00
lucy adeca21464 Add GNU glibc compatible secure_getenv
Add mostly glibc and msl compatible secure_getenv. Return NULL if
issetugid() indicates the process is tainted, otherwise getenv(x).  The
rational behind this is the fact that many Linux applications use this
function instead of getenv() as it's widely consider a, "best
practice".

Reviewed by: imp, mjg (feedback)
Pull Request: https://github.com/freebsd/freebsd-src/pull/686
Signed-off-by: Lucy Marsh <seafork@disroot.org>
2023-03-13 22:19:24 -06:00
David E. O'Brien 47d0f36c3c Document gethostbyname_r's public exposure in 6.2. 2023-03-12 18:43:05 -07:00
Konstantin Belousov c383f4857f lib/csu: do not compile the body of handle_static_init() for PIC build at all
The referenced symbols that provide init array boundaries are weak,
hidden, and undefined.  The code that iterates over that arrays is not
used for the case when libc is compiled as dso.

This should fix linking with ld.bfd.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
2023-03-12 23:47:41 +02:00
Konstantin Belousov 94e3409e2d libc/csu: add powerpcspe
Reported and tested by:	alfredo
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
2023-03-12 23:47:41 +02:00
Konstantin Belousov c5c9d980c4 libc/csu: rename ignore_init.c to libc_start1.c
The current name was a historical curiosity that started when init array
support was added, and then the file appeared a convenient place for the
addition of the MI common code to csu.  It is now referenced by name in
single place and the rename is easy, so do it.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
2023-03-12 00:56:46 +02:00
Konstantin Belousov 0c6f0c0db7 libc: move declaration of 'char **environ' to common private header
Suggested by:	imp
Reviewed by:	markj
Tested by:	markj (aarch64)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D37220
2023-03-12 00:50:04 +02:00
Konstantin Belousov 0303938539 x86: microoptimize static PIE startup
Do not call CPUID on each ireloc, instead call it once and cache
results, similar to how it is done on powerpc64.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D37220
2023-03-12 00:50:04 +02:00
Konstantin Belousov 51015e6d0f csu: move common code to libc
Why? Most trivial point, it shaves around 600 bytes from the dynamic
binaries on amd64. Less trivial, the removed code is no longer part of
the ABI, and we can ship updates to it with libc updates. Right now most
of the csu is linked into the binaries and require us to do somewhat
tricky ABI compat when it needs to change. For instance, the init_array
change would be much simpler and does not require note tagging if we
have init calling code in libc.

This could be improved more, by splitting dynamic and static
initialization. For instance, &_DYNAMIC tests can be removed then.
Such change, nonetheless, would require building libc three times.
I left this for later, after this change stabilizes, if ever.

Reviewed by:	markj
Discussed with:	jrtc27 (some objections, see the review), imp
Tested by:	markj (aarch64)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
Differential revision:	https://reviews.freebsd.org/D37220
2023-03-12 00:50:03 +02:00
Mark Johnston e1ccf64b88 netbsd-tests: Serialize message queue tests
They can fail when run in parallel since they all share a global queue
key.

MFC after:	1 week
2023-03-10 17:07:06 -05:00
Xin LI 75798f9b01 cap_*(2): Document ENOSYS behavior.
Summary:
All cap_* system calls would fail when capability mode support is
not present.

MFC after:	2 weeks
Reviewed by:	emaste, pauamma
Differential Revision: https://reviews.freebsd.org/D38976
2023-03-09 18:10:50 -08:00
Dag-Erling Smørgrav a9a38dea37 libc: Remove prototype and documentation for tzsetwall().
PR:		269445
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D38481
2023-03-07 17:20:49 +00:00
Val Packett c7a8502bdf open.2: describe O_RESOLVE_BENEATH errors correctly
The behavior is the same as in capability mode, it does not actually
return EINVAL for absolute lookups:

    openat(AT_FDCWD,"/tmp/test",O_RDONLY|O_DIRECTORY,00) = 3 (0x3)
    openat(3,"../../",O_RDONLY|0x800000,00)          ERR#93 'Capabilities insufficient'
    openat(3,"/etc/passwd",O_RDONLY|0x800000,00)     ERR#93 'Capabilities insufficient'

Fixes:          1f305be43 ("Document {O,AT}_RESOLVE_BENEATH...")
Reviewed by:    kib, pauamma (manpages), emaste
Sponsored by:   https://www.patreon.com/valpackett
Pull Request:	https://github.com/freebsd/freebsd-src/pull/680
Differential Revision: https://reviews.freebsd.org/D38675
2023-03-02 15:58:00 -05:00
Val Packett 939b24b0ab xlocale: garbage collect references to strtoq_l/strtouq_l
These were explicitly never implemented (see
lib/libc/locale/DESIGN.xlocale), but were referenced in the
manpage and the symbol map.

Fixes:          3c87aa1d3d ("Implement xlocale APIs from Darwin")
Reported by:    ld.lld 16 being --no-undefined-version by default
Reviewed by:    theraven, emaste
Sponsored by:   https://www.patreon.com/valpackett
Pull Request:	https://github.com/freebsd/freebsd-src/pull/679
Differential Revision: https://reviews.freebsd.org/D38408
2023-03-02 15:53:29 -05:00
Ihor Antonov 6e9b4e3e0d man 3 daemon: remove double negation
Rephrase double negated sentences to improve readability
OpenBSD has done the same in the past to their man 3 daemon

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/671
2023-02-27 08:40:08 -07:00
Gordon Bergling 211ceb62e8 inet6_opt_init.3: Some enhancements
- Be consistent with RFC references, so add a space after 'RFC'
- Add a LIBRARY section
- Use standard integer types in the SYNOPSIS section

Obtained from:	DragonflyBSD
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D27548
2023-02-25 14:11:27 +01:00
Paul Floyd 2c709ee70a libc: handle zero alignment in memalign()
For compatibility with glibc. The previous code would trigger a division
by zero in roundup() and terminate.  Instead, just pass through to
malloc() for align == 0.

PR:		269688
Reviewed by:	imp, mjg
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/655
2023-02-24 13:19:06 -05:00
Kyle Evans 4e696aff69 iconvlist(3): fix count argument type
count is just an unsigned int, not a pointer.

Sponsored by:	Klara, Inc.
2023-02-23 15:22:12 -06:00
Warner Losh 5f044c4e05 profil(2): profil(II) was in the v3 sources
profil(II) is in the scanned 3rd edition manual that we have. We don't
have the 3rd edition sources, nor do we have the 4th edition souces. We
have a mostly complete (missing pipes) 4th edition C rewrite where
profil system call number is reserved, but it's not implemented (it's in
the manx section for things that apeared to have been in 3rd edition but
weren't yet part of the reimplemented 4th edition). The 5th edition
sources we have do have it, however. For other items that have appeared
in earlier manuals, we've added the simple verbage to the manual and
relegated the rest of the data for that file to the commit message.
2023-02-15 12:44:32 -07:00
Dmitry Chagin cbc32e4c5e cpuset: Add compat shim to the sched_affinity functions
To allow to run a newer world on a pre-1400079 kernel a compat shims to
the sched_affinity functions has beed added.

Reported by:		antoine
Tested by:		antoine
Reviewed by:		kib
Differential revision:	https://reviews.freebsd.org/D38555
MFC after:		3 days
2023-02-15 12:23:15 +03:00
Konstantin Belousov 5942b4b6fd sys/param.h: Add _WANT_P_OSREL
Use it instead of defining IN_RTLD by base sources that want P_OSREL_
defines in userspace, but are not rtld.
This allows to remove abuse of IN_RTLD from userspace.

Reviewed by:	dchagin, markj, imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38585
2023-02-15 02:43:18 +02:00
Warner Losh ae902a5be9 libc: Simplify soft-float on 32-bit arm
Simplify the tests for 32-bit arm soft float support. For the files
included only on arm, drop the test entirely. For others, test
MACHINE_CPUARCH against arm.

No functional change intended. File lists appear the same before / after
the change.

Sponsored by:		Netflix
Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D38582
2023-02-14 09:53:08 -07:00
Warner Losh 09c4c1e836 prof: Remove sysctl docs for sysctls that are now gone.
GRPOF based kernel profiling was removed in aa3ea612be. However, the
docs for the sysctls were not. Remove them belatedly.

Sponsored by:		Netflix
2023-02-13 08:18:50 -07:00
Kyle Evans f123c6c425 libc: popen: slightly simplify cloexec logic
No need to check the mode again here; we know that `iop` wraps the
correct fd.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D37987
2023-02-13 00:33:57 -06:00
Kyle Evans d646513e57 getopt_long(3): note an inconsistency with getopt(3) in BUGS
getopt_long(3) will not allow an `optind` setting of 0 to be bug-for-bug
compatible with the GNU implementation, as some software does rely on
it.  Document it as a BUG, since it affects previous declarations of
compatibility with getopt(3).

Reviewed by:	pauamma (markup)
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37867
2023-02-10 23:32:50 -06:00
Kyle Evans f44df7959a libc: ssp: remove some GCC 4.2 remnants
With GCC 4.2 out of the tree for a while now and no sign of it
returning, we don't really need to support older versions that don't
allow us to specify a ctor priority anymore.

Noticed by:	mjg
2023-02-09 22:11:54 -06:00
Dag-Erling Smørgrav 71e0c8906e tzcode: Resurrect tzsetwall(3) with a deprecation warning.
This function has been around since 4.4BSD but was dropped upstream in 2020.  This went unnoticed when tzcode was updated.  Bring it back, but prepare for removing it before 14.0 is released.

PR:		269445
MFC after:	3 days
Reported by:	val@packett.cool
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D38445
2023-02-09 19:35:34 +01:00
Kyle Evans d4ecf62f12 libc: base64: trim some bogus trailing whitespace
No functional change, just a style fix.

Sponsored by:	Klara, Inc.
2023-02-08 00:39:25 -06:00
Alfonso 70164d957e Fix truncation when ssize_t is larger than MAX_INT
Casting to int truncates size on some platforms, resulting swab not
copying all the data. Cast len to size_t to avoid right shifting a
signed value: we know here it's > 0, so we can safely cast it w/o losing
precision.

In addition, be more careful with signedness of char pointers and
temporaries. Downgrade tmp from unsigned long to unsigned char since
we're only reading and writing characters.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/516
2023-02-04 21:14:14 -07:00
Mark Johnston 5f03f96fbe shm: Document shm_create_largepage()
While here, move notes about FreeBSD-specific functionality to the
COMPATIBILITY section, and document the ECAPMODE error for shm_open().

Reviewed by:	pauamma, kib
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D38282
2023-02-03 11:48:25 -05:00
Mark Johnston 26d105199e libc: Fall back to rdtsc when using pvclock and rdtscp is not available
In preparation for a follow-up revision wherein kvmclock may export
timekeeping info to userspace even in the absence of AMDID_RDTSCP, fall
back to using rdtsc when rdtscp isn't available.  This mimics
pvclock_read_time_info() in the kernel.

Reviewed by:	kib
Tested by:	Shrikanth R Kamath <kshrikanth@juniper.net>
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D38341
2023-02-03 11:47:11 -05:00
Dag-Erling Smørgrav 606d0e4a9a libc: Add tests for strchrnul(3).
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D38286
2023-02-02 15:45:45 +01:00
Warner Losh f051d72314 hyperv: Build and install where supported
Remove the hard-coded dependency on HYPERV being only x86. Instead, 100%
rely on MK_HYPERV. It's always right (since it's marked BROKEN (so set
to "no") on architectures we don't support).

Sponsored by:		Netflix
Reviewed by:		bz
Differential Revision:	https://reviews.freebsd.org/D38306
2023-02-01 10:21:57 -07:00
Dmitry Chagin c21b080f3d cpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux.
Under Linux to sched_[g|s]etaffinity() functions the value returned from a call
to gettid(2) (thread id) can be passed in the argument pid. Specifying pid as 0
will set the attribute for the calling thread, and passing the value returned
from a call to getpid(2) (process id) will set the attribute for the main thread
of the thread group.

Native cpuset(2) family of system calls has "which" argument to determine how
the value of id argument is interpreted, i.e., CPU_WHICH_TID is used to pass
a thread id and CPU_WHICH_PID - to pass a process id.

For now native sched_[g|s]etaffinity() implementation is wrong as uses "which"
CPU_WHICH_PID to pass both (process and thread id) to the kernel. To fix this
adding a new "which" CPU_WHICH_TIDPID intended to handle both id's.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D38209
MFC after:		1 week
2023-01-29 16:17:33 +03:00
Alexander Naumochkin 0311fe403d devname(3): apply S_ISBLK() to type, not dev_t
PR:	269190
Reviewed by:	kib
MFC after:	1 week
2023-01-28 20:04:35 +02:00
Jose Luis Duran f5924ad8fd strfmon(3): Match the return type
Reviewed by:	kib
MFC after:	1 week
2023-01-25 11:02:55 +02:00
Jose Luis Duran 59cc636d94 strfmon(3): Wording improvements
Use the same terminology as the other `_l` xlocale(3) functions.

Reviewed by:	kib
MFC after:	1 week
2023-01-25 11:02:55 +02:00
Jose Luis Duran cdd9d92dad strfmon(3): Add an EXAMPLES section
Reviewed by:	kib
MFC after:	1 week
2023-01-25 11:02:55 +02:00
Alexander V. Chernikov b0286ee504 man: add Netlink reference to socket(2)
Reviewed by:	lwhsu, pauamma, gbe
Differential Revision: https://reviews.freebsd.org/D38054
2023-01-15 11:27:43 +00:00
Brooks Davis a872c37054 xdr: store chars consistently
Cast char's through unsigned char before storing as an integer in
xdr_char(), this ensures that the encoded form is consistently not
sign-extended following Open Solaris's example.

Prior to this change, platforms with signed chars would sign extend
values with the high bit set but ones with unsigned chars would not
so 0xff would be stored as 0x000000ff on unsigned char platforms and
0xffffffff on signed char platforms.  Decoding has the same
result for either form so this is a largely cosmetic change, but it
seems best to produce consistent output.

For more discussion, see https://github.com/openzfs/zfs/issues/14173

Reviewed by:	mav, imp
Differential Revision:	https://reviews.freebsd.org/D37992
2023-01-12 18:16:17 +00:00
Dag-Erling Smørgrav 394cf6719a tzcode: Move configuration into separate header.
MFC after:	1 week
Sponsored by:	Klara, Inc.
2023-01-11 11:39:12 +01:00
Dag-Erling Smørgrav bc42155199 Bring our tzcode up to date.
* Replay 2010[acflm] which had been merged but not recorded.
* Merge 2010n.
* Reorganize (unsplit) the code to match the upstream layout.
* Merge 2022[cdefg].

MFC after:      1 week
Sponsored by:   Klara, Inc.
2023-01-10 16:14:27 +01:00
Gleb Popov 016e46fd86 libc: Fix build with WITHOUT_MACHDEP_OPTIMIZATIONS=YES set.
Test Plan: `make buildword WITHOUT_MACHDEP_OPTIMIZATIONS=YES` on 14-CURRENT and 13-STABLE

Reviewed by: emaste

Differential Revision: https://reviews.freebsd.org/D38017

PR:		266900
2023-01-10 17:00:41 +03:00
Jessica Clarke 9fb118bebc libc: Fix longjmp/_longjmp(buf, 0) for AArch64 and RISC-V
These architectures fail to handle this special case, and will cause the
corresponding setjmp/_setjmp to return 0 rather than 1. Fix this and add
regression tests (also committed upstream).

PR:		268684
Reviewed by:	arichardson, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29363
2023-01-09 18:34:43 +00:00
Val Packett 0b4531511e copyright: chase my name and email change
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37945
2023-01-06 15:28:42 -05:00
Eugene Grosbein 2ce3ef5503 syslog: fix PID of forking process
Do not cache PID for a process that does not fabricate it,
calls openlog() before forking and does not call exec() thereafter.

PR:		268666
Fixes:		e9ae9fa937
Tested by:	kp
MFC after:	3 days
2023-01-03 15:58:36 +07:00
Eugene Grosbein 6ab555cff6 syslog(3): expand a commentary adding a reference to RFC 3164. 2023-01-01 15:28:42 +07:00
Konstantin Belousov a98613f238 ptrace(2): document PT_SC_REMOTE
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:42 +02:00
Konstantin Belousov 0e07241c37 ptrace(2): explain how to select specific thread to operate on
Requested by:	emaste
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:35 +02:00
Jose Luis Duran 77e4249319 xlocale(3): Link man pages
- provide various missing MLINKS for library functions
- update various SEE ALSO section to include the
  new linked manual pages
- add various definitions of new functions like isideogram_l(3)
- document COMPATIBILITY for some functions
- bump man page dates

Reviewed by:	gbe, bcr
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/621
Differential Revision:	https://reviews.freebsd.org/D37203
2022-12-19 05:54:52 +01:00
John Baldwin 120eff994a ptrace.2: Fix warnings from igor.
Reviewed by:	pauamma, imp
Differential Revision:	https://reviews.freebsd.org/D37689
2022-12-15 11:26:57 -08:00
Piotr Kubaj 85dd853236 Revert "uname: switch machine to HW_MACHINE_ARCH"
Reverting because of issue in Makefile.inc1 during native builds:
make[1]: “.../freebsd/Makefile.inc1" line 163: Unknown target aarch64:aarch64.

Since I only tested this patch with make universe on amd64, this issue wasn't caught.

This reverts commit 83bf6ab568.
2022-12-12 15:42:05 +01:00
Piotr Kubaj 83bf6ab568 uname: switch machine to HW_MACHINE_ARCH
On powerpc64, powerpc64le and riscv64 some software wrongly assumes that
it runs on powerpc or riscv (32-bit).

Differential revision:	https://reviews.freebsd.org/D35962
Approved by:	alfredo, imp
2022-12-11 13:05:39 +01:00
Gordon Bergling 0393604aa8 getservent.3: Mention the service.db
- reference /var/db/services.db
- reference services_mkdb(8)

Obtained from:	NetBSD
MFC after:	3 days
2022-12-07 10:26:13 +01:00
Alan Somers 34120c0c52 [skip ci] document first appearance of fhlink et al
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D37575
2022-11-30 14:57:56 -07:00
Guilherme Janczak a6d40b0ad2 libc: remove unneeded sys/types.h include from several synopses
PR:	268028
Reviewed by:	kib
Discussed with:	imp
MFC after:	1 week
2022-11-30 00:45:07 +02:00
Konstantin Belousov ae507c25de amd64 libc: add missed GNU-stack annotation to memmove/memcpy
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-11-18 15:31:38 +02:00
Rick Macklem 032b04626b rpcb_clnt.c: Do not force use of UDP
Without this patch, the code in the rpcbind client forces
the use of UDP.  A comment notes that some rpcbind servers
only support UDP.  This makes NFSv3 mounts to Azure servers
impossible, since they require use of TCP for rpcbind.
Since the comment is very old (imported from NetBSD in 2001)
and I do not believe any UDP only rpcbind servers will
still exist, this patch comments out the code that forces
use of UDP, so that NFSv3 mounts to Azure servers can work.

For an NFSv3 mount, the "udp" mount option will still
make mount_nfs use UDP for rpcbind so that can be used
as a workaround for any old NFSv3 server that only
supports rpcbind over UDP (if any such server still exists).

I asked if doing this change is appropriate on freebsd-fs@
and I only got one reply (off list) that supported doing
the change.

PR:	267301
MFC after:	1 month
2022-11-13 12:16:06 -08:00
Dag-Erling Smørgrav 817f1f3064 libc: Don't warn about RRSIG replies.
PR:		213178
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D37303
2022-11-09 17:41:47 +01:00
Mark Johnston d0f8e31761 getsockopt.2: Clarify the SO_REUSEPORT_LB text a bit
Refer to sockets rather than processes, since one can have multiple
sockets in a load-balancing group within the same process.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
2022-11-02 13:46:24 -04:00
John Baldwin c9c9057c77 ktrace.2: Document KTRFAC_STRUCT_ARRAY.
Sponsored by:	DARPA
2022-11-02 10:35:26 -07:00
Mike Karels 1443613866 getaddrinfo: distinguish missing addrs from unresolvable names
Rework getaddrinfo(3) to return different error values for unresolvable
names (same as before, EAI_NONAME) and those without a requested addr
(EAI_ADDRFAMILY) when using DNS.  This is implemented via an added
error in the nsswitch layer, NS_ADDRFAMILY, which is used only by
getaddrinfo().  The error is passed through nsdispatch(3), but that
routine has no changes to handle this error.  The error originates in
the getaddrinfo DNS layer called via nsdispatch(), and is processed
by the search layer that calls nsdispatch().

While here, add a little style to returns near those that were
modified.

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by:    bz
MFC after:      1 month
2022-11-02 11:03:31 -05:00
Mike Karels e34adc71d3 gai_strerror.[c3]: re-enable EAI_ADDRFAMILY, EAI_NODATA
gai_strerror.c still has messages for EAI_ADDRFAMILY and EAI_NODATA,
but not the man page.  Re-add to the man page, and update comments
in the source.  Document the errors that are not in RFC 3493 or
POSIX.

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by:    bz, pauamma
MFC after:      1 month
2022-11-02 11:03:31 -05:00
Jose Luis Duran f0a15aafcb strfmon: Remove XXX marks
phantom@'s HDD crashed with the final version of strfmon.c, as explained
in 9d430a5991.

Now there are tests in place that cover these code paths.

Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:09:32 +03:00
Jose Luis Duran 621bf91893 strfmon_l: Use specified locale for number formatting
strfmon_l does not take fully into consideration the explicitly passed
locale to perform the formatting.

Parallel universe bug report:	https://sourceware.org/bugzilla/show_bug.cgi?id=19633

Obtained from:	Darwin
Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:09:11 +03:00
Jose Luis Duran 29972f06f9 strfmon_test: Add a test for strfmon_l
Attempt to test the correctness of strfmon_l(3).

Items marked with XXX represent an invalid output.

Obtained from:	e7eba0044f

Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:08:54 +03:00
Jose Luis Duran edcee003e5 strfmon_test: Reserve space for the null terminator
Otherwise strfmon(3) could overflow the buffer.

Here is mostly done for correctness and illustrative purposes, as there
is no chance it could actually happen.

Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:08:33 +03:00
Jose Luis Duran d96088b3ab strfmon_l(3): Add name to the man page
Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:08:19 +03:00
Jose Luis Duran 7cfd67ce96 strfmon(3): Fix # explanation
There's only one value that specifies the number of digits after the
decimal point (oh, sorry, the "radix character") the other specifies the
number before...

While here, add a little more info on the effects of using the #n value.

Obtained from:	d1dd1a0864
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:48:20 +03:00
Jose Luis Duran 0efec50e9e strfmon(3): Remove repeated words
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran 34f88528ed strfmon: Fix formatting of a second fixed-width value
There is a bug when formatting two consecutive values using fixed-widths
and the values need padding.  This was because the value of pad_size
was zeroed only every other time.

Format           Before                         After
[%8n] [%8n]      [ $123.45] [       $123.45]    [ $123.45] [ $123.45]

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran 750fe3e6a4 strfmon: Fix an edge case when sep_by_space is 2
Fix an edge case by printing the required space when, the currency
symbol succeeds the value, a space separates the sign from the value and
the sign position precedes the quantity and the currency symbol.

In other words:

    n_cs_precedes = 0
    n_sep_by_space = 2
    n_sign_posn = 1

From The Open Group's localeconv[1]:

> When {p,n,int_p,int_n}_sep_by_space is 2:
> If the currency symbol and sign string are adjacent, a space separates
> them; otherwise, a space separates the sign string from the value.

    Format    Before        After
    [%n]      [-123.45¤]    [- 123.45¤]

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html

Obtained from:	Darwin
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran 947efadc3d strfmon: Fix alignment when enclosed by parentheses
Take into consideration the possibility of quantities enclosed by
parentheses when aligning.

Matches the examples from The Open Group's:

Format  Before          After
%(#5n   [$   123.45]    [ $   123.45 ]  Use an alternative pos/neg style
        [($   123.45)]  [($   123.45)]
        [$ 3,456.78]    [ $ 3,456.78 ]

%!(#5n  [   123.45]     [    123.45 ]   Disable the currency symbol
        [(   123.45)]   [(   123.45)]
        [ 3,456.78]     [  3,456.78 ]

https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html

SD5-XSH-ERN-29 is applied, updating the examples for %(#5n and %!(#5n.

Obtained from:	Darwin
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran 6da51e19e3 strfmon: Trim the SPACE from international currency symbol
The international currency symbol (int_curr_symbol) has a mandatory
SPACE character as the last character.

Trim this space after reading it, otherwise this extra space will always
be printed when displaying the int_curr_symbol.

Fixes the output when the international currency format is selected
(%i).

    Locale         Format    Before           After
    en_US.UTF-8    [%i]      [USD 123.45]     [USD123.45]
    fr_FR.UTF-8    [%i]      [123,45 EUR ]    [123,45 EUR]

Note that the en_US.UTF-8 locale states that no space should be printed
between the currency symbol and the value (sep_by_space = 0).

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran 9e03b903e3 strfmon: Avoid an out-of-bounds access
Avoid an out-of-bounds access when trying to set the space_char using an
international currency format (%i) and the C/POSIX locale.

The current code tries to read the SPACE from int_curr_symbol[3]:

    currency_symbol = strdup(lc->int_curr_symbol);
    space_char = *(currency_symbol+3);

But on C/POSIX locales, int_curr_symbol is empty.

Three implementations have been examined: NetBSD[1], Darwin[2], and
Illumos[3].  Only NetBSD has fixed it[4].

Darwin and NetBSD also trim the mandatory final SPACE character after
reading it.

    Locale         Format    Darwin/NetBSD    FreeBSD/Illumos
    en_US.UTF-8    [%i]      [USD123.45]      [USD 123.45]
    fr_FR.UTF-8    [%i]      [123,45 EUR]     [123,45 EUR ]

This commit only fixes the out-of-bounds access.

[1]: https://github.com/NetBSD/src/blob/trunk/lib/libc/stdlib/strfmon.c
[2]: https://opensource.apple.com/source/Libc/Libc-1439.141.1/stdlib/NetBSD/strfmon.c.auto.html
[3]: https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libc/port/locale/strfmon.c
[4]: 3d7b5d498a

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran 0afd11d50f strfmon: Fix typos in source code comments
s/defult/default
s/internaltion/international

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:16 +03:00
Jose Luis Duran d5980dff6b strfmon: Fix typo in constant
s/SUPRESS_CURR_SYMBOL/SUPPRESS_CURR_SYMBOL

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:16 +03:00
Jose Luis Duran f81dfea291 strfmon: Code cleanup
No functional change intended.
Not claiming full style(9) compliance.

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:16 +03:00
Jose Luis Duran 3f97d37ac5 strfmon_test: Add some tests
Attempt to test the correctness of strfmon(3).

Some of them were inspired from the examples section at:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html

Items marked with XXX represent an invalid output.

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:29:26 +03:00
Jose Luis Duran f91301cc79 strfmon_test: Fix typo and remove extra space
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:28:33 +03:00
Warner Losh aec9453fec times: Use modern function definitions
Use the modern ANSI function defition syntax rather than the old K&R
syntax for times.

Sponsored by:		Netflix
2022-10-25 10:57:29 -06:00
Mark Johnston a4ee0edc4a libc: Make elf_aux_info() return an error if AT_USRSTACK* is undefined
Otherwise we do not fall back to sysctls if the auxv entries are not
defined by the kernel.  Arguably this is not a bug since we do not
support newer libc running on an older kernel, but we can be a bit more
gentle for the benefit of Valgrind or any other software which
synthesizes the auxv for virtualization purposes.

Reported by:	Paul Floyd <paulf2718@gmail.com>
MFC after:	1 week
Reviewed by:	brooks, kib
Differential Revision:	https://reviews.freebsd.org/D37036
2022-10-18 18:11:26 -04:00
Mitchell Horne 4a9b1a1463 getpagesize(3): cross-reference getpagesizes(3)
MFC after:	3 days
2022-10-17 15:16:12 -03:00
Michael Tuexen bc0d407676 Revert "listen(): improve POSIX compliance"
This reverts commit 76e6e4d72f.

Several programs in the tree use -1 instead of INT_MAX to use
the maximum value. Thanks to Eugene Grosbein for pointing this
out.
2022-10-12 04:33:00 +02:00
Michael Tuexen 76e6e4d72f listen(): improve POSIX compliance
Ensure that a negative backlog argument is handled as it if was 0.

Reviewed by:		markj@, glebius@
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D31821
2022-10-11 22:46:51 +02:00
Benedict Reuschling 44b0b943b8 Revert "Add extra EINVAL information about wrong block size to read(2)/write(2)"
This reverts commit 1c2be25f60.

kib@ pointed out that it is perfectly fine to write at arbitrary regular
file offsets. For example, in a 4K block size character device, geom
doesn't support writing / reading 515 byte blocks. The description is
perhaps not applicable to all EINVALs returned.
2022-10-08 10:23:51 +00:00
Benedict Reuschling 1c2be25f60 Add extra EINVAL information about wrong block size to read(2)/write(2)
The read system call will return EINVAL if the current file offset is
not a multiple of the block size. This also applies to write(2). Add an
entry for EINVAL about this error to both man pages.

PR:			91149
Event:			Aberdeen Hackathon 2022
Differential Revision:	https://reviews.freebsd.org/D24617
2022-10-07 11:32:37 +00:00
Brooks Davis c3fb59ed5c libc: Include quad support on long32 ABIs
Rather than not including it on all 64-bit platforms, just include it on
32-bit ones.

Reviewed by:	imp, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36422
2022-10-05 17:27:44 +01:00
Ed Maste 9515313b26 libc: Fix size range check in setvbuf
From enh at google.com via openbsd-tech mailing list via pfg@:

The existing test is wrong for LP64, where size_t has twice as many
relevant bits as int, not just one. (Found by inspection by
rprichard.)
2022-10-04 12:03:56 -04:00