tcpdump mailing list archives
Re: alignment
From: Guy Harris <gharris () sonic net>
Date: Sat, 9 Nov 2002 14:49:50 -0800
On Sun, Nov 10, 2002 at 01:56:23AM +0900, Jun-ichiro itojun Hagino wrote:
i mean, if there's any structure decl which depends on automatic
padding now, the struct definition will be interpreted differently
on 64bit and 32bit arch (= doesn't work correctly).
*Might* be interpreted differently.
I would expect compilers on at least some 64-bit architectures to lay
out
struct foo {
u_int32_t a;
u_int8_t b;
u_int32_t c;
};
the same as
struct foo_padded {
u_int32_t a;
u_int8_t b;
u_int8_t pad[3];
u_int32_t c;
};
as there's nothing in the structure requiring more than a 32-bit
alignment. (In fact, I'd be surprised if compilers on *any* 64-bit
architecture put more than 3 bytes of padding before "c".)
Now, a compiler on a 64-bit architecture might add an *additional* four
bytes of padding to pad "struct foo" - or "struct foo_padded" - to a
multiple of 8 bytes, but that can even happen on 32-bit architectures;
at least some versions of GCC on ARM apparently pad all structures to a
multiple of 4 bytes, which is why "ether.h" defines ETHER_HDRLEN as 14
and why "print-ether.c" uses ETHER_HDRLEN rather than "sizeof (struct
ether_header)".
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe
Current thread:
- alignment itojun (Nov 08)
- Re: alignment Guy Harris (Nov 08)
- Re: alignment Jun-ichiro itojun Hagino (Nov 08)
- Re: alignment Guy Harris (Nov 08)
- Re: alignment Jun-ichiro itojun Hagino (Nov 08)
- Re: alignment Guy Harris (Nov 08)
- Re: alignment Jun-ichiro itojun Hagino (Nov 09)
- Re: alignment Guy Harris (Nov 09)
- Re: alignment Jun-ichiro itojun Hagino (Nov 08)
- Re: alignment Guy Harris (Nov 10)
- Re: alignment Guy Harris (Nov 08)
- Re: alignment Guy Harris (Dec 11)
