diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-10 16:28:08 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-10 16:28:08 +0000 |
commit | c63a13af0b0ab849d62890c00d09ff1fab754141 (patch) | |
tree | 48c27624ef42160285f9202e4acd44537e496f76 /nuttx/net | |
parent | aa6af4588d7552b583662c9063d074a1b4f2d931 (diff) | |
download | px4-nuttx-c63a13af0b0ab849d62890c00d09ff1fab754141.tar.gz px4-nuttx-c63a13af0b0ab849d62890c00d09ff1fab754141.tar.bz2 px4-nuttx-c63a13af0b0ab849d62890c00d09ff1fab754141.zip |
Workaround for ARM optimization bug: Use memcmp/memcpy when working with arrays
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@435 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/uip/uip-tcpconn.c | 17 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpinput.c | 20 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpsend.c | 12 |
3 files changed, 10 insertions, 39 deletions
diff --git a/nuttx/net/uip/uip-tcpconn.c b/nuttx/net/uip/uip-tcpconn.c index d2e211232..0f48a4607 100644 --- a/nuttx/net/uip/uip-tcpconn.c +++ b/nuttx/net/uip/uip-tcpconn.c @@ -449,18 +449,12 @@ struct uip_conn *uip_tcpaccept(struct uip_tcpip_hdr *buf) uip_ipaddr_copy(conn->ripaddr, uip_ip4addr_conv(buf->srcipaddr)); conn->tcpstateflags = UIP_SYN_RCVD; - conn->snd_nxt[0] = g_tcp_sequence[0]; - conn->snd_nxt[1] = g_tcp_sequence[1]; - conn->snd_nxt[2] = g_tcp_sequence[2]; - conn->snd_nxt[3] = g_tcp_sequence[3]; + memcpy(conn->snd_nxt, g_tcp_sequence, 4); conn->len = 1; /* rcv_nxt should be the seqno from the incoming packet + 1. */ - conn->rcv_nxt[3] = buf->seqno[3]; - conn->rcv_nxt[2] = buf->seqno[2]; - conn->rcv_nxt[1] = buf->seqno[1]; - conn->rcv_nxt[0] = buf->seqno[0]; + memcpy(conn->rcv_nxt, buf->seqno, 4); /* Initialize the list of TCP read-ahead buffers */ @@ -612,14 +606,9 @@ int uip_tcpconnect(struct uip_conn *conn, const struct sockaddr_in *addr) /* Initialize and return the connection structure, bind it to the port number */ conn->tcpstateflags = UIP_SYN_SENT; - - conn->snd_nxt[0] = g_tcp_sequence[0]; - conn->snd_nxt[1] = g_tcp_sequence[1]; - conn->snd_nxt[2] = g_tcp_sequence[2]; - conn->snd_nxt[3] = g_tcp_sequence[3]; + memcpy(conn->snd_nxt, g_tcp_sequence, 4); conn->initialmss = conn->mss = UIP_TCP_MSS; - conn->len = 1; /* TCP length of the SYN is one. */ conn->nrtx = 0; conn->timer = 1; /* Send the SYN next time around. */ diff --git a/nuttx/net/uip/uip-tcpinput.c b/nuttx/net/uip/uip-tcpinput.c index 11fb7cee0..8b551ca9e 100644 --- a/nuttx/net/uip/uip-tcpinput.c +++ b/nuttx/net/uip/uip-tcpinput.c @@ -292,7 +292,7 @@ found: len = (BUF->tcpoffset >> 4) << 2; /* d_len will contain the length of the actual TCP data. This is - * calculated by subtracing the length of the TCP header (in + * calculated by subtracting the length of the TCP header (in * len) and the length of the IP header (20 bytes). */ @@ -307,10 +307,7 @@ found: ((BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK)))) { if ((dev->d_len > 0 || ((BUF->flags & (TCP_SYN | TCP_FIN)) != 0)) && - (BUF->seqno[0] != conn->rcv_nxt[0] || - BUF->seqno[1] != conn->rcv_nxt[1] || - BUF->seqno[2] != conn->rcv_nxt[2] || - BUF->seqno[3] != conn->rcv_nxt[3])) + memcmp(BUF->seqno, conn->rcv_nxt, 4) != 0) { uip_tcpsend(dev, conn, TCP_ACK, UIP_IPTCPH_LEN); return; @@ -330,15 +327,11 @@ found: uint8 acc32[4]; uip_add32(conn->snd_nxt, conn->len, acc32); - if (BUF->ackno[0] == acc32[0] && BUF->ackno[1] == acc32[1] && - BUF->ackno[2] == acc32[2] && BUF->ackno[3] == acc32[3]) + if (memcmp(BUF->ackno, acc32, 4) == 0) { /* Update sequence number. */ - conn->snd_nxt[0] = acc32[0]; - conn->snd_nxt[1] = acc32[1]; - conn->snd_nxt[2] = acc32[2]; - conn->snd_nxt[3] = acc32[3]; + memcpy(conn->snd_nxt, acc32, 4); /* Do RTT estimation, unless we have done retransmissions. */ @@ -477,10 +470,7 @@ found: } conn->tcpstateflags = UIP_ESTABLISHED; - conn->rcv_nxt[0] = BUF->seqno[0]; - conn->rcv_nxt[1] = BUF->seqno[1]; - conn->rcv_nxt[2] = BUF->seqno[2]; - conn->rcv_nxt[3] = BUF->seqno[3]; + memcpy(conn->rcv_nxt, BUF->seqno, 4); nvdbg("TCP state: UIP_ESTABLISHED\n"); uip_incr32(conn->rcv_nxt, 1); diff --git a/nuttx/net/uip/uip-tcpsend.c b/nuttx/net/uip/uip-tcpsend.c index ae58ad576..5b28539bb 100644 --- a/nuttx/net/uip/uip-tcpsend.c +++ b/nuttx/net/uip/uip-tcpsend.c @@ -170,18 +170,10 @@ static void uip_tcpsendcomplete(struct uip_driver_s *dev) static void uip_tcpsendcommon(struct uip_driver_s *dev, struct uip_conn *conn) { - BUF->ackno[0] = conn->rcv_nxt[0]; - BUF->ackno[1] = conn->rcv_nxt[1]; - BUF->ackno[2] = conn->rcv_nxt[2]; - BUF->ackno[3] = conn->rcv_nxt[3]; - - BUF->seqno[0] = conn->snd_nxt[0]; - BUF->seqno[1] = conn->snd_nxt[1]; - BUF->seqno[2] = conn->snd_nxt[2]; - BUF->seqno[3] = conn->snd_nxt[3]; + memcpy(BUF->ackno, conn->rcv_nxt, 4); + memcpy(BUF->seqno, conn->snd_nxt, 4); BUF->proto = UIP_PROTO_TCP; - BUF->srcport = conn->lport; BUF->destport = conn->rport; |