From f4b868017477eb924e1a686a9816b882cef3b370 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Mon, 23 Mar 2009 19:37:45 +0000 Subject: [PATCH] Defined the packetbuf buffer so that it is always aligned on a 16-bit boundary. --- core/net/rime/packetbuf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/net/rime/packetbuf.c b/core/net/rime/packetbuf.c index c476cb008..e953bcf4c 100644 --- a/core/net/rime/packetbuf.c +++ b/core/net/rime/packetbuf.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: packetbuf.c,v 1.1 2009/03/12 23:04:52 adamdunkels Exp $ + * $Id: packetbuf.c,v 1.2 2009/03/23 19:37:45 adamdunkels Exp $ */ /** @@ -88,7 +88,13 @@ const char *packetbuf_attr_strings[] = static uint16_t buflen, bufptr; static uint8_t hdrptr; -static uint8_t packetbuf[PACKETBUF_SIZE + PACKETBUF_HDR_SIZE]; + +/* The declarations below ensure that the packet buffer is aligned on + an even 16-bit boundary. On some platforms (most notably the + msp430), having apotentially misaligned packet buffer may lead to + problems when accessing 16-bit values. */ +static uint16_t packetbuf_aligned[(PACKETBUF_SIZE + PACKETBUF_HDR_SIZE) / 2 + 1]; +static uint8_t* packetbuf = packetbuf_aligned; static uint8_t *packetbufptr;