Compiler issue...

Parmelan, Edouard EP510777 at exchange.FRANCE.NCR.com
Wed Jan 27 11:13:34 PST 1999


Maxim,

> But this _does_ allocates 'data', which is at least double :-(
No, HArrayOfXXX is never use as a not allocated object.
Read the allocation function newArray() in object.c.

Then when an array is use, the code looklike:
unhand(anArray)->body[index] and body is defined as:

union {
  double align;
  whatever_type body[1];
} data[1];

body[N] don't contains at least double

The data[1] is to help unhand() macro that need data to be
a pointer.  As it's a field array, is looklike a pointer.

The body[1] is the same.

Edouard.


> Isn't it better to have some kind of system-specific
> macros that ensures correct align and goes to config.h,
> for example
> 
> // for gcc
> #define DOUBLE_ALIGN double align[0];
> // for another one
> #define DOUBLE_ALIGN \
>  union { \
>          double x; \
>          whatever type y; \
>  } align;
> 
> and put this in config.h ?
> 
> PS I really think that kaffe do not needs this align.
> Object's fields offsets are to be calculated
> based on it's type and system-depended align
> for this type. Arrays of primitive types
> may be processed on per-type base (by declaring
> DoubleArray, IntegerArray, ShortArray structures
> and so on).
> 
> Godmar Back wrote:
> > 
> >  I think Edouard's last patch removed the [0] arrays in favor of unions,
> > like so:
> > union {
> >         double x;
> >         whatever type y;
> > } data;
> > which achieve the same alignment.
> > 
> >         - Godmar
> > 
> > >
> > > > Actually, I would suggest hiding the [0] arrays behind a macro
called
> > > > ALIGNMENT(), as this would hide the GNU-ism and make it easier to
fix
> > > > under other compilers (which might provide pragmas or somesuch for
> > > > defining the alignment of a structure).
> > >
> > > Can you put a pragma inside a macro?  I didn't think you could put a
> > > #include inside a macro.
> > >
> > > Jason
> > >


More information about the kaffe mailing list