am 0101b06f: Merge "Kill HAVE_BIG_ENDIAN, HAVE_ENDIAN_H, and HAVE_LITTLE_ENDIAN."
* commit '0101b06fa6f9863ee87e89757e70900c3a0e7bfc': Kill HAVE_BIG_ENDIAN, HAVE_ENDIAN_H, and HAVE_LITTLE_ENDIAN.
This commit is contained in:
commit
e79cd67cfd
6 changed files with 10 additions and 89 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -20,21 +20,16 @@
|
|||
#ifndef _LIBS_UTILS_ENDIAN_H
|
||||
#define _LIBS_UTILS_ENDIAN_H
|
||||
|
||||
#if defined(HAVE_ENDIAN_H)
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
#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 <endian.h>
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*not HAVE_ENDIAN_H*/
|
||||
|
||||
#endif /*_LIBS_UTILS_ENDIAN_H*/
|
||||
|
|
|
|||
|
|
@ -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 <netinet/in.h>
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue