bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bitrotate


From: Paolo Bonzini
Subject: Re: bitrotate
Date: Thu, 28 Aug 2008 17:32:00 +0200
User-agent: Thunderbird 2.0.0.16 (Macintosh/20080707)

> +#define rotl32(x,n) \
> +  ((((x) << ((uint16_t)(n))) | ((x) >> (32 - (uint16_t)(n)))) & 0xFFFFFFFF)
> +#define rotr32(x,n) \
> +  ((((x) >> ((uint16_t)(n))) | ((x) << (32 - (uint16_t)(n)))) & 0xFFFFFFFF)
> +#define rotl16(x,n) \
> +  ((((x) << ((uint16_t)(n))) | ((x) >> (16 - (uint16_t)(n)))) & 0xFFFF)
> +#define rotr16(x,n) \
> +  ((((x) >> ((uint16_t)(n))) | ((x) << (16 - (uint16_t)(n)))) & 0xFFFF)

If you don't cast x to uint32_t or uint16_t the compiler won't be able
to recognize the rotate pattern.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]