lwip-devel
[Top][All Lists]
Advanced

[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:1.9.0.10) Gecko/2009042316 Firefox/3.0.10

URL:
  <http://savannah.nongnu.org/patch/?6843>

                 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

    _______________________________________________________

Details:

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





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?6843>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

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