From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] IP_t should be a "packed" struct
Date: Wed, 28 Jan 2009 13:52:15 -0800 [thread overview]
Message-ID: <4980D38F.4020100@gmail.com> (raw)
In-Reply-To: <20090128213828.13423832E416@gemini.denx.de>
Wolfgang Denk wrote:
> 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.
>
>
>
Well, yeah, I alluded to that in my other e-mail. I'm not crazy about
this either, but don't see any significant downside. Obviously if this
was a common problem, it would have surfaced a long time ago...
> 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__?
>
>
Yeah, I made the same observation, but am not fluent enough in the black
magic of Linux header files to know if packing was being enforced
somewhere else or in some other way that my little brain can't comprehend.
> Best regards,
>
> Wolfgang Denk
>
>
regards,
Ben
next prev parent reply other threads:[~2009-01-28 21:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-27 18:32 [U-Boot] IP_t should be a "packed" struct Luigi 'Comio' Mantellini
2009-01-28 9:42 ` Luigi 'Comio' Mantellini
2009-01-28 17:55 ` Ben Warren
2009-01-28 18:36 ` Jerry Van Baren
2009-01-28 18:58 ` Ben Warren
2009-01-28 20:40 ` Luigi Mantellini
2009-01-28 21:21 ` Ben Warren
2009-01-28 21:38 ` Wolfgang Denk
2009-01-28 21:52 ` Ben Warren [this message]
2009-01-28 22:21 ` Wolfgang Denk
2009-01-28 22:16 ` Luigi Mantellini
2009-01-28 22:27 ` Wolfgang Denk
2009-01-28 23:04 ` Luigi Mantellini
2009-01-29 10:20 ` Wolfgang Denk
2009-01-29 10:37 ` Alessandro Rubini
2009-01-28 20:58 ` Luigi Mantellini
2009-01-28 21:26 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4980D38F.4020100@gmail.com \
--to=biggerbadderben@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox