On Friday 21 January 2005 23:41, Matt Mackall wrote: > --- rnd2.orig/include/linux/bitops.h 2005-01-19 22:57:54.000000000 -0800 > +++ rnd2/include/linux/bitops.h 2005-01-20 09:20:24.641660815 -0800 > @@ -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) > +{ > + 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
gcc generates surprisingly good assembly for this, I coudn't beat it for 32bit rotations. Cool! So you are absolutely right here with not trying to asm optimize it. OTOH 64bit gcc rol is worse. -- vda - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/