From owner-cvs-all@FreeBSD.ORG Tue Nov 14 03:31:08 2006 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5100E16A407 for ; Tue, 14 Nov 2006 03:31:08 +0000 (UTC) (envelope-from jkoshy.freebsd@gmail.com) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.207]) by mx1.FreeBSD.org (Postfix) with ESMTP id D2EDC43D49 for ; Tue, 14 Nov 2006 03:31:06 +0000 (GMT) (envelope-from jkoshy.freebsd@gmail.com) Received: by nz-out-0102.google.com with SMTP id i11so886109nzh for ; Mon, 13 Nov 2006 19:31:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=elT2VxKWiMRoFFD3ZA3mh0LVnhFgVyzv8CFLa5mPKWi+j9buk2Z84RLrSaveWJb2P8I7/pXdI+NHMDcg8KG0QlyrmXo3gwuKXdvyHWRhc9y/TlpDNFfvMLdqCIEQ4zVG80uIdc/GUWCdl1qyP9EuY5LbzvCYy1bU/2K2e6Y5j2M= Received: by 10.64.199.2 with SMTP id w2mr225729qbf.1163475066183; Mon, 13 Nov 2006 19:31:06 -0800 (PST) Received: by 10.64.10.8 with HTTP; Mon, 13 Nov 2006 19:31:06 -0800 (PST) Message-ID: Date: Tue, 14 Nov 2006 09:01:06 +0530 From: "Joseph Koshy" Sender: jkoshy.freebsd@gmail.com To: "Bruce Evans" In-Reply-To: <20061114050457.M77914@delplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200611130428.kAD4ST0U093715@repoman.freebsd.org> <20061113173927.Q75708@delplex.bde.org> <20061113.101808.-1540392146.imp@bsdimp.com> <20061114050457.M77914@delplex.bde.org> X-Google-Sender-Auth: 1166472d036d73d0 Cc: cvs-src@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org, "M. Warner Losh" Subject: Re: cvs commit: src/include ar.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2006 03:31:08 -0000 bde> Non-broken code knows that byte-aligned data needs to be copied bde> into structs using memcpy(). Do keep in mind that this is `struct ar_hdr' we are talking about, not something else. Having to use memcpy() to copy from a collection of ASCII strings (in file) to a collection of ASCII strings (in struct ar_hdr) to cope with alignment issues is odd. To be truly portable, code needs to memcpy() in each ASCII string member of `struct ar_hdr' separately since we cannot make assumptions about the file and memory layout being identical. Needless to say no code in our tree does this today. So we need to look at the original intent of why a `struct ar_hdr' was declared as a collection of fixed size ASCII strings. My guess is that it was written that way to be able to directly describe its file layout: ASCII for portability and fixed size char[] arrays to avoid issues with structure padding. Declaring it as __packed informs today's compilers of this intent. It also brings down the alignment requirements for `struct ar_hdr' on the ARM to match that of other platforms as a side-effect. bde> I doubt that it is needed for more than breaking the warning. You bde> would have to be unlucky or shooting your feet for bde> "(struct ar *)&byte_array[offset]" to give a pointer that is actually bde> misaligned. Large arrays of chars are normally aligned to the word bde> size even if they are on the stack, and the archive header is at offset bde> 0 in files. In an ar(1) archive, there is a `struct ar_hdr' before each archive member. The only 'alignment' expected for this structure is that of falling on even offsets in the file. This is only enforced programmatically though. Regards, Koshy