Email List: Xaustin-review-lX
[All Lists]

Re: Defect in XSH posix_memalign

To: Geoff Clare <yyy@xxxxxxxxxxxxx>
Subject: Re: Defect in XSH posix_memalign
From: Nick Stoughton <yyyy@xxxxxxxxxx>
Date: Fri, 28 May 2004 11:50:41 -0700
Cc: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
References: <20040528180624.GA29246@squonk>
Since it is a side effect of this interface that sizeof(void *) must be
a power of two, it make NO difference which way you interpret this
sentence.

x * sizeof(void *) = y

if y must be a power of 2, then so must x. Therefore, no change is
required.

On Fri, 2004-05-28 at 11:06, Geoff Clare wrote:
> (Page and line numbers are for the 2004 edition.)
> 
> @ page 885 line 28831 section posix_memalign comment [gwc memalign multiple]
> 
> Problem:
> 
> Defect code :  3. Clarification required
> 
> This wording in the description of posix_memalign() is ambiguous:
> 
>     "The value of alignment shall be a multiple of sizeof(void *),
>     that is also a power of two."
> 
> It can be interpreted as meaning that the value of alignment must
> be a power of two, but presumably what it really means is that the
> multiple must be a power of two, as implied by the wording of
> the EINVAL error:
> 
BOTH the value of alignment AND the multiplier must be a power of 2. Or,
to put it another way, if the multiplier is a power of 2, so will the
alignment be, and if the alignment must be a power of 2, then so will
the multiplier.

This is basic factorization ... if
        x * y = z
and z must be a factor of 2, then both x & y must also be factors of 2.

If sizeof(void *) is not a simple factor of 2, then whatever you
multiply it by, you will never get rid of the non-2 factor(s)!
Therefore, sizeof(void *) == 2**n.

>     "The value of the alignment parameter is not a power of two
>     multiple of sizeof(void *)."
> 
> It would not make any sense to require that the value of alignment
> must be a power of two and must also be a multiple of sizeof(void *),
> as that would be impossible if sizeof(void *) is not a power of two.
> 
> Action:
> 
> Change "shall be a multiple of sizeof(void *), that is also a power
> of two" to "shall be a power of two multiple of sizeof(void *)".
-- 
Nick Stoughton <yyyy@xxxxxxxxxx>

<Prev in Thread] Current Thread [Next in Thread>