Re: SPARC tagged data

pardo@june.cs.washington.edu (David Keppel)
Fri, 10 May 91 18:12:12 GMT

          From comp.compilers

Related articles
SPARC tagged data horst@techfak.uni-bielefeld.de (1991-04-29)
Re: SPARC tagged data eb%watergate@lucid.com (Eric Benson) (1991-04-30)
Re: SPARC tagged data moss@cs.umass.edu (1991-04-30)
Re: SPARC tagged data weitek!weaver@Sun.COM (1991-04-30)
Re: SPARC tagged data kers@otter.hpl.hp.com (1991-05-07)
Re: SPARC tagged data pardo@june.cs.washington.edu (1991-05-08)
Re: SPARC tagged data henry@zoo.toronto.edu (1991-05-09)
Re: SPARC tagged data pardo@june.cs.washington.edu (1991-05-10)
| List of all articles for this month |

Newsgroups: comp.compilers
From: pardo@june.cs.washington.edu (David Keppel)
Keywords: architecture, C
Organization: Computer Science & Engineering, U. of Washington, Seattle
References: <MOSS.91Apr30083234@ibis.cs.umass.edu> <KERS.91May7093547@cdollin.hpl.hp.com> <91-05-073@iecc.cambridge.ma.us>
Date: Fri, 10 May 91 18:12:12 GMT

henry@zoo.toronto.edu (Henry Spencer) writes:
>[It may be difficult to pass structures to C anyway because of
> other design decisions made differently.]


Indeed, it may be difficult to pass structures between C and C if the
fragments were compiled with different compilers (e.g., libraries).
Problems include:


* Structure passing (most notably return) conventions
* Alignment
* Padding


So, for example, a compiler for a machine that allows unaligned fetches
(e.g., the VAX) might implement


struct { char c; int i; }


as:


one byte followed by 4 bytes, non-padded
one byte followed by 4 bytes, padded to 8 bytes
1 byte, padded to 4 bytes, followed by 4 bytes


I think these choices are all legal, but I wouldn't swear to it. The point
is that a compiler may legitimately derive different struct layouts from one
hadware specification. The second one is pretty silly, but the third may
actually improve performance by reducing the number of unaligned fetches.


So even if all the world programmed in C, we still wouldn't have solved
the interoperability problem :-)


;-D on ( Inter-city commuting? Inter-face computing ) Pardo
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.