From 18684e6e939e136dbbcf0eabcc75d0e9f5e306fa Mon Sep 17 00:00:00 2001 From: Matt Mackall Date: Mon, 7 Mar 2005 18:12:18 -0800 Subject: [PATCH] random: Create new rol32/ror32 bitops Add rol32 and ror32 bitops to bitops.h Signed-off-by: Matt Mackall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/bitops.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include/linux') 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 -- cgit v1.2.3