Index: src/api/api_lib.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/api_lib.c,v
retrieving revision 1.36
diff -u -r1.36 api_lib.c
--- src/api/api_lib.c	4 May 2007 15:18:30 -0000	1.36
+++ src/api/api_lib.c	8 May 2007 19:02:21 -0000
@@ -171,7 +171,7 @@
       if (buf_copy_len > len)
           buf_copy_len = len;
       /* copy the necessary parts of the buffer */
-      memcpy(&((char*)dataptr)[left], &((char*)p->payload)[offset], buf_copy_len);
+      MEMCPY(&((char*)dataptr)[left], &((char*)p->payload)[offset], buf_copy_len);
       left += buf_copy_len;
       len -= buf_copy_len;
       offset = 0;
Index: src/api/sockets.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/sockets.c,v
retrieving revision 1.44
diff -u -r1.44 sockets.c
--- src/api/sockets.c	4 May 2007 15:18:30 -0000	1.44
+++ src/api/sockets.c	8 May 2007 19:03:52 -0000
@@ -191,7 +191,7 @@
   if (*addrlen > sizeof(sin))
       *addrlen = sizeof(sin);
 
-  memcpy(addr, &sin, *addrlen);
+  SMEMCPY(addr, &sin, *addrlen);
 
   newsock = alloc_socket(newconn);
   if (newsock == -1) {
@@ -412,7 +412,7 @@
     if (*fromlen > sizeof(sin))
       *fromlen = sizeof(sin);
 
-    memcpy(from, &sin, *fromlen);
+    SMEMCPY(from, &sin, *fromlen);
 
     LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s));
     ip_addr_debug_print(SOCKETS_DEBUG, addr);
@@ -890,7 +890,7 @@
   if (*namelen > sizeof(sin))
       *namelen = sizeof(sin);
 
-  memcpy(name, &sin, *namelen);
+  SMEMCPY(name, &sin, *namelen);
   sock_set_errno(sock, 0);
   return 0;
 }
@@ -922,7 +922,7 @@
   if (*namelen > sizeof(sin))
       *namelen = sizeof(sin);
 
-  memcpy(name, &sin, *namelen);
+  SMEMCPY(name, &sin, *namelen);
   sock_set_errno(sock, 0);
   return 0;
 }
Index: src/core/pbuf.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/pbuf.c,v
retrieving revision 1.95
diff -u -r1.95 pbuf.c
--- src/core/pbuf.c	4 May 2007 21:31:25 -0000	1.95
+++ src/core/pbuf.c	8 May 2007 19:06:35 -0000
@@ -808,7 +808,7 @@
       /* current p_from does not fit into current p_to */
       len = p_to->len - offset_to;
     }
-    memcpy((u8_t*)p_to->payload + offset_to, (u8_t*)p_from->payload + offset_from, len);
+    MEMCPY((u8_t*)p_to->payload + offset_to, (u8_t*)p_from->payload + offset_from, len);
 #ifdef LWIP_DEBUG  
     copied += len;
 #endif
Index: src/core/tcp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/tcp.c,v
retrieving revision 1.55
diff -u -r1.55 tcp.c
--- src/core/tcp.c	12 Apr 2007 14:56:07 -0000	1.55
+++ src/core/tcp.c	8 May 2007 19:06:41 -0000
@@ -747,7 +747,7 @@
   if (cseg == NULL) {
     return NULL;
   }
-  memcpy((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); 
+  SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); 
   pbuf_ref(cseg->p);
   return cseg;
 }
Index: src/core/tcp_out.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/tcp_out.c,v
retrieving revision 1.50
diff -u -r1.50 tcp_out.c
--- src/core/tcp_out.c	12 Apr 2007 14:56:07 -0000	1.50
+++ src/core/tcp_out.c	8 May 2007 19:07:08 -0000
@@ -213,7 +213,7 @@
       }
       ++queuelen;
       if (arg != NULL) {
-        memcpy(seg->p->payload, ptr, seglen);
+        MEMCPY(seg->p->payload, ptr, seglen);
       }
       seg->dataptr = seg->p->payload;
     }
@@ -280,7 +280,7 @@
       /* Copy options into data portion of segment.
        Options can thus only be sent in non data carrying
        segments such as SYN|ACK. */
