lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] Checksum optimizations


From: address@hidden
Subject: Re: [lwip-devel] Checksum optimizations
Date: Mon, 25 Feb 2008 22:06:41 +0100
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Bill Auerbach wrote:

Additionally:

u16_t

inet_chksum(void *dataptr, u16_t len)

{

  u32_t acc;

  acc = LWIP_CHKSUM(dataptr, len);

  while ((acc >> 16) != 0) {

    acc = (acc & 0xffff) + (acc >> 16);

  }

  return (u16_t)~(acc & 0xffff);

}

Can be:

u16_t

inet_chksum(void *dataptr, u16_t len)

{

  u32_t acc;

  acc = LWIP_CHKSUM(dataptr, len);

  return (u16_t)~(acc & 0xffff);

}

Because LWIP_CHKSUM returns a u16_t and thus the while loop can never execute.

So the whole function can be effectively optimized away using:
#define inet_chksum(x,y) ~LWIP_CHKSUM(x,y)
?


Simon




reply via email to

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