>>>>> "LT" == Leopold Toetsch <[EMAIL PROTECTED]> writes:

  LT> Chromatic <[EMAIL PROTECTED]> wrote:
  LT> [ align issues ]

  LT> Nested structs are ugly. The alignment of the first item seems to depend
  LT> on the biggest item in the struct.

that is a known rule for alignment of nested structs. since larger items
usually have strict alignment requirements on many platforms (misaligned
accesses either fail with bus faults or pay a massive penalty as on the
alpha), the compiler has to align the whole struct so that item will be
aligned. it can't just pad internally since that could vary. a char
followed by a 32 bit item could need 1,2, or 3 bytes of padding
depending on where the struct starts. so cc will force that struct to 32
bit alignement and pad 3 bytes after the char to keep the 32 bit item
aligned.

  LT> So we need some notion of nested structs or a hint for correct
  LT> alignment. I've checked in basic alignment handling for "normal"
  LT> cases, but not the second one above.

you just need to do the same thing in offsetof but do it for the nested
struct elements. it won't necessarily be the same as when that struct is
top level so you can't cheat there.

it sounds like between the PIR solution and the cpan module that i don't
need to do my own hack. or should i still work on it? it would be an
external perl5/c solution that would be able to generate some form of
table of item offsets.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to