[releng_6 tinderbox] failure on sparc64/sparc64

Max Laier max at love2party.net
Sun Feb 5 07:55:48 PST 2006


On Sunday 05 February 2006 09:48, Stefan Farfeleder wrote:
> 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.

You could embed the original struct contents with an uint32_t array in an 
union.  That way you don't even have to cast.

e.g.:
struct foo {
	union {
		struct foo_orig {
			field1;
			field2;
		} orig;
		uint32_t array[SIZE];
	} wrap;
#define field1 wrap.orig.field1
#define field2 wrap.orig.field2
};

You should obviously make sure that the fields are named uniquely and the 
header is private to you.

-- 
/"\  Best regards,                      | mlaier at freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier at EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20060205/11168d71/attachment.bin


More information about the freebsd-arch mailing list