summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorMatt Mackall <mpm@selenic.com>2005-03-07 18:12:18 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-03-07 18:12:18 -0800
commit18684e6e939e136dbbcf0eabcc75d0e9f5e306fa (patch)
tree6cd9966aa26a4c1221f5c2532b74e407d2e76b15 /include/linux
parentc41f39c1442b3683e522cf65f5d28f037a0c019e (diff)
[PATCH] random: Create new rol32/ror32 bitops
Add rol32 and ror32 bitops to bitops.h Signed-off-by: Matt Mackall <mpm@selenic.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bitops.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 48f87b979ca9..7d1f8b67c6bf 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -134,4 +134,26 @@ static inline unsigned long hweight_long(unsigned long w)
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)
+{
+ 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)
+{
+ return (word >> shift) | (word << (32 - shift));
+}
+
#endif