History log of /freebsd/lib/libc/amd64/string/memcmp.S (Results 1 – 20 of 20)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: release/14.0.0
# 953b93cf 14-Sep-2023 Robert Clausecker <fuz@FreeBSD.org>

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

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: b2618b651b28fd29e62a4e285f5be09ea30a85d4
MFC after: 1 week

show more ...


# 8803f01e 12-Jul-2023 Robert Clausecker <fuz@FreeBSD.org>

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

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

show more ...


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# b3e76948 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


Revision tags: release/13.2.0, release/12.4.0, release/13.1.0
# fbc002cb 25-Mar-2022 Mateusz Guzik <mjg@FreeBSD.org>

amd64: bring back asm bcmp, shared with memcmp

Turns out clang converts "memcmp(foo, bar, len) == 0" and similar to
bcmp calls.

Reviewed by: emaste (previous version), jhb (previous version)
Differ

amd64: bring back asm bcmp, shared with memcmp

Turns out clang converts "memcmp(foo, bar, len) == 0" and similar to
bcmp calls.

Reviewed by: emaste (previous version), jhb (previous version)
Differential Revision: https://reviews.freebsd.org/D34673

show more ...


Revision tags: release/12.3.0, release/13.0.0
# f1be262e 31-Jan-2021 Mateusz Guzik <mjg@FreeBSD.org>

amd64: move memcmp checks upfront

This is a tradeoff which saves jumps for smaller sizes while making
the 8-16 range slower (roughly in line with the other cases).

Tested with glibc test suite.

Fo

amd64: move memcmp checks upfront

This is a tradeoff which saves jumps for smaller sizes while making
the 8-16 range slower (roughly in line with the other cases).

Tested with glibc test suite.

For example size 3 (most common with vfs namecache) (ops/s):
before: 407086026
after: 461391995

The regressed range of 8-16 (with 8 as example):
before: 540850489
after: 461671032

show more ...


# 0db6aef4 31-Jan-2021 Mateusz Guzik <mjg@FreeBSD.org>

amd64: add a note about simd to libc memset, memmove and memcmp


Revision tags: release/12.2.0, release/11.4.0
# 59abbffa 31-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r357270 through r357349.


# 8291e887 30-Jan-2020 Mateusz Guzik <mjg@FreeBSD.org>

amd64: sync up libc memcmp with the kernel version (r357309)


# bb1d0df5 29-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r357179 through r357269.


# 4846152a 29-Jan-2020 Mateusz Guzik <mjg@FreeBSD.org>

amd64: sync up libc memcmp with the kernel version (r357208)


Revision tags: release/12.1.0, release/11.3.0, release/12.0.0
# 01d4e214 05-Oct-2018 Glen Barber <gjb@FreeBSD.org>

MFH r338661 through r339200.

Sponsored by: The FreeBSD Foundation


# ce44d808 27-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r338731 through r338987.


# 5bbde333 27-Sep-2018 Mateusz Guzik <mjg@FreeBSD.org>

amd64: reimplement libc memcmp and bcmp with kernel memcmp

Both are significantly slower than hand-coded loops. See r338963 for
kernel commit.

bcmp differs from memcmp by always returning 1 when a

amd64: reimplement libc memcmp and bcmp with kernel memcmp

Both are significantly slower than hand-coded loops. See r338963 for
kernel commit.

bcmp differs from memcmp by always returning 1 when a difference is
found, as opposed to going for a value bigger or lower than 0
depending on what it is. This means it can do less work. For now the
code is duplicated and modified. This will get deduplicated after
another round of optimization when memcmp will get a longer-term form.

Both tested with the glibc suite. While the suite does not have a test
for bcmp, I created a wrapper routine which verified that values match
(0 vs 0, 1 vs non-zero).

Reviewed by: kib
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17336

show more ...


Revision tags: release/11.2.0, release/10.4.0, release/11.1.0, release/11.0.1, release/11.0.0, release/10.3.0, release/10.2.0, release/10.1.0, release/9.3.0, release/10.0.0, release/9.2.0, release/8.4.0, release/9.1.0, release/8.3.0_cvs, release/8.3.0, release/9.0.0, release/7.4.0_cvs, release/8.2.0_cvs, release/7.4.0, release/8.2.0
# 93ab7586 07-Jan-2011 Konstantin Belousov <kib@FreeBSD.org>

Add section .note.GNU-stack for assembly files used by 386 and amd64.


Revision tags: release/8.1.0_cvs, release/8.1.0, release/7.3.0_cvs, release/7.3.0, release/8.0.0_cvs, release/8.0.0, release/7.2.0_cvs, release/7.2.0, release/7.1.0_cvs, release/7.1.0
# e57c2b13 04-Dec-2008 Dag-Erling Smørgrav <des@FreeBSD.org>

integrate from head@185615


Revision tags: release/6.4.0_cvs, release/6.4.0
# 5d053f46 02-Nov-2008 Peter Wemm <peter@FreeBSD.org>

We've been lax about matching END() macros in asm code for some time. This
is used to set the ELF size attribute for functions. It isn't normally
critical but some things can make use of it (gdb fo

We've been lax about matching END() macros in asm code for some time. This
is used to set the ELF size attribute for functions. It isn't normally
critical but some things can make use of it (gdb for stack traces).
Valgrind needs it so I'm adding it in. The problem is present on all
branches and on both i386 and amd64.

show more ...


Revision tags: release/7.0.0_cvs, release/7.0.0, release/6.3.0_cvs, release/6.3.0, release/6.2.0_cvs, release/6.2.0, release/5.5.0_cvs, release/5.5.0, release/6.1.0_cvs, release/6.1.0, release/6.0.0_cvs, release/6.0.0, release/5.4.0_cvs, release/5.4.0
# 26f6218b 08-Apr-2005 Alan Cox <alc@FreeBSD.org>

Add machine-specific, optimized implementations of bcmp and memcmp.

PR: 73111
Submitted by: Ville-Pertti Keinonen <will@iki.fi> (taken from NetBSD)
MFC after: 3 weeks


Revision tags: release/6.4.0_cvs, release/6.4.0
# 5d053f46 02-Nov-2008 Peter Wemm <peter@FreeBSD.org>

We've been lax about matching END() macros in asm code for some time. This
is used to set the ELF size attribute for functions. It isn't normally
critical but some things can make use of it (gdb fo

We've been lax about matching END() macros in asm code for some time. This
is used to set the ELF size attribute for functions. It isn't normally
critical but some things can make use of it (gdb for stack traces).
Valgrind needs it so I'm adding it in. The problem is present on all
branches and on both i386 and amd64.

show more ...


Revision tags: release/7.0.0_cvs, release/7.0.0, release/6.3.0_cvs, release/6.3.0, release/6.2.0_cvs, release/6.2.0, release/5.5.0_cvs, release/5.5.0, release/6.1.0_cvs, release/6.1.0, release/6.0.0_cvs, release/6.0.0, release/5.4.0_cvs, release/5.4.0
# 26f6218b 08-Apr-2005 Alan Cox <alc@FreeBSD.org>

Add machine-specific, optimized implementations of bcmp and memcmp.

PR: 73111
Submitted by: Ville-Pertti Keinonen <will@iki.fi> (taken from NetBSD)
MFC after: 3 weeks