public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: ppc: drop host endian configure option
@ 2021-06-16  5:04 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2021-06-16  5:04 UTC (permalink / raw)
  To: gdb-patches

The --enable-sim-hostendian flag was purely so people had an escape route
for when cross-compiling.  This is because historically, AC_C_BIGENDIAN
did not work in those cases.  That was fixed a while ago though, so we can
require that macro everywhere now and simplify a good bit of code.

This was done for all the other ports years ago, so catch ppc up.
---
 sim/ppc/ChangeLog           |   20 +
 sim/ppc/Makefile.in         |    2 -
 sim/ppc/altivec_registers.h |    2 +-
 sim/ppc/config.in           |   15 -
 sim/ppc/configure           | 1698 +++++++++++++++--------------------
 sim/ppc/configure.ac        |   24 -
 sim/ppc/options.c           |    2 +-
 sim/ppc/psim.c              |   13 +-
 sim/ppc/sim-endian-n.h      |   12 +-
 sim/ppc/sim-endian.c        |    4 +-
 sim/ppc/sim-endian.h        |  175 ----
 sim/ppc/std-config.h        |   17 +-
 12 files changed, 765 insertions(+), 1219 deletions(-)

diff --git a/sim/ppc/ChangeLog b/sim/ppc/ChangeLog
index e2232a59d217..469d76bf2038 100644
--- a/sim/ppc/ChangeLog
+++ b/sim/ppc/ChangeLog
@@ -1,3 +1,23 @@
+2021-06-16  Mike Frysinger  <vapier@gentoo.org>
+
+	* Makefile.in (HOSTENDIAN_CFLAGS): Delete.
+	* configure.ac: Delete sim-hostendian logic.
+	* altivec_registers.h (WITH_HOST_BYTE_ORDER): Rename to ...
+	(HOST_BYTE_ORDER): ... this.
+	* options.c: Likewise.
+	* sim-endian.c: Likewise.
+	* psim.c (current_host_byte_order): Delete.
+	(CURRENT_HOST_BYTE_ORDER): Rename to ...
+	(HOST_BYTE_ORDER): ... this.
+	* sim-endian-n.h: Likewise.
+	* sim-endian.h: Delete all custom endian include & define logic.
+	* std-config.h (WITH_HOST_BYTE_ORDER): Delete.
+	(LITTLE_ENDIAN): Define fallback.
+	(BIG_ENDIAN): Likewise.
+	(HOST_BYTE_ORDER): Define based on WORDS_BIGENDIAN.
+	(current_host_byte_order, CURRENT_HOST_BYTE_ORDER): Delete.
+	* config.in, configure: Regenerate.
+
 2021-06-13  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (COMMON_OBJS_NAMES, +COMMON_OBJS): New variables.
diff --git a/sim/ppc/altivec_registers.h b/sim/ppc/altivec_registers.h
index 14c27cdb8196..2c0bff078431 100644
--- a/sim/ppc/altivec_registers.h
+++ b/sim/ppc/altivec_registers.h
@@ -49,7 +49,7 @@ struct altivec_regs {
    work on N independant bits of data.  This is only for the
    instructions that actually move data around.  */
 
-#if (WITH_HOST_BYTE_ORDER == BIG_ENDIAN)
+#if (HOST_BYTE_ORDER == BIG_ENDIAN)
 #define AV_BINDEX(x)	((x) & 15)
 #define AV_HINDEX(x)	((x) & 7)
 #else
diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac
index 3b93beefbfe0..188330fa5c72 100644
--- a/sim/ppc/configure.ac
+++ b/sim/ppc/configure.ac
@@ -287,29 +287,6 @@ if test x"$silent" != x"yes" && test x"$sim_hostbitsize" != x""; then
 fi],[sim_hostbitsize=""])dnl
 
 
