Re: [exim-dev] C question for test suite.

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: David Woodhouse
Fecha:  
A: John Jetmore
Cc: exim-dev
Asunto: Re: [exim-dev] C question for test suite.
On Fri, 2010-07-16 at 22:12 -0400, John Jetmore wrote:
>
> 357: bufnext_one = (char *) (((int)bufnext_one+3) & (-4));
> 406: bufnext_two = (char *) (((int)bufnext_two+3) & (-4));
>
> I can only kind of keep up with what's going on there, but it appears
> the source of the problem is a size difference between int and char*.
> I went back and checked and on every platform I've had the test suite
> working on sizeof(int) was 4 and sizeof(char*) was also 4. On both my
> MacBook and tahini sizeof(int) is 4 and sizeof(char*) is 8.


No idea why it's doing that, but that's a classic 'align to 4 bytes'.

Take the address, add three to it, and mask off the lower two bits (by
doing a logical AND with ~3, otherwise (and more confusingly) written as
-4. You end up with the next highest address which is a multiple of 4.

Just using 'long' instead of 'int' should suffice to fix it. Although
maybe it wants to align to 8 bytes instead? Or to sizeof(long)? As I
said, without looking more closely I'm not sure *why* it was doing that
in the first place.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@???                              Intel Corporation