diff options
author | Jiri Gaisler <jiri@gaisler.se> | 2015-03-16 01:14:09 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-03-16 01:16:35 -0400 |
commit | 9c5f41df36176d86afa65fc9b69b8fd6f6044547 (patch) | |
tree | 76a3dc2a8f5fff59c7e9a2fd7d3113455fed669e | |
parent | a4f851ffab57821a4904a9a28d8503500b77200e (diff) | |
download | gdb-9c5f41df36176d86afa65fc9b69b8fd6f6044547.zip gdb-9c5f41df36176d86afa65fc9b69b8fd6f6044547.tar.gz gdb-9c5f41df36176d86afa65fc9b69b8fd6f6044547.tar.bz2 |
sim/erc32: use SIM_AC_OPTION_HOSTENDIAN to probe for host endianess
-rw-r--r-- | sim/erc32/ChangeLog | 13 | ||||
-rw-r--r-- | sim/erc32/Makefile.in | 18 | ||||
-rw-r--r-- | sim/erc32/config.in | 15 | ||||
-rwxr-xr-x | sim/erc32/configure | 256 | ||||
-rw-r--r-- | sim/erc32/configure.ac | 1 | ||||
-rw-r--r-- | sim/erc32/end.c | 27 | ||||
-rw-r--r-- | sim/erc32/erc32.c | 1 | ||||
-rw-r--r-- | sim/erc32/exec.c | 7 | ||||
-rw-r--r-- | sim/erc32/func.c | 3 | ||||
-rw-r--r-- | sim/erc32/sis.h | 11 |
10 files changed, 296 insertions, 56 deletions
diff --git a/sim/erc32/ChangeLog b/sim/erc32/ChangeLog index b27c74d..41c465e 100644 --- a/sim/erc32/ChangeLog +++ b/sim/erc32/ChangeLog @@ -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. diff --git a/sim/erc32/Makefile.in b/sim/erc32/Makefile.in index 4e39549..108e8b6 100644 --- a/sim/erc32/Makefile.in +++ b/sim/erc32/Makefile.in @@ -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 diff --git a/sim/erc32/config.in b/sim/erc32/config.in index 5fed8c1..b367e14 100644 --- a/sim/erc32/config.in +++ b/sim/erc32/config.in @@ -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 @@ -135,6 +138,18 @@ #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 diff --git a/sim/erc32/configure b/sim/erc32/configure index b4636c9..4899feb 100755 --- a/sim/erc32/configure +++ b/sim/erc32/configure @@ -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 @@ -13098,6 +13100,255 @@ fi 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 diff --git a/sim/erc32/configure.ac b/sim/erc32/configure.ac index 8fc9fbb..2a6881b 100644 --- a/sim/erc32/configure.ac +++ b/sim/erc32/configure.ac @@ -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 index 9337198..0000000 --- a/sim/erc32/end.c +++ /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; -} diff --git a/sim/erc32/erc32.c b/sim/erc32/erc32.c index 428d6c4..6b771b4 100644 --- a/sim/erc32/erc32.c +++ b/sim/erc32/erc32.c @@ -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; diff --git a/sim/erc32/exec.c b/sim/erc32/exec.c index 07f3586..275218a 100644 --- a/sim/erc32/exec.c +++ b/sim/erc32/exec.c @@ -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 diff --git a/sim/erc32/func.c b/sim/erc32/func.c index 5123863..69d5eba 100644 --- a/sim/erc32/func.c +++ b/sim/erc32/func.c @@ -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 diff --git a/sim/erc32/sis.h b/sim/erc32/sis.h index dc02c65..6820cb4 100644 --- a/sim/erc32/sis.h +++ b/sim/erc32/sis.h @@ -23,8 +23,13 @@ #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 |