From owner-freebsd-arch@FreeBSD.ORG Mon Feb 13 08:48:38 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 3769516A420; Mon, 13 Feb 2006 08:48:38 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1D99D43D64; Mon, 13 Feb 2006 08:48:30 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from flame.pc (aris.bedc.ondsl.gr [62.103.39.226]) (authenticated bits=128) by igloo.linux.gr (8.13.5/8.13.5/Debian-3) with ESMTP id k1D8mC9e027694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 13 Feb 2006 10:48:13 +0200 Received: from flame.pc (flame [127.0.0.1]) by flame.pc (8.13.4/8.13.4) with ESMTP id k1D8m3wP060279; Mon, 13 Feb 2006 10:48:03 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by flame.pc (8.13.4/8.13.4/Submit) id k1D8m3MK060259; Mon, 13 Feb 2006 10:48:03 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 13 Feb 2006 10:48:02 +0200 From: Giorgos Keramidas To: Colin Percival Message-ID: <20060213084802.GA53779@flame.pc> References: <20060205084813.GN21806@wombat.fafoe.narf.at> <867j89n71d.fsf@xps.des.no> <20060205220211.GA5151@falcon.midgard.homeip.net> <20060213.002310.125802352.imp@bsdimp.com> <20060213082129.GA13997@flame.pc> <43F04494.4030900@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43F04494.4030900@freebsd.org> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (score=-3.354, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.84, BAYES_00 -2.60, DNS_FROM_RFC_ABUSE 0.20) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr Cc: arch@freebsd.org, stefanf@freebsd.org, des@des.no 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: Mon, 13 Feb 2006 08:48:38 -0000 On 2006-02-13 00:34, Colin Percival wrote: >Giorgos Keramidas wrote: >> On 2006-02-13 00:23, "M. Warner Losh" wrote: >>> struct foo foo; >>> uint32_t value[sizeof(foo) / sizeof(uint32_t)]; >>> >>> memcpy(value, &foo); >>> // write out value one 32-bit word at a time >>> >>> Is that right? Or at least 'proper' here means defined. >> >> AFAIK, yes. > > I agree that the behaviour of the above code is defined, but > I'd be much happier if value[] was defined to be an array of > length ((sizeof(foo) - 1) / sizeof(uint32_t) + 1), just in > case sizeof(foo) happens to not be a multiple of 4. :-) Good thinking. It's probably a good idea to avoid copying random garbage, and using something like: struct foo foo; uint32_t value[sizeof(uint32_t) * (sizeof(foo) / sizeof(uint32_t) + 1)]; and then copying only sizeof(foo) bytes. This is probably defined too and won't allow overflowing of value[], but I don't really want to know what it does on machines of varying endianess :-) - Giorgos