From: Wolfgang Denk Date: Mon, 04 Oct 2010 12:17:14 +0200 Subject: [U-Boot] packed attribute problem In-Reply-To: <4CA9A095.9000900@st.com> References: <4CA9A095.9000900@st.com> Message-ID: <20101004101714.A19931539A0@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 <4CA9A095.9000900@st.com> you wrote: > > I encountered a problem something like > > struct xyz { > int x; > int y; > int z[CONST]; > } __attribute__ ((packed)); > > struct xyz *abc; > u32 * status_reg = (u32 *)&abc->z[0]; > > writel(status, status_reg); > > 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? > Incidently, the same code works well with 4.2.4 ...which surprises me. I thought this has always been an ARM "feature". > The problem is visible in the usb host driver which uses the packed structures for > accessing device registers. Hm... Why do these structs have any "__attribute__ ((packed))" at all? 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 If I had to live my life again, I'd make the same mistakes, only sooner. -- Tallulah Bankhead