X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=support%2Fsdk%2Fc%2Fblip%2Flib6lowpan%2Fnwbyte.h;h=f94b3a5b5ca4376664d213c1b3d7582f1c8ad36e;hb=cd239b7b74dd2e5bbd538531e92e445e20058f76;hp=44d0ea8280151749cc600ac4f4292cf79b7fe617;hpb=622893623b38edfd9e183f4d31a48ba742ae0d22;p=tinyos-2.x.git diff --git a/support/sdk/c/blip/lib6lowpan/nwbyte.h b/support/sdk/c/blip/lib6lowpan/nwbyte.h index 44d0ea82..f94b3a5b 100644 --- a/support/sdk/c/blip/lib6lowpan/nwbyte.h +++ b/support/sdk/c/blip/lib6lowpan/nwbyte.h @@ -1,17 +1,10 @@ #ifndef _NWBYTE_H #define _NWBYTE_H_ -#if !defined(PC) -// if we're not on a pc, assume little endian for now -#define __LITTLE_ENDIAN 1234 -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif +#include "blip-platform.h" /* define normal network byte-orders routines */ #if defined(PC) -// use library versions if on linux -#include -#include #define ntoh16(X) ntohs(X) #define hton16(X) htons(X) @@ -25,7 +18,7 @@ #define hton16(X) (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff) /* this is much more efficient since gcc can insert swpb now. */ -static uint32_t __attribute__((unused)) ntoh32(uint32_t i) { +static inline uint32_t __attribute__((unused)) ntoh32(uint32_t i) { uint16_t lo = (uint16_t)i; uint16_t hi = (uint16_t)(i >> 16); lo = (lo << 8) | (lo >> 8); @@ -53,8 +46,8 @@ static uint32_t __attribute__((unused)) ntoh32(uint32_t i) { #endif #else -// assume big-endian byte-order -#define leton16(X) (X) +// big-endian byte-order +#define leton16(X) (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff) #define htole16(X) (((((uint16_t)(X)) << 8) | ((uint16_t)(X) >> 8)) & 0xffff) #endif