Collin Funk <[email protected]> writes: > I've attached patches adding the stdc_rotate_{left,right} macros and > functions, but have not pushed them yet. It is probably worth noting > that these functions are required to work when the shift is greater than > the width of the word. This is not the case with the ones from > bitrotate.h. > > Tested with GCC 4.8.5 which does not have the builtins for these > functions and GCC 15 & 16 which do.
I pushed the attached V2 patches of these, which I believe addresses all the points brought up in review. I tested them all again with GCC 4.8.5 and GCC 15, so that the builtin and non-builtin paths were checked. Thanks all for the review. Collin
>From ef7f1695319f7b3fffaffe89608fe21c5e56a079 Mon Sep 17 00:00:00 2001 Message-ID: <ef7f1695319f7b3fffaffe89608fe21c5e56a079.1773619835.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Sun, 15 Mar 2026 16:48:45 -0700 Subject: [PATCH v2 1/4] stdc_rotate_left: New module. * lib/stdbit.in.h (_GL_STDC_ROTATE_LEFT_INLINE, _gl_stdc_rotate_left) (stdc_rotate_left): New macros. (stdc_rotate_left_uc, stdc_rotate_left_us, stdc_rotate_left_ui) (stdc_rotate_left_ul, stdc_rotate_left_ull): New functions. * lib/stdc_rotate_left.c: New file. * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize GNULIB_STDC_ROTATE_LEFT. * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_ROTATE_LEFT. * modules/stdc_rotate_left: New file. * doc/posix-functions/stdc_rotate_left.texi: Mention the new module. --- ChangeLog | 14 +++++ doc/posix-functions/stdc_rotate_left.texi | 2 +- lib/stdbit.in.h | 62 +++++++++++++++++++++++ lib/stdc_rotate_left.c | 19 +++++++ m4/stdbit_h.m4 | 3 +- modules/stdbit-h | 1 + modules/stdc_rotate_left | 27 ++++++++++ 7 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 lib/stdc_rotate_left.c create mode 100644 modules/stdc_rotate_left diff --git a/ChangeLog b/ChangeLog index d9b7a63064..11fffd3b5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2026-03-15 Collin Funk <[email protected]> + + stdc_rotate_left: New module. + * lib/stdbit.in.h (_GL_STDC_ROTATE_LEFT_INLINE, _gl_stdc_rotate_left) + (stdc_rotate_left): New macros. + (stdc_rotate_left_uc, stdc_rotate_left_us, stdc_rotate_left_ui) + (stdc_rotate_left_ul, stdc_rotate_left_ull): New functions. + * lib/stdc_rotate_left.c: New file. + * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize + GNULIB_STDC_ROTATE_LEFT. + * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_ROTATE_LEFT. + * modules/stdc_rotate_left: New file. + * doc/posix-functions/stdc_rotate_left.texi: Mention the new module. + 2026-03-15 Bruno Haible <[email protected]> posix_spawn-internal: Move private Gnulib functions to _gl_* namespace. diff --git a/doc/posix-functions/stdc_rotate_left.texi b/doc/posix-functions/stdc_rotate_left.texi index 2ce4c22065..2e4c89c1b2 100644 --- a/doc/posix-functions/stdc_rotate_left.texi +++ b/doc/posix-functions/stdc_rotate_left.texi @@ -12,7 +12,7 @@ @node stdc_rotate_left @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.17. -Gnulib module: --- +Gnulib module: stdc_rotate_left Portability problems fixed by Gnulib: @itemize diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index e7d7e7a9ee..09bc0d307d 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -141,6 +141,9 @@ _GL_INLINE_HEADER_BEGIN #ifndef _GL_STDC_BIT_CEIL_INLINE # define _GL_STDC_BIT_CEIL_INLINE _GL_INLINE #endif +#ifndef _GL_STDC_ROTATE_LEFT_INLINE +# define _GL_STDC_ROTATE_LEFT_INLINE _GL_INLINE +#endif #ifndef _GL_STDC_MEMREVERSE8_INLINE # define _GL_STDC_MEMREVERSE8_INLINE _GL_INLINE #endif @@ -1160,6 +1163,65 @@ stdc_bit_ceil_ull (unsigned long long int n) #endif /* @HAVE_STDBIT_H@ */ +/* ISO C2y § 7.18.17 Rotate Left */ + +#if @GNULIB_STDC_ROTATE_LEFT@ + +# ifdef __has_builtin +# if __has_builtin (__builtin_stdc_rotate_left) +# define _gl_stdc_rotate_left __builtin_stdc_rotate_left +# define stdc_rotate_left __builtin_stdc_rotate_left +# endif +# endif + +# ifndef _gl_stdc_rotate_left +# define _gl_stdc_rotate_left(v, c) \ + (((v) << ((c) & (sizeof (v) * 8 - 1))) \ + | ((v) >> (-(c) & (sizeof (v) * 8 - 1)))) +# endif + +_GL_STDC_ROTATE_LEFT_INLINE unsigned char +stdc_rotate_left_uc (unsigned char v, unsigned int c) +{ + return _gl_stdc_rotate_left (v, c); +} + +_GL_STDC_ROTATE_LEFT_INLINE unsigned short int +stdc_rotate_left_us (unsigned short int v, unsigned int c) +{ + return _gl_stdc_rotate_left (v, c); +} + +_GL_STDC_ROTATE_LEFT_INLINE unsigned int +stdc_rotate_left_ui (unsigned int v, unsigned int c) +{ + return _gl_stdc_rotate_left (v, c); +} + +_GL_STDC_ROTATE_LEFT_INLINE unsigned long int +stdc_rotate_left_ul (unsigned long int v, unsigned int c) +{ + return _gl_stdc_rotate_left (v, c); +} + +_GL_STDC_ROTATE_LEFT_INLINE unsigned long long int +stdc_rotate_left_ull (unsigned long long int v, unsigned int c) +{ + return _gl_stdc_rotate_left (v, c); +} + +# ifndef stdc_rotate_left +# define stdc_rotate_left(v, c) \ + (_GL_STDBIT_TYPEOF_CAST \ + (v, \ + (sizeof (v) == 1 ? stdc_rotate_left_uc (v, c) \ + : sizeof (v) == sizeof (unsigned short int) ? stdc_rotate_left_us (v, c) \ + : sizeof (v) == sizeof 0u ? stdc_rotate_left_ui (v, c) \ + : sizeof (v) == sizeof 0ul ? stdc_rotate_left_ul (v, c) \ + : stdc_rotate_left_ull (v, c)))) +# endif + +#endif /* ISO C2y § 7.18.19 8-bit Memory Reversal */ diff --git a/lib/stdc_rotate_left.c b/lib/stdc_rotate_left.c new file mode 100644 index 0000000000..196aa963c9 --- /dev/null +++ b/lib/stdc_rotate_left.c @@ -0,0 +1,19 @@ +/* stdc_rotate_left_* 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_ROTATE_LEFT_INLINE _GL_EXTERN_INLINE +#include <config.h> +#include <stdbit.h> diff --git a/m4/stdbit_h.m4 b/m4/stdbit_h.m4 index a84aa3c8cb..33d0ce4d5d 100644 --- a/m4/stdbit_h.m4 +++ b/m4/stdbit_h.m4 @@ -1,5 +1,5 @@ # stdbit_h.m4 -# serial 11 +# serial 12 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_ROTATE_LEFT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_MEMREVERSE8]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_MEMREVERSE8U]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_LOAD8_ALIGNED]) diff --git a/modules/stdbit-h b/modules/stdbit-h index 1c1f76e358..7113d147cd 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_ROTATE_LEFT''@/$(GNULIB_STDC_ROTATE_LEFT)/g' \ -e 's/@''GNULIB_STDC_MEMREVERSE8''@/$(GNULIB_STDC_MEMREVERSE8)/g' \ -e 's/@''GNULIB_STDC_MEMREVERSE8U''@/$(GNULIB_STDC_MEMREVERSE8U)/g' \ -e 's/@''GNULIB_STDC_LOAD8_ALIGNED''@/$(GNULIB_STDC_LOAD8_ALIGNED)/g' \ diff --git a/modules/stdc_rotate_left b/modules/stdc_rotate_left new file mode 100644 index 0000000000..a2e22e71a1 --- /dev/null +++ b/modules/stdc_rotate_left @@ -0,0 +1,27 @@ +Description: +stdc_rotate_left macro, stdc_rotate_left_* functions: +Perform a left circular shift. + +Files: +lib/stdc_rotate_left.c + +Depends-on: +stdbit-h + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +gl_STDBIT_MODULE_INDICATOR([stdc_rotate_left]) + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_rotate_left.c +endif + +Include: +<stdbit.h> + +License: +LGPLv2+ + +Maintainer: +all -- 2.53.0
>From 72e6d321dd15536f1d48d02c63db87380eb3e4f5 Mon Sep 17 00:00:00 2001 Message-ID: <72e6d321dd15536f1d48d02c63db87380eb3e4f5.1773619835.git.collin.fu...@gmail.com> In-Reply-To: <ef7f1695319f7b3fffaffe89608fe21c5e56a079.1773619835.git.collin.fu...@gmail.com> References: <ef7f1695319f7b3fffaffe89608fe21c5e56a079.1773619835.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Sun, 15 Mar 2026 16:53:26 -0700 Subject: [PATCH v2 2/4] stdc_rotate_left: Add tests. * modules/stdc_rotate_left-tests: New file. * tests/test-stdc_rotate_left.c: Likewise. --- ChangeLog | 4 + modules/stdc_rotate_left-tests | 11 + tests/test-stdc_rotate_left.c | 461 +++++++++++++++++++++++++++++++++ 3 files changed, 476 insertions(+) create mode 100644 modules/stdc_rotate_left-tests create mode 100644 tests/test-stdc_rotate_left.c diff --git a/ChangeLog b/ChangeLog index 11fffd3b5f..125a021a0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2026-03-15 Collin Funk <[email protected]> + stdc_rotate_left: Add tests. + * modules/stdc_rotate_left-tests: New file. + * tests/test-stdc_rotate_left.c: Likewise. + stdc_rotate_left: New module. * lib/stdbit.in.h (_GL_STDC_ROTATE_LEFT_INLINE, _gl_stdc_rotate_left) (stdc_rotate_left): New macros. diff --git a/modules/stdc_rotate_left-tests b/modules/stdc_rotate_left-tests new file mode 100644 index 0000000000..f88e0adf97 --- /dev/null +++ b/modules/stdc_rotate_left-tests @@ -0,0 +1,11 @@ +Files: +tests/test-stdc_rotate_left.c +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-stdc_rotate_left +check_PROGRAMS += test-stdc_rotate_left diff --git a/tests/test-stdc_rotate_left.c b/tests/test-stdc_rotate_left.c new file mode 100644 index 0000000000..ab1a32e662 --- /dev/null +++ b/tests/test-stdc_rotate_left.c @@ -0,0 +1,461 @@ +/* Test the stdc_rotate_left_* functions and macro. + 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 General Public License as published + by the Free Software Foundation, either version 3 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 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 Collin Funk <[email protected]>, 2026. */ + +#include <config.h> + +/* Specification. */ +#include <stdbit.h> + +#include "macros.h" + +#define TEST_CASE(type, function, value, shift, expect) \ + do \ + { \ + type v = value; \ + type e = expect; \ + ASSERT (function (v, shift) == expect); \ + ASSERT (stdc_rotate_left (v, shift) == expect); \ + } \ + while (false) + +static void +test_stdc_rotate_left_uc (void) +{ + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 0, 0x96); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 1, 0x2d); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 2, 0x5a); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 3, 0xb4); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 4, 0x69); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 5, 0xd2); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 6, 0xa5); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 7, 0x4b); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 8, 0x96); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 9, 0x2d); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 10, 0x5a); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 11, 0xb4); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 12, 0x69); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 13, 0xd2); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 14, 0xa5); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 15, 0x4b); + TEST_CASE (unsigned char, stdc_rotate_left_uc, 0x96, 16, 0x96); +} + +static void +test_stdc_rotate_left_us (void) +{ + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 0, 0x5e1aU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 1, 0xbc34U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 2, 0x7869U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 3, 0xf0d2U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 4, 0xe1a5U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 5, 0xc34bU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 6, 0x8697U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 7, 0x0d2fU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 8, 0x1a5eU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 9, 0x34bcU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 10, 0x6978U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 11, 0xd2f0U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 12, 0xa5e1U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 13, 0x4bc3U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 14, 0x9786U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 15, 0x2f0dU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 16, 0x5e1aU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 17, 0xbc34U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 18, 0x7869U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 19, 0xf0d2U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 20, 0xe1a5U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 21, 0xc34bU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 22, 0x8697U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 23, 0x0d2fU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 24, 0x1a5eU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 25, 0x34bcU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 26, 0x6978U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 27, 0xd2f0U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 28, 0xa5e1U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 29, 0x4bc3U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 30, 0x9786U); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 31, 0x2f0dU); + TEST_CASE (unsigned short int, stdc_rotate_left_us, 0x5e1aU, 32, 0x5e1aU); +} + +#define TEST_CASES_32(type, function) \ + do \ + { \ + TEST_CASE (type, function, 0x51af3678UL, 0, 0x51af3678UL); \ + TEST_CASE (type, function, 0x51af3678UL, 1, 0xa35e6cf0UL); \ + TEST_CASE (type, function, 0x51af3678UL, 2, 0x46bcd9e1UL); \ + TEST_CASE (type, function, 0x51af3678UL, 3, 0x8d79b3c2UL); \ + TEST_CASE (type, function, 0x51af3678UL, 4, 0x1af36785UL); \ + TEST_CASE (type, function, 0x51af3678UL, 5, 0x35e6cf0aUL); \ + TEST_CASE (type, function, 0x51af3678UL, 6, 0x6bcd9e14UL); \ + TEST_CASE (type, function, 0x51af3678UL, 7, 0xd79b3c28UL); \ + TEST_CASE (type, function, 0x51af3678UL, 8, 0xaf367851UL); \ + TEST_CASE (type, function, 0x51af3678UL, 9, 0x5e6cf0a3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 10, 0xbcd9e146UL); \ + TEST_CASE (type, function, 0x51af3678UL, 11, 0x79b3c28dUL); \ + TEST_CASE (type, function, 0x51af3678UL, 12, 0xf367851aUL); \ + TEST_CASE (type, function, 0x51af3678UL, 13, 0xe6cf0a35UL); \ + TEST_CASE (type, function, 0x51af3678UL, 14, 0xcd9e146bUL); \ + TEST_CASE (type, function, 0x51af3678UL, 15, 0x9b3c28d7UL); \ + TEST_CASE (type, function, 0x51af3678UL, 16, 0x367851afUL); \ + TEST_CASE (type, function, 0x51af3678UL, 17, 0x6cf0a35eUL); \ + TEST_CASE (type, function, 0x51af3678UL, 18, 0xd9e146bcUL); \ + TEST_CASE (type, function, 0x51af3678UL, 19, 0xb3c28d79UL); \ + TEST_CASE (type, function, 0x51af3678UL, 20, 0x67851af3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 21, 0xcf0a35e6UL); \ + TEST_CASE (type, function, 0x51af3678UL, 22, 0x9e146bcdUL); \ + TEST_CASE (type, function, 0x51af3678UL, 23, 0x3c28d79bUL); \ + TEST_CASE (type, function, 0x51af3678UL, 24, 0x7851af36UL); \ + TEST_CASE (type, function, 0x51af3678UL, 25, 0xf0a35e6cUL); \ + TEST_CASE (type, function, 0x51af3678UL, 26, 0xe146bcd9UL); \ + TEST_CASE (type, function, 0x51af3678UL, 27, 0xc28d79b3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 28, 0x851af367UL); \ + TEST_CASE (type, function, 0x51af3678UL, 29, 0x0a35e6cfUL); \ + TEST_CASE (type, function, 0x51af3678UL, 30, 0x146bcd9eUL); \ + TEST_CASE (type, function, 0x51af3678UL, 31, 0x28d79b3cUL); \ + TEST_CASE (type, function, 0x51af3678UL, 32, 0x51af3678UL); \ + TEST_CASE (type, function, 0x51af3678UL, 33, 0xa35e6cf0UL); \ + TEST_CASE (type, function, 0x51af3678UL, 34, 0x46bcd9e1UL); \ + TEST_CASE (type, function, 0x51af3678UL, 35, 0x8d79b3c2UL); \ + TEST_CASE (type, function, 0x51af3678UL, 36, 0x1af36785UL); \ + TEST_CASE (type, function, 0x51af3678UL, 37, 0x35e6cf0aUL); \ + TEST_CASE (type, function, 0x51af3678UL, 38, 0x6bcd9e14UL); \ + TEST_CASE (type, function, 0x51af3678UL, 39, 0xd79b3c28UL); \ + TEST_CASE (type, function, 0x51af3678UL, 40, 0xaf367851UL); \ + TEST_CASE (type, function, 0x51af3678UL, 41, 0x5e6cf0a3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 42, 0xbcd9e146UL); \ + TEST_CASE (type, function, 0x51af3678UL, 43, 0x79b3c28dUL); \ + TEST_CASE (type, function, 0x51af3678UL, 44, 0xf367851aUL); \ + TEST_CASE (type, function, 0x51af3678UL, 45, 0xe6cf0a35UL); \ + TEST_CASE (type, function, 0x51af3678UL, 46, 0xcd9e146bUL); \ + TEST_CASE (type, function, 0x51af3678UL, 47, 0x9b3c28d7UL); \ + TEST_CASE (type, function, 0x51af3678UL, 48, 0x367851afUL); \ + TEST_CASE (type, function, 0x51af3678UL, 49, 0x6cf0a35eUL); \ + TEST_CASE (type, function, 0x51af3678UL, 50, 0xd9e146bcUL); \ + TEST_CASE (type, function, 0x51af3678UL, 51, 0xb3c28d79UL); \ + TEST_CASE (type, function, 0x51af3678UL, 52, 0x67851af3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 53, 0xcf0a35e6UL); \ + TEST_CASE (type, function, 0x51af3678UL, 54, 0x9e146bcdUL); \ + TEST_CASE (type, function, 0x51af3678UL, 55, 0x3c28d79bUL); \ + TEST_CASE (type, function, 0x51af3678UL, 56, 0x7851af36UL); \ + TEST_CASE (type, function, 0x51af3678UL, 57, 0xf0a35e6cUL); \ + TEST_CASE (type, function, 0x51af3678UL, 58, 0xe146bcd9UL); \ + TEST_CASE (type, function, 0x51af3678UL, 59, 0xc28d79b3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 60, 0x851af367UL); \ + TEST_CASE (type, function, 0x51af3678UL, 61, 0x0a35e6cfUL); \ + TEST_CASE (type, function, 0x51af3678UL, 62, 0x146bcd9eUL); \ + TEST_CASE (type, function, 0x51af3678UL, 63, 0x28d79b3cUL); \ + TEST_CASE (type, function, 0x51af3678UL, 64, 0x51af3678UL); \ + } \ + while (false) + +static void +test_stdc_rotate_left_ui (void) +{ + TEST_CASES_32 (unsigned int, stdc_rotate_left_ui); +} + +#define TEST_CASES_64(type, function) \ + do \ + { \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 0, \ + 0x59ae28915a84db37ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 1, \ + 0xb35c5122b509b66eULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 2, \ + 0x66b8a2456a136cddULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 3, \ + 0xcd71448ad426d9baULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 4, \ + 0x9ae28915a84db375ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 5, \ + 0x35c5122b509b66ebULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 6, \ + 0x6b8a2456a136cdd6ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 7, \ + 0xd71448ad426d9bacULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 8, \ + 0xae28915a84db3759ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 9, \ + 0x5c5122b509b66eb3ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 10, \ + 0xb8a2456a136cdd66ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 11, \ + 0x71448ad426d9bacdULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 12, \ + 0xe28915a84db3759aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 13, \ + 0xc5122b509b66eb35ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 14, \ + 0x8a2456a136cdd66bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 15, \ + 0x1448ad426d9bacd7ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 16, \ + 0x28915a84db3759aeULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 17, \ + 0x5122b509b66eb35cULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 18, \ + 0xa2456a136cdd66b8ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 19, \ + 0x448ad426d9bacd71ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 20, \ + 0x8915a84db3759ae2ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 21, \ + 0x122b509b66eb35c5ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 22, \ + 0x2456a136cdd66b8aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 23, \ + 0x48ad426d9bacd714ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 24, \ + 0x915a84db3759ae28ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 25, \ + 0x22b509b66eb35c51ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 26, \ + 0x456a136cdd66b8a2ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 27, \ + 0x8ad426d9bacd7144ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 28, \ + 0x15a84db3759ae289ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 29, \ + 0x2b509b66eb35c512ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 30, \ + 0x56a136cdd66b8a24ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 31, \ + 0xad426d9bacd71448ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 32, \ + 0x5a84db3759ae2891ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 33, \ + 0xb509b66eb35c5122ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 34, \ + 0x6a136cdd66b8a245ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 35, \ + 0xd426d9bacd71448aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 36, \ + 0xa84db3759ae28915ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 37, \ + 0x509b66eb35c5122bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 38, \ + 0xa136cdd66b8a2456ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 39, \ + 0x426d9bacd71448adULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 40, \ + 0x84db3759ae28915aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 41, \ + 0x09b66eb35c5122b5ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 42, \ + 0x136cdd66b8a2456aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 43, \ + 0x26d9bacd71448ad4ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 44, \ + 0x4db3759ae28915a8ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 45, \ + 0x9b66eb35c5122b50ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 46, \ + 0x36cdd66b8a2456a1ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 47, \ + 0x6d9bacd71448ad42ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 48, \ + 0xdb3759ae28915a84ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 49, \ + 0xb66eb35c5122b509ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 50, \ + 0x6cdd66b8a2456a13ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 51, \ + 0xd9bacd71448ad426ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 52, \ + 0xb3759ae28915a84dULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 53, \ + 0x66eb35c5122b509bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 54, \ + 0xcdd66b8a2456a136ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 55, \ + 0x9bacd71448ad426dULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 56, \ + 0x3759ae28915a84dbULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 57, \ + 0x6eb35c5122b509b6ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 58, \ + 0xdd66b8a2456a136cULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 59, \ + 0xbacd71448ad426d9ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 60, \ + 0x759ae28915a84db3ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 61, \ + 0xeb35c5122b509b66ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 62, \ + 0xd66b8a2456a136cdULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 63, \ + 0xacd71448ad426d9bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 64, \ + 0x59ae28915a84db37ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 65, \ + 0xb35c5122b509b66eULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 66, \ + 0x66b8a2456a136cddULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 67, \ + 0xcd71448ad426d9baULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 68, \ + 0x9ae28915a84db375ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 69, \ + 0x35c5122b509b66ebULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 70, \ + 0x6b8a2456a136cdd6ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 71, \ + 0xd71448ad426d9bacULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 72, \ + 0xae28915a84db3759ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 73, \ + 0x5c5122b509b66eb3ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 74, \ + 0xb8a2456a136cdd66ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 75, \ + 0x71448ad426d9bacdULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 76, \ + 0xe28915a84db3759aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 77, \ + 0xc5122b509b66eb35ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 78, \ + 0x8a2456a136cdd66bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 79, \ + 0x1448ad426d9bacd7ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 80, \ + 0x28915a84db3759aeULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 81, \ + 0x5122b509b66eb35cULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 82, \ + 0xa2456a136cdd66b8ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 83, \ + 0x448ad426d9bacd71ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 84, \ + 0x8915a84db3759ae2ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 85, \ + 0x122b509b66eb35c5ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 86, \ + 0x2456a136cdd66b8aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 87, \ + 0x48ad426d9bacd714ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 88, \ + 0x915a84db3759ae28ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 89, \ + 0x22b509b66eb35c51ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 90, \ + 0x456a136cdd66b8a2ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 91, \ + 0x8ad426d9bacd7144ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 92, \ + 0x15a84db3759ae289ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 93, \ + 0x2b509b66eb35c512ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 94, \ + 0x56a136cdd66b8a24ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 95, \ + 0xad426d9bacd71448ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 96, \ + 0x5a84db3759ae2891ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 97, \ + 0xb509b66eb35c5122ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 98, \ + 0x6a136cdd66b8a245ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 99, \ + 0xd426d9bacd71448aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 100, \ + 0xa84db3759ae28915ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 101, \ + 0x509b66eb35c5122bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 102, \ + 0xa136cdd66b8a2456ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 103, \ + 0x426d9bacd71448adULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 104, \ + 0x84db3759ae28915aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 105, \ + 0x09b66eb35c5122b5ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 106, \ + 0x136cdd66b8a2456aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 107, \ + 0x26d9bacd71448ad4ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 108, \ + 0x4db3759ae28915a8ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 109, \ + 0x9b66eb35c5122b50ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 110, \ + 0x36cdd66b8a2456a1ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 111, \ + 0x6d9bacd71448ad42ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 112, \ + 0xdb3759ae28915a84ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 113, \ + 0xb66eb35c5122b509ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 114, \ + 0x6cdd66b8a2456a13ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 115, \ + 0xd9bacd71448ad426ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 116, \ + 0xb3759ae28915a84dULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 117, \ + 0x66eb35c5122b509bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 118, \ + 0xcdd66b8a2456a136ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 119, \ + 0x9bacd71448ad426dULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 120, \ + 0x3759ae28915a84dbULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 121, \ + 0x6eb35c5122b509b6ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 122, \ + 0xdd66b8a2456a136cULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 123, \ + 0xbacd71448ad426d9ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 124, \ + 0x759ae28915a84db3ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 125, \ + 0xeb35c5122b509b66ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 126, \ + 0xd66b8a2456a136cdULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 127, \ + 0xacd71448ad426d9bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 128, \ + 0x59ae28915a84db37ULL); \ + } \ + while (false) + +static void +test_stdc_rotate_left_ul (void) +{ + if (sizeof 0ul < sizeof 0ull) + TEST_CASES_32 (unsigned long int, stdc_rotate_left_ul); + else + TEST_CASES_64 (unsigned long int, stdc_rotate_left_ul); +} + +static void +test_stdc_rotate_left_ull (void) +{ + TEST_CASES_64 (unsigned long long int, stdc_rotate_left_ull); +} + +int +main (void) +{ + test_stdc_rotate_left_uc (); + test_stdc_rotate_left_us (); + test_stdc_rotate_left_ui (); + test_stdc_rotate_left_ul (); + test_stdc_rotate_left_ull (); + return test_exit_status; +} -- 2.53.0
>From 7ffbb1f4fe48aa66b67191bfd6f2da9a2fa1ec39 Mon Sep 17 00:00:00 2001 Message-ID: <7ffbb1f4fe48aa66b67191bfd6f2da9a2fa1ec39.1773619835.git.collin.fu...@gmail.com> In-Reply-To: <ef7f1695319f7b3fffaffe89608fe21c5e56a079.1773619835.git.collin.fu...@gmail.com> References: <ef7f1695319f7b3fffaffe89608fe21c5e56a079.1773619835.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Sun, 15 Mar 2026 17:00:38 -0700 Subject: [PATCH v2 3/4] stdc_rotate_right: New module. * lib/stdbit.in.h (_GL_STDC_ROTATE_RIGHT_INLINE, _gl_stdc_rotate_right) (stdc_rotate_right): New macros. (stdc_rotate_right_uc, stdc_rotate_right_us, stdc_rotate_right_ui) (stdc_rotate_right_ul, stdc_rotate_right_ull): New functions. * lib/stdc_rotate_right.c: New file. * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize GNULIB_STDC_ROTATE_RIGHT. * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_ROTATE_RIGHT. * modules/stdc_rotate_right: New file. * doc/posix-functions/stdc_rotate_right.texi: Mention the new module. --- ChangeLog | 12 +++++ doc/posix-functions/stdc_rotate_right.texi | 2 +- lib/stdbit.in.h | 63 ++++++++++++++++++++++ lib/stdc_rotate_right.c | 19 +++++++ m4/stdbit_h.m4 | 3 +- modules/stdbit-h | 1 + modules/stdc_rotate_right | 27 ++++++++++ 7 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 lib/stdc_rotate_right.c create mode 100644 modules/stdc_rotate_right diff --git a/ChangeLog b/ChangeLog index 125a021a0b..1600534ee6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2026-03-15 Collin Funk <[email protected]> + stdc_rotate_right: New module. + * lib/stdbit.in.h (_GL_STDC_ROTATE_RIGHT_INLINE, _gl_stdc_rotate_right) + (stdc_rotate_right): New macros. + (stdc_rotate_right_uc, stdc_rotate_right_us, stdc_rotate_right_ui) + (stdc_rotate_right_ul, stdc_rotate_right_ull): New functions. + * lib/stdc_rotate_right.c: New file. + * m4/stdbit_h.m4 (gl_STDBIT_H_REQUIRE_DEFAULTS): Initialize + GNULIB_STDC_ROTATE_RIGHT. + * modules/stdbit-h (Makefile.am): Substitute GNULIB_STDC_ROTATE_RIGHT. + * modules/stdc_rotate_right: New file. + * doc/posix-functions/stdc_rotate_right.texi: Mention the new module. + stdc_rotate_left: Add tests. * modules/stdc_rotate_left-tests: New file. * tests/test-stdc_rotate_left.c: Likewise. diff --git a/doc/posix-functions/stdc_rotate_right.texi b/doc/posix-functions/stdc_rotate_right.texi index 9080fc69eb..78c08ce56a 100644 --- a/doc/posix-functions/stdc_rotate_right.texi +++ b/doc/posix-functions/stdc_rotate_right.texi @@ -12,7 +12,7 @@ @node stdc_rotate_right @url{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3783.pdf}) section 7.18.18. -Gnulib module: --- +Gnulib module: stdc_rotate_right Portability problems fixed by Gnulib: @itemize diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h index 09bc0d307d..919e472f63 100644 --- a/lib/stdbit.in.h +++ b/lib/stdbit.in.h @@ -144,6 +144,9 @@ _GL_INLINE_HEADER_BEGIN #ifndef _GL_STDC_ROTATE_LEFT_INLINE # define _GL_STDC_ROTATE_LEFT_INLINE _GL_INLINE #endif +#ifndef _GL_STDC_ROTATE_RIGHT_INLINE +# define _GL_STDC_ROTATE_RIGHT_INLINE _GL_INLINE +#endif #ifndef _GL_STDC_MEMREVERSE8_INLINE # define _GL_STDC_MEMREVERSE8_INLINE _GL_INLINE #endif @@ -1223,6 +1226,66 @@ stdc_rotate_left_ull (unsigned long long int v, unsigned int c) #endif +/* ISO C2y § 7.18.18 Rotate Right */ + +#if @GNULIB_STDC_ROTATE_RIGHT@ + +# ifdef __has_builtin +# if __has_builtin (__builtin_stdc_rotate_right) +# define _gl_stdc_rotate_right __builtin_stdc_rotate_right +# define stdc_rotate_right __builtin_stdc_rotate_right +# endif +# endif + +# ifndef _gl_stdc_rotate_right +# define _gl_stdc_rotate_right(v, c) \ + (((v) >> ((c) & (sizeof (v) * 8 - 1))) \ + | ((v) << (-(c) & (sizeof (v) * 8 - 1)))) +# endif + +_GL_STDC_ROTATE_RIGHT_INLINE unsigned char +stdc_rotate_right_uc (unsigned char v, unsigned int c) +{ + return _gl_stdc_rotate_right (v, c); +} + +_GL_STDC_ROTATE_RIGHT_INLINE unsigned short int +stdc_rotate_right_us (unsigned short int v, unsigned int c) +{ + return _gl_stdc_rotate_right (v, c); +} + +_GL_STDC_ROTATE_RIGHT_INLINE unsigned int +stdc_rotate_right_ui (unsigned int v, unsigned int c) +{ + return _gl_stdc_rotate_right (v, c); +} + +_GL_STDC_ROTATE_RIGHT_INLINE unsigned long int +stdc_rotate_right_ul (unsigned long int v, unsigned int c) +{ + return _gl_stdc_rotate_right (v, c); +} + +_GL_STDC_ROTATE_RIGHT_INLINE unsigned long long int +stdc_rotate_right_ull (unsigned long long int v, unsigned int c) +{ + return _gl_stdc_rotate_right (v, c); +} + +# ifndef stdc_rotate_right +# define stdc_rotate_right(v, c) \ + (_GL_STDBIT_TYPEOF_CAST \ + (v, \ + (sizeof (v) == 1 ? stdc_rotate_right_uc (v, c) \ + : sizeof (v) == sizeof (unsigned short int) ? stdc_rotate_right_us (v, c) \ + : sizeof (v) == sizeof 0u ? stdc_rotate_right_ui (v, c) \ + : sizeof (v) == sizeof 0ul ? stdc_rotate_right_ul (v, c) \ + : stdc_rotate_right_ull (v, c)))) +# endif + +#endif + /* ISO C2y § 7.18.19 8-bit Memory Reversal */ #if @GNULIB_STDC_MEMREVERSE8@ diff --git a/lib/stdc_rotate_right.c b/lib/stdc_rotate_right.c new file mode 100644 index 0000000000..6aa5e11797 --- /dev/null +++ b/lib/stdc_rotate_right.c @@ -0,0 +1,19 @@ +/* stdc_rotate_right_* 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_ROTATE_RIGHT_INLINE _GL_EXTERN_INLINE +#include <config.h> +#include <stdbit.h> diff --git a/m4/stdbit_h.m4 b/m4/stdbit_h.m4 index 33d0ce4d5d..0ab347767c 100644 --- a/m4/stdbit_h.m4 +++ b/m4/stdbit_h.m4 @@ -1,5 +1,5 @@ # stdbit_h.m4 -# serial 12 +# serial 13 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_ROTATE_LEFT]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_ROTATE_RIGHT]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_MEMREVERSE8]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_MEMREVERSE8U]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDC_LOAD8_ALIGNED]) diff --git a/modules/stdbit-h b/modules/stdbit-h index 7113d147cd..5bba8b8bad 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_ROTATE_LEFT''@/$(GNULIB_STDC_ROTATE_LEFT)/g' \ + -e 's/@''GNULIB_STDC_ROTATE_RIGHT''@/$(GNULIB_STDC_ROTATE_RIGHT)/g' \ -e 's/@''GNULIB_STDC_MEMREVERSE8''@/$(GNULIB_STDC_MEMREVERSE8)/g' \ -e 's/@''GNULIB_STDC_MEMREVERSE8U''@/$(GNULIB_STDC_MEMREVERSE8U)/g' \ -e 's/@''GNULIB_STDC_LOAD8_ALIGNED''@/$(GNULIB_STDC_LOAD8_ALIGNED)/g' \ diff --git a/modules/stdc_rotate_right b/modules/stdc_rotate_right new file mode 100644 index 0000000000..5492c59b29 --- /dev/null +++ b/modules/stdc_rotate_right @@ -0,0 +1,27 @@ +Description: +stdc_rotate_right macro, stdc_rotate_right_* functions: +Perform a right circular shift. + +Files: +lib/stdc_rotate_right.c + +Depends-on: +stdbit-h + +configure.ac: +AC_REQUIRE([gl_STDBIT_H]) +gl_STDBIT_MODULE_INDICATOR([stdc_rotate_right]) + +Makefile.am: +if GL_GENERATE_STDBIT_H +lib_SOURCES += stdc_rotate_right.c +endif + +Include: +<stdbit.h> + +License: +LGPLv2+ + +Maintainer: +all -- 2.53.0
>From 766f86918b8d558293894b65a0653317c2bbc879 Mon Sep 17 00:00:00 2001 Message-ID: <766f86918b8d558293894b65a0653317c2bbc879.1773619835.git.collin.fu...@gmail.com> In-Reply-To: <ef7f1695319f7b3fffaffe89608fe21c5e56a079.1773619835.git.collin.fu...@gmail.com> References: <ef7f1695319f7b3fffaffe89608fe21c5e56a079.1773619835.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Sun, 15 Mar 2026 17:01:40 -0700 Subject: [PATCH v2 4/4] stdc_rotate_right: Add tests. * modules/stdc_rotate_right-tests: New file. * tests/test-stdc_rotate_right.c: Likewise. --- ChangeLog | 4 + modules/stdc_rotate_right-tests | 11 + tests/test-stdc_rotate_right.c | 461 ++++++++++++++++++++++++++++++++ 3 files changed, 476 insertions(+) create mode 100644 modules/stdc_rotate_right-tests create mode 100644 tests/test-stdc_rotate_right.c diff --git a/ChangeLog b/ChangeLog index 1600534ee6..c1c6051875 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2026-03-15 Collin Funk <[email protected]> + stdc_rotate_right: Add tests. + * modules/stdc_rotate_right-tests: New file. + * tests/test-stdc_rotate_right.c: Likewise. + stdc_rotate_right: New module. * lib/stdbit.in.h (_GL_STDC_ROTATE_RIGHT_INLINE, _gl_stdc_rotate_right) (stdc_rotate_right): New macros. diff --git a/modules/stdc_rotate_right-tests b/modules/stdc_rotate_right-tests new file mode 100644 index 0000000000..8a8047010e --- /dev/null +++ b/modules/stdc_rotate_right-tests @@ -0,0 +1,11 @@ +Files: +tests/test-stdc_rotate_right.c +tests/macros.h + +Depends-on: + +configure.ac: + +Makefile.am: +TESTS += test-stdc_rotate_right +check_PROGRAMS += test-stdc_rotate_right diff --git a/tests/test-stdc_rotate_right.c b/tests/test-stdc_rotate_right.c new file mode 100644 index 0000000000..c424d75cc2 --- /dev/null +++ b/tests/test-stdc_rotate_right.c @@ -0,0 +1,461 @@ +/* Test the stdc_rotate_right_* functions and macro. + 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 General Public License as published + by the Free Software Foundation, either version 3 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 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 Collin Funk <[email protected]>, 2026. */ + +#include <config.h> + +/* Specification. */ +#include <stdbit.h> + +#include "macros.h" + +#define TEST_CASE(type, function, value, shift, expect) \ + do \ + { \ + type v = value; \ + type e = expect; \ + ASSERT (function (v, shift) == expect); \ + ASSERT (stdc_rotate_right (v, shift) == expect); \ + } \ + while (false) + +static void +test_stdc_rotate_right_uc (void) +{ + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 0, 0x96); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 1, 0x4b); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 2, 0xa5); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 3, 0xd2); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 4, 0x69); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 5, 0xb4); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 6, 0x5a); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 7, 0x2d); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 8, 0x96); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 9, 0x4b); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 10, 0xa5); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 11, 0xd2); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 12, 0x69); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 13, 0xb4); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 14, 0x5a); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 15, 0x2d); + TEST_CASE (unsigned char, stdc_rotate_right_uc, 0x96, 16, 0x96); +} + +static void +test_stdc_rotate_right_us (void) +{ + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 0, 0x5e1aU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 1, 0x2f0dU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 2, 0x9786U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 3, 0x4bc3U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 4, 0xa5e1U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 5, 0xd2f0U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 6, 0x6978U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 7, 0x34bcU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 8, 0x1a5eU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 9, 0x0d2fU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 10, 0x8697U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 11, 0xc34bU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 12, 0xe1a5U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 13, 0xf0d2U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 14, 0x7869U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 15, 0xbc34U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 16, 0x5e1aU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 17, 0x2f0dU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 18, 0x9786U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 19, 0x4bc3U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 20, 0xa5e1U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 21, 0xd2f0U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 22, 0x6978U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 23, 0x34bcU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 24, 0x1a5eU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 25, 0x0d2fU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 26, 0x8697U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 27, 0xc34bU); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 28, 0xe1a5U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 29, 0xf0d2U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 30, 0x7869U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 31, 0xbc34U); + TEST_CASE (unsigned short int, stdc_rotate_right_us, 0x5e1aU, 32, 0x5e1aU); +} + +#define TEST_CASES_32(type, function) \ + do \ + { \ + TEST_CASE (type, function, 0x51af3678UL, 0, 0x51af3678UL); \ + TEST_CASE (type, function, 0x51af3678UL, 1, 0x28d79b3cUL); \ + TEST_CASE (type, function, 0x51af3678UL, 2, 0x146bcd9eUL); \ + TEST_CASE (type, function, 0x51af3678UL, 3, 0x0a35e6cfUL); \ + TEST_CASE (type, function, 0x51af3678UL, 4, 0x851af367UL); \ + TEST_CASE (type, function, 0x51af3678UL, 5, 0xc28d79b3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 6, 0xe146bcd9UL); \ + TEST_CASE (type, function, 0x51af3678UL, 7, 0xf0a35e6cUL); \ + TEST_CASE (type, function, 0x51af3678UL, 8, 0x7851af36UL); \ + TEST_CASE (type, function, 0x51af3678UL, 9, 0x3c28d79bUL); \ + TEST_CASE (type, function, 0x51af3678UL, 10, 0x9e146bcdUL); \ + TEST_CASE (type, function, 0x51af3678UL, 11, 0xcf0a35e6UL); \ + TEST_CASE (type, function, 0x51af3678UL, 12, 0x67851af3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 13, 0xb3c28d79UL); \ + TEST_CASE (type, function, 0x51af3678UL, 14, 0xd9e146bcUL); \ + TEST_CASE (type, function, 0x51af3678UL, 15, 0x6cf0a35eUL); \ + TEST_CASE (type, function, 0x51af3678UL, 16, 0x367851afUL); \ + TEST_CASE (type, function, 0x51af3678UL, 17, 0x9b3c28d7UL); \ + TEST_CASE (type, function, 0x51af3678UL, 18, 0xcd9e146bUL); \ + TEST_CASE (type, function, 0x51af3678UL, 19, 0xe6cf0a35UL); \ + TEST_CASE (type, function, 0x51af3678UL, 20, 0xf367851aUL); \ + TEST_CASE (type, function, 0x51af3678UL, 21, 0x79b3c28dUL); \ + TEST_CASE (type, function, 0x51af3678UL, 22, 0xbcd9e146UL); \ + TEST_CASE (type, function, 0x51af3678UL, 23, 0x5e6cf0a3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 24, 0xaf367851UL); \ + TEST_CASE (type, function, 0x51af3678UL, 25, 0xd79b3c28UL); \ + TEST_CASE (type, function, 0x51af3678UL, 26, 0x6bcd9e14UL); \ + TEST_CASE (type, function, 0x51af3678UL, 27, 0x35e6cf0aUL); \ + TEST_CASE (type, function, 0x51af3678UL, 28, 0x1af36785UL); \ + TEST_CASE (type, function, 0x51af3678UL, 29, 0x8d79b3c2UL); \ + TEST_CASE (type, function, 0x51af3678UL, 30, 0x46bcd9e1UL); \ + TEST_CASE (type, function, 0x51af3678UL, 31, 0xa35e6cf0UL); \ + TEST_CASE (type, function, 0x51af3678UL, 32, 0x51af3678UL); \ + TEST_CASE (type, function, 0x51af3678UL, 33, 0x28d79b3cUL); \ + TEST_CASE (type, function, 0x51af3678UL, 34, 0x146bcd9eUL); \ + TEST_CASE (type, function, 0x51af3678UL, 35, 0x0a35e6cfUL); \ + TEST_CASE (type, function, 0x51af3678UL, 36, 0x851af367UL); \ + TEST_CASE (type, function, 0x51af3678UL, 37, 0xc28d79b3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 38, 0xe146bcd9UL); \ + TEST_CASE (type, function, 0x51af3678UL, 39, 0xf0a35e6cUL); \ + TEST_CASE (type, function, 0x51af3678UL, 40, 0x7851af36UL); \ + TEST_CASE (type, function, 0x51af3678UL, 41, 0x3c28d79bUL); \ + TEST_CASE (type, function, 0x51af3678UL, 42, 0x9e146bcdUL); \ + TEST_CASE (type, function, 0x51af3678UL, 43, 0xcf0a35e6UL); \ + TEST_CASE (type, function, 0x51af3678UL, 44, 0x67851af3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 45, 0xb3c28d79UL); \ + TEST_CASE (type, function, 0x51af3678UL, 46, 0xd9e146bcUL); \ + TEST_CASE (type, function, 0x51af3678UL, 47, 0x6cf0a35eUL); \ + TEST_CASE (type, function, 0x51af3678UL, 48, 0x367851afUL); \ + TEST_CASE (type, function, 0x51af3678UL, 49, 0x9b3c28d7UL); \ + TEST_CASE (type, function, 0x51af3678UL, 50, 0xcd9e146bUL); \ + TEST_CASE (type, function, 0x51af3678UL, 51, 0xe6cf0a35UL); \ + TEST_CASE (type, function, 0x51af3678UL, 52, 0xf367851aUL); \ + TEST_CASE (type, function, 0x51af3678UL, 53, 0x79b3c28dUL); \ + TEST_CASE (type, function, 0x51af3678UL, 54, 0xbcd9e146UL); \ + TEST_CASE (type, function, 0x51af3678UL, 55, 0x5e6cf0a3UL); \ + TEST_CASE (type, function, 0x51af3678UL, 56, 0xaf367851UL); \ + TEST_CASE (type, function, 0x51af3678UL, 57, 0xd79b3c28UL); \ + TEST_CASE (type, function, 0x51af3678UL, 58, 0x6bcd9e14UL); \ + TEST_CASE (type, function, 0x51af3678UL, 59, 0x35e6cf0aUL); \ + TEST_CASE (type, function, 0x51af3678UL, 60, 0x1af36785UL); \ + TEST_CASE (type, function, 0x51af3678UL, 61, 0x8d79b3c2UL); \ + TEST_CASE (type, function, 0x51af3678UL, 62, 0x46bcd9e1UL); \ + TEST_CASE (type, function, 0x51af3678UL, 63, 0xa35e6cf0UL); \ + TEST_CASE (type, function, 0x51af3678UL, 64, 0x51af3678UL); \ + } \ + while (false) + +static void +test_stdc_rotate_right_ui (void) +{ + TEST_CASES_32 (unsigned int, stdc_rotate_right_ui); +} + +#define TEST_CASES_64(type, function) \ + do \ + { \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 0, \ + 0x59ae28915a84db37ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 1, \ + 0xacd71448ad426d9bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 2, \ + 0xd66b8a2456a136cdULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 3, \ + 0xeb35c5122b509b66ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 4, \ + 0x759ae28915a84db3ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 5, \ + 0xbacd71448ad426d9ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 6, \ + 0xdd66b8a2456a136cULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 7, \ + 0x6eb35c5122b509b6ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 8, \ + 0x3759ae28915a84dbULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 9, \ + 0x9bacd71448ad426dULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 10, \ + 0xcdd66b8a2456a136ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 11, \ + 0x66eb35c5122b509bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 12, \ + 0xb3759ae28915a84dULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 13, \ + 0xd9bacd71448ad426ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 14, \ + 0x6cdd66b8a2456a13ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 15, \ + 0xb66eb35c5122b509ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 16, \ + 0xdb3759ae28915a84ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 17, \ + 0x6d9bacd71448ad42ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 18, \ + 0x36cdd66b8a2456a1ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 19, \ + 0x9b66eb35c5122b50ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 20, \ + 0x4db3759ae28915a8ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 21, \ + 0x26d9bacd71448ad4ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 22, \ + 0x136cdd66b8a2456aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 23, \ + 0x09b66eb35c5122b5ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 24, \ + 0x84db3759ae28915aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 25, \ + 0x426d9bacd71448adULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 26, \ + 0xa136cdd66b8a2456ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 27, \ + 0x509b66eb35c5122bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 28, \ + 0xa84db3759ae28915ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 29, \ + 0xd426d9bacd71448aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 30, \ + 0x6a136cdd66b8a245ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 31, \ + 0xb509b66eb35c5122ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 32, \ + 0x5a84db3759ae2891ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 33, \ + 0xad426d9bacd71448ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 34, \ + 0x56a136cdd66b8a24ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 35, \ + 0x2b509b66eb35c512ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 36, \ + 0x15a84db3759ae289ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 37, \ + 0x8ad426d9bacd7144ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 38, \ + 0x456a136cdd66b8a2ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 39, \ + 0x22b509b66eb35c51ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 40, \ + 0x915a84db3759ae28ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 41, \ + 0x48ad426d9bacd714ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 42, \ + 0x2456a136cdd66b8aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 43, \ + 0x122b509b66eb35c5ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 44, \ + 0x8915a84db3759ae2ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 45, \ + 0x448ad426d9bacd71ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 46, \ + 0xa2456a136cdd66b8ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 47, \ + 0x5122b509b66eb35cULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 48, \ + 0x28915a84db3759aeULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 49, \ + 0x1448ad426d9bacd7ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 50, \ + 0x8a2456a136cdd66bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 51, \ + 0xc5122b509b66eb35ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 52, \ + 0xe28915a84db3759aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 53, \ + 0x71448ad426d9bacdULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 54, \ + 0xb8a2456a136cdd66ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 55, \ + 0x5c5122b509b66eb3ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 56, \ + 0xae28915a84db3759ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 57, \ + 0xd71448ad426d9bacULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 58, \ + 0x6b8a2456a136cdd6ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 59, \ + 0x35c5122b509b66ebULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 60, \ + 0x9ae28915a84db375ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 61, \ + 0xcd71448ad426d9baULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 62, \ + 0x66b8a2456a136cddULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 63, \ + 0xb35c5122b509b66eULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 64, \ + 0x59ae28915a84db37ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 65, \ + 0xacd71448ad426d9bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 66, \ + 0xd66b8a2456a136cdULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 67, \ + 0xeb35c5122b509b66ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 68, \ + 0x759ae28915a84db3ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 69, \ + 0xbacd71448ad426d9ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 70, \ + 0xdd66b8a2456a136cULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 71, \ + 0x6eb35c5122b509b6ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 72, \ + 0x3759ae28915a84dbULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 73, \ + 0x9bacd71448ad426dULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 74, \ + 0xcdd66b8a2456a136ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 75, \ + 0x66eb35c5122b509bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 76, \ + 0xb3759ae28915a84dULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 77, \ + 0xd9bacd71448ad426ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 78, \ + 0x6cdd66b8a2456a13ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 79, \ + 0xb66eb35c5122b509ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 80, \ + 0xdb3759ae28915a84ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 81, \ + 0x6d9bacd71448ad42ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 82, \ + 0x36cdd66b8a2456a1ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 83, \ + 0x9b66eb35c5122b50ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 84, \ + 0x4db3759ae28915a8ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 85, \ + 0x26d9bacd71448ad4ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 86, \ + 0x136cdd66b8a2456aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 87, \ + 0x09b66eb35c5122b5ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 88, \ + 0x84db3759ae28915aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 89, \ + 0x426d9bacd71448adULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 90, \ + 0xa136cdd66b8a2456ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 91, \ + 0x509b66eb35c5122bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 92, \ + 0xa84db3759ae28915ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 93, \ + 0xd426d9bacd71448aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 94, \ + 0x6a136cdd66b8a245ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 95, \ + 0xb509b66eb35c5122ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 96, \ + 0x5a84db3759ae2891ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 97, \ + 0xad426d9bacd71448ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 98, \ + 0x56a136cdd66b8a24ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 99, \ + 0x2b509b66eb35c512ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 100, \ + 0x15a84db3759ae289ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 101, \ + 0x8ad426d9bacd7144ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 102, \ + 0x456a136cdd66b8a2ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 103, \ + 0x22b509b66eb35c51ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 104, \ + 0x915a84db3759ae28ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 105, \ + 0x48ad426d9bacd714ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 106, \ + 0x2456a136cdd66b8aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 107, \ + 0x122b509b66eb35c5ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 108, \ + 0x8915a84db3759ae2ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 109, \ + 0x448ad426d9bacd71ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 110, \ + 0xa2456a136cdd66b8ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 111, \ + 0x5122b509b66eb35cULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 112, \ + 0x28915a84db3759aeULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 113, \ + 0x1448ad426d9bacd7ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 114, \ + 0x8a2456a136cdd66bULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 115, \ + 0xc5122b509b66eb35ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 116, \ + 0xe28915a84db3759aULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 117, \ + 0x71448ad426d9bacdULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 118, \ + 0xb8a2456a136cdd66ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 119, \ + 0x5c5122b509b66eb3ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 120, \ + 0xae28915a84db3759ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 121, \ + 0xd71448ad426d9bacULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 122, \ + 0x6b8a2456a136cdd6ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 123, \ + 0x35c5122b509b66ebULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 124, \ + 0x9ae28915a84db375ULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 125, \ + 0xcd71448ad426d9baULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 126, \ + 0x66b8a2456a136cddULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 127, \ + 0xb35c5122b509b66eULL); \ + TEST_CASE (type, function, 0x59ae28915a84db37ULL, 128, \ + 0x59ae28915a84db37ULL); \ + } \ + while (false) + +static void +test_stdc_rotate_right_ul (void) +{ + if (sizeof 0ul < sizeof 0ull) + TEST_CASES_32 (unsigned long int, stdc_rotate_right_ul); + else + TEST_CASES_64 (unsigned long int, stdc_rotate_right_ul); +} + +static void +test_stdc_rotate_right_ull (void) +{ + TEST_CASES_64 (unsigned long long int, stdc_rotate_right_ull); +} + +int +main (void) +{ + test_stdc_rotate_right_uc (); + test_stdc_rotate_right_us (); + test_stdc_rotate_right_ui (); + test_stdc_rotate_right_ul (); + test_stdc_rotate_right_ull (); + return test_exit_status; +} -- 2.53.0
