From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kenneth Johansson Date: Mon, 11 Aug 2008 18:50:02 +0200 Subject: [U-Boot] __attribute__((__packed__)) switching to byte-access on ARM In-Reply-To: References: <20080811160630.20B7D248EA@gemini.denx.de> Message-ID: <1218473402.7889.17.camel@localhost.localdomain> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, 2008-08-11 at 18:23 +0200, Guennadi Liakhovetski wrote: > I cannot think of any such examples... I know access-types can be changed > on the hardware, say, on a 16-bit bus a 32-bit access can be split into > two 16-bit accesses, but I currently cannot think of any examples of the > compiler doing such things. But, I think, I can imagine _why_ the compiler > might decide to do that - it cannot guarantee, that the structure is > 32-bit aligned, so, it is opting for the "safe" variant... So, the > question is: is the compiler right and the c-code was wrong, or the other > way round? Both are "right" :). C has a lot of implementation specific stuff that can make life interesting. Simple thing like if char is signed or unsigned sometimes is really important. If you have to make sure that the read/write is done in 16 bit the only option is to use assembler code.