[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pnet-developers] ILTypeIdentical
From: |
Rhys Weatherley |
Subject: |
Re: [Pnet-developers] ILTypeIdentical |
Date: |
Mon, 25 Oct 2004 18:58:52 +1000 |
User-agent: |
KMail/1.4.3 |
On Monday 25 October 2004 05:47 pm, Simon Posnjak wrote:
> The problem I am seeing is that the memory allocated by malloc is
> aligned, but the layout of the struct in the allocated memory is not
> aligned. The structs are *packed* on CRIS and using union and struct
> makes it impossible to make all fields of that struct/union to align to
> 4 (or 2^n). So to fix this it will not help if I change the malloc,
> because this problem is related to how CRIS gcc does struct/union
> layout.
It should only be necessary for the start of a malloc'ed region to be aligned.
The ILType pointers refer to the start of a structure, not something in the
middle. The alignment of other fields shouldn't matter.
I think however I am beginning to see the true problem. ILType structures are
normally allocated from a memory pool, which allocates structures on a
multiple of IL_BEST_ALIGNMENT (defined in "include/il_align.h").
Pnet tries to automagically determine the best alignment by measuring
structure padding. If, as you say, gcc packs everything with a sub-4
alignment value, then this could cause IL_BEST_ALIGNMENT to end up being 1 or
2 or something similarly small.
This is easy to fix. Add the following to the end of "il_align.h":
#ifdef cris
#undef IL_BEST_ALIGNMENT
#define IL_BEST_ALIGNMENT 4
#endif
where "cris" is whatever macro you need to use to detect your CPU.
Cheers,
Rhys.