Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Feb 2006 16:56:57 +0100
From:      Max Laier <max@love2party.net>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        des@des.no, Stefan Farfeleder <stefanf@freebsd.org>, freebsd-arch@freebsd.org
Subject:   Re: [releng_6 tinderbox] failure on sparc64/sparc64
Message-ID:  <200602051657.06224.max@love2party.net>
In-Reply-To: <20060205084813.GN21806@wombat.fafoe.narf.at>
References:  <20060204211357.GD7604@ip.net.ua> <20060204.155856.39766510.imp@bsdimp.com> <20060205084813.GN21806@wombat.fafoe.narf.at>

next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart2221331.id6B1i7EH1
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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] =3D 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=20
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=20
header is private to you.

=2D-=20
/"\  Best regards,                      | mlaier@freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News

--nextPart2221331.id6B1i7EH1
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (FreeBSD)

iD8DBQBD5iBSXyyEoT62BG0RAjqVAJ9RTT6uq28fZJonsL/m6tHgrGRTFQCdGZ5h
3I+Fc5f8wAk89tmqE9IwXxk=
=FiKF
-----END PGP SIGNATURE-----

--nextPart2221331.id6B1i7EH1--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602051657.06224.max>