[Top][All Lists]

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

Re: bitrotate

From: Bruno Haible
Subject: Re: bitrotate
Date: Sat, 30 Aug 2008 01:34:27 +0200
User-agent: KMail/1.5.4

Ben Pfaff wrote:
> Since you're using the inline keyword, you should add a
> dependency on the inline module.

He's only using 'static inline'; therefore an AC_REQUIRE([AC_C_INLINE])
is all that he needs.

> > +/* Given an unsigned 32-bit argument X, return the value corresponding
> > +   to rotating the bits N steps to the left.  N must be between 1 and
> > +   31 inclusive. */
> > +static inline uint32_t
> > +rotl32 (uint32_t x, int n)
> > +{
> > +  return ((x << n) | (x >> (32 - n))) & 0xFFFFFFFF;
> > +}
> There is no benefit to the bitwise "and" operation: a uint32_t is
> guaranteed to have exactly 32 bits, so the conversion implied by
> the return statement will trim off any high bits.

The '& 0xFFFFFFFF' serves the purpose of clarity. When I copy & paste
an expression from one file to another, the editor that I'm using does not
copy the implicit conversion in the form of a cast. Since relying on
implicit casts of return values is quite rare, I would overlook it in such
a situation.


reply via email to

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