[releng_6 tinderbox] failure on sparc64/sparc64
M. Warner Losh
imp at bsdimp.com
Sun Feb 5 08:27:18 PST 2006
In message: <867j89n71d.fsf at xps.des.no>
des at des.no (Dag-Erling Smørgrav) writes:
: Stefan Farfeleder <stefanf at 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 passed
: > > the cast through a (void *). Is that allowed? Eg:
: > >
: > > struct foo foo;
: > > ((uint32_t *)(void *)&foo)[3] = 12;
: > >
: > > is that OK?
: > I'm afraid that only silences the warning without solving the underlying
: > 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 = 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
More information about the freebsd-arch
mailing list