Included patch #5920: Create define to override C-library memcpy. 2 Defines are created: MEMCPY() for normal memcpy, SMEMCPY() for situations where some compilers might inline the copy and save a function call. Also replaced all calls to memcpy() with calls to (S)MEMCPY().

This commit is contained in:
goldsimon
2007-05-10 05:20:05 +00:00
parent b41520f9e2
commit 255d5a748f
18 changed files with 51 additions and 34 deletions

View File

@@ -141,7 +141,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
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 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
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;

View File

@@ -74,7 +74,7 @@ copy_from_pbuf(struct pbuf *p, u16_t * offset,
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 @@ ip_reass(struct pbuf *p)
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(struct pbuf *p)
("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 @@ ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest)
/* 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));

View File

@@ -130,7 +130,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
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 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
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;

View File

@@ -58,7 +58,7 @@ ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2)
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];

View File

@@ -808,7 +808,7 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from)
/* 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

View File

@@ -747,7 +747,7 @@ tcp_seg_copy(struct tcp_seg *seg)
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;
}

View File

@@ -213,7 +213,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
}
++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 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* 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),