|
From: Tom H. <th...@cy...> - 2003-11-28 07:21:03
|
In message <106...@ix...>
Jeremy Fitzhardinge <je...@go...> wrote:
> On Thu, 2003-11-27 at 15:55, Tom Hughes wrote:
> > /* Test whether the SIZE argument is valid. It must be a power of
> > two multiple of sizeof (void *). */
> > if (size % sizeof (void *) != 0 || (size & (size - 1)) != 0)
> > return VKI_EINVAL /*22*/ /*EINVAL*/;
> > Specifically by the second half of the or condition, which doesn't
> > seem to make any sense to me.
>
> N & (N-1) == 0 iff N is a power of 2 - it's the quick idiom to see if a
> number is a power of 2 or not.
I realised that I just couldn't understand why it wanted to insist
on the size begin a power of two ;-) After reading the manual page
it became obvious where the mistake was.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|