Article View: comp.arch
Article #20661Re: Sorting struct members for alignment (was Re: Unaligned Accesses)
From: Jim Giles
Date: Wed, 05 Apr 1989 22:11
Date: Wed, 05 Apr 1989 22:11
16 lines
1414 bytes
1414 bytes
From article <583@geovision.UUCP>, by gd@geovision.uucp (Gord Deinstadt): > And it's about time there was such a keyword. We've got a million plus > lines of C code here, and hardly a line of it needs to know what a structure > looks like internally. For our purposes (as for most application programmers) > structure member reordering should be the default. I disagree. One of the main reasons I use structures is to describe tables that will be used to share data between machines and/or between languages. For this reason, I want all the fields to be in the order I specify _AND_ I want them contiguous (_NO_ compiler generated padding). Any automatically generated padding or alignment may vary from compiler to compiler and almost certainly _will_ vary from one machine to another. If I design a table that tends to span word boudaries with fields, or has fields that begin at clumsy places - that's my fault and I'll take the performance penalty - at least the data will be shared correctly.
Technical Details
Message-ID:
<11541@lanl.gov>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lanl!jlgReferences:
<583@geovision.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.arch Subject: Re: Sorting struct members for alignment (was Re: Unaligned Accesses) Message-ID: <11541@lanl.gov> Date: 5 Apr 89 22:11:42 GMT References: <583@geovision.UUCP> Organization: Los Alamos National Laboratory Lines: 16