From c1d490b6a7e64c8c9d5694d4dd5befa095313a74 Mon Sep 17 00:00:00 2001 From: nifi Date: Mon, 6 Apr 2009 13:07:37 +0000 Subject: [PATCH] added workaround for memcpy/memset bug in mspgcc --- cpu/msp430/msp430def.h | 27 ++++++++++++++++++++++++++- platform/sky/contiki-conf.h | 3 ++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/cpu/msp430/msp430def.h b/cpu/msp430/msp430def.h index 2b7ead749..c6be9e869 100644 --- a/cpu/msp430/msp430def.h +++ b/cpu/msp430/msp430def.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)$Id: msp430def.h,v 1.2 2009/02/04 18:28:44 joxe Exp $ + * @(#)$Id: msp430def.h,v 1.3 2009/04/06 13:07:37 nifi Exp $ */ #ifndef MSP430DEF_H @@ -71,4 +71,29 @@ spl_t splhigh_(void); #define splhigh() splhigh_() #define splx(sr) __asm__ __volatile__("bis %0, r2" : : "r" (sr)) +/* Workaround for bug in msp430-gcc compiler */ +#if defined(__MSP430__) && defined(__GNUC__) && MSP430_MEMCPY_WORKAROUND +#ifndef memcpy +#include + +#define memcpy(dest, src, count) do { \ + if(count == 2) { \ + *((uint8_t *)dest) = *((uint8_t *)src); \ + *((uint8_t *)dest + 1) = *((uint8_t *)src + 1); \ + } else { \ + memcpy(dest, src, count); \ + } \ +} while(0) + +#define memset(dest, value, count) do { \ + if(count == 2) { \ + *((uint8_t *)dest) = (uint8_t)value; \ + *((uint8_t *)dest + 1) = (uint8_t)value; \ + } else { \ + memset(dest, value, count); \ + } \ +} while(0) +#endif /* memcpy */ +#endif /* __GNUC__ && __MSP430__ && MSP430_MEMCPY_WORKAROUND */ + #endif /* MSP430DEF_H */ diff --git a/platform/sky/contiki-conf.h b/platform/sky/contiki-conf.h index feea6a159..5482c3679 100644 --- a/platform/sky/contiki-conf.h +++ b/platform/sky/contiki-conf.h @@ -1,5 +1,5 @@ /* -*- C -*- */ -/* @(#)$Id: contiki-conf.h,v 1.42 2009/04/03 11:46:48 adamdunkels Exp $ */ +/* @(#)$Id: contiki-conf.h,v 1.43 2009/04/06 13:07:41 nifi Exp $ */ #ifndef CONTIKI_CONF_H #define CONTIKI_CONF_H @@ -26,6 +26,7 @@ #define ENERGEST_CONF_ON 1 #define HAVE_STDINT_H +#define MSP430_MEMCPY_WORKAROUND 1 #include "msp430def.h" #ifndef RF_CHANNEL