patchlwIP - A Lightweight TCP/IP stack - Patches: patch #6843, tcp.h macro optimization patch

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #6843: tcp.h macro optimization patch

Submitter:  Bill Auerbach <billauerbach>
Submitted:  Thu 28 May 2009 07:43:38 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  goldsimon Open/Closed:  Closed
Planned Release:  1.4.0

Sun 23 Aug 2009 11:13:56 AM UTC, comment #1: 

Checked in after adding casts to u16_t where the compiler needed them.

Simon Goldschmidt <goldsimon>
Group administrator
Thu 28 May 2009 07:43:38 PM UTC, original submission:  

Provided for further testing and possible inclusion in lwIP.  These macros saved over 725 bytes and increased bandwidth noticeably on my not so high-powered little endian processor.  There may be much less (if any) improvement on big endian processors.

The changes in all 3 macros leverage the compiler to do much of the work at compile time instead of at run-time.  This is a prime example where efficient programming can be far superior to a compiler's optimizer regardless of how good its optimizer may be.

For experimenting, place this after the #define for TCP_TCPLEN.  Obviously the #if 1 can be changed to #if 0 to revert to the current macros or to switch back and forth.


#if 1
#undef TCPH_FLAGS_SET
#undef TCPH_SET_FLAG
#undef TCP_TCPLEN
#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & htons(~TCP_FLAGS)) | htons(flags))
#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags))
#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN|TCP_SYN))!=0))
#endif

Bill Auerbach <billauerbach>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by kieranm (Updated the item)
  • -email is unavailable- added by billauerbach (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-08-23 goldsimon Open/ClosedOpen Closed
        StatusNone Done
        Assigned toNone goldsimon
    2009-06-25 kieranm Planned ReleaseNone 1.4.0

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code