changed uip_buf to a union for 32-bit alignment

This commit is contained in:
joxe 2010-05-24 10:07:34 +00:00
parent 9db7f06368
commit 2d447502d4
4 changed files with 18 additions and 17 deletions

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: sicslowpan.c,v 1.39 2010/05/11 10:02:29 nifi Exp $
* $Id: sicslowpan.c,v 1.40 2010/05/24 10:07:34 joxe Exp $
*/
/**
* \file
@ -157,8 +157,8 @@ void uip_log(char *msg);
/** \name Pointers in the sicslowpan and uip buffer
* @{
*/
#define SICSLOWPAN_IP_BUF ((struct uip_ip_hdr *)&sicslowpan_buf[UIP_LLH_LEN])
#define SICSLOWPAN_UDP_BUF ((struct uip_udp_hdr *)&sicslowpan_buf[UIP_LLIPH_LEN])
#define SICSLOWPAN_IP_BUF ((struct uip_ip_hdr *)&sicslowpan_buf.u8[UIP_LLH_LEN])
#define SICSLOWPAN_UDP_BUF ((struct uip_udp_hdr *)&sicslowpan_buf.u8[UIP_LLIPH_LEN])
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define UIP_UDP_BUF ((struct uip_udp_hdr *)&uip_buf[UIP_LLIPH_LEN])
@ -221,9 +221,7 @@ static u16_t sicslowpan_len;
* It has a fix size as we do not use dynamic memory allocation.
*/
/* Allocate buffer as 32 bit to ensure that it is 32-bit aligned */
static uint32_t uip_buf32[(UIP_BUFSIZE + 3) / 4];
static uint8_t * const sicslowpan_buf = (uint8_t * const) uip_buf32;
static uip_buf_t sicslowpan_buf;
/** The total length of the IPv6 packet in the sicslowpan_buf. */

View file

@ -41,7 +41,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: uip.c,v 1.27 2010/05/08 07:23:55 oliverschmidt Exp $
* $Id: uip.c,v 1.28 2010/05/24 10:07:34 joxe Exp $
*
*/
@ -126,13 +126,11 @@ const struct uip_eth_addr uip_ethaddr = {{UIP_ETHADDR0,
struct uip_eth_addr uip_ethaddr = {{0,0,0,0,0,0}};
#endif
/* The packet buffer that contains incoming packets. */
#ifdef UIP_CONF_PLAIN_BUFFER
uint8_t uip_buf[UIP_BUFSIZE + 2];
#else /* UIP_CONF_PLAIN_BUFFER */
static uint32_t uip_buf32[(UIP_BUFSIZE + 3) / 4];
uint8_t * const uip_buf = (uint8_t * const)uip_buf32;
/* The packet buffer that contains
incoming packets. */
uip_buf_t uip_aligned_buf;
#endif /* UIP_CONF_PLAIN_BUFFER */
void *uip_appdata; /* The uip_appdata pointer points to

View file

@ -47,7 +47,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: uip.h,v 1.32 2010/05/08 07:23:55 oliverschmidt Exp $
* $Id: uip.h,v 1.33 2010/05/24 10:07:34 joxe Exp $
*
*/
@ -476,10 +476,17 @@ void uip_reass_over(void);
}
\endcode
*/
typedef union {
uint32_t u32[(UIP_BUFSIZE + 3) / 4];
uint8_t u8[UIP_BUFSIZE];
} uip_buf_t;
#ifdef UIP_CONF_PLAIN_BUFFER
CCIF extern uint8_t uip_buf[UIP_BUFSIZE+2];
#else /* UIP_CONF_PLAIN_BUFFER */
CCIF extern uint8_t * const uip_buf;
CCIF extern uip_buf_t uip_aligned_buf;
#define uip_buf (uip_aligned_buf.u8)
#endif /* UIP_CONF_PLAIN_BUFFER */

View file

@ -41,7 +41,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: uip6.c,v 1.22 2010/05/07 20:45:16 oliverschmidt Exp $
* $Id: uip6.c,v 1.23 2010/05/24 10:07:34 joxe Exp $
*
*/
@ -170,11 +170,9 @@ u8_t uip_ext_opt_offset = 0;
*/
/** Packet buffer for incoming and outgoing packets */
#ifndef UIP_CONF_EXTERNAL_BUFFER
static uint32_t uip_buf32[(UIP_BUFSIZE + 3) / 4];
uip_buf_t uip_aligned_buf;
#endif /* UIP_CONF_EXTERNAL_BUFFER */
uint8_t * const uip_buf = (uint8_t * const) uip_buf32;
/* The uip_appdata pointer points to application data. */
void *uip_appdata;
/* The uip_appdata pointer points to the application data which is to be sent*/