Skip to contentSkip to conversation

random: Create new rol32/ror32 bitops

PATCH New Geert Uytterhoeven 2 participants 2 messages Mar 10, 2005 1 message not in the archive Bitops API

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

include/linux/bitops.h line 143

Quoted 13 lines · Linux Kernel Mailing List
include/linux/bitops.h +7 -0
@@ -134,4 +134,26 @@
 	return sizeof(w) == 4 ? generic_hweight32(w) : generic_hweight64(w);
 }
 
+/*
+ * rol32 - rotate a 32-bit value left
+ *
+ * @word: value to rotate
+ * @shift: bits to roll
+ */
+static inline __u32 rol32(__u32 word, int shift)
                                         ^^^

include/linux/bitops.h line 154

Quoted 11 lines
include/linux/bitops.h +11 -0
+{
+	return (word << shift) | (word >> (32 - shift));
+}
+
+/*
+ * ror32 - rotate a 32-bit value right
+ *
+ * @word: value to rotate
+ * @shift: bits to roll
+ */
+static inline __u32 ror32(__u32 word, int shift)
                                         ^^^

include/linux/bitops.h line 159

Quoted 5 lines
include/linux/bitops.h +4 -0
+{
+	return (word >> shift) | (word << (32 - shift));
+}
+
 #endif

`unsigned int', while we're at it?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#2 lore raw

PATCH 1/1 rol/ror type cleanup

Quoted 1 line · Geert Uytterhoeven

`unsigned int', while we're at it?

Minor type cleanup.

include/linux/bitops.h +2 -2
Index: bk/include/linux/bitops.h
===================================================================
@@ -140,7 +140,7 @@ static inline unsigned long hweight_long
  * @word: value to rotate
  * @shift: bits to roll
  */
-static inline __u32 rol32(__u32 word, int shift)
+static inline __u32 rol32(__u32 word, unsigned int shift)
 {
 	return (word << shift) | (word >> (32 - shift));
 }
@@ -151,7 +151,7 @@ static inline __u32 rol32(__u32 word, in
  * @word: value to rotate
  * @shift: bits to roll
  */
-static inline __u32 ror32(__u32 word, int shift)
+static inline __u32 ror32(__u32 word, unsigned int shift)
 {
 	return (word >> shift) | (word << (32 - shift));
 }
Signature · 1 line
Mathematics is the supreme nostalgia of our time.