diff --git a/adb/adb.h b/adb/adb.h index 44e5981bd..f584c571e 100644 --- a/adb/adb.h +++ b/adb/adb.h @@ -376,7 +376,6 @@ void usb_kick(usb_handle *h); int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol); #endif -unsigned host_to_le32(unsigned n); int adb_commandline(int argc, char **argv); int connection_state(atransport *t); diff --git a/adb/file_sync_service.h b/adb/file_sync_service.h index 5dd2e8041..c3c8574de 100644 --- a/adb/file_sync_service.h +++ b/adb/file_sync_service.h @@ -17,22 +17,10 @@ #ifndef _FILE_SYNC_SERVICE_H_ #define _FILE_SYNC_SERVICE_H_ -#ifdef HAVE_BIG_ENDIAN -static inline unsigned __swap_uint32(unsigned x) -{ - return (((x) & 0xFF000000) >> 24) - | (((x) & 0x00FF0000) >> 8) - | (((x) & 0x0000FF00) << 8) - | (((x) & 0x000000FF) << 24); -} -#define htoll(x) __swap_uint32(x) -#define ltohl(x) __swap_uint32(x) -#define MKID(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24)) -#else #define htoll(x) (x) #define ltohl(x) (x) + #define MKID(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) -#endif #define ID_STAT MKID('S','T','A','T') #define ID_LIST MKID('L','I','S','T') diff --git a/adb/transport_local.c b/adb/transport_local.c index 948cc1581..6c4e22025 100644 --- a/adb/transport_local.c +++ b/adb/transport_local.c @@ -28,21 +28,6 @@ #define TRACE_TAG TRACE_TRANSPORT #include "adb.h" -#ifdef HAVE_BIG_ENDIAN -#define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24) -static inline void fix_endians(apacket *p) -{ - p->msg.command = H4(p->msg.command); - p->msg.arg0 = H4(p->msg.arg0); - p->msg.arg1 = H4(p->msg.arg1); - p->msg.data_length = H4(p->msg.data_length); - p->msg.data_check = H4(p->msg.data_check); - p->msg.magic = H4(p->msg.magic); -} -#else -#define fix_endians(p) do {} while (0) -#endif - #if ADB_HOST /* we keep a list of opened transports. The atransport struct knows to which * local transport it is connected. The list is used to detect when we're @@ -62,12 +47,6 @@ static int remote_read(apacket *p, atransport *t) return -1; } - fix_endians(p); - -#if 0 && defined HAVE_BIG_ENDIAN - D("read remote packet: %04x arg0=%0x arg1=%0x data_length=%0x data_check=%0x magic=%0x\n", - p->msg.command, p->msg.arg0, p->msg.arg1, p->msg.data_length, p->msg.data_check, p->msg.magic); -#endif if(check_header(p)) { D("bad header: terminated (data)\n"); return -1; @@ -90,12 +69,6 @@ static int remote_write(apacket *p, atransport *t) { int length = p->msg.data_length; - fix_endians(p); - -#if 0 && defined HAVE_BIG_ENDIAN - D("write remote packet: %04x arg0=%0x arg1=%0x data_length=%0x data_check=%0x magic=%0x\n", - p->msg.command, p->msg.arg0, p->msg.arg1, p->msg.data_length, p->msg.data_check, p->msg.magic); -#endif if(writex(t->sfd, &p->msg, sizeof(amessage) + length)) { D("remote local: write terminated\n"); return -1; diff --git a/adb/transport_usb.c b/adb/transport_usb.c index 3d198030e..1138dddc5 100644 --- a/adb/transport_usb.c +++ b/adb/transport_usb.c @@ -23,29 +23,6 @@ #define TRACE_TAG TRACE_TRANSPORT #include "adb.h" -#ifdef HAVE_BIG_ENDIAN -#define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24) -static inline void fix_endians(apacket *p) -{ - p->msg.command = H4(p->msg.command); - p->msg.arg0 = H4(p->msg.arg0); - p->msg.arg1 = H4(p->msg.arg1); - p->msg.data_length = H4(p->msg.data_length); - p->msg.data_check = H4(p->msg.data_check); - p->msg.magic = H4(p->msg.magic); -} -unsigned host_to_le32(unsigned n) -{ - return H4(n); -} -#else -#define fix_endians(p) do {} while (0) -unsigned host_to_le32(unsigned n) -{ - return n; -} -#endif - static int remote_read(apacket *p, atransport *t) { if(usb_read(t->usb, &p->msg, sizeof(amessage))){ @@ -53,8 +30,6 @@ static int remote_read(apacket *p, atransport *t) return -1; } - fix_endians(p); - if(check_header(p)) { D("remote usb: check_header failed\n"); return -1; @@ -79,8 +54,6 @@ static int remote_write(apacket *p, atransport *t) { unsigned size = p->msg.data_length; - fix_endians(p); - if(usb_write(t->usb, &p->msg, sizeof(amessage))) { D("remote usb: 1 - write terminated\n"); return -1; diff --git a/include/utils/Endian.h b/include/utils/Endian.h index 19f250494..a38309337 100644 --- a/include/utils/Endian.h +++ b/include/utils/Endian.h @@ -20,21 +20,16 @@ #ifndef _LIBS_UTILS_ENDIAN_H #define _LIBS_UTILS_ENDIAN_H -#if defined(HAVE_ENDIAN_H) - -#include - -#else /*not HAVE_ENDIAN_H*/ +#if defined(_WIN32) #define __BIG_ENDIAN 0x1000 #define __LITTLE_ENDIAN 0x0001 +#define __BYTE_ORDER __LITTLE_ENDIAN -#if defined(HAVE_LITTLE_ENDIAN) -# define __BYTE_ORDER __LITTLE_ENDIAN #else -# define __BYTE_ORDER __BIG_ENDIAN + +#include + #endif -#endif /*not HAVE_ENDIAN_H*/ - #endif /*_LIBS_UTILS_ENDIAN_H*/ diff --git a/libutils/Unicode.cpp b/libutils/Unicode.cpp index 378d2a786..d9334f783 100644 --- a/libutils/Unicode.cpp +++ b/libutils/Unicode.cpp @@ -24,17 +24,10 @@ # undef nhtos # undef htons -# ifdef HAVE_LITTLE_ENDIAN -# define ntohl(x) ( ((x) << 24) | (((x) >> 24) & 255) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) ) -# define htonl(x) ntohl(x) -# define ntohs(x) ( (((x) << 8) & 0xff00) | (((x) >> 8) & 255) ) -# define htons(x) ntohs(x) -# else -# define ntohl(x) (x) -# define htonl(x) (x) -# define ntohs(x) (x) -# define htons(x) (x) -# endif +# define ntohl(x) ( ((x) << 24) | (((x) >> 24) & 255) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) ) +# define htonl(x) ntohl(x) +# define ntohs(x) ( (((x) << 8) & 0xff00) | (((x) >> 8) & 255) ) +# define htons(x) ntohs(x) #else # include #endif