Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97ac0e1b authored by Elliott Hughes's avatar Elliott Hughes
Browse files

Kill HAVE_BIG_ENDIAN, HAVE_ENDIAN_H, and HAVE_LITTLE_ENDIAN.

Change-Id: I9e25ac9d27e95b04fb8bf7a66c619af0139d8b8f
parent 6fe92d1a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -375,7 +375,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);
+1 −13
Original line number Diff line number Diff line
@@ -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')
+0 −27
Original line number Diff line number Diff line
@@ -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;
+0 −27
Original line number Diff line number Diff line
@@ -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;
+5 −10
Original line number Diff line number Diff line
@@ -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

#if defined(HAVE_LITTLE_ENDIAN)
#define __BYTE_ORDER __LITTLE_ENDIAN

#else
# define __BYTE_ORDER __BIG_ENDIAN
#endif

#endif /*not HAVE_ENDIAN_H*/
#include <endian.h>

#endif

#endif /*_LIBS_UTILS_ENDIAN_H*/
Loading