Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Nov 2006 10:18:48 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        phk@phk.freebsd.dk
Cc:        jkoshy@freebsd.org, src-committers@freebsd.org, cvs-all@freebsd.org, bde@zeta.org.au, cvs-src@freebsd.org
Subject:   Re: cvs commit: src/include ar.h 
Message-ID:  <20061113.101848.-1558770561.imp@bsdimp.com>
In-Reply-To: <3801.1163410519@critter.freebsd.dk>
References:  <20061113173927.Q75708@delplex.bde.org> <3801.1163410519@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <3801.1163410519@critter.freebsd.dk>
            "Poul-Henning Kamp" <phk@phk.freebsd.dk> writes:
: In message <20061113173927.Q75708@delplex.bde.org>, Bruce Evans writes:
: >On Mon, 13 Nov 2006, Joseph Koshy wrote:
: >
: >> jkoshy      2006-11-13 04:28:29 UTC
: >>
: >>  FreeBSD src repository
: >>
: >>  Modified files:
: >>    include              ar.h
: >>  Log:
: >>  Attempt to improve application portability by marking `struct ar_hdr'
: >>  as `packed'.
: >>
: >>  The C standard leaves the alignment of individual members of a C
: >>  struct upto the implementation, so pedantically speaking portable
: >>  code cannot assume that the layout of a `struct ar_hdr' in memory
: >>  will match its layout in a file.  Using a __packed attribute
: >>  declaration forces file and memory layouts for this structure to
: >>  match.
: >>
: >>  Submitted by:   ru
: >
: >I don't see how this can be more portable.
: 
: I agree with bruce that __packed is not the way to go.
: 
: For things that represent communication protocols, even if
: they happen through files, I advocate using the functions
: in sys/endian.h to explicitly decode and encode fields into
: bytestrings.

Until that happens, __packed is the only way to get correct code on
the arm.

Warner



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