Date: Sun, 05 Feb 2006 09:25:07 -0700 (MST) From: "M. Warner Losh" <imp@bsdimp.com> To: des@des.no Cc: arch@FreeBSD.org, stefanf@FreeBSD.org Subject: Re: [releng_6 tinderbox] failure on sparc64/sparc64 Message-ID: <20060205.092507.58804812.imp@bsdimp.com> In-Reply-To: <867j89n71d.fsf@xps.des.no> References: <20060204.155856.39766510.imp@bsdimp.com> <20060205084813.GN21806@wombat.fafoe.narf.at> <867j89n71d.fsf@xps.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <867j89n71d.fsf@xps.des.no> des@des.no (Dag-Erling Sm=F8rgrav) writes: : Stefan Farfeleder <stefanf@FreeBSD.org> writes: : > On Sat, Feb 04, 2006 at 03:58:56PM -0700, M. Warner Losh wrote: : > > This driver wants to access these structures as arrays of uint32_= t. : > > It used to cast directly, but that isn't allowed. So, I've passe= d : > > the cast through a (void *). Is that allowed? Eg: : > > = : > > struct foo foo; : > > ((uint32_t *)(void *)&foo)[3] =3D 12; : > > = : > > is that OK? : > I'm afraid that only silences the warning without solving the under= lying : > problem. I don't think there's a Standard conforming way to treat = a : > struct foo as an uint32_t array. : = : A union should do the trick. Does the answer change when all that's being done is reading the contents of the memory to be sent out over, say, the pci bus to a specific memory location? The code I corrected in an does originally was: for (i =3D 0; i < sizeof(an_rx_desc) / 4; i++) CSR_MEM_AUX_WRITE_4(sc, AN_RX_DESC_OFFSET = + (desc * sizeof(an_rx_desc)) + (i * 4), ((u_int32_t*)&an_rx_desc)[i]); where the second arg is the offset in the card's memory and the third arg is the 32-bit word to write. an_rx_desc looks like: struct an_card_rx_desc { unsigned an_ctrl:15; unsigned an_done:1; unsigned an_len:15; unsigned an_valid:1; u_int64_t an_phys; }; (note to self: this can't work on a big endian machine). I can re-write these things with a union, but isn't there any other way= ? Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060205.092507.58804812.imp>