
Dear Ben Warren,
In message 4980CC59.1070302@gmail.com you wrote:
My idea should be to declare a define like this
#define PKT_HEADER __attribute__((__packed__))
my 2EuroCents.
best regards,
luigi
OK, sounds good. Send a patch please.
Hm... and what does this give us?
How long until sombebody detects that all the data structures describing device register layout or so many processors and chips don't use any __packed__ either? Except for some (IMHO broken, but I know that I'm more attached to PowerPC anyway) ARM systems it is sufficient to use a "sane" selection of data types.
I vote against changing this code. Just for a quick cross-check: do the corresponding data structs in the Linux kernel use any __packed__?
Here is for example a copy of /usr/include/netinet/ip.h :
... struct iphdr { #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int ihl:4; unsigned int version:4; #elif __BYTE_ORDER == __BIG_ENDIAN unsigned int version:4; unsigned int ihl:4; #else # error "Please fix <bits/endian.h>" #endif u_int8_t tos; u_int16_t tot_len; u_int16_t id; u_int16_t frag_off; u_int8_t ttl; u_int8_t protocol; u_int16_t check; u_int32_t saddr; u_int32_t daddr; /*The options start here. */ }; ...
Do you see any __packed__?
Best regards,
Wolfgang Denk