From cd5dfa9692b97f09b2778f3a5a25e3a54b905465 Mon Sep 17 00:00:00 2001 From: joxe Date: Wed, 5 May 2010 13:07:45 +0000 Subject: [PATCH] added const for the uip_buf pointer for more efficient and smaller uip code and fixed same construct for the sicslowpan code --- core/net/sicslowpan.c | 9 ++++----- core/net/uip.c | 4 ++-- core/net/uip.h | 5 ++--- core/net/uip6.c | 6 ++++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/net/sicslowpan.c b/core/net/sicslowpan.c index db28d8645..7ed406869 100644 --- a/core/net/sicslowpan.c +++ b/core/net/sicslowpan.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: sicslowpan.c,v 1.37 2010/04/01 10:56:00 adamdunkels Exp $ + * $Id: sicslowpan.c,v 1.38 2010/05/05 13:07:45 joxe Exp $ */ /** * \file @@ -209,9 +209,6 @@ static u8_t uncomp_hdr_len; * @{ */ - -/* NOTE: lenght is before the buffer to ensure alignment of the - buffer */ static u16_t sicslowpan_len; /** * The buffer used for the 6lowpan reassembly. @@ -219,7 +216,9 @@ static u16_t sicslowpan_len; * It has a fix size as we do not use dynamic memory allocation. */ -static u8_t sicslowpan_buf[UIP_BUFSIZE]; +/* 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; /** The total length of the IPv6 packet in the sicslowpan_buf. */ diff --git a/core/net/uip.c b/core/net/uip.c index 81801aaac..d6e5d92cc 100644 --- a/core/net/uip.c +++ b/core/net/uip.c @@ -41,7 +41,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: uip.c,v 1.24 2010/05/04 09:19:41 joxe Exp $ + * $Id: uip.c,v 1.25 2010/05/05 13:07:45 joxe Exp $ * */ @@ -128,7 +128,7 @@ struct uip_eth_addr uip_ethaddr = {{0,0,0,0,0,0}}; #ifndef UIP_CONF_EXTERNAL_BUFFER static uint32_t uip_buf32[(UIP_BUFSIZE + 3) / 4]; -uint8_t *uip_buf = (uint8_t *)uip_buf32; /* The packet buffer that contains +uint8_t * const uip_buf = (uint8_t * const)uip_buf32; /* The packet buffer that contains incoming packets. */ #endif /* UIP_CONF_EXTERNAL_BUFFER */ diff --git a/core/net/uip.h b/core/net/uip.h index 916003a58..3deab20ae 100644 --- a/core/net/uip.h +++ b/core/net/uip.h @@ -47,7 +47,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: uip.h,v 1.30 2010/05/04 09:19:41 joxe Exp $ + * $Id: uip.h,v 1.31 2010/05/05 13:07:45 joxe Exp $ * */ @@ -476,8 +476,7 @@ void uip_reass_over(void); } \endcode */ -CCIF extern uint8_t *uip_buf; - +CCIF extern uint8_t * const uip_buf; /** @} */ diff --git a/core/net/uip6.c b/core/net/uip6.c index c83e9e7e2..1da8ddcfb 100644 --- a/core/net/uip6.c +++ b/core/net/uip6.c @@ -41,7 +41,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: uip6.c,v 1.20 2010/05/04 09:19:41 joxe Exp $ + * $Id: uip6.c,v 1.21 2010/05/05 13:07:45 joxe Exp $ * */ @@ -170,8 +170,10 @@ 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]; -uint8_t *uip_buf = (uint8_t *) uip_buf32; +uint8_t * const uip_buf = (uint8_t * const) uip_buf32; + #endif /* UIP_CONF_EXTERNAL_BUFFER */ /* The uip_appdata pointer points to application data. */