| #
2a5c5b8f
|
| 14-Jan-2026 |
John Baldwin <jhb@FreeBSD.org> |
swab: Correctly treat the data as misaligned
The __aligned attribute in the previous version applied to the location of the pointers, not the data the pointers pointed to. While this could be fixed
swab: Correctly treat the data as misaligned
The __aligned attribute in the previous version applied to the location of the pointers, not the data the pointers pointed to. While this could be fixed by applying the attribute to a local typedef of uint16_t, just using memcpy() for the unaligned access is simpler and ISO C.
This fixes the build on CHERI architectures which do not support misaligned pointers and were thus failing with:
lib/libc/string/swab.c:12:18: error: alignment (1) of 'const uint16_t *' (aka 'const unsigned short *') is less than the required capability alignment (16) [-Werror,-Wcheri-capability-misuse] 12 | const uint16_t *f __aligned(1) = from; |
Co-authored by: Jessica Clarke <jrtc27@FreeBSD.org> Fixes: 02ebbc781f08 ("swab: Fix implementation to support overlapping copies") Sponsored by: AFRL, DARPA
Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D54399
show more ...
|
| #
02ebbc78
|
| 06-Jan-2025 |
Warner Losh <imp@FreeBSD.org> |
swab: Fix implementation to support overlapping copies
A number of image processing packages assume that swab() can handle to and from being the same. However, POSIX.1 states that overlapping buffer
swab: Fix implementation to support overlapping copies
A number of image processing packages assume that swab() can handle to and from being the same. However, POSIX.1 states that overlapping buffers produces undefined results. Our old implementation would produce coherent results, but the recent change to the musl-inspired code does not. Since there's complaints in the forums for these image processing packages for musl and now FreeBSD, update the algorithm to just read a word at a time and bswap16 the results. All FreeBSD's architecutres support unaligned access in userland, and swab is not used in the kernel (g_part_apm has its own copy), so opt for even simpler code that's easier to understand. This makes the overlapping behavior match i386 again, since its assembler routine for swab handles overlapping correctly.
PR: 283698 Sponsored by: Netflix Reviewed by: nwhitehorn Differential Revision: https://reviews.freebsd.org/D48259
show more ...
|
| #
bac2eea1
|
| 22-Apr-2024 |
rilysh <nightquick@proton.me> |
swab.c(libc): use a simplified version of byte swapping
This version of swab function simplifies the logic of swapping adjacent bytes. Previous version of swab() used an arbitrary unrolling, which w
swab.c(libc): use a simplified version of byte swapping
This version of swab function simplifies the logic of swapping adjacent bytes. Previous version of swab() used an arbitrary unrolling, which was relevant back in the day but unnecessary for modern compilers, as if the input size is known at compile time, they can do it automatically.
This version of swab() is inspired by musl. A similar version can be found at: https://github.com/openbsd/src/blob/master/lib/libc/string/swab.c
Signed-off-by: rilysh <nightquick@proton.me> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1086
show more ...
|
| #
dc36d6f9
|
| 23-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl s
lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script.
Sponsored by: Netflix
show more ...
|
| #
559a218c
|
| 01-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
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. Kee
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
show more ...
|
| #
1d386b48
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| #
70164d95
|
| 24-Jul-2021 |
Alfonso <gfunni234@gmail.com> |
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
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
show more ...
|
| #
2a5c5b8f
|
| 14-Jan-2026 |
John Baldwin <jhb@FreeBSD.org> |
swab: Correctly treat the data as misaligned
The __aligned attribute in the previous version applied to the location of the pointers, not the data the pointers pointed to. While this could be fixed
swab: Correctly treat the data as misaligned
The __aligned attribute in the previous version applied to the location of the pointers, not the data the pointers pointed to. While this could be fixed by applying the attribute to a local typedef of uint16_t, just using memcpy() for the unaligned access is simpler and ISO C.
This fixes the build on CHERI architectures which do not support misaligned pointers and were thus failing with:
lib/libc/string/swab.c:12:18: error: alignment (1) of 'const uint16_t *' (aka 'const unsigned short *') is less than the required capability alignment (16) [-Werror,-Wcheri-capability-misuse] 12 | const uint16_t *f __aligned(1) = from; |
Co-authored by: Jessica Clarke <jrtc27@FreeBSD.org> Fixes: 02ebbc781f08 ("swab: Fix implementation to support overlapping copies") Sponsored by: AFRL, DARPA
Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D54399
show more ...
|
| #
02ebbc78
|
| 06-Jan-2025 |
Warner Losh <imp@FreeBSD.org> |
swab: Fix implementation to support overlapping copies
A number of image processing packages assume that swab() can handle to and from being the same. However, POSIX.1 states that overlapping buffer
swab: Fix implementation to support overlapping copies
A number of image processing packages assume that swab() can handle to and from being the same. However, POSIX.1 states that overlapping buffers produces undefined results. Our old implementation would produce coherent results, but the recent change to the musl-inspired code does not. Since there's complaints in the forums for these image processing packages for musl and now FreeBSD, update the algorithm to just read a word at a time and bswap16 the results. All FreeBSD's architecutres support unaligned access in userland, and swab is not used in the kernel (g_part_apm has its own copy), so opt for even simpler code that's easier to understand. This makes the overlapping behavior match i386 again, since its assembler routine for swab handles overlapping correctly.
PR: 283698 Sponsored by: Netflix Reviewed by: nwhitehorn Differential Revision: https://reviews.freebsd.org/D48259
show more ...
|
| #
bac2eea1
|
| 22-Apr-2024 |
rilysh <nightquick@proton.me> |
swab.c(libc): use a simplified version of byte swapping
This version of swab function simplifies the logic of swapping adjacent bytes. Previous version of swab() used an arbitrary unrolling, which w
swab.c(libc): use a simplified version of byte swapping
This version of swab function simplifies the logic of swapping adjacent bytes. Previous version of swab() used an arbitrary unrolling, which was relevant back in the day but unnecessary for modern compilers, as if the input size is known at compile time, they can do it automatically.
This version of swab() is inspired by musl. A similar version can be found at: https://github.com/openbsd/src/blob/master/lib/libc/string/swab.c
Signed-off-by: rilysh <nightquick@proton.me> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1086
show more ...
|
| #
dc36d6f9
|
| 23-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl s
lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script.
Sponsored by: Netflix
show more ...
|
| #
559a218c
|
| 01-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
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. Kee
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
show more ...
|
| #
1d386b48
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| #
70164d95
|
| 24-Jul-2021 |
Alfonso <gfunni234@gmail.com> |
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
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
show more ...
|
| #
82725ba9
|
| 23-Nov-2017 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Merge ^/head r325999 through r326131.
|
| #
8a16b7a1
|
| 20-Nov-2017 |
Pedro F. Giffuni <pfg@FreeBSD.org> |
General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.
The Software Package Data Exchange (SPDX) group provides a specification to make it easier f
General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.
The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts.
Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point.
show more ...
|
| #
d1d01586
|
| 05-Sep-2013 |
Simon J. Gerraty <sjg@FreeBSD.org> |
Merge from head
|
| #
40f65a4d
|
| 07-Aug-2013 |
Peter Grehan <grehan@FreeBSD.org> |
IFC @ r254014
|
| #
552311f4
|
| 17-Jul-2013 |
Xin LI <delphij@FreeBSD.org> |
IFC @253398
|
| #
cfe30d02
|
| 19-Jun-2013 |
Gleb Smirnoff <glebius@FreeBSD.org> |
Merge fresh head.
|
| #
3fb3b97c
|
| 28-May-2013 |
Ed Maste <emaste@FreeBSD.org> |
Renumber clauses to reduce diffs to other versions
NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3, so follow suit to make comparison easier.
|
| #
6a068746
|
| 15-May-2012 |
Alexander Motin <mav@FreeBSD.org> |
MFC
|
| #
38f1b189
|
| 26-Apr-2012 |
Peter Grehan <grehan@FreeBSD.org> |
IFC @ r234692
sys/amd64/include/cpufunc.h sys/amd64/include/fpu.h sys/amd64/amd64/fpu.c sys/amd64/vmm/vmm.c
- Add API to allow vmm FPU state init/save/restore.
FP stuff discussed with: kib
|
| #
867099fa
|
| 08-Mar-2012 |
Gleb Smirnoff <glebius@FreeBSD.org> |
Merge head up to r232685 to projects/pf/head.
|
| #
82725ba9
|
| 23-Nov-2017 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Merge ^/head r325999 through r326131.
|