Re: MemPools rewrite

From: Alex Rousskov <rousskov@dont-contact.us>
Date: Thu, 2 Nov 2000 12:08:58 -0700 (MST)

On Thu, 2 Nov 2000, Andres Kroonmaa wrote:

> It has been noted that doubles must be aligned on double boundaries
> for some CPU's.
>
> struct _MemChunk {
> void **freeList;
> void *objCache;
> int count;
> double dummy;
> MemChunk *next;
> MemChunk *prev;
> };
>
> when printing out offsets from start of structure, I get:
>
> chunk->freeList: 0
> chunk->objCache: 4
> chunk->count: 8
> chunk->dummy: 12
> chunk->next: 20
> chunk->prev: 24
>
> showing that gcc has NOT aligned double on 8-byte, but 4-byte.
> this is on Intel. Should I assume that CC behaves differently
> depending on CPU?

I do not know. However, to be safe, I would assume that it may behave
differently depending on the CPU or other external factors.
 
> How can I determite required alignment for the system in code?

If you know the datatype and you want to check its alignment runtime,
you probably can do it by calculating the offset in the following
structure:

        struct { char ch; datatype_to_check dummy; };

However, IMHO, the code that tests for things like that is too low
level for Squid -- if something requires an alignment test, Squid
would be better of, IMHO, without that something.

Alex.
Received on Thu Nov 02 2000 - 12:09:09 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:54 MST