aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-01-02 17:46:16 -0500
committerMike Frysinger <vapier@gentoo.org>2016-01-03 00:18:07 -0500
commit1ac72f0659d64d6a14da862242db0d841d2878d0 (patch)
treed7d792ba2df8227b99240650e99087e1f6008813 /sim/common
parent987f8739051ff368ecaf6ca1e0fc966c974381a1 (diff)
downloadgdb-1ac72f0659d64d6a14da862242db0d841d2878d0.zip
gdb-1ac72f0659d64d6a14da862242db0d841d2878d0.tar.gz
gdb-1ac72f0659d64d6a14da862242db0d841d2878d0.tar.bz2
sim: convert to bfd_endian
Rather than re-invent endian defines, as well as maintain our own list of OS & arch-specific includes, punt all that logic in favor of the bfd ones already set up and maintained elsewhere. We already rely on the bfd library, so leveraging the endian aspect should be fine.
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/ChangeLog41
-rw-r--r--sim/common/acinclude.m434
-rw-r--r--sim/common/cgen-ops.h10
-rw-r--r--sim/common/nrun.c2
-rw-r--r--sim/common/sim-config.c44
-rw-r--r--sim/common/sim-config.h190
-rw-r--r--sim/common/sim-endian.c8
-rw-r--r--sim/common/sim-events.c12
-rw-r--r--sim/common/sim-events.h6
-rw-r--r--sim/common/sim-n-core.h4
-rw-r--r--sim/common/sim-n-endian.h10
-rw-r--r--sim/common/sim-options.c8
12 files changed, 125 insertions, 244 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 65a0abf..6991786 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,5 +1,46 @@
2016-01-02 Mike Frysinger <vapier@gentoo.org>
+ * acinclude.m4 (SIM_AC_OPTION_ENDIAN): Change BIG_ENDIAN to
+ BFD_ENDIAN_BIG, LITTLE_ENDIAN to BFD_ENDIAN_LITTLE, and 0 to
+ BFD_ENDIAN_UNKNOWN.
+ (SIM_AC_OPTION_HOSTENDIAN): Likewise.
+ * cgen-ops.h (SUBWORDXFSI): Change BIG_ENDIAN to BFD_ENDIAN_BIG.
+ (SUBWORDTFSI, JOINSIDF, JOINSIXF, JOINSITF): Likewise.
+ * nrun.c (main): Likewise.
+ * sim-config.c (current_host_byte_order): Change type to enum
+ bfd_endian. Initialize to BFD_ENDIAN_UNKNOWN.
+ (current_target_byte_order): Likewise.
+ (config_byte_order_to_a): Likewise. Change BIG_ENDIAN to
+ BFD_ENDIAN_BIG, LITTLE_ENDIAN to BFD_ENDIAN_LITTLE, and 0 to
+ BFD_ENDIAN_UNKNOWN.
+ (sim_config): Change prefered_target_byte_order type to enum
+ bfd_endian. Change BIG_ENDIAN to BFD_ENDIAN_BIG, LITTLE_ENDIAN
+ to BFD_ENDIAN_LITTLE, and 0 to BFD_ENDIAN_UNKNOWN.
+ * sim-config.h: Change BIG_ENDIAN to BFD_ENDIAN_BIG, LITTLE_ENDIAN
+ to BFD_ENDIAN_LITTLE, and 0 to BFD_ENDIAN_UNKNOWN.
+ Delete all the various arch/OS endian includes & defines.
+ (current_host_byte_order): Change type to enum bfd_endian.
+ (current_target_byte_order): Likewise.
+ (CURRENT_HOST_BYTE_ORDER): Compare to BFD_ENDIAN_UNKNOWN, not 0.
+ (CURRENT_TARGET_BYTE_ORDER): Likewise.
+ * sim-endian.c: Change LITTLE_ENDIAN to BFD_ENDIAN_LITTLE.
+ * sim-events.c (sim_events_watch_sim): Change BIG_ENDIAN to
+ BFD_ENDIAN_BIG, LITTLE_ENDIAN to BFD_ENDIAN_LITTLE, and 0 to
+ BFD_ENDIAN_UNKNOWN.
+ (sim_events_watch_core): Likewise.
+ * sim-events.h: Likewise.
+ * sim-n-core.h (sim_core_read_misaligned_N): Change BIG_ENDIAN to
+ BFD_ENDIAN_BIG.
+ (sim_core_write_misaligned_N): Likewise.
+ * sim-n-endian.h (endian_h2be_N): Likewise.
+ (endian_be2h_N): Likewise.
+ (endian_h2le_N): Change LITTLE_ENDIAN to BFD_ENDIAN_LITTLE.
+ (offset_N): Likewise.
+ * sim-options.c (standard_option_handler): Change LITTLE_ENDIAN to
+ BFD_ENDIAN_LITTLE and BIG_ENDIAN to BFD_ENDIAN_BIG.
+
+2016-01-02 Mike Frysinger <vapier@gentoo.org>
+
* cgen-defs.h (current_state): Delete.
* sim-base.h (CURRENT_STATE_REG, CURRENT_STATE): Delete.
* sim-utils.c (current_state): Delete.
diff --git a/sim/common/acinclude.m4 b/sim/common/acinclude.m4
index ebb6d1b..2af6d5d 100644
--- a/sim/common/acinclude.m4
+++ b/sim/common/acinclude.m4
@@ -449,26 +449,26 @@ AC_ARG_ENABLE(sim-endian,
[AS_HELP_STRING([--enable-sim-endian=endian],
[Specify target byte endian orientation])],
[case "${enableval}" in
- b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BIG_ENDIAN";;
- l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN";;
+ b*|B*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG";;
+ l*|L*) sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE";;
yes) if test x"$wire_endian" != x; then
- sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
+ sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
else
- if test x"$default_endian" != x; then
- sim_endian="-DWITH_TARGET_BYTE_ORDER=${default_endian}"
+ if test x"$default_endian" != x; then
+ sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
else
echo "No hard-wired endian for target $target" 1>&6
- sim_endian="-DWITH_TARGET_BYTE_ORDER=0"
+ sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
fi
fi;;
no) if test x"$default_endian" != x; then
- sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
+ sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
else
if test x"$wire_endian" != x; then
- sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${wire_endian}"
+ sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
else
echo "No default endian for target $target" 1>&6
- sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=0"
+ sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
fi
fi;;
*) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-endian"); sim_endian="";;
@@ -477,10 +477,10 @@ if test x"$silent" != x"yes" && test x"$sim_endian" != x""; then
echo "Setting endian flags = $sim_endian" 6>&1
fi],
[if test x"$default_endian" != x; then
- sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=${default_endian}"
+ sim_endian="-DWITH_DEFAULT_TARGET_BYTE_ORDER=BFD_ENDIAN_${default_endian}"
else
if test x"$wire_endian" != x; then
- sim_endian="-DWITH_TARGET_BYTE_ORDER=${wire_endian}"
+ sim_endian="-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_${wire_endian}"
else
sim_endian=
fi
@@ -498,9 +498,9 @@ AC_ARG_ENABLE(sim-hostendian,
[AS_HELP_STRING([--enable-sim-hostendian=end],
[Specify host byte endian orientation])],
[case "${enableval}" in
- no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=0";;
- b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN";;
- l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN";;
+ no) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BFD_ENDIAN_UNKNOWN";;
+ b*|B*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BFD_ENDIAN_BIG";;
+ l*|L*) sim_hostendian="-DWITH_HOST_BYTE_ORDER=BFD_ENDIAN_LITTLE";;
*) AC_MSG_ERROR("Unknown value $enableval for --enable-sim-hostendian"); sim_hostendian="";;
esac
if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
@@ -509,12 +509,12 @@ fi],[
if test "x$cross_compiling" = "xno"; then
AC_C_BIGENDIAN
if test $ac_cv_c_bigendian = yes; then
- sim_hostendian="-DWITH_HOST_BYTE_ORDER=BIG_ENDIAN"
+ sim_hostendian="-DWITH_HOST_BYTE_ORDER=BFD_ENDIAN_BIG"
else
- sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
+ sim_hostendian="-DWITH_HOST_BYTE_ORDER=BFD_ENDIAN_LITTLE"
fi
else
- sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
+ sim_hostendian="-DWITH_HOST_BYTE_ORDER=BFD_ENDIAN_UNKNOWN"
fi])dnl
])
AC_SUBST(sim_hostendian)
diff --git a/sim/common/cgen-ops.h b/sim/common/cgen-ops.h
index 9256d8b..7ff1b4d 100644
--- a/sim/common/cgen-ops.h
+++ b/sim/common/cgen-ops.h
@@ -404,7 +404,7 @@ SUBWORDXFSI (XF in, int word)
/* Note: typedef struct { SI parts[3]; } XF; */
union { XF in; SI out[3]; } x;
x.in = in;
- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
return x.out[word];
else
return x.out[2 - word];
@@ -416,7 +416,7 @@ SUBWORDTFSI (TF in, int word)
/* Note: typedef struct { SI parts[4]; } TF; */
union { TF in; SI out[4]; } x;
x.in = in;
- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
return x.out[word];
else
return x.out[3 - word];
@@ -432,7 +432,7 @@ SEMOPS_INLINE DF
JOINSIDF (SI x0, SI x1)
{
union { SI in[2]; DF out; } x;
- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
x.in[0] = x0, x.in[1] = x1;
else
x.in[1] = x0, x.in[0] = x1;
@@ -443,7 +443,7 @@ SEMOPS_INLINE XF
JOINSIXF (SI x0, SI x1, SI x2)
{
union { SI in[3]; XF out; } x;
- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
x.in[0] = x0, x.in[1] = x1, x.in[2] = x2;
else
x.in[2] = x0, x.in[1] = x1, x.in[0] = x2;
@@ -454,7 +454,7 @@ SEMOPS_INLINE TF
JOINSITF (SI x0, SI x1, SI x2, SI x3)
{
union { SI in[4]; TF out; } x;
- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
x.in[0] = x0, x.in[1] = x1, x.in[2] = x2, x.in[3] = x3;
else
x.in[3] = x0, x.in[2] = x1, x.in[1] = x2, x.in[0] = x3;
diff --git a/sim/common/nrun.c b/sim/common/nrun.c
index 61c3c04..2e47715 100644
--- a/sim/common/nrun.c
+++ b/sim/common/nrun.c
@@ -99,7 +99,7 @@ main (int argc, char **argv)
/* We can't set the endianness in the callback structure until
sim_config is called, which happens in sim_open. */
default_callback.target_endian
- = (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN
+ = (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG
? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE);
/* Was there a program to run? */
diff --git a/sim/common/sim-config.c b/sim/common/sim-config.c
index ff20983..8e9b1dd 100644
--- a/sim/common/sim-config.c
+++ b/sim/common/sim-config.c
@@ -25,8 +25,8 @@
#include "bfd.h"
-int current_host_byte_order;
-int current_target_byte_order;
+enum bfd_endian current_host_byte_order = BFD_ENDIAN_UNKNOWN;
+enum bfd_endian current_target_byte_order = BFD_ENDIAN_UNKNOWN;
int current_stdio;
enum sim_alignments current_alignment;
@@ -40,16 +40,16 @@ int current_floating_point;
/* map a byte order onto a textual string */
static const char *
-config_byte_order_to_a (int byte_order)
+config_byte_order_to_a (enum bfd_endian byte_order)
{
switch (byte_order)
{
- case LITTLE_ENDIAN:
+ case BFD_ENDIAN_LITTLE:
return "LITTLE_ENDIAN";
- case BIG_ENDIAN:
+ case BFD_ENDIAN_BIG:
return "BIG_ENDIAN";
- case 0:
- return "0";
+ case BFD_ENDIAN_UNKNOWN:
+ return "UNKNOWN_ENDIAN";
}
return "UNKNOWN";
}
@@ -140,7 +140,7 @@ sim_config_default (SIM_DESC sd)
SIM_RC
sim_config (SIM_DESC sd)
{
- int prefered_target_byte_order;
+ enum bfd_endian prefered_target_byte_order;
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
/* extract all relevant information */
@@ -149,18 +149,18 @@ sim_config (SIM_DESC sd)
"--architecture"), it'll have no endianness. */
|| (!bfd_little_endian (STATE_PROG_BFD (sd))
&& !bfd_big_endian (STATE_PROG_BFD (sd))))
- prefered_target_byte_order = 0;
+ prefered_target_byte_order = BFD_ENDIAN_UNKNOWN;
else
prefered_target_byte_order = (bfd_little_endian (STATE_PROG_BFD (sd))
- ? LITTLE_ENDIAN
- : BIG_ENDIAN);
+ ? BFD_ENDIAN_LITTLE
+ : BFD_ENDIAN_BIG);
/* set the host byte order */
current_host_byte_order = 1;
if (*(char*)(&current_host_byte_order))
- current_host_byte_order = LITTLE_ENDIAN;
+ current_host_byte_order = BFD_ENDIAN_LITTLE;
else
- current_host_byte_order = BIG_ENDIAN;
+ current_host_byte_order = BFD_ENDIAN_BIG;
/* verify the host byte order */
if (CURRENT_HOST_BYTE_ORDER != current_host_byte_order)
@@ -174,22 +174,22 @@ sim_config (SIM_DESC sd)
/* set the target byte order */
#if (WITH_TREE_PROPERTIES)
- if (current_target_byte_order == 0)
+ if (current_target_byte_order == BFD_ENDIAN_UNKNOWN)
current_target_byte_order
= (tree_find_boolean_property (root, "/options/little-endian?")
- ? LITTLE_ENDIAN
- : BIG_ENDIAN);
+ ? BFD_ENDIAN_LITTLE
+ : BFD_ENDIAN_BIG);
#endif
- if (current_target_byte_order == 0
- && prefered_target_byte_order != 0)
+ if (current_target_byte_order == BFD_ENDIAN_UNKNOWN
+ && prefered_target_byte_order != BFD_ENDIAN_UNKNOWN)
current_target_byte_order = prefered_target_byte_order;
- if (current_target_byte_order == 0)
+ if (current_target_byte_order == BFD_ENDIAN_UNKNOWN)
current_target_byte_order = WITH_TARGET_BYTE_ORDER;
- if (current_target_byte_order == 0)
+ if (current_target_byte_order == BFD_ENDIAN_UNKNOWN)
current_target_byte_order = WITH_DEFAULT_TARGET_BYTE_ORDER;
/* verify the target byte order */
- if (CURRENT_TARGET_BYTE_ORDER == 0)
+ if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_UNKNOWN)
{
sim_io_eprintf (sd, "Target byte order unspecified\n");
return SIM_RC_FAIL;
@@ -198,7 +198,7 @@ sim_config (SIM_DESC sd)
sim_io_eprintf (sd, "Target (%s) and configured (%s) byte order in conflict\n",
config_byte_order_to_a (current_target_byte_order),
config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER));
- if (prefered_target_byte_order != 0
+ if (prefered_target_byte_order != BFD_ENDIAN_UNKNOWN
&& CURRENT_TARGET_BYTE_ORDER != prefered_target_byte_order)
sim_io_eprintf (sd, "Target (%s) and specified (%s) byte order in conflict\n",
config_byte_order_to_a (CURRENT_TARGET_BYTE_ORDER),
diff --git a/sim/common/sim-config.h b/sim/common/sim-config.h
index a5a8950..fbd9b25 100644
--- a/sim/common/sim-config.h
+++ b/sim/common/sim-config.h
@@ -30,181 +30,19 @@
particular it defines the macro's:
WITH_HOST_BYTE_ORDER The byte order of the host. Could
- be any of LITTLE_ENDIAN, BIG_ENDIAN
- or 0 (unknown). Those macro's also
+ be any of BFD_ENDIAN_LITTLE, BFD_ENDIAN_BIG,
+ or BFD_ENDIAN_UNKNOWN. Those macro's also
need to be defined.
*/
-/* NetBSD:
-
- NetBSD is easy, everything you could ever want is in a header file
- (well almost :-) */
-
-#if defined(__NetBSD__)
-# include <machine/endian.h>
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER BYTE_ORDER
-# endif
-# if (BYTE_ORDER != WITH_HOST_BYTE_ORDER)
-# error "host endian incorrectly configured, check config.h"
-# endif
-#endif
-
-/* Linux is similarly easy. */
-
-#if defined(__linux__)
-# include <endian.h>
-# if defined(__LITTLE_ENDIAN) && !defined(LITTLE_ENDIAN)
-# define LITTLE_ENDIAN __LITTLE_ENDIAN
-# endif
-# if defined(__BIG_ENDIAN) && !defined(BIG_ENDIAN)
-# define BIG_ENDIAN __BIG_ENDIAN
-# endif
-# if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
-# define BYTE_ORDER __BYTE_ORDER
-# endif
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER BYTE_ORDER
-# endif
-# if (BYTE_ORDER != WITH_HOST_BYTE_ORDER)
-# error "host endian incorrectly configured, check config.h"
-# endif
-#endif
-
-/* INSERT HERE - hosts that have available LITTLE_ENDIAN and
- BIG_ENDIAN macro's */
-
-
-/* Some hosts don't define LITTLE_ENDIAN or BIG_ENDIAN, help them out */
-
-#ifndef LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1234
-#endif
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN 4321
-#endif
-
-
-/* SunOS on SPARC:
-
- Big endian last time I looked */
-
-#if defined(sparc) || defined(__sparc__)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER BIG_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != BIG_ENDIAN)
-# error "sun was big endian last time I looked ..."
-# endif
-#endif
-
-
-/* Random x86
-
- Little endian last time I looked */
-
-#if defined(i386) || defined(i486) || defined(i586) || defined (i686) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined (__i686__)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER LITTLE_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != LITTLE_ENDIAN)
-# error "x86 was little endian last time I looked ..."
-# endif
-#endif
-
#if (defined (__i486__) || defined (__i586__) || defined (__i686__)) && defined(__GNUC__) && WITH_BSWAP
#undef htonl
#undef ntohl
#define htonl(IN) __extension__ ({ int _out; __asm__ ("bswap %0" : "=r" (_out) : "0" (IN)); _out; })
#define ntohl(IN) __extension__ ({ int _out; __asm__ ("bswap %0" : "=r" (_out) : "0" (IN)); _out; })
#endif
-
-/* Power or PowerPC running AIX */
-#if defined(_POWER) && defined(_AIX)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER BIG_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != BIG_ENDIAN)
-# error "Power/PowerPC AIX was big endian last time I looked ..."
-# endif
-#endif
-
-/* Solaris running PowerPC */
-#if defined(__PPC) && defined(__sun__)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER LITTLE_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != LITTLE_ENDIAN)
-# error "Solaris on PowerPCs was little endian last time I looked ..."
-# endif
-#endif
-
-/* HP/PA */
-#if defined(__hppa__)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER BIG_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != BIG_ENDIAN)
-# error "HP/PA was big endian last time I looked ..."
-# endif
-#endif
-
-/* Big endian MIPS */
-#if defined(__MIPSEB__)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER BIG_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != BIG_ENDIAN)
-# error "MIPSEB was big endian last time I looked ..."
-# endif
-#endif
-
-/* Little endian MIPS */
-#if defined(__MIPSEL__)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER LITTLE_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != LITTLE_ENDIAN)
-# error "MIPSEL was little endian last time I looked ..."
-# endif
-#endif
-
-/* Windows NT */
-#if defined(__WIN32__)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER LITTLE_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != LITTLE_ENDIAN)
-# error "Windows NT was little endian last time I looked ..."
-# endif
-#endif
-
-/* Alpha running DEC unix */
-#if defined(__osf__) && defined(__alpha__)
-# if (WITH_HOST_BYTE_ORDER == 0)
-# undef WITH_HOST_BYTE_ORDER
-# define WITH_HOST_BYTE_ORDER LITTLE_ENDIAN
-# endif
-# if (WITH_HOST_BYTE_ORDER != LITTLE_ENDIAN)
-# error "AXP running DEC unix was little endian last time I looked ..."
-# endif
-#endif
-
-
-/* INSERT HERE - additional hosts that do not have LITTLE_ENDIAN and
- BIG_ENDIAN definitions available. */
/* Until devices and tree properties are sorted out, tell sim-config.c
not to call the tree_find_foo fns. */
@@ -217,28 +55,28 @@
of the host/target it is able to eliminate slower generic endian
handling code.
- Possible values are 0 (unknown), LITTLE_ENDIAN, BIG_ENDIAN */
+ Possible values are BFD_ENDIAN_UNKNOWN, BFD_ENDIAN_LITTLE, BFD_ENDIAN_BIG. */
#ifndef WITH_HOST_BYTE_ORDER
-#define WITH_HOST_BYTE_ORDER 0 /*unknown*/
+#define WITH_HOST_BYTE_ORDER BFD_ENDIAN_UNKNOWN
#endif
#ifndef WITH_TARGET_BYTE_ORDER
-#define WITH_TARGET_BYTE_ORDER 0 /*unknown*/
+#define WITH_TARGET_BYTE_ORDER BFD_ENDIAN_UNKNOWN
#endif
#ifndef WITH_DEFAULT_TARGET_BYTE_ORDER
-#define WITH_DEFAULT_TARGET_BYTE_ORDER 0 /* fatal */
+#define WITH_DEFAULT_TARGET_BYTE_ORDER BFD_ENDIAN_UNKNOWN
#endif
-extern int current_host_byte_order;
-#define CURRENT_HOST_BYTE_ORDER (WITH_HOST_BYTE_ORDER \
- ? WITH_HOST_BYTE_ORDER \
- : current_host_byte_order)
-extern int current_target_byte_order;
-#define CURRENT_TARGET_BYTE_ORDER (WITH_TARGET_BYTE_ORDER \
- ? WITH_TARGET_BYTE_ORDER \
- : current_target_byte_order)
+extern enum bfd_endian current_host_byte_order;
+#define CURRENT_HOST_BYTE_ORDER \
+ (WITH_HOST_BYTE_ORDER != BFD_ENDIAN_UNKNOWN \
+ ? WITH_HOST_BYTE_ORDER : current_host_byte_order)
+extern enum bfd_endian current_target_byte_order;
+#define CURRENT_TARGET_BYTE_ORDER \
+ (WITH_TARGET_BYTE_ORDER != BFD_ENDIAN_UNKNOWN \
+ ? WITH_TARGET_BYTE_ORDER : current_target_byte_order)
diff --git a/sim/common/sim-endian.c b/sim/common/sim-endian.c
index a699577..e8ef534 100644
--- a/sim/common/sim-endian.c
+++ b/sim/common/sim-endian.c
@@ -31,7 +31,7 @@
#define _SWAP_1(SET,RAW) SET (RAW)
#endif
-#if !defined(_SWAP_2) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htons)
+#if !defined(_SWAP_2) && (WITH_HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) && defined(htons)
#define _SWAP_2(SET,RAW) SET htons (RAW)
#endif
@@ -39,7 +39,7 @@
#define _SWAP_2(SET,RAW) SET (((RAW) >> 8) | ((RAW) << 8))
#endif
-#if !defined(_SWAP_4) && (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htonl)
+#if !defined(_SWAP_4) && (WITH_HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) && defined(htonl)
#define _SWAP_4(SET,RAW) SET htonl (RAW)
#endif
@@ -93,7 +93,7 @@ INLINE_SIM_ENDIAN\
(unsigned_8)
sim_endian_split_16 (unsigned_16 word, int w)
{
- if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN)
+ if (CURRENT_HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
return word.a[1 - w];
}
@@ -110,7 +110,7 @@ sim_endian_join_16 (unsigned_8 h, unsigned_8 l)
{
unsigned_16 word;
- if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN)
+ if (CURRENT_HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
word.a[0] = l;
word.a[1] = h;
diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c
index f29e40c..54d75c2 100644
--- a/sim/common/sim-events.c
+++ b/sim/common/sim-events.c
@@ -635,7 +635,7 @@ sim_events_watch_sim (SIM_DESC sd,
/* type */
switch (byte_order)
{
- case 0:
+ case BFD_ENDIAN_UNKNOWN:
switch (nr_bytes)
{
case 1: new_event->watching = watch_sim_host_1; break;
@@ -645,7 +645,7 @@ sim_events_watch_sim (SIM_DESC sd,
default: sim_io_error (sd, "sim_events_watch_sim - invalid nr bytes");
}
break;
- case BIG_ENDIAN:
+ case BFD_ENDIAN_BIG:
switch (nr_bytes)
{
case 1: new_event->watching = watch_sim_be_1; break;
@@ -655,7 +655,7 @@ sim_events_watch_sim (SIM_DESC sd,
default: sim_io_error (sd, "sim_events_watch_sim - invalid nr bytes");
}
break;
- case LITTLE_ENDIAN:
+ case BFD_ENDIAN_LITTLE:
switch (nr_bytes)
{
case 1: new_event->watching = watch_sim_le_1; break;
@@ -714,7 +714,7 @@ sim_events_watch_core (SIM_DESC sd,
/* type */
switch (byte_order)
{
- case 0:
+ case BFD_ENDIAN_UNKNOWN:
switch (nr_bytes)
{
case 1: new_event->watching = watch_core_targ_1; break;
@@ -724,7 +724,7 @@ sim_events_watch_core (SIM_DESC sd,
default: sim_io_error (sd, "sim_events_watch_core - invalid nr bytes");
}
break;
- case BIG_ENDIAN:
+ case BFD_ENDIAN_BIG:
switch (nr_bytes)
{
case 1: new_event->watching = watch_core_be_1; break;
@@ -734,7 +734,7 @@ sim_events_watch_core (SIM_DESC sd,
default: sim_io_error (sd, "sim_events_watch_core - invalid nr bytes");
}
break;
- case LITTLE_ENDIAN:
+ case BFD_ENDIAN_LITTLE:
switch (nr_bytes)
{
case 1: new_event->watching = watch_core_le_1; break;
diff --git a/sim/common/sim-events.h b/sim/common/sim-events.h
index 60e2046..c01cea0 100644
--- a/sim/common/sim-events.h
+++ b/sim/common/sim-events.h
@@ -154,7 +154,8 @@ extern sim_event *sim_events_watch_clock
true.
HOST_ADDR: pointer into the host address space.
- BYTE_ORDER: 0 - host endian; BIG_ENDIAN; LITTLE_ENDIAN */
+ BYTE_ORDER: BFD_ENDIAN_UNKNOWN - host endian; BFD_ENDIAN_BIG;
+ BFD_ENDIAN_LITTLE. */
extern sim_event *sim_events_watch_sim
(SIM_DESC sd,
@@ -173,7 +174,8 @@ extern sim_event *sim_events_watch_sim
true.
CORE_ADDR/MAP: pointer into the target address space.
- BYTE_ORDER: 0 - current target endian; BIG_ENDIAN; LITTLE_ENDIAN */
+ BYTE_ORDER: BFD_ENDIAN_UNKNOWN - host endian; BFD_ENDIAN_BIG;
+ BFD_ENDIAN_LITTLE. */
extern sim_event *sim_events_watch_core
(SIM_DESC sd,
diff --git a/sim/common/sim-n-core.h b/sim/common/sim-n-core.h
index d67fb9c..0c1cb7a 100644
--- a/sim/common/sim-n-core.h
+++ b/sim/common/sim-n-core.h
@@ -250,7 +250,7 @@ sim_core_read_misaligned_N(sim_cpu *cpu,
read_transfer, sim_core_unaligned_signal);
if (CURRENT_HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
val = SWAP_M (val);
- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
val >>= (M - N) * 8;
PROFILE_COUNT_CORE (cpu, addr, N, map);
if (TRACE_P (cpu, TRACE_CORE_IDX))
@@ -366,7 +366,7 @@ sim_core_write_misaligned_N(sim_cpu *cpu,
unsigned_M val)
{
unsigned_M data = val;
- if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (CURRENT_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
data <<= (M - N) * 8;
if (CURRENT_HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
data = SWAP_M (data);
diff --git a/sim/common/sim-n-endian.h b/sim/common/sim-n-endian.h
index 4cfb925..ef7d2ce 100644
--- a/sim/common/sim-n-endian.h
+++ b/sim/common/sim-n-endian.h
@@ -81,7 +81,7 @@ INLINE_SIM_ENDIAN\
(unsigned_N)
endian_h2be_N(unsigned_N raw_in)
{
- if (CURRENT_HOST_BYTE_ORDER == BIG_ENDIAN) {
+ if (CURRENT_HOST_BYTE_ORDER == BFD_ENDIAN_BIG) {
return raw_in;
}
else {
@@ -95,7 +95,7 @@ INLINE_SIM_ENDIAN\
(unsigned_N)
endian_be2h_N(unsigned_N raw_in)
{
- if (CURRENT_HOST_BYTE_ORDER == BIG_ENDIAN) {
+ if (CURRENT_HOST_BYTE_ORDER == BFD_ENDIAN_BIG) {
return raw_in;
}
else {
@@ -109,7 +109,7 @@ INLINE_SIM_ENDIAN\
(unsigned_N)
endian_h2le_N(unsigned_N raw_in)
{
- if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN) {
+ if (CURRENT_HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) {
return raw_in;
}
else {
@@ -123,7 +123,7 @@ INLINE_SIM_ENDIAN\
(unsigned_N)
endian_le2h_N(unsigned_N raw_in)
{
- if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN) {
+ if (CURRENT_HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) {
return raw_in;
}
else {
@@ -145,7 +145,7 @@ offset_N (unsigned_N *x,
ASSERT (offset + sizeof_word <= sizeof(unsigned_N));
ASSERT (word < (sizeof (unsigned_N) / sizeof_word));
ASSERT ((sizeof (unsigned_N) % sizeof_word) == 0);
- if (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN)
+ if (WITH_HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
out = in + sizeof (unsigned_N) - offset - sizeof_word;
}
diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index 1fca5de..e252756 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -197,23 +197,23 @@ standard_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
case OPTION_ENDIAN:
if (strcmp (arg, "big") == 0)
{
- if (WITH_TARGET_BYTE_ORDER == LITTLE_ENDIAN)
+ if (WITH_TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
sim_io_eprintf (sd, "Simulator compiled for little endian only.\n");
return SIM_RC_FAIL;
}
/* FIXME:wip: Need to set something in STATE_CONFIG. */
- current_target_byte_order = BIG_ENDIAN;
+ current_target_byte_order = BFD_ENDIAN_BIG;
}
else if (strcmp (arg, "little") == 0)
{
- if (WITH_TARGET_BYTE_ORDER == BIG_ENDIAN)
+ if (WITH_TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
sim_io_eprintf (sd, "Simulator compiled for big endian only.\n");
return SIM_RC_FAIL;
}
/* FIXME:wip: Need to set something in STATE_CONFIG. */
- current_target_byte_order = LITTLE_ENDIAN;
+ current_target_byte_order = BFD_ENDIAN_LITTLE;
}
else
{