[comp.sys.nsc.32k] GENIX compiler 'feature'

cyrus@hi.UUCP (Tait Cyrus) (07/30/87)

Here at UNM we are porting GENIX 4.2 to the nodes of a hypercube we are
building.  Currently we are 'playing' with ethernet code and ran, for
the second time, into a C compiler 'feature', although I would call it
a bug.

We have a structure which contains several other structures.  These
structures HAVE TO, because of the tcp/ip specs, be in certain places.
Well, the compiler appears to be quad aligning the different structures
within the outermost structure.

This is not the first time I have seen the GENIX C compiler generate
code where it aligned certain things on a quad boundry.  Why?  The
32xxx processor does not care where chars/words/ints/ptrs are, unlike
other machines.

Granted, if an int is NOT on a word/quad boundry, it will be slower
in execution, but it WILL work.

I guess my question is WHY is the GENIX 4.2 C compiler doing this and
is there a way to get it to NOT do this?

Thanks in advance,

-- 
    @__________@    W. Tait Cyrus   (505) 277-0806
   /|         /|    University of New Mexico
  / |        / |    Dept of EECE - Hypercube Project
 @__|_______@  |    Albuquerque, New Mexico 87131
 |  |       |  |
 |  |  hc   |  |    e-mail:
 |  @.......|..@       cyrus@hc.dspo.gov or
 | /        | /        seismo!unmvax!hi!cyrus
 @/_________@/

avi@nsta.UUCP (Avi Bloch) (08/03/87)

In article <12301@hi.UUCP> cyrus@hi.UUCP (Tait Cyrus) writes:
>
>This is not the first time I have seen the GENIX C compiler generate
>code where it aligned certain things on a quad boundry.  Why?  The
>32xxx processor does not care where chars/words/ints/ptrs are, unlike
>other machines.
>
>Granted, if an int is NOT on a word/quad boundry, it will be slower
>in execution, but it WILL work.
>
>I guess my question is WHY is the GENIX 4.2 C compiler doing this and
>is there a way to get it to NOT do this?
>
>Thanks in advance,
>

Actually, you've answered the first question yourself. The compiler puts
ints/ptrs/structs on quad boundaries so that the generated code will
execute faster, even though this wastes space. Most compilers will
almost always give preference to speed over space. In fact, it would
seem to me most unfair to penalize all users for those few who need to
have everything byte-aligned. Therefore, I consider this to be a feature
and not a bug.

BTW, this feature is not unique to the GENIX 4.2 C compiler. The VAX/UNIX
4.3 C compiler also puts ints/ptrs/structs on quad boundaries.

As to the second question, to the best of my knowledge there is no way to
force byte-alignment in the compiler in question. However, National is
marketing a new compiler together with its GNX 5.3 tools. The new revision
of this compiler will have an option allowing the user to control the packing
of records.