Remade the rimeaddr_t u16 to be an array rather than a scalar

This commit is contained in:
adamdunkels 2007-03-21 23:22:11 +00:00
parent b377a83730
commit b7afd2baf0
2 changed files with 13 additions and 6 deletions

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rimeaddr.c,v 1.1 2007/03/15 19:43:07 adamdunkels Exp $
* $Id: rimeaddr.c,v 1.2 2007/03/21 23:22:11 adamdunkels Exp $
*/
/**
@ -41,18 +41,24 @@
#include "rimeaddr.h"
rimeaddr_t rimeaddr_node_addr;
const rimeaddr_t rimeaddr_null = {.u16 = 0};
const rimeaddr_t rimeaddr_null = {.u16 = {0}};
/*---------------------------------------------------------------------------*/
void
rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *src)
{
dest->u16 = src->u16;
dest->u16[0] = src->u16[0];
}
/*---------------------------------------------------------------------------*/
int
rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2)
{
return addr1->u16 == addr2->u16;
return addr1->u16[0] == addr2->u16[0];
}
/*---------------------------------------------------------------------------*/
void
rimeaddr_set_node_addr(rimeaddr_t *t)
{
rimeaddr_copy(&rimeaddr_node_addr, t);
}
/*---------------------------------------------------------------------------*/

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rimeaddr.h,v 1.1 2007/03/15 19:43:07 adamdunkels Exp $
* $Id: rimeaddr.h,v 1.2 2007/03/21 23:22:11 adamdunkels Exp $
*/
/**
@ -43,11 +43,12 @@
typedef union {
unsigned char u8[2];
unsigned short u16;
unsigned short u16[1];
} rimeaddr_t;
void rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *from);
int rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2);
void rimeaddr_set_node_addr(rimeaddr_t *t);
extern rimeaddr_t rimeaddr_node_addr;