[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #50097] Disabling struct packing should be official

From: Daniel Elstner
Subject: [lwip-devel] [bug #50097] Disabling struct packing should be official
Date: Thu, 19 Jan 2017 19:33:22 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/55.0.2883.87 Chrome/55.0.2883.87 Safari/537.36


                 Summary: Disabling struct packing should be official
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: danielk
            Submitted on: Thu 19 Jan 2017 08:33:20 PM CET
                Category: Documentation
                Severity: 3 - Normal
              Item Group: Feature Request
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: git head



My project is based on the AVR32 UC3C microcontroller, which does not support
unaligned access. For packed structs, the compiler has to assume byte
alignment and thus generates code that does single byte reads/writes and
combines them to 32-bit words using logic operations.

To avoid having to pay that penalty, I define ETH_PAD_SIZE to 2 in my config
and have this in my cc.h header:

#define PACK_STRUCT_FIELD(x) x

This alone accounts for about 6 kiB code size reduction of my flash image. I
haven't made detailed measurements of the runtime speed-up, but the saving
should be to the tune of 6 to 7 cycles per 32-bit word access.

The wiki <http://lwip.wikia.com/wiki/Porting_for_an_OS> hints at the
possibility to disable structure packing, while mentioning that one should
"make sure the system runs stable" when doing so.

Well I did (for several months), and I'm happy to report that it works like a
charm. I also went through all the proto header files and reviewed them to
make sure that none of the proto structs change layout when structure packing
is disabled. All of them appear fine to me.

Thus I think disabling structure packing should perhaps be made an official
configuration option, or at least be mentioned in the reference documentation.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]