r4696 - in trunk/src/host/dfu-util: . src
laforge at docs.openmoko.org
laforge at docs.openmoko.org
Tue Oct 7 15:14:08 CEST 2008
Author: laforge
Date: 2008-10-07 15:14:07 +0200 (Tue, 07 Oct 2008)
New Revision: 4696
Modified:
trunk/src/host/dfu-util/configure.ac
trunk/src/host/dfu-util/src/main.c
Log:
don't use non-portable headesr for endian conversion but rather implements a
private, portable endianness conversion routine (Closes: #1835)
Modified: trunk/src/host/dfu-util/configure.ac
===================================================================
--- trunk/src/host/dfu-util/configure.ac 2008-10-07 08:58:16 UTC (rev 4695)
+++ trunk/src/host/dfu-util/configure.ac 2008-10-07 13:14:07 UTC (rev 4696)
@@ -7,7 +7,6 @@
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-10-07 08:58:16 UTC (rev 4695)
+++ trunk/src/host/dfu-util/src/main.c 2008-10-07 13:14:07 UTC (rev 4696)
@@ -26,8 +26,6 @@
#include <getopt.h>
#include <usb.h>
#include <errno.h>
-#include <byteswap.h>
-#include <endian.h>
#include "dfu.h"
#include "usb_dfu.h"
@@ -41,18 +39,14 @@
#include <usbpath.h>
#endif
-/* define a portable macro for swapping a 16bit word */
-#if defined(WORDS_BIGENDIAN)
-# if defined(__APPLE__) && defined (OSX)
-# include <libkern/OSByteOrder.h>
-# define LE2CPU16(x) OSSwapInt16(x)
-# else
-# define LE2CPU16(x) bswap_16(x)
-# endif
-#else
-# define LE2CPU16(x) (x)
-#endif
+/* define a portable function for reading a 16bit little-endian word */
+unsigned short get_int16_le(const void *p)
+{
+ const unsigned char *cp = p;
+ return ( cp[0] ) | ( ((unsigned short)cp[1]) << 8 );
+}
+
int debug;
static int verbose = 0;
@@ -765,8 +759,7 @@
"descriptor: %s\n", usb_strerror());
transfer_size = page_size;
} else {
- func_dfu.wTransferSize = LE2CPU16(func_dfu.wTransferSize);
- transfer_size = func_dfu.wTransferSize;
+ transfer_size = get_int16_le(&func_dfu.wTransferSize);
}
}
More information about the commitlog
mailing list