-AC_ARG_ENABLE(sim-hostendian,
-[  --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";;
-  *)	 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
-  echo "Setting hostendian flags = $sim_hostendian" 6>&1
-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"
-  else
-    sim_hostendian="-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN"
-  fi
-else
-  sim_hostendian="-DWITH_HOST_BYTE_ORDER=0"
-fi])dnl
-
-
 AC_ARG_ENABLE(sim-icache,
 [  --enable-sim-icache=size		Specify instruction-decode cache size and type.],
 [icache="-R"
@@ -799,7 +776,6 @@ AC_SUBST(sim_pk_obj)
 AC_SUBST(sim_inline)
 AC_SUBST(sim_endian)
 AC_SUBST(sim_xor_endian)
-AC_SUBST(sim_hostendian)
 AC_SUBST(sim_smp)
 AC_SUBST(sim_igen_smp)
 AC_SUBST(sim_bitsize)
diff --git a/sim/ppc/options.c b/sim/ppc/options.c
index e327187b3756..330332ddf08d 100644
--- a/sim/ppc/options.c
+++ b/sim/ppc/options.c
@@ -117,7 +117,7 @@ print_options (void)
   printf_filtered ("Compiled on %s %s\n", __DATE__, __TIME__);
 #endif
 
-  printf_filtered ("WITH_HOST_BYTE_ORDER     = %s\n", options_byte_order (WITH_HOST_BYTE_ORDER));
+  printf_filtered ("HOST_BYTE_ORDER          = %s\n", options_byte_order (HOST_BYTE_ORDER));
   printf_filtered ("WITH_TARGET_BYTE_ORDER   = %s\n", options_byte_order (WITH_TARGET_BYTE_ORDER));
   printf_filtered ("WITH_XOR_ENDIAN          = %d\n", WITH_XOR_ENDIAN);
   printf_filtered ("WITH_SMP                 = %d\n", WITH_SMP);
diff --git a/sim/ppc/psim.c b/sim/ppc/psim.c
index 70c02f7141d4..0c3f5a1090c3 100644
--- a/sim/ppc/psim.c
+++ b/sim/ppc/psim.c
@@ -64,7 +64,6 @@ struct _psim {
 
 
 int current_target_byte_order;
-int current_host_byte_order;
 int current_environment;
 int current_alignment;
 int current_floating_point;
@@ -456,14 +455,6 @@ psim_create(const char *file_name,
   if (CURRENT_TARGET_BYTE_ORDER != current_target_byte_order)
     error("target and configured byte order conflict\n");
 
-  /* fill in the missing HOST BYTE ORDER information */
-  current_host_byte_order = (current_host_byte_order = 1,
-			     (*(char*)(&current_host_byte_order)
-			      ? LITTLE_ENDIAN
-			      : BIG_ENDIAN));
-  if (CURRENT_HOST_BYTE_ORDER != current_host_byte_order)
-    error("host and configured byte order conflict\n");
-
   /* fill in the missing OEA/VEA information */
   env = tree_find_string_property(root, "/openprom/options/env");
   current_environment = ((strcmp(env, "user") == 0
@@ -917,7 +908,7 @@ psim_read_register(psim *system,
       break;
 #ifdef WITH_ALTIVEC
     case 16:
-      if (CURRENT_HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
+      if (HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
         {
 	  union { vreg v; unsigned_8 d[2]; } h, t;
           memcpy(&h.v/*dest*/, cooked_buf/*src*/, description.size);
@@ -996,7 +987,7 @@ psim_write_register(psim *system,
       break;
 #ifdef WITH_ALTIVEC
     case 16:
-      if (CURRENT_HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
+      if (HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
         {
 	  union { vreg v; unsigned_8 d[2]; } h, t;
           memcpy(&t.v/*dest*/, buf/*src*/, description.size);
diff --git a/sim/ppc/sim-endian-n.h b/sim/ppc/sim-endian-n.h
index 095a642e9ee6..415149e569dd 100644
--- a/sim/ppc/sim-endian-n.h
+++ b/sim/ppc/sim-endian-n.h
@@ -38,7 +38,7 @@ INLINE_PSIM_ENDIAN\
 (unsigned_N)
 endian_t2h_N(unsigned_N raw_in)
 {
-  if (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER) {
+  if (CURRENT_TARGET_BYTE_ORDER == HOST_BYTE_ORDER) {
     return raw_in;
   }
   else {
@@ -51,7 +51,7 @@ INLINE_PSIM_ENDIAN\
 (unsigned_N)
 endian_h2t_N(unsigned_N raw_in)
 {
-  if (CURRENT_TARGET_BYTE_ORDER == CURRENT_HOST_BYTE_ORDER) {
+  if (CURRENT_TARGET_BYTE_ORDER == HOST_BYTE_ORDER) {
     return raw_in;
   }
   else {
@@ -73,7 +73,7 @@ INLINE_PSIM_ENDIAN\
 (unsigned_N)
 endian_h2be_N(unsigned_N raw_in)
 {
-  if (CURRENT_HOST_BYTE_ORDER == BIG_ENDIAN) {
+  if (HOST_BYTE_ORDER == BIG_ENDIAN) {
     return raw_in;
   }
   else {
@@ -86,7 +86,7 @@ INLINE_PSIM_ENDIAN\
 (unsigned_N)
 endian_be2h_N(unsigned_N raw_in)
 {
-  if (CURRENT_HOST_BYTE_ORDER == BIG_ENDIAN) {
+  if (HOST_BYTE_ORDER == BIG_ENDIAN) {
     return raw_in;
   }
   else {
@@ -99,7 +99,7 @@ INLINE_PSIM_ENDIAN\
 (unsigned_N)
 endian_h2le_N(unsigned_N raw_in)
 {
-  if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN) {
+  if (HOST_BYTE_ORDER == LITTLE_ENDIAN) {
     return raw_in;
   }
   else {
@@ -112,7 +112,7 @@ INLINE_PSIM_ENDIAN\
 (unsigned_N)
 endian_le2h_N(unsigned_N raw_in)
 {
-  if (CURRENT_HOST_BYTE_ORDER == LITTLE_ENDIAN) {
+  if (HOST_BYTE_ORDER == LITTLE_ENDIAN) {
     return raw_in;
   }
   else {
diff --git a/sim/ppc/sim-endian.c b/sim/ppc/sim-endian.c
index 2625d80d0b8b..0f76b239256f 100644
--- a/sim/ppc/sim-endian.c
+++ b/sim/ppc/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) && (HOST_BYTE_ORDER == LITTLE_ENDIAN) && 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) && (HOST_BYTE_ORDER == LITTLE_ENDIAN) && defined(htonl)
 #define _SWAP_4(SET,RAW) SET htonl (RAW)
 #endif
 
diff --git a/sim/ppc/sim-endian.h b/sim/ppc/sim-endian.h
index 9a873333a118..e07457212874 100644
--- a/sim/ppc/sim-endian.h
+++ b/sim/ppc/sim-endian.h
@@ -60,181 +60,6 @@ INLINE_PSIM_ENDIAN(unsigned_4) endian_le2h_4(unsigned_4 x);
 INLINE_PSIM_ENDIAN(unsigned_8) endian_le2h_8(unsigned_8 x);
 
 
-/* Host dependant:
-
-   The CPP below defines information about the compilation host.  In
-   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
-				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
-
-/* 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.  */
-
 /* SWAP */
 
 #define SWAP_1 swap_1
diff --git a/sim/ppc/std-config.h b/sim/ppc/std-config.h
index 6cf7f27fe558..375ba730beac 100644
--- a/sim/ppc/std-config.h
+++ b/sim/ppc/std-config.h
@@ -30,18 +30,23 @@
 
    Possible values are 0 (unknown), LITTLE_ENDIAN, BIG_ENDIAN */
 
-#ifndef WITH_HOST_BYTE_ORDER
-#define WITH_HOST_BYTE_ORDER		0 /*unknown*/
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 1234
+#endif
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN 4321
+#endif
+
+#ifdef WORDS_BIGENDIAN
+# define HOST_BYTE_ORDER BIG_ENDIAN
+#else
+# define HOST_BYTE_ORDER LITTLE_ENDIAN
 #endif
 
 #ifndef WITH_TARGET_BYTE_ORDER
 #define WITH_TARGET_BYTE_ORDER		0 /*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 \
-- 
2.31.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-16  5:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16  5:04 [PATCH] sim: ppc: drop host endian configure option Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).