This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: On alignment


Nicola Pero writes:
 > 
 > > >  > > That packing rule is part of the i86 psABI
 > > >  > 
 > > >  > It's still mighty odd, and of course in Ada you have to override this rule
 > > >  > since it conflicts with the Ada standard, which requires that the default
 > > >  > minimum alignment of a composite be not less than the alignment of any
 > > >  > component.
 > > >
 > > > It's pretty weird in C++.
 > > 
 > > It's the same in C.  Weird or not, that's what the SVR4 psABI says, so
 > > that's what we do.
 > 
 > I suspect this is not just weird, but it would have consequences
 > for Objective-C.
 > 
 > The ObjC runtime library is supposed to be able to compute
 > alignments in structures at runtime (for various tasks, like
 > encoding / decoding / forwarding).
 > 
 > At runtime, the ObjC runtime library has information about the
 > struct - the type of each member.  At the moment, it loops on the
 > struct members, and uses __alignof__ on each of them to get the
 > alignment of that member inside the struct (then, can read/write
 > the struct members).

That's what we do in gcj, and that is precisely why I raised the
issue.

 > As far as I understand from this discussion, this doesn't work any
 > longer.
 > 
 > For a typical example, look at libobjc/archive.c, functions
 > objc_write_type() and objc_read_type().
 > 
 > Assuming that we have to live with this weird ABI thing, what
 > alternative is there in order to compute alignments inside structs
 > at runtime ?
 > 
 > In other words, how can objc_write_type() and objc_read_type() be
 > fixed/rewritten in order to work with the weird/unsane ABI thing ?

You have to create a struct that contains each base type and look at
its alignment.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]