[Tinyos-commits] CVS: tinyos-1.x/tos/lib/VM/languages/motlle/mate/rep-float MotlleRepM.nc, 1.5, 1.6

David Gay idgay at users.sourceforge.net
Wed Nov 23 15:16:25 PST 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/rep-float
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22964/rep-float

Modified Files:
	MotlleRepM.nc 
Log Message:
telosb support - better handling of alignment issues


Index: MotlleRepM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/rep-float/MotlleRepM.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MotlleRepM.nc	1 Nov 2005 02:28:11 -0000	1.5
--- MotlleRepM.nc	23 Nov 2005 23:16:23 -0000	1.6
***************
*** 55,65 ****
--- 55,89 ----
  
    command mvalue V.read(svalue *location) {
+ #ifdef PLATFORM_LITTLE_ENDIAN
      return (mvalue)*location;
+ #else
+     return call V.read_unaligned(location);
+ #endif
  }
  
+   command mvalue V.read_unaligned(svalue *location) {
+ #if defined(PLATFORM_REQUIRES_ALIGNMENT) || !defined(PLATFORM_LITTLE_ENDIAN)
+     uint8_t *loc = (uint8_t *)location;
+ 
+     return (mvalue)loc[0] | (mvalue)loc[1] << 8 |
+       (mvalue)loc[2] << 16 | (mvalue)loc[3] << 24;
+ #else
+     return call V.read(location);
+ #endif
+   }
+ 
    command void V.write(svalue *location, mvalue x) {
+ #ifdef PLATFORM_LITTLE_ENDIAN
      *location = (svalue)x;
+ #else
+     uint8_t *loc = (uint8_t *)location;
+     loc[0] = x;
+     loc[1] = x >> 8;
+     loc[2] = x >> 16;
+     loc[3] = x >> 24;
+ #endif
    }
  
+ 
    // Categories
  



More information about the Tinyos-commits mailing list