r3830 - in trunk/src/host/dfu-util: . src
laforge at sita.openmoko.org
laforge at sita.openmoko.org
Mon Jan 14 21:36:24 CET 2008
Author: laforge
Date: 2008-01-14 21:36:23 +0100 (Mon, 14 Jan 2008)
New Revision: 3830
Modified:
trunk/src/host/dfu-util/configure.ac
trunk/src/host/dfu-util/src/main.c
Log:
introduce LE2CPU16 macro to deal with big-endian systems and little-endian USB descriptors. This should now also work on OSX (thanks to suggestion by Daniel Hembree)
Modified: trunk/src/host/dfu-util/configure.ac
===================================================================
--- trunk/src/host/dfu-util/configure.ac 2008-01-14 15:53:02 UTC (rev 3829)
+++ trunk/src/host/dfu-util/configure.ac 2008-01-14 20:36:23 UTC (rev 3830)
@@ -7,6 +7,7 @@
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
#AC_CONFIG_SRCDIR([src/atmel.c])
AM_CONFIG_HEADER([config.h])
+AC_C_BIGENDIAN
AM_MAINTAINER_MODE
Modified: trunk/src/host/dfu-util/src/main.c
===================================================================
--- trunk/src/host/dfu-util/src/main.c 2008-01-14 15:53:02 UTC (rev 3829)
+++ trunk/src/host/dfu-util/src/main.c 2008-01-14 20:36:23 UTC (rev 3830)
@@ -41,6 +41,16 @@
#include <usbpath.h>
#endif
+/* define a portable macro for swapping a 16bit word */
+#if defined(WORDS_BIGENDIAN)
+# if defined(__APPLE__) && defined (OSX)
+# define LE2CPU16(x) OSSwapInt16(x)
+# else
+# define LE2CPU16(x) bswap_16(x)
+# endif
+#else
+# define LE2CPU16(x) (x)
+#endif
int debug;
static int verbose = 0;
@@ -754,9 +764,7 @@
"descriptor: %s\n", usb_strerror());
transfer_size = page_size;
} else {
-#if __BYTE_ORDER == __BIG_ENDIAN
- func_dfu.wTransferSize = bswap_16(func_dfu.wTransferSize);
-#endif
+ func_dfu.wTransferSize = LE2CPU16(func_dfu.wTransferSize);
transfer_size = func_dfu.wTransferSize;
}
}
More information about the commitlog
mailing list