From: Wolfgang Denk Date: Mon, 04 Oct 2010 12:44:43 +0200 Subject: [U-Boot] packed attribute problem In-Reply-To: <4CA9ACAA.2020001@st.com> References: <4CA9A095.9000900@st.com> <20101004101714.A19931539A0@gemini.denx.de> <4CA9ACAA.2020001@st.com> Message-ID: <20101004104443.09AE41539A0@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Vipin Kumar, In message <4CA9ACAA.2020001@st.com> you wrote: > > >> This writel results in writing byte by byte on the address pointed to by status_reg. > >> This problem is visible with both gcc version 4.4.1 as well as 4.5.0 > > > > I bet this is on some ARM system? > > Yes, it is on an ARM system (CortexA9). But I still feel that since I am creating > a new u32 * status_reg, the code should not use any intelligence and use the pointer > only to produce an str instruction in the form > str r0, [r1] > > But it retains the packed property of the structure even with a new u32 ponter > typecasted to u32 * > u32 * status_reg = (u32 *)xyz->x; > > A writel to status_reg results in byte by byte writing I agree with you. I always considered such behaviour of the ARM C compiler a bug, and still do. However, people with better knowledge of the ARm architecture than me might be able to explain why the responsible PTB consider this to be a good and necessary "feature" of th compiler. > > Hm... Why do these structs have any "__attribute__ ((packed))" at all? > > Even I could not understand that very well Eventually alignment of these structs cannot be guaranteed? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de PLEASE NOTE: Some Quantum Physics Theories Suggest That When the Con- sumer Is Not Directly Observing This Product, It May Cease to Exist or Will Exist Only in a Vague and Undetermined State.