| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
| |
The memcpy() function first appeared in AT&T System V UNIX and was
reimplemented for 4.3BSD-Tahoe. The mempcpy() function first appeared in
FreeBSD 13.1.
PR: 272227
Differential Revision: https://reviews.freebsd.org/D42630
(cherry picked from commit 8c8ffe541eabb23e21ddffb534ecda7ac6d7e04a)
|
| |
|
|
|
|
|
|
| |
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 7fde0187cc443468561f0a30d589ff0cfe45eef5)
(cherry picked from commit 560e22c8fe460e00d16e5268fe1fbb316ad81101)
(cherry picked from commit 5b5fa75acff11d871d0c90045f8c1a58fed85365)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The removed text claimed that memcpy is implemented using bcopy and thus
strings may overlap. Use of bcopy is an implementation detail that is
no longer true, even if the implementation (on some archs) does allow
overlap.
In any case behaviour is undefined per the C standard if memcpy is
called with overlapping objects, and this man page already claimed that
src and dst may not overlap.
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31192
(cherry picked from commit 37296464defda0aa769c39ab554deb4875aef000)
|
| |
|
|
|
|
| |
PR: 273401
(cherry picked from commit 09ec5e67a7a6605e5a58a2e3e82dab243a90609a)
|
| |
|
|
|
|
|
| |
Remove /^\.\\"\s*\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit b2c76c41be32)
|
| |
|
|
|
|
|
| |
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit fa9896e082a1)
|
| |
|
|
|
|
|
| |
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
Similar commit in main:
(cherry picked from commit d0b2dbfa0ecf)
|
| |
|
|
|
|
|
| |
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
Similar commit in main:
(cherry picked from commit 1d386b48a555)
|
| |
|
|
|
|
|
| |
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
Similar commit in main:
(cherry picked from commit 42b388439bd3)
|
| |
|
|
|
|
|
| |
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit b3e7694832e8)
|
| |
|
|
|
|
|
|
|
|
|
| |
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
(cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
(cherry picked from commit 4da7282a1882fc03c99591c27d44a2e6dfda364b)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Most architectures we support (except for riscv64) have instructions
to compute these functions very quickly. Replace old code with the
ftz and clz builtin functions, allowing clang to generate good code
for all architectures.
We cannot use the ffs builtins as gcc uses ffs() to implement these on
some platforms, potentially causing an infinite loop.
As a consequence, toss out arm and i386 ffs() implementations.
Sponsored by: The FreeBSD Foundation
Reported by: jlduran@gmail.com, jhb
Approved by: mhorne, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40730
Differential Revision: https://reviews.freebsd.org/D40966
(cherry picked from commit ee8b0c436d7221c25e8be3c3fe1f9da78b9d5b16)
(cherry picked from commit 3f5788e0ed8e85567f651ad360596b8c330af5a9)
|
| |
|
|
|
|
|
|
|
|
| |
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
(cherry picked from commit 30da840c627c80800c06edef346d907d6e5066a6)
|
| |
|
|
|
|
|
|
|
|
|
| |
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
(cherry picked from commit 016e46fd869ebf9891ca4b2cf1d22b337717a8c8)
|
| |
|
|
| |
(cherry picked from commit 05c9a0158f6837bb3a3781e4ed75f66115f6415a)
|
| |
|
|
|
|
|
|
|
|
|
| |
There are some sections which could be improved
and work to do so is on going. The work will be
covered via 'X-MFC-WITH' commits.
Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D34759
(cherry picked from commit 4b7f35db44cbf901e994fc9a4bcd4c98ebe8c4a1)
|
| |
|
|
|
|
|
|
|
| |
It was obtained from musl, and is MIT licensed.
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 2e9bc9d14440aa17e6945a9b6613ebb1711fe960)
|
| |
|
|
|
|
| |
Obtained from: musl c53e9b239418
(cherry picked from commit c6750f07b43d18d39729570533f4ecb56da286bf)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Parentheses added to HASZERO macro to avoid a GCC warning, and formatted
with clang-format as we have adopted these and don't consider them
'contrib' code.
Obtained from: musl (snapshot at commit 4d0a82170a25)
Reviewed by: kib (libc integration), mjg (both earlier)
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17630
(cherry picked from commit 7f72497ef756ff7d03d5560c2d1c1f92f73fcb52)
|
| |
|
|
| |
(cherry picked from commit ee37f64cf875255338f917a9da76c643cf59786c)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
While most 64-bit architectures have an assembly implementation of this
file, RISC-V does not. As we now store 8 bytes instead of 4 it should speed
up RISC-V.
Reviewed By: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29536
(cherry picked from commit ab147542b7c0bbc41f7f0499b16933bd8f3f31d7)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While most 64-bit architectures have an assembly implementation of this
file RISC-V does not. As we now copy 8 bytes instead of 4 it should speed
up RISC-V. Using intptr_t instead of int also allows using this file for
CHERI pure-capability code since trying to copy pointers using integer
loads/stores will invalidate pointers.
Reviewed By: kib
Obtained from: CheriBSD (partially)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29535
(cherry picked from commit 0b4ad01d91a3b24cea00d54d25beed0f487c0183)
|
| |
|
|
|
|
|
|
|
| |
MFC note: this plus the merge of two preliminary removal of __NO_TLS
definitions for mips and risc-v break ABI. It was decided that doing
ABI break on tier 2 platforms at this stage of 13.0 release process is
better than drag on __NO_TLS presence for the 13.x branch lifetime.
(cherry picked from commit 3ae8d83d04a7a6ec11b64c89ee60c180b0bde30e)
|
| |
|
|
|
|
|
|
|
|
|
| |
This reverts commit 710e45c4b8539d028877769f1a4ec088c48fb5f1.
It breaks for some corner cases on big endian ppc64.
Given the stage of the release process it is best to revert for now.
Reported by: jhibbits
(cherry picked from commit 33f0540b13d949c7cc226a79927ddc2062ff98bf)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous code neglected to use primitives which can find the end
of the string without having to branch on every character.
While here augment the somewhat misleading commentary -- strlen as
implemented here leaves performance on the table, especially so for
userspace. Every arch should get a dedicated variant instead.
In the meantime this commit lessens the problem.
Tested with glibc test suite.
Naive test just calling strlen in a loop on Haswell (ops/s):
$(perl -e "print 'A' x 3"):
before: 211198039
after: 338626619
$(perl -e "print 'A' x 100"):
before: 83151997
after: 98285919
(cherry picked from commit 710e45c4b8539d028877769f1a4ec088c48fb5f1)
|
| |
|
|
|
|
|
| |
MFC with: 368714
Notes:
svn path=/head/; revision=368770
|
| |
|
|
|
|
|
|
|
|
|
| |
This is a nice and quick reference.
Reviewed by: jilles, yuripv
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27623
Notes:
svn path=/head/; revision=368714
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Only for the arches that provide user-mode TLS.
PR: 251651
Requested by: yuri
Discussed with: emaste, jilles, tijl
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27495
MFC after: 2 weeks
Notes:
svn path=/head/; revision=368692
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Linux claims 4.3BSD, we claim 4.4BSD and OpenBSD claims 4.3BSD-Reno. It turns
out that OpenBSD got it right: the function was added in late 1988 a few months
after 4.3BSD-Tahoe, well in advance of 4.3BSD-Reno.
Reviewed by: bcr
Approved by: bcr
Differential Revision: https://reviews.freebsd.org/D27392
Notes:
svn path=/head/; revision=368625
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
unsigned char promotes to int, which can overflow when shifted left by
24 bits or more. this has been reported multiple times but then
forgotten. it's expected to be benign UB, but can trap when built with
explicit overflow catching (ubsan or similar). fix it now.
note that promotion to uint32_t is safe and portable even outside of
the assumptions usually made in musl, since either uint32_t has rank
at least unsigned int, so that no further default promotions happen,
or int is wide enough that the shift can't overflow. this is a
desirable property to have in case someone wants to reuse the code
elsewhere.
musl commit: 593caa456309714402ca4cb77c3770f4c24da9da
Obtained from: musl
Notes:
svn path=/head/; revision=367823
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
first, the condition (mem && k < p) is redundant, because mem being
nonzero implies the needle is periodic with period exactly p, in which
case any byte that appears in the needle must appear in the last p
bytes of the needle, bounding the shift (k) by p.
second, the whole point of replacing the shift k by mem (=l-p) is to
prevent shifting by less than mem when discarding the memory on shift,
in which case linear time could not be guaranteed. but as written, the
check also replaced shifts greater than mem by mem, reducing the
benefit of the shift. there is no possible benefit to this reduction of
the shift; since mem is being cleared, the full shift is valid and
more optimal. so only replace the shift by mem when it would be less
than mem.
musl commits:
8f5a820d147da36bcdbddd201b35d293699dacd8
122d67f846cb0be2c9e1c3880db9eb9545bbe38c
Obtained from: musl
MFC after: 2 weeks
Notes:
svn path=/head/; revision=367822
|
| |
|
|
|
|
|
|
|
|
|
| |
We have adopted these and don't consider them 'contrib' code, so bring
them closer to style(9). This is a followon to r315467 and r351700.
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Notes:
svn path=/head/; revision=367821
|
| |
|
|
|
|
|
| |
MFC after: 1 week
Notes:
svn path=/head/; revision=362495
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Add STANDARDS and HISTORY sections within the appropriate manpages
- Mention two USENIX papers within kqueue(2) and strlcpy(3)
Reviewed by: bcr (mentor)
Approved by: bcr (mentor)
Obtained from: NetBSD
MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D24650
Notes:
svn path=/head/; revision=362171
|
| |
|
|
|
|
|
|
|
|
| |
Attempted to clean up the language around "this is a malloc'd object." May be
passed as a parameter to free(3) is a bit obtuse.
Sponsored by: Dell EMC Isilon
Notes:
svn path=/head/; revision=360664
|
| |
|
|
|
|
|
|
|
| |
Upon re-reading the whole sentence this is a better fix.
MFC with: r357681
Notes:
svn path=/head/; revision=357683
|
| |
|
|
| |
Notes:
svn path=/head/; revision=357681
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Assembly optimization of strncpy for PowerPC64, using double words
instead of bytes to copy strings.
Submitted by: Leonardo Bianconi <leonardo.bianconi_eldorado.org.br> (original version)
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D15369
Notes:
svn path=/head/; revision=356766
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Assembly optimization of strcpy for PowerPC64, using double words
instead of bytes to copy strings.
Submitted by: Leonardo Bianconi <leonardo.bianconi_eldorado.org.br> (original version)
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D15368
Notes:
svn path=/head/; revision=356765
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Parentheses added to HASZERO macro to avoid a GCC warning.
Reviewed by: kib, mjg
Obtained from: musl (snapshot at commit 4d0a82170a)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17631
Notes:
svn path=/head/; revision=351700
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the length of the source wide character string, passed in via the
"size_t n" parameter, is set to zero, the function should only return
the required length for the destination wide character string. In this
case, it should *not* attempt to write to the destination, so the "dst"
parameter is permitted to be NULL.
However, when the internally called _collate_wxfrm() function returns an
error, such as when using the "C" locale, as a fallback wcscpy(3) or
wcsncpy(3) are used. But if the input length is zero, wcsncpy(3) will
be called with a length of -1! If the "dst" parameter is NULL, this
will immediately result in a segfault, or if "dst" is a valid pointer,
it will most likely result in unexpectedly overwritten memory.
Fix this by explicitly checking for an input length greater than zero,
before calling wcsncpy(3).
Note that a similar situation does not occur in strxfrm(3), the plain
character version of this function, as it uses strlcpy(3) for the error
case. The strlcpy(3) function does not write to the destination if the
input length is zero.
MFC after: 1 week
Notes:
svn path=/head/; revision=350697
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
musl commits:
122d67f846cb0be2c9e1c3880db9eb9545bbe38c
0239cd0681e889a269fb7691f60e81ef8d081e6b
8f5a820d147da36bcdbddd201b35d293699dacd8
Submitted by: David CARLIER <devnexen_gmail.com>
Obtained from: musl
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19834
Notes:
svn path=/head/; revision=346054
|
| |
|
|
|
|
|
|
|
| |
Reported by: gj
MFC after: 13 days
Sponsored by: The FreeBSD Foundation
Notes:
svn path=/head/; revision=342574
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Addition of the new errno values requires adding new elements to
sys_errlist array, which is actually ABI-incompatible, since ELF
records the object size. Expand array in advance to 150 elements so
that we have our users to go over the issue only once, at least until
more than 53 new errors are added.
I did not bumped the symbol version, same as it was not done for
previous increases of the array size. Runtime linker only copies as
much data into binary object on copy relocation as the binary'object
specifies. This is not fixable for binaries which access sys_errlist
directly.
While there, correct comment and calculation of the temporary buffer
size for the message printed for unknown error. The on-stack buffer
is used only for the number and delimiter since r108603.
Requested by: mckusick
Reviewed by: mckusick, yuripv
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D18656
Notes:
svn path=/head/; revision=342551
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
commit 51bdcdc424bd7169c8cccdc2de7cad17f5ea0f70
Author: Alexander Monakov <amonakov@ispras.ru>
Date: Fri Jun 30 00:35:33 2017 +0300
fix OOB reads in Xbyte_memmem
Reported by Leah Neukirchen.
Reviewed by: emaste
Approved by: re (kib)
Notes:
svn path=/head/; revision=339370
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Mention abort_handler_s(3) and ignore_handler_s(3), provide
cross-reference from memset(3).
Submitted by: Yuri Pankov <yuripv@yuripv.net>
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D16797
Notes:
svn path=/head/; revision=338051
|
| |
|
|
|
|
|
|
|
|
|
| |
Fix typos and other nits.
Submitted by: Yuri Pankov <yuripv@yuripv.net>
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D16797
Notes:
svn path=/head/; revision=338049
|
| |
|
|
|
|
|
| |
Sponsored by: Dell EMC Isilon
Notes:
svn path=/head/; revision=334738
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the DESCRIPTION, put the more commonly used functions first in the
corresponding sentence, to help catch the eye.
Pull out the note about overlapping buffers to its own paragraph, as it
applies to all routines documented by this page.
Emphasize the potentially surprising strncpy(3) behavior of zero-filling the
remainder of a buffer larger than the source string.
Encourage strlcpy use; remove portability note about strlcpy(3). Adapting a
strlcpy-using code base to a platform that does not provide strlcpy in libc
is so trivial as to not be worth mentioning. (Just copy strlcpy.c out of
any BSD libc, or include and link the pre-packaged libbsd library on non-BSD
platforms.)
Likewise, expand the page's warning about ease of potential misuse to cover
all functions documented herein, and explicitly suggest using strlcpy most
of the time. The text was mostly cribbed from a similar suggestion in
gets(3).
Finally, document the remaining valid use of strncpy -- the rare
fixed-length record with no expectation of nul-termination.
Sponsored by: Dell EMC Isilon
Notes:
svn path=/head/; revision=334733
|