2026-03-15 Collin Funk <collin.funk1@gmail.com>
+ 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.
@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
#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
#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@
--- /dev/null
+/* 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>
# 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,
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])
-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' \
--- /dev/null
+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