From owner-freebsd-arch@FreeBSD.ORG Sun Feb 5 16:27:18 2006 Return-Path: X-Original-To: arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 05AB716A420; Sun, 5 Feb 2006 16:27:18 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9631743D46; Sun, 5 Feb 2006 16:27:17 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id k15GP4FM029015; Sun, 5 Feb 2006 09:25:04 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Sun, 05 Feb 2006 09:25:07 -0700 (MST) Message-Id: <20060205.092507.58804812.imp@bsdimp.com> To: des@des.no From: "M. Warner Losh" 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> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Sun, 05 Feb 2006 09:25:04 -0700 (MST) Cc: arch@FreeBSD.org, stefanf@FreeBSD.org Subject: Re: [releng_6 tinderbox] failure on sparc64/sparc64 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Feb 2006 16:27:18 -0000 In message: <867j89n71d.fsf@xps.des.no> des@des.no (Dag-Erling Sm=F8rgrav) writes: : Stefan Farfeleder 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