9
0
Fork 0

Workaround for ARM optimization bug: Use memcmp/memcpy when working with arrays

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@435 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2007-12-10 16:28:08 +00:00
parent 0ab59c9ca6
commit 9ed2b9876c
3 changed files with 10 additions and 39 deletions

View File

@ -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. */

View File

@ -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);

View File

@ -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;