tcpdump mailing list archives

Re: alignment


From: Guy Harris <guy () netapp com>
Date: Fri, 8 Nov 2002 18:03:40 -0800

On Sat, Nov 09, 2002 at 10:34:50AM +0900, Jun-ichiro itojun Hagino wrote:
   on alignment - what was the reason why we can't do
   __alignment__((__packed__))?  is it GCC specific?
Yes, it is GCC-specific.

      is there any portable way of doing this? (other than byte-by-byte
      fetching)

None that I know of.  Some compilers have similar features, I think
(MSVC++ has something similar).  I don't know whether all compilers that
have it generate "safe" code on strict-alignment processors (although it
seems stupid *not* to).  I suspect not all compilers people would use to
compile tcpdump or libpcap have it.

      if not, is it acceptable if we test the feature in
      configure.in and use it if available?

I'd say so (as long as this doesn't involve peppering the code with
#ifdefs - if the feature *isn't* available, you still have to use the
EXTRACT macros), although note that "__attribute((packed))", at least
according to the GCC 3.2 manual:

        http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Variable-Attributes.html#Variable%20Attributes

changes the layout of the structure, so you'd have to add padding to
structures that lack it.
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe


Current thread: