tcpdump mailing list archives

Re: alignment


From: Jun-ichiro itojun Hagino <itojun () iijlab net>
Date: Sat, 09 Nov 2002 11:50:17 +0900

     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),

        i was thinking about something like this:

#if GCC
#define __ATTRIBUTE_PACKED__    __attribute__((packed))
#else
#define __ATTRIBUTE_PACKED__
#endif

struct foo {
        u_int32_t bar;
        u_int32_t baz;
} __ATTRIBUTE_PACKED__;

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.

        if they don't have padding, they do not work right even now.

itojun
-
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: