Thanks for doing that!

On 2026-03-07 15:09, Collin Funk wrote:

+# if ! defined __gl_stdc_rotate_left

The existing style in that file is to prefer #ifdef and #ifndef to the longer wording. (Call me a traditionalist....) Here and elsewhere.


+#  define __gl_stdc_rotate_left(value, count)             \
+  ((value << (count & (sizeof value * 8 - 1)))            \
+   | (value >> ((-count) & (sizeof value * 8 - 1))))
+# endif

8 * sizeof (something) is easier to read than sizeof (something) * 8. To avoid glitches after possible later modifications, should parenthesize args when used. No need for those parens in (-count). E.g.:

  #  define __gl_stdc_rotate_left(v, c) \
    (((v) << ((c) & (8 * sizeof (v) - 1))) \
     | ((v) >> (-(c) & (8 * sizeof (v) - 1))))

Similarly for __gl_stdc_rotate_right.


+#  define stdc_rotate_left(value, count)                                \
+  (_GL_STDBIT_TYPEOF_CAST                                               \
+   (value,                                                              \
+    (sizeof (value) == 1 ? stdc_rotate_left_uc (value, count)           \
+     : (sizeof (value) == sizeof (unsigned short int)                   \
+        ? stdc_rotate_left_us (value, count)                            \
+        : (sizeof (value) == sizeof 0u                                  \
+           ? stdc_rotate_left_ui (value, count)                         \
+           : (sizeof (value) == sizeof 0ul                              \
+              ? stdc_rotate_left_ul (value, count)                      \
+              : stdc_rotate_left_ull (value, count)))))))

The staggered indenting is a bit hard to read. Could we redo this in the existing style (e.g. stdbit_bit_ceil) by using shorter arg names v, c? That should be easier to read.

Reply via email to