paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [5244] added a test for bswap


From: antoine drouin
Subject: [paparazzi-commits] [5244] added a test for bswap
Date: Fri, 06 Aug 2010 08:06:27 +0000

Revision: 5244
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5244
Author:   poine
Date:     2010-08-06 08:06:27 +0000 (Fri, 06 Aug 2010)
Log Message:
-----------
added a test for bswap

Added Paths:
-----------
    paparazzi3/trunk/sw/airborne/lisa/test/test_bswap.c

Added: paparazzi3/trunk/sw/airborne/lisa/test/test_bswap.c
===================================================================
--- paparazzi3/trunk/sw/airborne/lisa/test/test_bswap.c                         
(rev 0)
+++ paparazzi3/trunk/sw/airborne/lisa/test/test_bswap.c 2010-08-06 08:06:27 UTC 
(rev 5244)
@@ -0,0 +1,36 @@
+
+#include <inttypes.h>
+//#include <byteswap.h>
+
+
+#define MyByteSwap16(n)                                     \
+  ( ((((uint16_t) n) << 8) & 0xFF00) |              \
+    ((((uint16_t) n) >> 8) & 0x00FF) )
+
+#define MyByteSwap32(n)                                     \
+  ( ((((uint32_t) n) << 24) & 0xFF000000) |         \
+    ((((uint32_t) n) <<  8) & 0x00FF0000) |         \
+    ((((uint32_t) n) >>  8) & 0x0000FF00) |         \
+    ((((uint32_t) n) >> 24) & 0x000000FF) )
+
+
+int main(void) {
+
+  //  uint32_t foo = 0;
+  //  uint32_t bar = __builtin_bswap32(*(uint32_t*)&foo);
+
+  //  uint16_t foo = 12345;
+  //  uint16_t bar = foo >> 8 | foo << 8;
+
+  //  uint16_t foo = 12345;
+  //  uint16_t bar = ByteSwap(foo);
+
+  uint16_t foo = 12345;
+  uint16_t bar = MyByteSwap16(foo);
+
+
+  uint32_t a = 23456;
+  uint32_t b = MyByteSwap32(a);
+
+  return 0;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]