-      memcpy(seg->dataptr, optdata, optlen);
+      SMEMCPY(seg->dataptr, optdata, optlen);
     }
     LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, ("tcp_enqueue: queueing %"U32_F":%"U32_F" (0x%"X16_F")\n",
       ntohl(seg->tcphdr->seqno),
Index: src/core/ipv4/icmp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv4/icmp.c,v
retrieving revision 1.27
diff -u -r1.27 icmp.c
--- src/core/ipv4/icmp.c	12 Apr 2007 18:55:44 -0000	1.27
+++ src/core/ipv4/icmp.c	8 May 2007 19:05:36 -0000
@@ -141,7 +141,7 @@
   ICMPH_TYPE_SET(idur, ICMP_DUR);
   ICMPH_CODE_SET(idur, t);
 
-  memcpy((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8);
+  SMEMCPY((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8);
 
   /* calculate checksum */
   idur->chksum = 0;
@@ -179,7 +179,7 @@
   ICMPH_CODE_SET(tehdr, t);
 
   /* copy fields from original packet */
-  memcpy((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8);
+  SMEMCPY((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8);
 
   /* calculate checksum */
   tehdr->chksum = 0;
Index: src/core/ipv4/ip_frag.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv4/ip_frag.c,v
retrieving revision 1.26
diff -u -r1.26 ip_frag.c
--- src/core/ipv4/ip_frag.c	6 Mar 2007 19:31:49 -0000	1.26
+++ src/core/ipv4/ip_frag.c	8 May 2007 19:06:09 -0000
@@ -74,7 +74,7 @@
   p->len -= *offset;
   while (len) {
     l = len < p->len ? len : p->len;
-    memcpy(buffer, p->payload, l);
+    MEMCPY(buffer, p->payload, l);
     buffer += l;
     len -= l;
     if (len)
@@ -141,7 +141,7 @@
      buffer. The timer is updated with the maximum age. */
   if (ip_reasstmr == 0) {
     LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: new packet\n"));
-    memcpy(iphdr, fraghdr, IP_HLEN);
+    SMEMCPY(iphdr, fraghdr, IP_HLEN);
     ip_reasstmr = IP_REASS_MAXAGE;
     ip_reassflags = 0;
     /* Clear the bitmap. */
@@ -277,7 +277,7 @@
            ("ip_reass: memcpy from %p (%"S16_F") to %p, %"S16_F" bytes\n",
             (void *)&ip_reassbuf[i], i, q->payload,
             q->len > ip_reasslen - i ? ip_reasslen - i : q->len));
-          memcpy(q->payload, &ip_reassbuf[i],
+          MEMCPY(q->payload, &ip_reassbuf[i],
             q->len > ip_reasslen - i ? ip_reasslen - i : q->len);
           i += q->len;
         }
@@ -333,7 +333,7 @@
 
   /* Copy the IP header in it */
   iphdr = rambuf->payload;
-  memcpy(iphdr, p->payload, IP_HLEN);
+  SMEMCPY(iphdr, p->payload, IP_HLEN);
 
   /* Save original offset */
   tmp = ntohs(IPH_OFFSET(iphdr));
Index: src/core/ipv6/icmp6.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv6/icmp6.c,v
retrieving revision 1.14
diff -u -r1.14 icmp6.c
--- src/core/ipv6/icmp6.c	25 Nov 2005 12:03:38 -0000	1.14
+++ src/core/ipv6/icmp6.c	8 May 2007 19:06:17 -0000
@@ -130,7 +130,7 @@
   idur->type = (u8_t)ICMP6_DUR;
   idur->icode = (u8_t)t;
 
-  memcpy((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8);
+  SMEMCPY((u8_t *)q->payload + 8, p->payload, IP_HLEN + 8);
 
   /* calculate checksum */
   idur->chksum = 0;
@@ -162,7 +162,7 @@
   tehdr->icode = (u8_t)t;
 
   /* copy fields from original packet */
-  memcpy((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8);
+  SMEMCPY((u8_t *)q->payload + 8, (u8_t *)p->payload, IP_HLEN + 8);
 
   /* calculate checksum */
   tehdr->chksum = 0;
Index: src/core/ipv6/ip6_addr.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/ipv6/ip6_addr.c,v
retrieving revision 1.10
diff -u -r1.10 ip6_addr.c
--- src/core/ipv6/ip6_addr.c	10 Apr 2007 13:18:14 -0000	1.10
+++ src/core/ipv6/ip6_addr.c	8 May 2007 19:06:24 -0000
@@ -58,7 +58,7 @@
 void
 ip_addr_set(struct ip_addr *dest, struct ip_addr *src)
 {
-  memcpy(dest, src, sizeof(struct ip_addr));
+  SMEMCPY(dest, src, sizeof(struct ip_addr));
   /*  dest->addr[0] = src->addr[0];
   dest->addr[1] = src->addr[1];
   dest->addr[2] = src->addr[2];
Index: src/include/lwip/opt.h
===================================================================
RCS file: /sources/lwip/lwip/src/include/lwip/opt.h,v
retrieving revision 1.55
diff -u -r1.55 opt.h
--- src/include/lwip/opt.h	30 Apr 2007 13:12:33 -0000	1.55
+++ src/include/lwip/opt.h	4 May 2007 19:44:13 -0000
@@ -53,6 +53,18 @@
 #define NO_SYS                          0
 #endif
 
+/* override this if you have a faster implementation at hand than the one
+   included in your C library */
+#ifndef MEMCPY
+#define MEMCPY(dst,src,len)             memcpy(dst,src,len)
+#endif
+
+/* override this with care: some compilers (e.g. gcc) can inline a call to
+   memcpy() if the length is known at compile time and is small */
+#ifndef SMEMCPY
+#define SMEMCPY(dst,src,len)            memcpy(dst,src,len)
+#endif
+
 /* ---------- Memory options ---------- */
 #ifndef MEM_LIBC_MALLOC
 #define MEM_LIBC_MALLOC                 0
Index: src/netif/etharp.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/etharp.c,v
retrieving revision 1.106
diff -u -r1.106 etharp.c
--- src/netif/etharp.c	4 May 2007 21:31:25 -0000	1.106
+++ src/netif/etharp.c	8 May 2007 19:07:18 -0000
@@ -576,8 +576,8 @@
  
   /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without
    * structure packing (not using structure copy which breaks strict-aliasing rules). */
-  memcpy(&sipaddr, &hdr->sipaddr, sizeof(sipaddr));
-  memcpy(&dipaddr, &hdr->dipaddr, sizeof(dipaddr));
+  SMEMCPY(&sipaddr, &hdr->sipaddr, sizeof(sipaddr));
+  SMEMCPY(&dipaddr, &hdr->dipaddr, sizeof(dipaddr));
 
   /* this interface is not configured? */
   if (netif->ip_addr.addr == 0) {
Index: src/netif/loopif.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/loopif.c,v
retrieving revision 1.14
diff -u -r1.14 loopif.c
--- src/netif/loopif.c	24 Apr 2007 08:42:32 -0000	1.14
+++ src/netif/loopif.c	8 May 2007 19:07:30 -0000
@@ -114,7 +114,7 @@
    */
   ptr = r->payload;
   for(q = p; q != NULL; q = q->next) {
-    memcpy(ptr, q->payload, q->len);
+    MEMCPY(ptr, q->payload, q->len);
     ptr += q->len;
   }
 
Index: src/netif/ppp/md5.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/ppp/md5.c,v
retrieving revision 1.2
diff -u -r1.2 md5.c
--- src/netif/ppp/md5.c	30 May 2003 08:49:34 -0000	1.2
+++ src/netif/ppp/md5.c	8 May 2007 19:07:36 -0000
@@ -199,7 +199,7 @@
     mdContext->digest[ii+3] =
       (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
   }
-  memcpy(hash, mdContext->digest, 16);
+  SMEMCPY(hash, mdContext->digest, 16);
 }
 
 /* Basic MD5 step. Transforms buf based on in.
Index: src/netif/ppp/ppp.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/ppp/ppp.c,v
retrieving revision 1.12
diff -u -r1.12 ppp.c
--- src/netif/ppp/ppp.c	11 Apr 2007 19:39:40 -0000	1.12
+++ src/netif/ppp/ppp.c	8 May 2007 19:07:56 -0000
@@ -840,7 +840,7 @@
  */
 void ppp_set_xaccm(int unit, ext_accm *accm)
 {
-    memcpy(pppControl[unit].outACCM, accm, sizeof(ext_accm));
+    SMEMCPY(pppControl[unit].outACCM, accm, sizeof(ext_accm));
     PPPDEBUG((LOG_INFO, "ppp_set_xaccm[%d]: outACCM=%X %X %X %X\n",
                 unit,
                 pppControl[unit].outACCM[0],
@@ -1075,11 +1075,11 @@
         st = 0;
         PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd));
     } else {
-		memcpy(&pc->addrs.our_ipaddr, &o, sizeof(o));
-		memcpy(&pc->addrs.his_ipaddr, &h, sizeof(h));
-		memcpy(&pc->addrs.netmask, &m, sizeof(m));
-		memcpy(&pc->addrs.dns1, &ns1, sizeof(ns1));
-		memcpy(&pc->addrs.dns2, &ns2, sizeof(ns2));
+		SMEMCPY(&pc->addrs.our_ipaddr, &o, sizeof(o));
+		SMEMCPY(&pc->addrs.his_ipaddr, &h, sizeof(h));
+		SMEMCPY(&pc->addrs.netmask, &m, sizeof(m));
+		SMEMCPY(&pc->addrs.dns1, &ns1, sizeof(ns1));
+		SMEMCPY(&pc->addrs.dns2, &ns2, sizeof(ns2));
     }
     return st;
 }
@@ -1269,7 +1269,7 @@
 	}
 
 	for(b = p, pl = q->payload; b != NULL; b = b->next) {
-		memcpy(pl, b->payload, b->len);
+		MEMCPY(pl, b->payload, b->len);
 		pl += b->len;
 	}
 
@@ -1394,7 +1394,7 @@
                 }
 #if BYTE_ORDER == LITTLE_ENDIAN
 		protocol = htons(protocol);
-		memcpy(nb->payload, &protocol, sizeof(protocol));
+		SMEMCPY(nb->payload, &protocol, sizeof(protocol));
 #endif
 		lcp_sprotrej(pd, nb->payload, nb->len);
 	}
Index: src/netif/ppp/ppp.h
===================================================================
RCS file: /sources/lwip/lwip/src/netif/ppp/ppp.h,v
retrieving revision 1.8
diff -u -r1.8 ppp.h
--- src/netif/ppp/ppp.h	14 Feb 2007 08:08:35 -0000	1.8
+++ src/netif/ppp/ppp.h	8 May 2007 19:08:11 -0000
@@ -206,7 +206,7 @@
 #define DECPTR(n, cp)   ((cp) -= (n))
 
 #define BCMP(s0, s1, l)     memcmp((u_char *)(s0), (u_char *)(s1), (l))
-#define BCOPY(s, d, l)      memcpy((d), (s), (l))
+#define BCOPY(s, d, l)      MEMCPY((d), (s), (l))
 #define BZERO(s, n)         memset(s, 0, n)
 #if PPP_DEBUG
 #define PRINTMSG(m, l)  { m[l] = '\0'; ppp_trace(LOG_INFO, "Remote message: %s\n", m); }
Index: src/netif/ppp/randm.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/ppp/randm.c,v
retrieving revision 1.4
diff -u -r1.4 randm.c
--- src/netif/ppp/randm.c	14 Nov 2003 14:56:31 -0000	1.4
+++ src/netif/ppp/randm.c	8 May 2007 19:08:26 -0000
@@ -127,7 +127,7 @@
         MD5Update(&md5, (u_char *)&randCount, sizeof(randCount));
         MD5Final(tmp, &md5);
         randCount++;
-        memcpy(buf, tmp, n);
+        MEMCPY(buf, tmp, n);
         buf += n;
         bufLen -= n;
     }
Index: src/netif/ppp/vj.c
===================================================================
RCS file: /sources/lwip/lwip/src/netif/ppp/vj.c,v
retrieving revision 1.6
diff -u -r1.6 vj.c
--- src/netif/ppp/vj.c	21 Mar 2007 12:55:01 -0000	1.6
+++ src/netif/ppp/vj.c	8 May 2007 19:08:42 -0000
@@ -605,7 +605,7 @@
 
 		bufptr = n0->payload;
 		for(q = np; q != NULL; q = q->next) {
-			memcpy(q->payload, bufptr, q->len);
+			MEMCPY(q->payload, bufptr, q->len);
 			bufptr += q->len;
 		}
 
@@ -631,7 +631,7 @@
 		n0 = np;
 	}
 	LWIP_ASSERT("n0->len >= cs->cs_hlen", n0->len >= cs->cs_hlen);
-	memcpy(n0->payload, &cs->cs_ip, cs->cs_hlen);
+	MEMCPY(n0->payload, &cs->cs_ip, cs->cs_hlen);
 
 	*nb = n0;
 
