[Top][All Lists]

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

[lwip-devel] [patch #6843] tcp.h macro optimization patch

From: Bill Auerbach
Subject: [lwip-devel] [patch #6843] tcp.h macro optimization patch
Date: Thu, 28 May 2009 19:43:40 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2009042316 Firefox/3.0.10


                 Summary: tcp.h macro optimization patch
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: billauerbach
            Submitted on: Thu 28 May 2009 03:43:38 PM EDT
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None



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
#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) &


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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