These two modules implement the stdc_load8_* functions from the ISO C2y draft.
2026-03-12 Bruno Haible <[email protected]> stdc_load8: Add tests. * tests/test-stdc_load8.c: New file, based on tests/test-stdc_load8_aligned.c. * modules/stdc_load8-tests: New file. stdc_load8: New module. * lib/stdbit.in.h (_GL_STDC_LOAD8_INLINE): New macro. (stdc_load8_beu{8,16,32,64}, stdc_load8_leu{8,16,32,64}, stdc_load8_bes{8,16,32,64}, stdc_load8_les{8,16,32,64}): New functions. * lib/stdc_load8.c: New file. * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize GNULIB_STDC_LOAD8. * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_LOAD8. * modules/stdc_load8: New file. * doc/posix-functions/stdc_load8_beu8.texi: Mention the new module. * doc/posix-functions/stdc_load8_beu16.texi: Likewise. * doc/posix-functions/stdc_load8_beu32.texi: Likewise. * doc/posix-functions/stdc_load8_beu64.texi: Likewise. * doc/posix-functions/stdc_load8_leu8.texi: Likewise. * doc/posix-functions/stdc_load8_leu16.texi: Likewise. * doc/posix-functions/stdc_load8_leu32.texi: Likewise. * doc/posix-functions/stdc_load8_leu64.texi: Likewise. * doc/posix-functions/stdc_load8_bes8.texi: Likewise. * doc/posix-functions/stdc_load8_bes16.texi: Likewise. * doc/posix-functions/stdc_load8_bes32.texi: Likewise. * doc/posix-functions/stdc_load8_bes64.texi: Likewise. * doc/posix-functions/stdc_load8_les8.texi: Likewise. * doc/posix-functions/stdc_load8_les16.texi: Likewise. * doc/posix-functions/stdc_load8_les32.texi: Likewise. * doc/posix-functions/stdc_load8_les64.texi: Likewise. 2026-03-12 Bruno Haible <[email protected]> stdc_load8_aligned: Add tests. * tests/test-stdc_load8_aligned.c: New file. * modules/stdc_load8_aligned-tests: New file. stdc_load8_aligned: New module. * lib/stdbit.in.h: Include <stdint.h>, <byteswap.h>. (_GL_STDC_LOAD8_ALIGNED_INLINE): New macro. (stdc_load8_aligned_beu{8,16,32,64}, stdc_load8_aligned_leu{8,16,32,64}, stdc_load8_aligned_bes{8,16,32,64}, stdc_load8_aligned_les{8,16,32,64}): New functions. * lib/stdc_load8_aligned.c: New file. * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize GNULIB_STDC_LOAD8_ALIGNED. * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_LOAD8_ALIGNED. * modules/stdc_load8_aligned: New file. * doc/posix-functions/stdc_load8_aligned_beu8.texi: Mention the new module. * doc/posix-functions/stdc_load8_aligned_beu16.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_beu32.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_beu64.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_leu8.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_leu16.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_leu32.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_leu64.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_bes8.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_bes16.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_bes32.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_bes64.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_les8.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_les16.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_les32.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_les64.texi: Likewise.
From b4c079667180f2b1b711016e124884f5d7ed4a73 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Thu, 12 Mar 2026 15:31:41 +0100 Subject: [PATCH 1/4] stdc_load8_aligned: New module. * lib/stdbit.in.h: Include <stdint.h>, <byteswap.h>. (_GL_STDC_LOAD8_ALIGNED_INLINE): New macro. (stdc_load8_aligned_beu{8,16,32,64}, stdc_load8_aligned_leu{8,16,32,64}, stdc_load8_aligned_bes{8,16,32,64}, stdc_load8_aligned_les{8,16,32,64}): New functions. * lib/stdc_load8_aligned.c: New file. * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize GNULIB_STDC_LOAD8_ALIGNED. * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_LOAD8_ALIGNED. * modules/stdc_load8_aligned: New file. * doc/posix-functions/stdc_load8_aligned_beu8.texi: Mention the new module. * doc/posix-functions/stdc_load8_aligned_beu16.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_beu32.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_beu64.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_leu8.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_leu16.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_leu32.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_leu64.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_bes8.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_bes16.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_bes32.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_bes64.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_les8.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_les16.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_les32.texi: Likewise. * doc/posix-functions/stdc_load8_aligned_les64.texi: Likewise. --- ChangeLog | 33 +++- .../stdc_load8_aligned_bes16.texi | 9 +- .../stdc_load8_aligned_bes32.texi | 9 +- .../stdc_load8_aligned_bes64.texi | 9 +- .../stdc_load8_aligned_bes8.texi | 9 +- .../stdc_load8_aligned_beu16.texi | 9 +- .../stdc_load8_aligned_beu32.texi | 9 +- .../stdc_load8_aligned_beu64.texi | 9 +- .../stdc_load8_aligned_beu8.texi | 9 +- .../stdc_load8_aligned_les16.texi | 9 +- .../stdc_load8_aligned_les32.texi | 9 +- .../stdc_load8_aligned_les64.texi | 9 +- .../stdc_load8_aligned_les8.texi | 9 +- .../stdc_load8_aligned_leu16.texi | 9 +- .../stdc_load8_aligned_leu32.texi | 9 +- .../stdc_load8_aligned_leu64.texi | 9 +- .../stdc_load8_aligned_leu8.texi | 9 +- lib/stdbit.in.h | 177 ++++++++++++++++++ lib/stdc_load8_aligned.c | 19 ++ m4/stdbit_h.m4 | 3 +- modules/stdbit-h | 1 + modules/stdc_load8_aligned | 28 +++ 22 files changed, 339 insertions(+), 66 deletions(-) create mode 100644 lib/stdc_load8_aligned.c create mode 100644 modules/stdc_load8_aligned diff --git a/ChangeLog b/ChangeLog index 0945887002..97e88741ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,35 @@ -2026-03-09 Bruno Haible <[email protected]> +2026-03-12 Bruno Haible <[email protected]> + + stdc_load8_aligned: New module. + * lib/stdbit.in.h: Include <stdint.h>, <byteswap.h>. + (_GL_STDC_LOAD8_ALIGNED_INLINE): New macro. + (stdc_load8_aligned_beu{8,16,32,64}, stdc_load8_aligned_leu{8,16,32,64}, + stdc_load8_aligned_bes{8,16,32,64}, stdc_load8_aligned_les{8,16,32,64}): + New functions. + * lib/stdc_load8_aligned.c: New file. + * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize + GNULIB_STDC_LOAD8_ALIGNED. + * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_LOAD8_ALIGNED. + * modules/stdc_load8_aligned: New file. + * doc/posix-functions/stdc_load8_aligned_beu8.texi: Mention the new + module. + * doc/posix-functions/stdc_load8_aligned_beu16.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_beu32.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_beu64.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_leu8.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_leu16.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_leu32.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_leu64.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_bes8.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_bes16.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_bes32.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_bes64.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_les8.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_les16.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_les32.texi: Likewise. + * doc/posix-functions/stdc_load8_aligned_les64.texi: Likewise. + +2026-03-12 Bruno Haible <[email protected]> doc: Document C2y stdc_* <stdbit.h> functions, part 2. * doc/posix-functions/stdc_load8_aligned_bes8.texi: New file. diff --git a/doc/posix-functions/stdc_load8_aligned_bes16.texi b/doc/posix-functions/stdc_load8_aligned_bes16.texi index 70ca385782..a6f077165e 100644 --- a/doc/posix-functions/stdc_load8_aligned_bes16.texi +++ b/doc/posix-functions/stdc_load8_aligned_bes16.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_bes32.texi b/doc/posix-functions/stdc_load8_aligned_bes32.texi index e9c49cf808..0d39cdce2d 100644 --- a/doc/posix-functions/stdc_load8_aligned_bes32.texi +++ b/doc/posix-functions/stdc_load8_aligned_bes32.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_bes64.texi b/doc/posix-functions/stdc_load8_aligned_bes64.texi index 0c5fe26bd3..73e629f437 100644 --- a/doc/posix-functions/stdc_load8_aligned_bes64.texi +++ b/doc/posix-functions/stdc_load8_aligned_bes64.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_bes8.texi b/doc/posix-functions/stdc_load8_aligned_bes8.texi index 769359f8a5..10d90d0e15 100644 --- a/doc/posix-functions/stdc_load8_aligned_bes8.texi +++ b/doc/posix-functions/stdc_load8_aligned_bes8.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_beu16.texi b/doc/posix-functions/stdc_load8_aligned_beu16.texi index 7f32ebbd60..777257b0a5 100644 --- a/doc/posix-functions/stdc_load8_aligned_beu16.texi +++ b/doc/posix-functions/stdc_load8_aligned_beu16.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_beu32.texi b/doc/posix-functions/stdc_load8_aligned_beu32.texi index 20a9037cfa..43687d7d93 100644 --- a/doc/posix-functions/stdc_load8_aligned_beu32.texi +++ b/doc/posix-functions/stdc_load8_aligned_beu32.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_beu64.texi b/doc/posix-functions/stdc_load8_aligned_beu64.texi index 3ee7d85536..a730b4fa26 100644 --- a/doc/posix-functions/stdc_load8_aligned_beu64.texi +++ b/doc/posix-functions/stdc_load8_aligned_beu64.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_beu8.texi b/doc/posix-functions/stdc_load8_aligned_beu8.texi index abadb5bb92..e68886be4f 100644 --- a/doc/posix-functions/stdc_load8_aligned_beu8.texi +++ b/doc/posix-functions/stdc_load8_aligned_beu8.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_les16.texi b/doc/posix-functions/stdc_load8_aligned_les16.texi index 872965d071..b63f40ef09 100644 --- a/doc/posix-functions/stdc_load8_aligned_les16.texi +++ b/doc/posix-functions/stdc_load8_aligned_les16.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_les32.texi b/doc/posix-functions/stdc_load8_aligned_les32.texi index 89e5bafa2e..d074e3038a 100644 --- a/doc/posix-functions/stdc_load8_aligned_les32.texi +++ b/doc/posix-functions/stdc_load8_aligned_les32.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_les64.texi b/doc/posix-functions/stdc_load8_aligned_les64.texi index 753e14288f..c82a5a3b61 100644 --- a/doc/posix-functions/stdc_load8_aligned_les64.texi +++ b/doc/posix-functions/stdc_load8_aligned_les64.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_les8.texi b/doc/posix-functions/stdc_load8_aligned_les8.texi index 83863f4298..b1df2bb218 100644 --- a/doc/posix-functions/stdc_load8_aligned_les8.texi +++ b/doc/posix-functions/stdc_load8_aligned_les8.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_leu16.texi b/doc/posix-functions/stdc_load8_aligned_leu16.texi index 89eca836b9..8f70a6b907 100644 --- a/doc/posix-functions/stdc_load8_aligned_leu16.texi +++ b/doc/posix-functions/stdc_load8_aligned_leu16.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_leu32.texi b/doc/posix-functions/stdc_load8_aligned_leu32.texi index 286b71c805..236b744756 100644 --- a/doc/posix-functions/stdc_load8_aligned_leu32.texi +++ b/doc/posix-functions/stdc_load8_aligned_leu32.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_leu64.texi b/doc/posix-functions/stdc_load8_aligned_leu64.texi index 523217a222..7dcd47d56f 100644 --- a/doc/posix-functions/stdc_load8_aligned_leu64.texi +++ b/doc/posix-functions/stdc_load8_aligned_leu64.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_aligned_leu8.texi b/doc/posix-functions/stdc_load8_aligned_leu8.texi index 25d8155252..167fac2d3d 100644 --- a/doc/posix-functions/stdc_load8_aligned_leu8.texi +++ b/doc/posix-functions/stdc_load8_aligned_leu8.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8_aligned +@mindex stdc_load8_aligned Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index 7ea26926be..a26ce77292 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -37,6 +37,17 @@ #error "Please include config.h first." #endif +#if @GNULIB_STDC_LOAD8_ALIGNED@ + +/* Get int_least8_t, int_least16_t, int_least32_t, int_least64_t, + uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t. */ +# include <stdint.h> + +/* Get bswap_16, bswap_32, bswap_64. */ +# include <byteswap.h> + +#endif + _GL_INLINE_HEADER_BEGIN #ifndef _GL_STDBIT_INLINE @@ -84,6 +95,9 @@ _GL_INLINE_HEADER_BEGIN #ifndef _GL_STDC_BIT_CEIL_INLINE # define _GL_STDC_BIT_CEIL_INLINE _GL_INLINE #endif +#ifndef _GL_STDC_LOAD8_ALIGNED_INLINE +# define _GL_STDC_LOAD8_ALIGNED_INLINE _GL_INLINE +#endif /* An expression, preferably with the type of A, that has the value of B. */ #if ((defined __GNUC__ && 2 <= __GNUC__) \ @@ -1086,6 +1100,169 @@ stdc_bit_ceil_ull (unsigned long long int n) #endif /* @HAVE_STDBIT_H@ */ +/* ISO C2y ?? 7.18.21 Endian-Aware 8-Bit Load */ + +#if @GNULIB_STDC_LOAD8_ALIGNED@ + +_GL_STDC_LOAD8_ALIGNED_INLINE uint_least8_t +stdc_load8_aligned_beu8 (const unsigned char ptr[1]) +{ + return ptr[0]; +} + +_GL_STDC_LOAD8_ALIGNED_INLINE uint_least16_t +stdc_load8_aligned_beu16 (const unsigned char ptr[2]) +{ + uint16_t value = *(const uint16_t *)ptr; +# ifdef WORDS_BIGENDIAN + return value; +# else + return bswap_16 (value); +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE uint_least32_t +stdc_load8_aligned_beu32 (const unsigned char ptr[4]) +{ + uint32_t value = *(const uint32_t *)ptr; +# ifdef WORDS_BIGENDIAN + return value; +# else + return bswap_32 (value); +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE uint_least64_t +stdc_load8_aligned_beu64 (const unsigned char ptr[8]) +{ + uint64_t value = *(const uint64_t *)ptr; +# ifdef WORDS_BIGENDIAN + return value; +# else + return bswap_64 (value); +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE uint_least8_t +stdc_load8_aligned_leu8 (const unsigned char ptr[1]) +{ + return ptr[0]; +} + +_GL_STDC_LOAD8_ALIGNED_INLINE uint_least16_t +stdc_load8_aligned_leu16 (const unsigned char ptr[2]) +{ + uint16_t value = *(const uint16_t *)ptr; +# ifdef WORDS_BIGENDIAN + return bswap_16 (value); +# else + return value; +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE uint_least32_t +stdc_load8_aligned_leu32 (const unsigned char ptr[4]) +{ + uint32_t value = *(const uint32_t *)ptr; +# ifdef WORDS_BIGENDIAN + return bswap_32 (value); +# else + return value; +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE uint_least64_t +stdc_load8_aligned_leu64 (const unsigned char ptr[8]) +{ + uint64_t value = *(const uint64_t *)ptr; +# ifdef WORDS_BIGENDIAN + return bswap_64 (value); +# else + return value; +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE int_least8_t +stdc_load8_aligned_bes8 (const unsigned char ptr[1]) +{ + return *(signed char *)ptr; +} + +_GL_STDC_LOAD8_ALIGNED_INLINE int_least16_t +stdc_load8_aligned_bes16 (const unsigned char ptr[2]) +{ +# ifdef WORDS_BIGENDIAN + return *(const int16_t *)ptr; +# else + uint16_t value = *(const uint16_t *)ptr; + return (int16_t) bswap_16 (value); +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE int_least32_t +stdc_load8_aligned_bes32 (const unsigned char ptr[4]) +{ +# ifdef WORDS_BIGENDIAN + return *(const int32_t *)ptr; +# else + uint32_t value = *(const uint32_t *)ptr; + return (int32_t) bswap_32 (value); +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE int_least64_t +stdc_load8_aligned_bes64 (const unsigned char ptr[8]) +{ +# ifdef WORDS_BIGENDIAN + return *(const int64_t *)ptr; +# else + uint64_t value = *(const uint64_t *)ptr; + return (int64_t) bswap_64 (value); +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE int_least8_t +stdc_load8_aligned_les8 (const unsigned char ptr[1]) +{ + return *(signed char *)ptr; +} + +_GL_STDC_LOAD8_ALIGNED_INLINE int_least16_t +stdc_load8_aligned_les16 (const unsigned char ptr[2]) +{ +# ifdef WORDS_BIGENDIAN + uint16_t value = *(const uint16_t *)ptr; + return (int16_t) bswap_16 (value); +# else + return *(const int16_t *)ptr; +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE int_least32_t +stdc_load8_aligned_les32 (const unsigned char ptr[4]) +{ +# ifdef WORDS_BIGENDIAN + uint32_t value = *(const uint32_t *)ptr; + return (int32_t) bswap_32 (value); +# else + return *(const int32_t *)ptr; +# endif +} + +_GL_STDC_LOAD8_ALIGNED_INLINE int_least64_t +stdc_load8_aligned_les64 (const unsigned char ptr[8]) +{ +# ifdef WORDS_BIGENDIAN + uint64_t value = *(const uint64_t *)ptr; + return (int64_t) bswap_64 (value); +# else + return *(const int64_t *)ptr; +# endif +} + +#endif + + #ifdef __cplusplus } #endif diff --git a/lib/stdc_load8_aligned.c b/lib/stdc_load8_aligned.c new file mode 100644 index 0000000000..c82387626a --- /dev/null +++ b/lib/stdc_load8_aligned.c @@ -0,0 +1,19 @@ +/* stdc_load8_aligned_* functions. + Copyright (C) 2026 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#define _GL_STDC_LOAD8_ALIGNED_INLINE _GL_EXTERN_INLINE +#include <config.h> +#include <stdbit.h> diff --git a/m4/stdbit_h.m4 b/m4/stdbit_h.m4 index 3328644e2d..31f82c375c 100644 --- a/m4/stdbit_h.m4 +++ b/m4/stdbit_h.m4 @@ -1,5 +1,5 @@ # stdbit_h.m4 -# serial 5 +# serial 6 dnl Copyright 2024-2026 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -66,6 +66,7 @@ AC_DEFUN([gl_STDBIT_H_REQUIRE_DEFAULTS] gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_BIT_WIDTH]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_BIT_FLOOR]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_BIT_CEIL]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_LOAD8_ALIGNED]) ]) m4_require(GL_MODULE_INDICATOR_PREFIX[_STDBIT_H_MODULE_INDICATOR_DEFAULTS]) AC_REQUIRE([gl_STDBIT_H_DEFAULTS]) diff --git a/modules/stdbit-h b/modules/stdbit-h index 7c739fbd48..69e4a3ea19 100644 --- a/modules/stdbit-h +++ b/modules/stdbit-h @@ -46,6 +46,7 @@ stdbit.h: stdbit.in.h $(top_builddir)/config.status -e 's/@''GNULIB_STDC_BIT_WIDTH''@/$(GNULIB_STDC_BIT_WIDTH)/g' \ -e 's/@''GNULIB_STDC_BIT_FLOOR''@/$(GNULIB_STDC_BIT_FLOOR)/g' \ -e 's/@''GNULIB_STDC_BIT_CEIL''@/$(GNULIB_STDC_BIT_CEIL)/g' \ + -e 's/@''GNULIB_STDC_LOAD8_ALIGNED''@/$(GNULIB_STDC_LOAD8_ALIGNED)/g' \ $(srcdir)/stdbit.in.h > $@-t $(AM_V_at)mv $@-t $@ lib_SOURCES += stdbit.c diff --git a/modules/stdc_load8_aligned b/modules/stdc_load8_aligned new file mode 100644 index 0000000000..9d312218fe --- /dev/null +++ b/modules/stdc_load8_aligned @@ -0,0 +1,28 @@ +Description: +stdc_load8_aligned_* functions: Endian-aware loading of a few bytes. + +Files: +lib/stdc_load8_aligned.c + +Depends-on: +stdbit-h +stdint-h +byteswap + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +gl_STDBIT_MODULE_INDICATOR([stdc_load8_aligned]) + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_load8_aligned.c +endif + +Include: +<stdbit.h> + +License: +LGPLv2+ + +Maintainer: +all -- 2.52.0
>From f8e0085058ed03c9792fe479969a1f53a87e872f Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Thu, 12 Mar 2026 19:37:52 +0100 Subject: [PATCH 2/4] stdc_load8_aligned: Add tests. * tests/test-stdc_load8_aligned.c: New file. * modules/stdc_load8_aligned-tests: New file. --- ChangeLog | 4 + modules/stdc_load8_aligned-tests | 11 ++ tests/test-stdc_load8_aligned.c | 186 +++++++++++++++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 modules/stdc_load8_aligned-tests create mode 100644 tests/test-stdc_load8_aligned.c diff --git a/ChangeLog b/ChangeLog index 97e88741ee..603cf779ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2026-03-12 Bruno Haible <[email protected]> + stdc_load8_aligned: Add tests. + * tests/test-stdc_load8_aligned.c: New file. + * modules/stdc_load8_aligned-tests: New file. + stdc_load8_aligned: New module. * lib/stdbit.in.h: Include <stdint.h>, <byteswap.h>. (_GL_STDC_LOAD8_ALIGNED_INLINE): New macro. diff --git a/modules/stdc_load8_aligned-tests b/modules/stdc_load8_aligned-tests new file mode 100644 index 0000000000..86a8bc6daa --- /dev/null +++ b/modules/stdc_load8_aligned-tests @@ -0,0 +1,11 @@ +Files: +tests/test-stdc_load8_aligned.c +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-stdc_load8_aligned +check_PROGRAMS += test-stdc_load8_aligned diff --git a/tests/test-stdc_load8_aligned.c b/tests/test-stdc_load8_aligned.c new file mode 100644 index 0000000000..2aa285059d --- /dev/null +++ b/tests/test-stdc_load8_aligned.c @@ -0,0 +1,186 @@ +/* Test of stdc_load8_aligned_* functions. + Copyright (C) 2026 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <[email protected]>, 2026. */ + +#include <config.h> + +#include <stdbit.h> + +#include "macros.h" + +static void +test_stdc_load8_aligned_beu8 (void) +{ + static unsigned char data[1] = { 0xD5 }; + uint8_t result = stdc_load8_aligned_beu8 (data); + ASSERT (result == 0xD5); +} + +static void +test_stdc_load8_aligned_beu16 (void) +{ + static union { unsigned char bytes[2]; uint16_t align; } data = + { { 0xD5, 0xE6 } }; + uint16_t result = stdc_load8_aligned_beu16 (data.bytes); + ASSERT (result == 0xD5E6); +} + +static void +test_stdc_load8_aligned_beu32 (void) +{ + static union { unsigned char bytes[4]; uint32_t align; } data = + { { 0xD5, 0xE6, 0xC2, 0xF4 } }; + uint32_t result = stdc_load8_aligned_beu32 (data.bytes); + ASSERT (result == 0xD5E6C2F4U); +} + +static void +test_stdc_load8_aligned_beu64 (void) +{ + static union { unsigned char bytes[8]; uint64_t align; } data = + { { 0xD5, 0xE6, 0xC2, 0xF4, 0xF1, 0xC9, 0xEA, 0xDF } }; + uint64_t result = stdc_load8_aligned_beu64 (data.bytes); + ASSERT (result == 0xD5E6C2F4F1C9EADFULL); +} + +static void +test_stdc_load8_aligned_leu8 (void) +{ + static unsigned char data[1] = { 0xD5 }; + uint8_t result = stdc_load8_aligned_leu8 (data); + ASSERT (result == 0xD5); +} + +static void +test_stdc_load8_aligned_leu16 (void) +{ + static union { unsigned char bytes[2]; uint16_t align; } data = + { { 0xD5, 0xE6 } }; + uint16_t result = stdc_load8_aligned_leu16 (data.bytes); + ASSERT (result == 0xE6D5); +} + +static void +test_stdc_load8_aligned_leu32 (void) +{ + static union { unsigned char bytes[4]; uint32_t align; } data = + { { 0xD5, 0xE6, 0xC2, 0xF4 } }; + uint32_t result = stdc_load8_aligned_leu32 (data.bytes); + ASSERT (result == 0xF4C2E6D5U); +} + +static void +test_stdc_load8_aligned_leu64 (void) +{ + static union { unsigned char bytes[8]; uint64_t align; } data = + { { 0xD5, 0xE6, 0xC2, 0xF4, 0xF1, 0xC9, 0xEA, 0xDF } }; + uint64_t result = stdc_load8_aligned_leu64 (data.bytes); + ASSERT (result == 0xDFEAC9F1F4C2E6D5ULL); +} + +static void +test_stdc_load8_aligned_bes8 (void) +{ + static unsigned char data[1] = { 0xD5 }; + int8_t result = stdc_load8_aligned_bes8 (data); + ASSERT (result == (int8_t) 0xD5); +} + +static void +test_stdc_load8_aligned_bes16 (void) +{ + static union { unsigned char bytes[2]; int16_t align; } data = + { { 0xD5, 0xE6 } }; + int16_t result = stdc_load8_aligned_bes16 (data.bytes); + ASSERT (result == (int16_t) 0xD5E6); +} + +static void +test_stdc_load8_aligned_bes32 (void) +{ + static union { unsigned char bytes[4]; int32_t align; } data = + { { 0xD5, 0xE6, 0xC2, 0xF4 } }; + int32_t result = stdc_load8_aligned_bes32 (data.bytes); + ASSERT (result == 0xD5E6C2F4); +} + +static void +test_stdc_load8_aligned_bes64 (void) +{ + static union { unsigned char bytes[8]; int64_t align; } data = + { { 0xD5, 0xE6, 0xC2, 0xF4, 0xF1, 0xC9, 0xEA, 0xDF } }; + int64_t result = stdc_load8_aligned_bes64 (data.bytes); + ASSERT (result == 0xD5E6C2F4F1C9EADFLL); +} + +static void +test_stdc_load8_aligned_les8 (void) +{ + static unsigned char data[1] = { 0xD5 }; + int8_t result = stdc_load8_aligned_les8 (data); + ASSERT (result == (int8_t) 0xD5); +} + +static void +test_stdc_load8_aligned_les16 (void) +{ + static union { unsigned char bytes[2]; int16_t align; } data = + { { 0xD5, 0xE6 } }; + int16_t result = stdc_load8_aligned_les16 (data.bytes); + ASSERT (result == (int16_t) 0xE6D5); +} + +static void +test_stdc_load8_aligned_les32 (void) +{ + static union { unsigned char bytes[4]; int32_t align; } data = + { { 0xD5, 0xE6, 0xC2, 0xF4 } }; + int32_t result = stdc_load8_aligned_les32 (data.bytes); + ASSERT (result == 0xF4C2E6D5); +} + +static void +test_stdc_load8_aligned_les64 (void) +{ + static union { unsigned char bytes[8]; int64_t align; } data = + { { 0xD5, 0xE6, 0xC2, 0xF4, 0xF1, 0xC9, 0xEA, 0xDF } }; + int64_t result = stdc_load8_aligned_les64 (data.bytes); + ASSERT (result == 0xDFEAC9F1F4C2E6D5LL); +} + +int +main () +{ + test_stdc_load8_aligned_beu8 (); + test_stdc_load8_aligned_beu16 (); + test_stdc_load8_aligned_beu32 (); + test_stdc_load8_aligned_beu64 (); + test_stdc_load8_aligned_leu8 (); + test_stdc_load8_aligned_leu16 (); + test_stdc_load8_aligned_leu32 (); + test_stdc_load8_aligned_leu64 (); + test_stdc_load8_aligned_bes8 (); + test_stdc_load8_aligned_bes16 (); + test_stdc_load8_aligned_bes32 (); + test_stdc_load8_aligned_bes64 (); + test_stdc_load8_aligned_les8 (); + test_stdc_load8_aligned_les16 (); + test_stdc_load8_aligned_les32 (); + test_stdc_load8_aligned_les64 (); + + return test_exit_status; +} -- 2.52.0
>From dc3770cc98b839dec509ece03ddfb927093373e5 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Thu, 12 Mar 2026 20:37:13 +0100 Subject: [PATCH 3/4] stdc_load8: New module. * lib/stdbit.in.h (_GL_STDC_LOAD8_INLINE): New macro. (stdc_load8_beu{8,16,32,64}, stdc_load8_leu{8,16,32,64}, stdc_load8_bes{8,16,32,64}, stdc_load8_les{8,16,32,64}): New functions. * lib/stdc_load8.c: New file. * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize GNULIB_STDC_LOAD8. * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_LOAD8. * modules/stdc_load8: New file. * doc/posix-functions/stdc_load8_beu8.texi: Mention the new module. * doc/posix-functions/stdc_load8_beu16.texi: Likewise. * doc/posix-functions/stdc_load8_beu32.texi: Likewise. * doc/posix-functions/stdc_load8_beu64.texi: Likewise. * doc/posix-functions/stdc_load8_leu8.texi: Likewise. * doc/posix-functions/stdc_load8_leu16.texi: Likewise. * doc/posix-functions/stdc_load8_leu32.texi: Likewise. * doc/posix-functions/stdc_load8_leu64.texi: Likewise. * doc/posix-functions/stdc_load8_bes8.texi: Likewise. * doc/posix-functions/stdc_load8_bes16.texi: Likewise. * doc/posix-functions/stdc_load8_bes32.texi: Likewise. * doc/posix-functions/stdc_load8_bes64.texi: Likewise. * doc/posix-functions/stdc_load8_les8.texi: Likewise. * doc/posix-functions/stdc_load8_les16.texi: Likewise. * doc/posix-functions/stdc_load8_les32.texi: Likewise. * doc/posix-functions/stdc_load8_les64.texi: Likewise. --- ChangeLog | 28 +++++ doc/posix-functions/stdc_load8_bes16.texi | 9 +- doc/posix-functions/stdc_load8_bes32.texi | 9 +- doc/posix-functions/stdc_load8_bes64.texi | 9 +- doc/posix-functions/stdc_load8_bes8.texi | 9 +- doc/posix-functions/stdc_load8_beu16.texi | 9 +- doc/posix-functions/stdc_load8_beu32.texi | 9 +- doc/posix-functions/stdc_load8_beu64.texi | 9 +- doc/posix-functions/stdc_load8_beu8.texi | 9 +- doc/posix-functions/stdc_load8_les16.texi | 9 +- doc/posix-functions/stdc_load8_les32.texi | 9 +- doc/posix-functions/stdc_load8_les64.texi | 9 +- doc/posix-functions/stdc_load8_les8.texi | 9 +- doc/posix-functions/stdc_load8_leu16.texi | 9 +- doc/posix-functions/stdc_load8_leu32.texi | 9 +- doc/posix-functions/stdc_load8_leu64.texi | 9 +- doc/posix-functions/stdc_load8_leu8.texi | 9 +- lib/stdbit.in.h | 129 +++++++++++++++++++++- lib/stdc_load8.c | 19 ++++ m4/stdbit_h.m4 | 3 +- modules/stdbit-h | 1 + modules/stdc_load8 | 27 +++++ 22 files changed, 285 insertions(+), 66 deletions(-) create mode 100644 lib/stdc_load8.c create mode 100644 modules/stdc_load8 diff --git a/ChangeLog b/ChangeLog index 603cf779ca..8bb1cdfdc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2026-03-12 Bruno Haible <[email protected]> + + stdc_load8: New module. + * lib/stdbit.in.h (_GL_STDC_LOAD8_INLINE): New macro. + (stdc_load8_beu{8,16,32,64}, stdc_load8_leu{8,16,32,64}, + stdc_load8_bes{8,16,32,64}, stdc_load8_les{8,16,32,64}): New functions. + * lib/stdc_load8.c: New file. + * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize + GNULIB_STDC_LOAD8. + * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_LOAD8. + * modules/stdc_load8: New file. + * doc/posix-functions/stdc_load8_beu8.texi: Mention the new module. + * doc/posix-functions/stdc_load8_beu16.texi: Likewise. + * doc/posix-functions/stdc_load8_beu32.texi: Likewise. + * doc/posix-functions/stdc_load8_beu64.texi: Likewise. + * doc/posix-functions/stdc_load8_leu8.texi: Likewise. + * doc/posix-functions/stdc_load8_leu16.texi: Likewise. + * doc/posix-functions/stdc_load8_leu32.texi: Likewise. + * doc/posix-functions/stdc_load8_leu64.texi: Likewise. + * doc/posix-functions/stdc_load8_bes8.texi: Likewise. + * doc/posix-functions/stdc_load8_bes16.texi: Likewise. + * doc/posix-functions/stdc_load8_bes32.texi: Likewise. + * doc/posix-functions/stdc_load8_bes64.texi: Likewise. + * doc/posix-functions/stdc_load8_les8.texi: Likewise. + * doc/posix-functions/stdc_load8_les16.texi: Likewise. + * doc/posix-functions/stdc_load8_les32.texi: Likewise. + * doc/posix-functions/stdc_load8_les64.texi: Likewise. + 2026-03-12 Bruno Haible <[email protected]> stdc_load8_aligned: Add tests. diff --git a/doc/posix-functions/stdc_load8_bes16.texi b/doc/posix-functions/stdc_load8_bes16.texi index 8f94a58ac1..9801f59702 100644 --- a/doc/posix-functions/stdc_load8_bes16.texi +++ b/doc/posix-functions/stdc_load8_bes16.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_bes32.texi b/doc/posix-functions/stdc_load8_bes32.texi index 37ee0e72c1..c86c1b307e 100644 --- a/doc/posix-functions/stdc_load8_bes32.texi +++ b/doc/posix-functions/stdc_load8_bes32.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_bes64.texi b/doc/posix-functions/stdc_load8_bes64.texi index a4dd1896c2..716d609864 100644 --- a/doc/posix-functions/stdc_load8_bes64.texi +++ b/doc/posix-functions/stdc_load8_bes64.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_bes8.texi b/doc/posix-functions/stdc_load8_bes8.texi index 24cd7ec159..a84185ea8d 100644 --- a/doc/posix-functions/stdc_load8_bes8.texi +++ b/doc/posix-functions/stdc_load8_bes8.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_beu16.texi b/doc/posix-functions/stdc_load8_beu16.texi index d2f844e3a5..b3eb5e020f 100644 --- a/doc/posix-functions/stdc_load8_beu16.texi +++ b/doc/posix-functions/stdc_load8_beu16.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_beu32.texi b/doc/posix-functions/stdc_load8_beu32.texi index 7c50db4c83..c853598acf 100644 --- a/doc/posix-functions/stdc_load8_beu32.texi +++ b/doc/posix-functions/stdc_load8_beu32.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_beu64.texi b/doc/posix-functions/stdc_load8_beu64.texi index a63a60ec82..980191b98f 100644 --- a/doc/posix-functions/stdc_load8_beu64.texi +++ b/doc/posix-functions/stdc_load8_beu64.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_beu8.texi b/doc/posix-functions/stdc_load8_beu8.texi index 20fc1a1ceb..a7d0a5741b 100644 --- a/doc/posix-functions/stdc_load8_beu8.texi +++ b/doc/posix-functions/stdc_load8_beu8.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_les16.texi b/doc/posix-functions/stdc_load8_les16.texi index 872bfa74fe..3d83af3468 100644 --- a/doc/posix-functions/stdc_load8_les16.texi +++ b/doc/posix-functions/stdc_load8_les16.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_les32.texi b/doc/posix-functions/stdc_load8_les32.texi index 31fa9307ca..4bdd948624 100644 --- a/doc/posix-functions/stdc_load8_les32.texi +++ b/doc/posix-functions/stdc_load8_les32.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_les64.texi b/doc/posix-functions/stdc_load8_les64.texi index 0e8bca6511..186ac64f97 100644 --- a/doc/posix-functions/stdc_load8_les64.texi +++ b/doc/posix-functions/stdc_load8_les64.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_les8.texi b/doc/posix-functions/stdc_load8_les8.texi index 461395ea73..c8cb49bd75 100644 --- a/doc/posix-functions/stdc_load8_les8.texi +++ b/doc/posix-functions/stdc_load8_les8.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_leu16.texi b/doc/posix-functions/stdc_load8_leu16.texi index 563da34f3c..7efaf5108b 100644 --- a/doc/posix-functions/stdc_load8_leu16.texi +++ b/doc/posix-functions/stdc_load8_leu16.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_leu32.texi b/doc/posix-functions/stdc_load8_leu32.texi index 9f273bd41b..58d0759891 100644 --- a/doc/posix-functions/stdc_load8_leu32.texi +++ b/doc/posix-functions/stdc_load8_leu32.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_leu64.texi b/doc/posix-functions/stdc_load8_leu64.texi index b91a2dc20c..0b5ce4efd6 100644 --- a/doc/posix-functions/stdc_load8_leu64.texi +++ b/doc/posix-functions/stdc_load8_leu64.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/doc/posix-functions/stdc_load8_leu8.texi b/doc/posix-functions/stdc_load8_leu8.texi index b2c62b5159..1f8b41b339 100644 --- a/doc/posix-functions/stdc_load8_leu8.texi +++ b/doc/posix-functions/stdc_load8_leu8.texi @@ -7,15 +7,16 @@ @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.21. -Gnulib module: --- +Gnulib module: stdc_load8 +@mindex stdc_load8 Portability problems fixed by Gnulib: @itemize +@item +This function is missing on many platforms: +glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on many platforms: -glibc 2.43, macOS 26, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.8, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15. @end itemize diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index a26ce77292..e171606e25 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -37,12 +37,16 @@ #error "Please include config.h first." #endif -#if @GNULIB_STDC_LOAD8_ALIGNED@ +#if @GNULIB_STDC_LOAD8_ALIGNED@ || @GNULIB_STDC_LOAD8@ /* Get int_least8_t, int_least16_t, int_least32_t, int_least64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t. */ # include <stdint.h> +#endif + +#if @GNULIB_STDC_LOAD8_ALIGNED@ + /* Get bswap_16, bswap_32, bswap_64. */ # include <byteswap.h> @@ -98,6 +102,9 @@ _GL_INLINE_HEADER_BEGIN #ifndef _GL_STDC_LOAD8_ALIGNED_INLINE # define _GL_STDC_LOAD8_ALIGNED_INLINE _GL_INLINE #endif +#ifndef _GL_STDC_LOAD8_INLINE +# define _GL_STDC_LOAD8_INLINE _GL_INLINE +#endif /* An expression, preferably with the type of A, that has the value of B. */ #if ((defined __GNUC__ && 2 <= __GNUC__) \ @@ -1262,6 +1269,126 @@ stdc_load8_aligned_les64 (const unsigned char ptr[8]) #endif +#if @GNULIB_STDC_LOAD8@ + +_GL_STDC_LOAD8_INLINE uint_least8_t +stdc_load8_beu8 (const unsigned char ptr[1]) +{ + return ptr[0]; +} + +_GL_STDC_LOAD8_INLINE uint_least16_t +stdc_load8_beu16 (const unsigned char ptr[2]) +{ + return ((uint_fast16_t) ptr[0] << 8) | (uint_fast16_t) ptr[1]; +} + +_GL_STDC_LOAD8_INLINE uint_least32_t +stdc_load8_beu32 (const unsigned char ptr[4]) +{ + return ((uint_fast32_t) ptr[0] << 24) | ((uint_fast32_t) ptr[1] << 16) + | ((uint_fast32_t) ptr[2] << 8) | (uint_fast32_t) ptr[3]; +} + +_GL_STDC_LOAD8_INLINE uint_least64_t +stdc_load8_beu64 (const unsigned char ptr[8]) +{ + return ((uint_fast64_t) ptr[0] << 56) | ((uint_fast64_t) ptr[1] << 48) + | ((uint_fast64_t) ptr[2] << 40) | ((uint_fast64_t) ptr[3] << 32) + | ((uint_fast64_t) ptr[4] << 24) | ((uint_fast64_t) ptr[5] << 16) + | ((uint_fast64_t) ptr[6] << 8) | (uint_fast64_t) ptr[7]; +} + +_GL_STDC_LOAD8_INLINE uint_least8_t +stdc_load8_leu8 (const unsigned char ptr[1]) +{ + return ptr[0]; +} + +_GL_STDC_LOAD8_INLINE uint_least16_t +stdc_load8_leu16 (const unsigned char ptr[2]) +{ + return (uint_fast16_t) ptr[0] | ((uint_fast16_t) ptr[1] << 8); +} + +_GL_STDC_LOAD8_INLINE uint_least32_t +stdc_load8_leu32 (const unsigned char ptr[4]) +{ + return (uint_fast32_t) ptr[0] | ((uint_fast32_t) ptr[1] << 8) + | ((uint_fast32_t) ptr[2] << 16) | ((uint_fast32_t) ptr[3] << 24); +} + +_GL_STDC_LOAD8_INLINE uint_least64_t +stdc_load8_leu64 (const unsigned char ptr[8]) +{ + return (uint_fast64_t) ptr[0] | ((uint_fast64_t) ptr[1] << 8) + | ((uint_fast64_t) ptr[2] << 16) | ((uint_fast64_t) ptr[3] << 24) + | ((uint_fast64_t) ptr[4] << 32) | ((uint_fast64_t) ptr[5] << 40) + | ((uint_fast64_t) ptr[6] << 48) | ((uint_fast64_t) ptr[7] << 56); +} + +_GL_STDC_LOAD8_INLINE int_least8_t +stdc_load8_bes8 (const unsigned char ptr[1]) +{ + return *(signed char *)ptr; +} + +_GL_STDC_LOAD8_INLINE int_least16_t +stdc_load8_bes16 (const unsigned char ptr[2]) +{ + return (int16_t) (((uint_fast16_t) ptr[0] << 8) | (uint_fast16_t) ptr[1]); +} + +_GL_STDC_LOAD8_INLINE int_least32_t +stdc_load8_bes32 (const unsigned char ptr[4]) +{ + return (int32_t) + (((uint_fast32_t) ptr[0] << 24) | ((uint_fast32_t) ptr[1] << 16) + | ((uint_fast32_t) ptr[2] << 8) | (uint_fast32_t) ptr[3]); +} + +_GL_STDC_LOAD8_INLINE int_least64_t +stdc_load8_bes64 (const unsigned char ptr[8]) +{ + return (int64_t) + (((uint_fast64_t) ptr[0] << 56) | ((uint_fast64_t) ptr[1] << 48) + | ((uint_fast64_t) ptr[2] << 40) | ((uint_fast64_t) ptr[3] << 32) + | ((uint_fast64_t) ptr[4] << 24) | ((uint_fast64_t) ptr[5] << 16) + | ((uint_fast64_t) ptr[6] << 8) | (uint_fast64_t) ptr[7]); +} + +_GL_STDC_LOAD8_INLINE int_least8_t +stdc_load8_les8 (const unsigned char ptr[1]) +{ + return *(signed char *)ptr; +} + +_GL_STDC_LOAD8_INLINE int_least16_t +stdc_load8_les16 (const unsigned char ptr[2]) +{ + return (int16_t) ((uint_fast16_t) ptr[0] | ((uint_fast16_t) ptr[1] << 8)); +} + +_GL_STDC_LOAD8_INLINE int_least32_t +stdc_load8_les32 (const unsigned char ptr[4]) +{ + return (int32_t) + ((uint_fast32_t) ptr[0] | ((uint_fast32_t) ptr[1] << 8) + | ((uint_fast32_t) ptr[2] << 16) | ((uint_fast32_t) ptr[3] << 24)); +} + +_GL_STDC_LOAD8_INLINE int_least64_t +stdc_load8_les64 (const unsigned char ptr[8]) +{ + return (int64_t) + ((uint_fast64_t) ptr[0] | ((uint_fast64_t) ptr[1] << 8) + | ((uint_fast64_t) ptr[2] << 16) | ((uint_fast64_t) ptr[3] << 24) + | ((uint_fast64_t) ptr[4] << 32) | ((uint_fast64_t) ptr[5] << 40) + | ((uint_fast64_t) ptr[6] << 48) | ((uint_fast64_t) ptr[7] << 56)); +} + +#endif + #ifdef __cplusplus } diff --git a/lib/stdc_load8.c b/lib/stdc_load8.c new file mode 100644 index 0000000000..af3d4118fc --- /dev/null +++ b/lib/stdc_load8.c @@ -0,0 +1,19 @@ +/* stdc_load8_* (unaligned) functions. + Copyright (C) 2026 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +#define _GL_STDC_LOAD8_INLINE _GL_EXTERN_INLINE +#include <config.h> +#include <stdbit.h> diff --git a/m4/stdbit_h.m4 b/m4/stdbit_h.m4 index 31f82c375c..7872902b6c 100644 --- a/m4/stdbit_h.m4 +++ b/m4/stdbit_h.m4 @@ -1,5 +1,5 @@ # stdbit_h.m4 -# serial 6 +# serial 7 dnl Copyright 2024-2026 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -67,6 +67,7 @@ AC_DEFUN([gl_STDBIT_H_REQUIRE_DEFAULTS] gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_BIT_FLOOR]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_BIT_CEIL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_LOAD8_ALIGNED]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_LOAD8]) ]) m4_require(GL_MODULE_INDICATOR_PREFIX[_STDBIT_H_MODULE_INDICATOR_DEFAULTS]) AC_REQUIRE([gl_STDBIT_H_DEFAULTS]) diff --git a/modules/stdbit-h b/modules/stdbit-h index 69e4a3ea19..2e4ca2ebcc 100644 --- a/modules/stdbit-h +++ b/modules/stdbit-h @@ -47,6 +47,7 @@ stdbit.h: stdbit.in.h $(top_builddir)/config.status -e 's/@''GNULIB_STDC_BIT_FLOOR''@/$(GNULIB_STDC_BIT_FLOOR)/g' \ -e 's/@''GNULIB_STDC_BIT_CEIL''@/$(GNULIB_STDC_BIT_CEIL)/g' \ -e 's/@''GNULIB_STDC_LOAD8_ALIGNED''@/$(GNULIB_STDC_LOAD8_ALIGNED)/g' \ + -e 's/@''GNULIB_STDC_LOAD8''@/$(GNULIB_STDC_LOAD8)/g' \ $(srcdir)/stdbit.in.h > $@-t $(AM_V_at)mv $@-t $@ lib_SOURCES += stdbit.c diff --git a/modules/stdc_load8 b/modules/stdc_load8 new file mode 100644 index 0000000000..db82fc11d4 --- /dev/null +++ b/modules/stdc_load8 @@ -0,0 +1,27 @@ +Description: +stdc_load8_* (unaligned) functions: Endian-aware loading of a few bytes. + +Files: +lib/stdc_load8.c + +Depends-on: +stdbit-h +stdint-h + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +gl_STDBIT_MODULE_INDICATOR([stdc_load8]) + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_load8.c +endif + +Include: +<stdbit.h> + +License: +LGPLv2+ + +Maintainer: +all -- 2.52.0
>From b95d0eb8bba8dbe51546dd15acf9150dbf19be3f Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Thu, 12 Mar 2026 20:38:27 +0100 Subject: [PATCH 4/4] stdc_load8: Add tests. * tests/test-stdc_load8.c: New file, based on tests/test-stdc_load8_aligned.c. * modules/stdc_load8-tests: New file. --- ChangeLog | 5 ++ modules/stdc_load8-tests | 11 +++ tests/test-stdc_load8.c | 186 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 modules/stdc_load8-tests create mode 100644 tests/test-stdc_load8.c diff --git a/ChangeLog b/ChangeLog index 8bb1cdfdc4..e9a7699cd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2026-03-12 Bruno Haible <[email protected]> + stdc_load8: Add tests. + * tests/test-stdc_load8.c: New file, based on + tests/test-stdc_load8_aligned.c. + * modules/stdc_load8-tests: New file. + stdc_load8: New module. * lib/stdbit.in.h (_GL_STDC_LOAD8_INLINE): New macro. (stdc_load8_beu{8,16,32,64}, stdc_load8_leu{8,16,32,64}, diff --git a/modules/stdc_load8-tests b/modules/stdc_load8-tests new file mode 100644 index 0000000000..6ec3bdfe44 --- /dev/null +++ b/modules/stdc_load8-tests @@ -0,0 +1,11 @@ +Files: +tests/test-stdc_load8.c +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-stdc_load8 +check_PROGRAMS += test-stdc_load8 diff --git a/tests/test-stdc_load8.c b/tests/test-stdc_load8.c new file mode 100644 index 0000000000..ebb4ef97a8 --- /dev/null +++ b/tests/test-stdc_load8.c @@ -0,0 +1,186 @@ +/* Test of stdc_load8_* (unaligned) functions. + Copyright (C) 2026 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <[email protected]>, 2026. */ + +#include <config.h> + +#include <stdbit.h> + +#include "macros.h" + +static void +test_stdc_load8_beu8 (void) +{ + static unsigned char data[1] = { 0xD5 }; + uint8_t result = stdc_load8_beu8 (data); + ASSERT (result == 0xD5); +} + +static void +test_stdc_load8_beu16 (void) +{ + static union { unsigned char bytes[1 + 2]; uint16_t align; } data = + { { 0, 0xD5, 0xE6 } }; + uint16_t result = stdc_load8_beu16 (data.bytes + 1); + ASSERT (result == 0xD5E6); +} + +static void +test_stdc_load8_beu32 (void) +{ + static union { unsigned char bytes[1 + 4]; uint32_t align; } data = + { { 0, 0xD5, 0xE6, 0xC2, 0xF4 } }; + uint32_t result = stdc_load8_beu32 (data.bytes + 1); + ASSERT (result == 0xD5E6C2F4U); +} + +static void +test_stdc_load8_beu64 (void) +{ + static union { unsigned char bytes[1 + 8]; uint64_t align; } data = + { { 0, 0xD5, 0xE6, 0xC2, 0xF4, 0xF1, 0xC9, 0xEA, 0xDF } }; + uint64_t result = stdc_load8_beu64 (data.bytes + 1); + ASSERT (result == 0xD5E6C2F4F1C9EADFULL); +} + +static void +test_stdc_load8_leu8 (void) +{ + static unsigned char data[1] = { 0xD5 }; + uint8_t result = stdc_load8_leu8 (data); + ASSERT (result == 0xD5); +} + +static void +test_stdc_load8_leu16 (void) +{ + static union { unsigned char bytes[1 + 2]; uint16_t align; } data = + { { 0, 0xD5, 0xE6 } }; + uint16_t result = stdc_load8_leu16 (data.bytes + 1); + ASSERT (result == 0xE6D5); +} + +static void +test_stdc_load8_leu32 (void) +{ + static union { unsigned char bytes[1 + 4]; uint32_t align; } data = + { { 0, 0xD5, 0xE6, 0xC2, 0xF4 } }; + uint32_t result = stdc_load8_leu32 (data.bytes + 1); + ASSERT (result == 0xF4C2E6D5U); +} + +static void +test_stdc_load8_leu64 (void) +{ + static union { unsigned char bytes[1 + 8]; uint64_t align; } data = + { { 0, 0xD5, 0xE6, 0xC2, 0xF4, 0xF1, 0xC9, 0xEA, 0xDF } }; + uint64_t result = stdc_load8_leu64 (data.bytes + 1); + ASSERT (result == 0xDFEAC9F1F4C2E6D5ULL); +} + +static void +test_stdc_load8_bes8 (void) +{ + static unsigned char data[1] = { 0xD5 }; + int8_t result = stdc_load8_bes8 (data); + ASSERT (result == (int8_t) 0xD5); +} + +static void +test_stdc_load8_bes16 (void) +{ + static union { unsigned char bytes[1 + 2]; int16_t align; } data = + { { 0, 0xD5, 0xE6 } }; + int16_t result = stdc_load8_bes16 (data.bytes + 1); + ASSERT (result == (int16_t) 0xD5E6); +} + +static void +test_stdc_load8_bes32 (void) +{ + static union { unsigned char bytes[1 + 4]; int32_t align; } data = + { { 0, 0xD5, 0xE6, 0xC2, 0xF4 } }; + int32_t result = stdc_load8_bes32 (data.bytes + 1); + ASSERT (result == 0xD5E6C2F4); +} + +static void +test_stdc_load8_bes64 (void) +{ + static union { unsigned char bytes[1 + 8]; int64_t align; } data = + { { 0, 0xD5, 0xE6, 0xC2, 0xF4, 0xF1, 0xC9, 0xEA, 0xDF } }; + int64_t result = stdc_load8_bes64 (data.bytes + 1); + ASSERT (result == 0xD5E6C2F4F1C9EADFLL); +} + +static void +test_stdc_load8_les8 (void) +{ + static unsigned char data[1] = { 0xD5 }; + int8_t result = stdc_load8_les8 (data); + ASSERT (result == (int8_t) 0xD5); +} + +static void +test_stdc_load8_les16 (void) +{ + static union { unsigned char bytes[1 + 2]; int16_t align; } data = + { { 0, 0xD5, 0xE6 } }; + int16_t result = stdc_load8_les16 (data.bytes + 1); + ASSERT (result == (int16_t) 0xE6D5); +} + +static void +test_stdc_load8_les32 (void) +{ + static union { unsigned char bytes[1 + 4]; int32_t align; } data = + { { 0, 0xD5, 0xE6, 0xC2, 0xF4 } }; + int32_t result = stdc_load8_les32 (data.bytes + 1); + ASSERT (result == 0xF4C2E6D5); +} + +static void +test_stdc_load8_les64 (void) +{ + static union { unsigned char bytes[1 + 8]; int64_t align; } data = + { { 0, 0xD5, 0xE6, 0xC2, 0xF4, 0xF1, 0xC9, 0xEA, 0xDF } }; + int64_t result = stdc_load8_les64 (data.bytes + 1); + ASSERT (result == 0xDFEAC9F1F4C2E6D5LL); +} + +int +main () +{ + test_stdc_load8_beu8 (); + test_stdc_load8_beu16 (); + test_stdc_load8_beu32 (); + test_stdc_load8_beu64 (); + test_stdc_load8_leu8 (); + test_stdc_load8_leu16 (); + test_stdc_load8_leu32 (); + test_stdc_load8_leu64 (); + test_stdc_load8_bes8 (); + test_stdc_load8_bes16 (); + test_stdc_load8_bes32 (); + test_stdc_load8_bes64 (); + test_stdc_load8_les8 (); + test_stdc_load8_les16 (); + test_stdc_load8_les32 (); + test_stdc_load8_les64 (); + + return test_exit_status; +} -- 2.52.0
