public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Pantelis Antoniou <panto@intracom.gr>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] struct NS16550 {...} __attribute__ ((packed)) at ns16550.h
Date: Tue, 26 Apr 2005 09:23:33 +0300	[thread overview]
Message-ID: <426DDE65.4060009@intracom.gr> (raw)
In-Reply-To: <20050425194342.9B7F5C1510@atlas.denx.de>

Wolfgang Denk wrote:
> In message <426D0A4C.5000105@intracom.gr> you wrote:
> 
>>Not on ARM it does not.
> 
> 
> Yes, I know? Why did you not quote this part of my message, too?
> 
> 
>>ARM (silently) does the wrong thing i.e. masks out the lower 2 bits.
>>So gcc on ARM generates byte load/stores.
> 
> 
> ...which is broken, especially when there is no need to do this since
> the fields are properly aligned.
> 

The compiler does not know this. A pointer to the structure could be
pointing to an non-aligned address, and when an aligned field within
the structure is accessed it will be not aligned.

This typically happens when networking.

IMHO __attribute((packed)) is deceivingly named, since it implies
two things.

1) Don't leave any space between fields of the structure.
2) Access the fields of the structure even when the alignment of the
    pointer pointing to it is wrong.

Just by the name, you expect only (1).

> Best regards,
> 
> Wolfgang Denk
> 

Regards

Pantelis

  parent reply	other threads:[~2005-04-26  6:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-22 14:57 [U-Boot-Users] struct NS16550 {...} __attribute__ ((packed)) at ns16550.h Woojung.Huh at smsc.com
2005-04-22 18:39 ` Wolfgang Denk
2005-04-25  7:44   ` Jean-Paul Saman
2005-04-25  8:20     ` Wolfgang Denk
2005-04-25 14:06       ` Arthur Shipkowski
2005-04-25 14:56         ` Wolfgang Denk
2005-04-25 15:18           ` Pantelis Antoniou
2005-04-25 19:43             ` Wolfgang Denk
2005-04-25 20:15               ` Arthur Shipkowski
2005-04-25 20:59                 ` Wolfgang Denk
2005-04-26  6:23               ` Pantelis Antoniou [this message]
2005-04-26  7:21                 ` Wolfgang Denk
2005-04-26 14:32                   ` Cory Tusar
  -- strict thread matches above, loose matches on Subject: below --
2005-04-22 18:55 Woojung.Huh at smsc.com

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=426DDE65.4060009@intracom.gr \
    --to=panto@intracom.gr \
    --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