This is the mail archive of the 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]

Re: How to stop gcc padding structs???

On Mon, Jan 29, 2001 at 05:48:14PM -0000, David Korn wrote:
> >> True.  I suppose for maximum portability I should just use
> >> pointer arithmatic with hard-wired offsets.  It's just so ugly.
> >
> >Which of course will not work so well if your device is put into a non-x86
> or
> >non-ppc that traps when given an unaligned pointer (ie, a normal RISC
> >machine).
>   IOW, for maximum portability, you must memcpy every struct element larger
> than a byte into an object of the correct type, then use ntoh(l,s) whatever
> to handle endian-ness, and only then reference it.

The other way is to pick up each individual byte and or/shift them together.
I've thought about in the past having GCC recognize such loads and turn them
into a single unaligned load operation (possibly an unaligned load and reverse
byte operation).  This is how BFD handles things.

Michael Meissner, Red Hat, Inc.  (GCC group)
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:		phone: +1 978-486-9304
Non-work:	fax:   +1 978-692-4482

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