Commit graph

24191 commits

Author SHA1 Message Date
Konstantin Belousov
8309579720 Document aio_read2/aio_write2
(cherry picked from commit a52cb4c480f270fc7158a0f58179f7b80d8a5b3c)
2024-02-18 12:01:46 +02:00
Konstantin Belousov
e331ce2d60 aio_read2/aio_write2: add AIO_OP2_VECTORED
(cherry picked from commit 8dfc788b8480a13f1f945f0a94d8b1e327af5c6f)
2024-02-18 12:01:46 +02:00
Konstantin Belousov
e9014ead57 libc: add aio_read2() and aio_write2() functions
(cherry picked from commit 06cb1c3f9528f088bdaf10d28dcfe7eeaad726d3)
2024-02-18 12:01:46 +02:00
Konstantin Belousov
1298ecb6ba lio_listio(2): add LIO_FOFFSET flag to ignore aiocb aio_offset
(cherry picked from commit e4b7bbd6ab77e908a60362aa29e518f224a117b0)
2024-02-18 12:01:46 +02:00
Brooks Davis
0667d0e0e3 libc: expose execvpe for Linux compat
PR:		275370

(cherry picked from commit 8ccd0b876e67fda6249f294ff484798cc1e1569f)
2024-02-18 12:01:46 +02:00
Cy Schubert
e2b44c401c unbound: Vendor import 1.19.1
Release notes at
    https://www.nlnetlabs.nl/news/2024/Feb/13/unbound-1.19.1-released/

Security:	CVE-2023-50387, CVE-2023-50868

(cherry picked from commit b76ef9a7cb8a7c62d10ae8101f41014f34819174)
2024-02-17 05:44:30 -08:00
Ed Maste
090674a3db csu: add crtbrand.o dependency on sys/param.h
__FreeBSD_version is recorded in *crt1.o and crti.o via crtbrand.o.  Add
an explicit dependency to pick up __FreeBSD_version bumps.

Additional changes are required to fully plumb *crt1.o dependencies
through the build.

Reported by:	bapt
Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43417

(cherry picked from commit ed3563b0ac31d854bf907d4d847ac0195ec9637b)
2024-02-14 12:15:14 -05:00
Konstantin Belousov
16b1438c73 read.2: Describe debug.iosize_max_clamp
PR:	276937

(cherry picked from commit 3e9515846f8cbff0ecccaab65d9f70890d04429e)
2024-02-14 05:41:54 +02:00
Minsoo Choo
fd15ba7d72 libc: Specify parameter types for function pointer
Reviewed by:	dab
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D43726

(cherry picked from commit 6bd60e15b1484c6a3f5a87469e42a8e6ad9ab733)
2024-02-11 10:15:07 -05:00
Mark Johnston
5e21d7cd31 libjail: Guard against programmer error in jailparam_export()
If the caller didn't use jailparam_import() to fetch the parameter
value, an attempt to export it will trigger a segfault.  Make it a bit
easier to figure out what's happening in this situation.

PR:		276809
Reviewed by:	jamie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43732

(cherry picked from commit dfabf3efaa795e657f3858b7e2d0b11f8a51ecb5)
2024-02-11 10:14:59 -05:00
Mark Johnston
d146da5d08 libthr: Force the thr_wake() symbol to be resolved during initialization
Otherwise the lock upgrade performed by rtld's load_filtees() can result
in infinite recursion, wherein:
1. _rtld_bind() acquires the bind read lock,
2. the source DSO's filtees haven't been loaded yet, so the lock upgrade
   in load_filtees() cause rtld to jump to _rtld_bind() and release the
   bind lock,
3. _thr_rtld_lock_release() calls _thr_ast(), which calls thr_wake(),
   which hasn't been resolved yet,
4. _rtld_bind() acquires the bind read lock in order to resolve
   thr_wake(),
5. ...

