summaryrefslogtreecommitdiff
path: root/ext/dnet/ip.h
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dnet/ip.h')
-rw-r--r--ext/dnet/ip.h44
1 files changed, 5 insertions, 39 deletions
diff --git a/ext/dnet/ip.h b/ext/dnet/ip.h
index 95b7718fb..d2f9ad1d8 100644
--- a/ext/dnet/ip.h
+++ b/ext/dnet/ip.h
@@ -428,47 +428,13 @@ inline int
ip_cksum_add(const void *buf, size_t len, int cksum)
{
uint16_t *sp = (uint16_t *)buf;
- int n, sn;
+ int sn;
sn = len / 2;
- n = (sn + 15) / 16;
-
- /* XXX - unroll loop using Duff's device. */
- switch (sn % 16) {
- case 0: do {
- cksum += *sp++;
- case 15:
- cksum += *sp++;
- case 14:
- cksum += *sp++;
- case 13:
- cksum += *sp++;
- case 12:
- cksum += *sp++;
- case 11:
- cksum += *sp++;
- case 10:
- cksum += *sp++;
- case 9:
- cksum += *sp++;
- case 8:
- cksum += *sp++;
- case 7:
- cksum += *sp++;
- case 6:
- cksum += *sp++;
- case 5:
- cksum += *sp++;
- case 4:
- cksum += *sp++;
- case 3:
- cksum += *sp++;
- case 2:
- cksum += *sp++;
- case 1:
- cksum += *sp++;
- } while (--n > 0);
- }
+
+ do {
+ cksum += *sp++;
+ } while (--sn > 0);
if (len & 1)
cksum += htons(*(u_char *)sp << 8);