From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.redhat.com (Postfix) with ESMTP id 6E0623FF8E for ; Fri, 18 Oct 2002 11:37:00 -0400 (EDT) Received: (from mail@localhost) by int-mx1.corp.redhat.com (8.11.6/8.11.6) id g9IFb0P09183 for axp-list@listman.redhat.com; Fri, 18 Oct 2002 11:37:00 -0400 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with SMTP id g9IFb0f09179 for ; Fri, 18 Oct 2002 11:37:00 -0400 Received: from ellpspace.math.ualberta.ca (ellpspace.math.ualberta.ca [129.128.207.67]) by mx1.redhat.com (8.11.6/8.11.6) with SMTP id g9IFG1w28205 for ; Fri, 18 Oct 2002 11:16:01 -0400 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.11.6/8.11.6) id g9IFaqf02539 for axp-list@redhat.com; Fri, 18 Oct 2002 09:36:52 -0600 Date: Fri, 18 Oct 2002 09:36:52 -0600 From: Michal Jaegermann To: axp-list@redhat.com Subject: Re: unaligned traps question Message-ID: <20021018093652.A2475@ellpspace.math.ualberta.ca> References: <01da01c273e4$d5c57320$35de2b09@Viswanadha> <02101511334803.01593@shadowfax.middleearth> <01d001c2762a$ecdbffa0$35de2b09@Viswanadha> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <01d001c2762a$ecdbffa0$35de2b09@Viswanadha>; from ram@jtcsv.com on Thu, Oct 17, 2002 at 03:17:04PM -0700 X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0.1 Precedence: bulk Reply-To: axp-list@redhat.com List-Help: List-Post: List-Subscribe: , List-Id: Linux and Red Hat on Alpha processors List-Unsubscribe: , List-Archive: On Thu, Oct 17, 2002 at 03:17:04PM -0700, Ram Viswanadha wrote: .... > > so the fix was to change storage to > struct{ > double bogus; /* needed for aligining the storage */ > uint8_t storage[10000000]; > } storageHolder; > > The expectation of the API is that input param "data" is aligned. Err... if you are using such tricks to extricate yourself from bad "type punning", then I would think that using union instead of struct would be vastly preferable. Not only you avoid reserving some memory which we know will be not used for anything but you also get much better chances that alignment restriction for the widest type will be applied to all union members. With struct a compiler can insert any amount of padding betwen fields. Sure, in this particular case you would not expect that but relying on a compiler "reasonable behaviour" is by its nature non C Standard conforming hence not portable. "Worksforme on x86" is behind a huge portion of bugs we are seeing on Alpha (and which you will see on Itanium, or Hammer, or ... ). gcc has a way to affect a stucture layout with '__attribute__ ((packed))' but this is "gcc private" construct; widely used in Linux kernel, BTW. It does affect what compiler generated to access fields in structures. Michal