See the linked pull request for an instance of this problem arising with
libsys.  That particular instance is also worked around by commit
e7951d0b04e6.

Reported by:	brooks
Reviewed by:	kib
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
MFC after:	1 week
Sponsored by:	Innovate UK

(cherry picked from commit 36f0a34ca645d49ec79d60ea7e773374ef0991ea)
2024-02-09 09:55:46 -05:00
Mark Johnston
324e914106 libc: Annotate a couple of local functions as such
No functional change intended.

MFC after:	1 week

(cherry picked from commit 8d5353de74471038bd75a6cb39bf58f50a600642)
2024-02-09 09:55:45 -05:00
Hodong
e4cfb5981d libstdthreads: destroy mutexattr in mtx_init()
PR:	276818

(cherry picked from commit a03f768612ad98a886458197c531a0b92203bf84)
2024-02-09 02:38:04 +02:00
Dimitry Andric
6d5c1c562c Merge libcxxrt master 03c83f5a57be8c5b1a29a68de5638744f17d28ba
Interesting fixes (* were already cherry-picked):
- 03c83f5 add __cxa_init_primary_exception (#23)
* 5d8a158 Fix two bugs in __cxa_end_cleanup()
* b00c6c5 Insert padding in __cxa_dependent_exception
* 45ca8b1 Insert padding in __cxa_exception struct for compatibility
* f2e5509 Fix unlock in two-word version and add missing comment.
- 6229590 Add an option for disabling emergency buffers. (#14)

MFC after:	2 weeks

(cherry picked from commit ecf4106237505fa9459ae871793b754334989c17)
2024-02-08 20:26:04 +01:00
Piotr Pawel Stefaniak
43b7fec10b libcompat: silence -Wdeprecated-non-prototype
by removing unnecessary re-declarations and converting K&R-style
function definitions.

Differential Revision:	https://reviews.freebsd.org/D43723
Reviewed by:	imp, emaste

(cherry picked from commit 12bae251fbfa33f375d134e0840d88c4363b8b94)
2024-02-08 18:40:06 +01:00
Steve Kargl
66aa73282a lib/msun: Cleanup after $FreeBSD$ removal
PR:	276669

(cherry picked from commit 0dd5a5603e7a33d976f8e6015620bbc79839c609)
2024-02-04 02:26:28 +02:00
Olivier Certner
7e2bfa3d7a
login_cap.h: Remove LOGIN_DEFPRI
This is an implementation detail which is likely to become irrelevant in
the future, as we move to not resetting the priority if the
corresponding capability is not present in the configuration file
('/etc/login.conf').

GitHub's code search and Google show no use of this public constant, and
it doesn't exist in OpenBSD and NetBSD.

So, remove this definition and its sole use in-tree.

PR:                     276570 (exp-run)
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43609

(cherry picked from commit c7e645269f1c7e9872a7ccf6b72f045c55a66793)

Approved by:            markj (mentor)
2024-02-01 22:30:20 +01:00
Olivier Certner
ce92a977db
login_cap.h: Remove LOGIN_DEFUMASK
This public constant has not been used in-tree since 1997 (this was
noticed while working on previous commit "setusercontext(): umask: Set
it only once (in the common case)").

Since it was an implementation detail and GitHub's code search and
Google show no use of this symbol today, simply remove it.

PR:                     276570 (exp-run)
Reviewed by:            emaste, kib (earlier version, then part of D40344)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43608

(cherry picked from commit e3a396eb2a029e5dc9161469735aa3f7f16845d1)

Approved by:            markj (mentor)
2024-02-01 22:30:14 +01:00
Olivier Certner
d2d66fedc4
setusercontext(): Set priority from '~/.login_conf' as well
Setting the process priority is done only when the current process'
effective UID corresponds to that for which context is to be set.
Consequently, setting priority is done with appropriate credentials and
will fail if the target user tries to raise it unduly via his
'~/.login_conf'.

PR:                     271751
Reviewed by:            kib, Andrew Gierth <andrew_tao173.riddles.org.uk>
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40352

(cherry picked from commit f2a0277d3e51a6a839151eef17f466d0db2b7300)

Approved by:            markj (mentor)
2024-02-01 22:30:08 +01:00
Olivier Certner
a2fe14d73f
login.conf(5): Document priority's special value 'inherit'
Reviewed by:            emaste, yuripv (older version)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40691

(cherry picked from commit 33d4ce5496efe96bbaa7663e298876395b1db62c)

Approved by:            markj (mentor)
2024-02-01 22:30:01 +01:00
Olivier Certner
a8c273b3c9
setclasspriority(): New possible value 'inherit'
It indicates to the login.conf machinery (setusercontext() /
setclasscontext()) to leave priority alone, effectively inheriting it
from the parent process.

PR:                     271749
Reviewed by:            emaste, yuripv
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40690

(cherry picked from commit d162d7e2ad327ceada4102c5d6779f9ecd809502)

Approved by:            markj (mentor)
2024-02-01 22:29:55 +01:00
Olivier Certner
f49953dd49
setusercontext(): Move priority setting in new setclasspriority()
In preparation for setting priorities from '~/.login_conf' and to ease
reading of setusercontext().

No functional change.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40350

(cherry picked from commit 7b94ec550ef6e7b75d608e125e9b78478197d4e7)

Approved by:            markj (mentor)
2024-02-01 22:29:48 +01:00
Olivier Certner
e7b89962dc
login.conf(5): Document priority's default and possible values
Priority is reset to 0 if not explicitly specified.

While here, be more explicit about what "Initial priority (nice) level"
means and document that it is possible to set real-time or idle class'
priorities with this capability.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40689

(cherry picked from commit aa96945e71b0f724e6ce673194d23f58d2d637d3)

Approved by:            markj (mentor)
2024-02-01 22:29:41 +01:00
Olivier Certner
f17cc92d15
setusercontext(): Better error messages when priority is not set correctly
Polish the syslog messages to contain readily useful information.

Behavior of capability 'priority' is inconsistent with what is done for
all other contexts: 'umask', 'cpumask', resource limits, etc., where an
absence of capability means to inherit the value.  It is currently
preserved for compatibility, but is subject to change on a future major
release.

Reviewed by:            emaste, kib (older version)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40349

(cherry picked from commit d988621b0c25209866ed5a98b1a8b20269935761)

Approved by:            markj (mentor)
2024-02-01 22:29:35 +01:00
Olivier Certner
63c3be3b4f
login.conf(5): Default values: Rename column, elaborate on absence of such
Column "Notes" in fact only contains default values for capabilities, so
make this clear by renaming it to "Default".

Add a small introductory text mentioning it, and what an absence of
default value means (inheritance).

PR:                     271748
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40347

(cherry picked from commit 92b2c4358f57ef84f161efd8370ba4832bd9261a)

Approved by:            markj (mentor)
2024-02-01 22:29:26 +01:00
Olivier Certner
83ac32d9a0
setlogincontext(): Comply to style(9)
Remove indentation by inverting the big 'if (lc)' and using 'return'.
Use explicit binary operators to produce booleans.

Reviewed by:            emaste, kib, dchagin
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40346

(cherry picked from commit 771d5c93ab5a3fb1701d9706df2ce87d6a9da6f3)

Approved by:            markj (mentor)
2024-02-01 22:29:17 +01:00
Olivier Certner
bbbe9b4c64
login.conf(5): Document umask's special value 'inherit'
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40688

(cherry picked from commit ea9bd448102b938ccb8d4b484684a6ba2d934931)

Approved by:            markj (mentor)
2024-02-01 22:29:09 +01:00
Olivier Certner
6f6186e19f
setclassumask(): Accept 'inherit' as a value
'inherit' explicitly indicates that the umask should not be changed.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40687

(cherry picked from commit c328e6c6ccaa4cdf921c16d68a2f2c5992dd3b72)

Approved by:            markj (mentor)
2024-02-01 22:28:58 +01:00
Olivier Certner
787abe7d6e
setusercontext(): Set umask in a separate function, setclassumask()
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40686

(cherry picked from commit 0dd1705f584947625892988afe59e4cedb5cdd09)

Approved by:            markj (mentor)
2024-02-01 22:28:52 +01:00
Olivier Certner
44c898329d
login_cap(3): Document login_getcapenum()
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40685

(cherry picked from commit 97256feb7a65cccac51a03846c5308894a2cb445)

Approved by:            markj (mentor)
2024-02-01 22:28:46 +01:00
Olivier Certner
37aaacd410
New login_getcapenum(): Allows to read named enum values
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40684

(cherry picked from commit 90e914cd5ac1c8ecbf1ea88e9a65e7fa866c17a9)

Approved by:            markj (mentor)
2024-02-01 22:28:40 +01:00
Olivier Certner
f0551aa362
login.conf(5): umask has no default value
The umask is simply left unchanged if no explicit value is specified in
the login class capabilities database.

PR:                     271747
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40345

(cherry picked from commit 0d1fe948d97d2d6e3708349b74cf438f9604a8d1)

Approved by:            markj (mentor)
2024-02-01 22:28:34 +01:00
Olivier Certner
3dec4c30c7
setusercontext(): umask: Set it only once (in the common case)
Simplify the code and make it more coherent (umask was the only context
setting not modified by setlogincontext() directly).

Preserve the current behavior of not changing the umask if none is
specified in the login class capabilities database, but without the
superfluous umask() dance.  (The only exception to this is that
a special value no user is likely to input in the database now stands
for no specification.)

If some user has a 'umask' override in its '~/.login_conf', the umask
will still be set twice as before (as is the case for all other context
settings overriden in '~/.login_conf').

Log a warning in case of an invalid umask specification.

This change makes it apparent that the value of LOGIN_DEFUMASK doesn't
matter.  It will be removed in a subsequent commit.

PR:                     271747
Reviewed by:            emaste, kib (earlier version)
Approved by:            emaste
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40344

(cherry picked from commit e99c28e93bd4d04ff877459734e9ce06ad2335a7)

Approved by:            markj (mentor)
2024-02-01 22:28:27 +01:00
Konstantin Belousov
14b7cf92e7 open(2): describe *at behavior for dirfd opened without O_SEARCH
(cherry picked from commit a570fe4d0dd979ce099374259ffc45d56ae4e471)
2024-02-01 02:30:40 +02:00
Mark Johnston
ea3197e69b kcmp: Add a manual page
Reviewed by:	kib, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D43562

(cherry picked from commit af0d437dd31f71726f7eb5e9aca9fbd374a8277a)
2024-01-31 09:16:29 -05:00
Yuri Pankov
c0565e7d34 Create namespace for the symbols added during 15-CURRENT cycle
Reviewed by:	kib

(cherry picked from commit 95a4709b2cca726c6b76c6743ba2d665c1730666)
2024-01-31 01:14:38 -06:00
Konstantin Belousov
f8d885c08d Add kcmp(2) userspace bits
(cherry picked from commit 211bdd601ee51f90da9b123807ef68ac122116b9)
2024-01-30 22:24:42 +02:00
Mike Karels
e9e63d77c6 inet(3): clarify syntax accepted by inet_pton
The section INTERNET ADDRESSES describes the acceptance of dotted
values with varying number of parts in multiple bases.  This applies
to inet_aton and inet_addr, but not to inet_pton.  Clarify this
section by listing the functions to which this applies.  Move the
description of what inet_pton accepts into this section from STANDARDS,
where it is easily missed.  Rename the section to clarify that it
applies only to IPv4.  (inet_pton also works with IPv6.)

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43537

(cherry picked from commit 9231c42127bf8e47588169ecc395f57cae0e15fb)
2024-01-30 14:10:30 -06:00
Mark Johnston
06fc42c0cb libc/amd64: Disable ASAN for amd64_archlevel.c
The code in this file runs before the sanitizer can initialize its
shadow map.

Fixes:	ad2fac552c ("lib/libc/amd64: add archlevel-based simd dispatch framework")

(cherry picked from commit 4dedcb1bb54cbbe8043c79ad733f966b6ffc6972)
2024-01-30 13:01:58 -05:00
Dimitry Andric
6ccc51fd6f Add libllvm and liblldb source files to enable WITH_ASAN build
This is another part of fixing the WITH_ASAN build. Some additional
source files had to be added to libllvm and liblldb, since the ASan
instrumentation causes symbols in those files to be referenced.

Reported by:	markj
PR:		276597
MFC after:	3 days

(cherry picked from commit 5c38ea60a04199dae2c6e5db82461e7275c7def6)
2024-01-30 18:53:25 +01:00
Dimitry Andric
277382e928 msun: remove fabs from Symbol.map, and adjust comment
We have s_fabs.c, but fabs(3) is already provided by libc due to
historical reasons, so it is not compiled into libm. When the linker
does not use --undefined-version, this leads to a complaint about the
symbol being nonexistent, so remove it from Symbol.map.

While here, adjust the comment about some functions being supplied by
libc: while it is true that all these are indeed in libc, libm still
includes its own versions of frexp(3), isnan(3), isnanf(3), and
isnanl(3).

Reported by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
MFC after:	3 days

(cherry picked from commit d04e03c19a8d7660ea36f62720eef9bc96b69889)
2024-01-30 18:53:19 +01:00
Michael Gmelin
e65182c7bc libifconfig: Fix bridge status member list
When this functionality was moved to libifconfig in 3dfbda3401,
the end of list calculation was modified for unknown reasons, practically
limiting the number of bridge member returned to (about) 102.

This patch changes the calculation back to what it was originally and
adds a unit test to verify it works as expected.

Reported by:	Patrick M. Hausen (via ML)
Reviewed by:	kp
Approved by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43135

(cherry picked from commit 3d36053ca6d6a17d408c8f92c504e6135dc9d8df)
2024-01-28 18:55:56 +01:00
Olivier Certner
f68a255ff3
pthread_attr_get_np(): Use malloc(), report ENOMEM, don't tamper on error
Similarly as in the previous commit, using calloc() instead of malloc()
is useless here in the regular case since the subsequent call to
cpuset_getaffinify() is going to completely fill the allocated memory.

However, there is an additional complication.  This function tries to
allocate memory to hold the cpuset if it previously wasn't, and does so
before the thread lock is acquired, which can fail on a bad thread ID.
In this case, it is necessary to deallocate the memory allocated in this
function so that the attributes object appears unmodified to the caller
when an error is returned.  Without this, a subsequent call to
pthread_attr_getaffinity_np() would expose uninitialized memory (not
a security problem per se, since it comes from the same process) instead
of returning a full mask as it would before the failing call to
pthread_attr_get_np().  So the caller would be able to notice a change
in the state of the attributes object even if pthread_attr_get_np()
reported failure, which would be quite surprising.  A similar problem
that could occur on failure of cpuset_setaffinity() has been fixed.

Finally, we shall always report memory allocation failure.  This already
goes for pthread_attr_init(), so, if for nothing else, just be
consistent.

Reviewed by:            emaste, kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43329

(cherry picked from commit aadb4a1b3fd185d547087f6eafca6ce0b4df3291)

Approved by:            markj (mentor)
2024-01-26 22:01:30 +01:00
Olivier Certner
194df67ef5
libhtr: pthread_attr_setaffinity_np(): Replace calloc() with malloc()
Using calloc() instead of malloc() is useless here since the allocated
memory is to be wholly crushed by the memcpy() call that follows.

Suggested by:           kib
Reviewed by:            emaste, kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Differential Revision:  https://reviews.freebsd.org/D43328

(cherry picked from commit 15bb0300eeca233827a6a13cd2ed883e0034979d)

Approved by:            markj (mentor)
2024-01-26 21:59:11 +01:00
Olivier Certner
a431d0f4a2
libthr: thr_attr.c: More style and clarity fixes
The change of argument for sizeof() (from a type to an object) is to be
consistent with the change done for the malloc() code just above in the
preceding commit touching this file.

Consider bit flags as integers and test whether they are set with an
explicit comparison with 0.

Use an explicit flag value (PTHREAD_SCOPE_SYSTEM) in place of a variable
that has this value at point of substitution.

All other changes are straightforward.

Suggested by:           kib
Reviewed by:            kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Differential Revision:  https://reviews.freebsd.org/D43327

(cherry picked from commit 4d312aa051414ad77d3515f258230d01ad11d6dc)

Approved by:            markj (mentor)
2024-01-26 21:58:22 +01:00
Robert Clausecker
ff7799e003 lib/libc/amd64/string: add memrchr() scalar, baseline implementation
The scalar implementation is fairly simplistic and only performs
slightly better than the generic C implementation. It could be
improved by using the same algorithm as for memchr, but it would
have been a lot more complicated.

The baseline implementation is similar to timingsafe_memcmp.  It's
slightly slower than memchr() due to the more complicated main
loop, but I don't think that can be significantly improved.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42925

(cherry picked from commit fb197a4f7751bb4e116989e57ba7fb12a981895f)
2024-01-24 20:39:31 +01:00
Robert Clausecker
acb47064d6 lib/libc/tests/string: add memrchr unit tests
The "values" test case is specifically crafted to detect the off-by-one
error previous discovered in the scalar strchrnul implementation.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42925

(cherry picked from commit 691ff1832e09a6ccbc8f5b04c88cafc7452b3ce6)
2024-01-24 20:39:30 +01:00
Robert Clausecker
667fa9c404 lib/libc/string: document restrict qualification of memccpy() arguments
POSIX.1-2004 and the upcoming C23 agree that memccpy()'s arguments
are restrict qualified and must not overlap.  In 2002, restrict
qualifiers were added to <string.h>'s declaration of the function.
Make things official and document that the arguments must not
overlap.

See also:	61b60edfd3
Approved by:	kib
MFC after:	1 month
MFC to:		stable/14

(cherry picked from commit e0d4f419ac41aa91b862f3ceadc32a86abf08572)
2024-01-24 20:39:30 +01:00
Robert Clausecker
ddab9e6461 lib/libc/amd64/string: implement strncat() by calling strlen(), memccpy()
This picks up the accelerated implementation of memccpy().

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision: https://reviews.freebsd.org/D42902

(cherry picked from commit ea7b13771cc9d45bf1bc6c6edad8d1b7bce12990)
2024-01-24 20:39:30 +01:00
Robert Clausecker
a3ce82e5b8 lib/libc/amd64/string: add memccpy scalar, baseline implementation
Based on the strlcpy code from D42863, this patch adds a SIMD-enhanced
implementation of memccpy for amd64. A scalar implementation calling
into memchr and memcpy to do the job is provided, too.

Please note that this code does not behave exactly the same as the C
implementation of memccpy for overlapping inputs. However, overlapping
inputs are not allowed for this function by ISO/IEC 9899:1999 and neither
has the C implementation any code to deal with the possibility. It just
proceeds byte-by-byte, which may or may not do the expected thing for
some overlaps. We do not document whether overlapping inputs are
supported in memccpy(3).

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42902

(cherry picked from commit fc0e38a7a67a6d43095efb00cf19ee5f95dcf710)
2024-01-24 20:39:30 +01:00