]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim/erc32: use SIM_AC_OPTION_HOSTENDIAN to probe for host endianess
authorJiri Gaisler <jiri@gaisler.se>
Mon, 16 Mar 2015 05:14:09 +0000 (01:14 -0400)
committerMike Frysinger <vapier@gentoo.org>
Mon, 16 Mar 2015 05:16:35 +0000 (01:16 -0400)
sim/erc32/ChangeLog
sim/erc32/Makefile.in
sim/erc32/config.in
sim/erc32/configure
sim/erc32/configure.ac
sim/erc32/end.c [deleted file]
sim/erc32/erc32.c
sim/erc32/exec.c
sim/erc32/func.c
sim/erc32/sis.h

index b27c74d259b0f869dca1daf45f53111c9a16e83f..41c465e5405d4495e3cb3c5ebd31c2150f13656f 100644 (file)
@@ -1,3 +1,16 @@
+2015-03-16  Jiri Gaisler  <jiri@gaisler.se>
+
+       * Makefile.in (end, end.h): Remove target rules.
+       (clean): Remove end and end.h.
+       (erc32.o, exec.o, float.o, func.o, help.o, interf.o, sis.o): Delete
+       rules.
+       * configure, config.in: Regenerate.
+       * configure.ac: Use SIM_AC_OPTION_HOSTENDIAN
+       * end.c: Delete.
+       * erc32.c: Remove end.h include.
+       * exec.c: Remove end.h include. Use HOST_LITTLE_ENDIAN.
+       * func.c, sis.c: Likewise.
+
 2015-03-14  Mike Frysinger  <vapier@gentoo.org>
 
        * Makefile.in (SIM_RUN_OBJS): Set to sis.o.
index 4e39549ef53bd72850958f0b6cc4088224d892ce..108e8b65f4033f4c2d34e83a09824dc520794f35 100644 (file)
@@ -42,21 +42,13 @@ sis: sis.o $(SIS_OFILES) $(COMMON_OBJS) $(LIBDEPS)
        $(CC) $(ALL_CFLAGS) -o sis \
          sis.o $(SIS_OFILES) $(COMMON_OBJS) $(EXTRA_LIBS)
 
-# FIXME: This computes the build host's endianness, doesn't it?
-# There is AC_C_BIGENDIAN but it doesn't handle float endianness.
-# [Are int/float endians every different on a sparc?]
-end: $(srcdir)/end.c
-       $(CC_FOR_BUILD) -I. $(srcdir)/end.c -o end
-end.h: end
-       ./end > end.h
-
 # Copy the files into directories where they will be run.
 install-sis: installdirs
        n=`echo sis | sed '$(program_transform_name)'`; \
        $(INSTALL_PROGRAM) sis$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT)
 
 clean-sis:
-       rm -f sis end end.h
+       rm -f sis
 
 configure:
        @echo "Rebuilding configure..."
@@ -65,11 +57,3 @@ configure:
        else true ; fi ; \
        (cd $${srcdir}; autoconf --localdir=../common)
 
-# Circumvent Sun Make bug with VPATH.
-erc32.o: erc32.c sis.h end.h
-exec.o: exec.c sis.h end.h
-float.o: float.c sis.h end.h
-func.o: func.c sis.h end.h
-help.o: help.c sis.h end.h
-interf.o: interf.c sis.h end.h 
-sis.o: sis.c sis.h end.h
index 5fed8c1815b0cf19b1960ebd5f06247dfbe251be..b367e1429a720ad79054414381a455099322fd18 100644 (file)
@@ -1,5 +1,8 @@
 /* config.in.  Generated from configure.ac by autoheader.  */
 
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
 #endif
 
 
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
+#endif
+
 /* Define to 1 if on MINIX. */
 #undef _MINIX
 
index b4636c96b7c1874bdf69e6d614f27fc7f887eb25..4899feb7c7b650ac9ed096dada206940cbe97e4e 100755 (executable)
@@ -761,6 +761,7 @@ enable_sim_trace
 enable_sim_profile
 with_pkgversion
 with_bugurl
+enable_sim_hostendian
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1403,6 +1404,7 @@ Optional Features:
   --enable-sim-stdio                   Specify whether to use stdio for console input/output.
   --enable-sim-trace=opts              Enable tracing flags
   --enable-sim-profile=opts            Enable profiling flags
+  --enable-sim-hostendian=end          Specify host byte endian orientation.
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -12354,7 +12356,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12357 "configure"
+#line 12359 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12460,7 +12462,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12463 "configure"
+#line 12465 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
 fi
 
 
