[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bitrotate
From: |
Paolo Bonzini |
Subject: |
Re: bitrotate |
Date: |
Fri, 29 Aug 2008 17:51:42 +0200 |
User-agent: |
Thunderbird 2.0.0.16 (Macintosh/20080707) |
> +/* Given an unsigned 16-bit argument X, return the value corresponding
> + to rotating the bits N steps to the left. N must be between 1 to
> + 15 inclusive. */
> +static inline uint16_t
> +rotl16 (uint16_t x, int n)
> +{
> + return ((x << n) | (x >> (16 - n))) & 0xFFFFFFFF;
> +}
& 0xFFFF;
> +/* Given an unsigned 16-bit argument X, return the value corresponding
> + to rotating the bits N steps to the right. N must be in 1 to 15
> + inclusive. */
> +static inline uint16_t
> +rotr16 (uint16_t x, int n)
> +{
> + return ((x >> n) | (x << (16 - n))) & 0xFFFFFFFF;
> +}
Likewise.
I'd also double-check at least on i686-pc-linux-gnu that GCC does
generate ro{l,r}{w,l} instructions.
Paolo