+# Check whether --enable-sim-hostendian was given.
+if test "${enable_sim_hostendian+set}" = set; then :
+  enableval=$enable_sim_hostendian; 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";;
+  *)    as_fn_error "\"Unknown value $enableval for --enable-sim-hostendian\"" "$LINENO" 5; sim_hostendian="";;
+esac
+if test x"$silent" != x"yes" && test x"$sim_hostendian" != x""; then
+  echo "Setting hostendian flags = $sim_hostendian" 6>&1
+fi
+else
+
+if test "x$cross_compiling" = "xno"; then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
+$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
+if test "${ac_cv_c_bigendian+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_bigendian=unknown
+    # See if we're dealing with a universal compiler.
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __APPLE_CC__
+              not a universal capable compiler
+            #endif
+            typedef int dummy;
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+       # Check for potential -arch flags.  It is not universal unless
+       # there are at least two -arch flags with different values.
+       ac_arch=
+       ac_prev=
+       for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
+        if test -n "$ac_prev"; then
+          case $ac_word in
+            i?86 | x86_64 | ppc | ppc64)
+              if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
+                ac_arch=$ac_word
+              else
+                ac_cv_c_bigendian=universal
+                break
+              fi
+              ;;
+          esac
+          ac_prev=
+        elif test "x$ac_word" = "x-arch"; then
+          ac_prev=arch
+        fi
+       done
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    if test $ac_cv_c_bigendian = unknown; then
+      # See if sys/param.h defines the BYTE_ORDER macro.
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+            #include <sys/param.h>
+
+int
+main ()
+{
+#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
+                    && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
+                    && LITTLE_ENDIAN)
+             bogus endian macros
+            #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  # It does; now see whether it defined to BIG_ENDIAN or not.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+               #include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+                not big endian
+               #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_bigendian=yes
+else
+  ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    fi
+    if test $ac_cv_c_bigendian = unknown; then
+      # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+
+int
+main ()
+{
+#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
+             bogus endian macros
+            #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  # It does; now see whether it defined to _BIG_ENDIAN or not.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+
+int
+main ()
+{
+#ifndef _BIG_ENDIAN
+                not big endian
+               #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_bigendian=yes
+else
+  ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    fi
+    if test $ac_cv_c_bigendian = unknown; then
+      # Compile a test program.
+      if test "$cross_compiling" = yes; then :
+  # Try to guess by grepping values from an object file.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+short int ascii_mm[] =
+                 { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+               short int ascii_ii[] =
+                 { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+               int use_ascii (int i) {
+                 return ascii_mm[i] + ascii_ii[i];
+               }
+               short int ebcdic_ii[] =
+                 { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+               short int ebcdic_mm[] =
+                 { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+               int use_ebcdic (int i) {
+                 return ebcdic_mm[i] + ebcdic_ii[i];
+               }
+               extern int foo;
+
+int
+main ()
+{
+return use_ascii (foo) == use_ebcdic (foo);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
+             ac_cv_c_bigendian=yes
+           fi
+           if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+             if test "$ac_cv_c_bigendian" = unknown; then
+               ac_cv_c_bigendian=no
+             else
+               # finding both strings is unlikely to happen, but who knows?
+               ac_cv_c_bigendian=unknown
+             fi
+           fi
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+
+            /* Are we little or big endian?  From Harbison&Steele.  */
+            union
+            {
+              long int l;
+              char c[sizeof (long int)];
+            } u;
+            u.l = 1;
+            return u.c[sizeof (long int) - 1] == 1;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_c_bigendian=no
+else
+  ac_cv_c_bigendian=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+    fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
+$as_echo "$ac_cv_c_bigendian" >&6; }
+ case $ac_cv_c_bigendian in #(
+   yes)
+     $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
+;; #(
+   no)
+      ;; #(
+   universal)
+
+$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+
+     ;; #(
+   *)
+     as_fn_error "unknown endianness
+ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
+ esac
+
+  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
+fi
+
+
 ac_sources="$sim_link_files"
 ac_dests="$sim_link_links"
 while test -n "$ac_sources"; do
@@ -13232,6 +13483,7 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
 
+
 : ${CONFIG_STATUS=./config.status}
 ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
index 8fc9fbbe0daabb3076f68e357acda15a9351bd2c..2a6881bd733382ffefce2821b2d20bc308629c3d 100644 (file)
@@ -30,4 +30,5 @@ else
               AC_ERROR([the required "readline" library is missing]), $TERMCAP)
 fi
 AC_SUBST(READLINE)
+SIM_AC_OPTION_HOSTENDIAN
 SIM_AC_OUTPUT
diff --git a/sim/erc32/end.c b/sim/erc32/end.c
deleted file mode 100644 (file)
index 9337198..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "config.h"
-#include <stdio.h>
-
-int
-main()
-{
-
-    unsigned int    u1;
-    char           *c;
-    double          d1;
-    float          *f1;
-
-    c = (char *) &u1;
-    u1 = 0x0F;
-    if (c[0] == 0x0F)
-       puts("#define HOST_LITTLE_ENDIAN\n");
-    else
-       puts("#define HOST_BIG_ENDIAN\n");
-
-    d1 = 1.0;
-    f1 = (float *) &d1;
-    if (*((int *) f1) != 0x3ff00000)
-       puts("#define HOST_LITTLE_ENDIAN_FLOAT\n");
-    else
-       puts("#define HOST_BIG_ENDIAN_FLOAT\n");
-    return 0;
-}
index 428d6c461c312a1a20c6fb45936981e7e777a067..6b771b4eb8a06ebafa553d50ec6f55b7aa2afd67 100644 (file)
@@ -30,7 +30,6 @@
 #include <sys/file.h>
 #include <unistd.h>
 #include "sis.h"
-#include "end.h"
 #include "sim-config.h"
 
 extern int      ctrl_c;
index 07f35861c4b6cf1a56888682415167bcc04c03a0..275218a02004f54aa954c1140be4115f72fbc97e 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "config.h"
 #include "sis.h"
-#include "end.h"
 #include <math.h>
 #include <stdio.h>
 
@@ -1696,7 +1695,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
        but what about machines where float values are different endianness
        from integer values? */
 
-#ifdef HOST_LITTLE_ENDIAN_FLOAT
+#ifdef HOST_LITTLE_ENDIAN
     rs1 &= 0x1f;
     switch (opf) {
        case FADDd:
@@ -1874,7 +1873,7 @@ fpexec(op3, rd, rs1, rs2, sregs)
 
     accex = get_accex();
 
-#ifdef HOST_LITTLE_ENDIAN_FLOAT
+#ifdef HOST_LITTLE_ENDIAN
     switch (opf) {
     case FADDd:
     case FDIVd:
@@ -2021,7 +2020,7 @@ init_regs(sregs)
     sregs->err_mode = 0;
     ext_irl = 0;
     sregs->g[0] = 0;
-#ifdef HOST_LITTLE_ENDIAN_FLOAT
+#ifdef HOST_LITTLE_ENDIAN
     sregs->fdp = (float32 *) sregs->fd;
     sregs->fsi = (int32 *) sregs->fs;
 #else
index 51238630856d108536d843e9212082398411dfea..69d5ebaa703a37f98a2af0df9c40d6867c5a042e 100644 (file)
@@ -26,7 +26,6 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include "sis.h"
-#include "end.h"
 #include <dis-asm.h>
 #include "sim-config.h"
 
@@ -730,7 +729,7 @@ disp_fpu(sregs)
 
     printf("\n fsr: %08X\n\n", sregs->fsr);
 
-#ifdef HOST_LITTLE_ENDIAN_FLOAT
+#ifdef HOST_LITTLE_ENDIAN
     for (i = 0; i < 32; i++)
       sregs->fdp[i ^ 1] = sregs->fs[i];
 #endif
index dc02c65f6626111aed6da447e87bd65c19dd4a27..6820cb45f3de07cc9a56dd608cbaa7059ee0bd5f 100644 (file)
 #include "ansidecl.h"
 #include "gdb/callback.h"
 #include "gdb/remote-sim.h"
-
-#include "end.h"
+#include <sim-config.h>
+#if WITH_HOST_BYTE_ORDER == BIG_ENDIAN
+#define HOST_BIG_ENDIAN
+#else
+#define HOST_LITTLE_ENDIAN
+#endif
 
 #define I_ACC_EXC 1
 
@@ -60,7 +65,7 @@ typedef long long int64;         /* 64-bit signed int */
 struct pstate {
 
     float64         fd[16];    /* FPU registers */
-#ifdef HOST_LITTLE_ENDIAN_FLOAT
+#ifdef HOST_LITTLE_ENDIAN
     float32         fs[32];
     float32        *fdp;
 #else