From: borutr Date: Wed, 27 Jun 2007 16:17:14 +0000 (+0000) Subject: * support/regression/generate-cases.py: corrected the file name X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4df0866f3a46125114c3230f54a25d6ed3def732;p=fw%2Fsdcc * support/regression/generate-cases.py: corrected the file name in warning * configure.in, configure, sdccconf_in.h: find out the endianess of host machine git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4864 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index ee00e522..77e199a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-06-27 Borut Razem + + * support/regression/generate-cases.py: corrected the file name + in warning + * configure.in, configure, sdccconf_in.h: find out the endianess of + host machine + 2007-06-27 Gudjon I. Gudjonsson * device/include/mcs51/p89c66x.h: NXP header file, OK to change licence @@ -12,7 +19,6 @@ * support/librarian/sdcclib.c: fixed warning: format '%s' expects type 'char *', but argument 2 has type 'int' - 2007-06-25 Jesus Calvino-Fraga * support/librarian/sdcclib.c: Added feature Requests [1510635] diff --git a/configure b/configure index df428ca2..149bd2d9 100755 --- a/configure +++ b/configure @@ -6037,9 +6037,14 @@ cat >>confdefs.h <<_ACEOF _ACEOF -{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then + +# SDCC_BUILD_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN]) +# ------------------------------------------------------------------------- +# SDCC_BUILD_BIGENDIAN + +{ echo "$as_me:$LINENO: checking whether build machine byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether build machine byte ordering is bigendian... $ECHO_C" >&6; } +if test "${sdcc_cv_build_bigendian+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # See if sys/param.h defines the BYTE_ORDER macro. @@ -6119,12 +6124,12 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - ac_cv_c_bigendian=yes + sdcc_cv_build_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_c_bigendian=no + sdcc_cv_build_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -6135,7 +6140,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 # It does not; compile a test program. if test "$cross_compiling" = yes; then # try to guess the endianness by grepping values into an object file - ac_cv_c_bigendian=unknown + sdcc_cv_build_bigendian=unknown cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -6174,14 +6179,14 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 test ! -s conftest.err } && test -s conftest.$ac_objext; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then - ac_cv_c_bigendian=yes + sdcc_cv_build_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 + if test "$sdcc_cv_build_bigendian" = unknown; then + sdcc_cv_build_bigendian=no else # finding both strings is unlikely to happen, but who knows? - ac_cv_c_bigendian=unknown + sdcc_cv_build_bigendian=unknown fi fi else @@ -6237,14 +6242,14 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_c_bigendian=no + sdcc_cv_build_bigendian=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -ac_cv_c_bigendian=yes +sdcc_cv_build_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi @@ -6254,22 +6259,22 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } -case $ac_cv_c_bigendian in +{ echo "$as_me:$LINENO: result: $sdcc_cv_build_bigendian" >&5 +echo "${ECHO_T}$sdcc_cv_build_bigendian" >&6; } +case $sdcc_cv_build_bigendian in yes) cat >>confdefs.h <<\_ACEOF -#define WORDS_BIGENDIAN 1 +#define BUILD_WORDS_BIGENDIAN 1 _ACEOF ;; no) ;; *) { { echo "$as_me:$LINENO: error: unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +presetting sdcc_cv_build_bigendian=no (or yes) will help" >&5 echo "$as_me: error: unknown endianness -presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} +presetting sdcc_cv_build_bigendian=no (or yes) will help" >&2;} { (exit 1); exit 1; }; } ;; esac diff --git a/configure.in b/configure.in index 7b9632b9..2ceadb5e 100644 --- a/configure.in +++ b/configure.in @@ -376,7 +376,78 @@ AC_DEFINE_UNQUOTED(TYPE_UBYTE, unsigned $TYPE_CHAR) AC_DEFINE_UNQUOTED(TYPE_UWORD, unsigned $TYPE_WORD) AC_DEFINE_UNQUOTED(TYPE_UDWORD, unsigned $TYPE_DWORD) -AC_C_BIGENDIAN + +# SDCC_BUILD_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN]) +# ------------------------------------------------------------------------- +AC_DEFUN([SDCC_BUILD_BIGENDIAN], +[AC_CACHE_CHECK(whether build machine byte ordering is bigendian, sdcc_cv_build_bigendian, +[# See if sys/param.h defines the BYTE_ORDER macro. +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include +#include +], +[#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) + bogus endian macros +#endif +])], +[# It does; now see whether it defined to BIG_ENDIAN or not. +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include +#include +], [#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif +])], [sdcc_cv_build_bigendian=yes], [sdcc_cv_build_bigendian=no])], +[# It does not; compile a test program. +AC_RUN_IFELSE( +[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[ + /* 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; +]])], + [sdcc_cv_build_bigendian=no], + [sdcc_cv_build_bigendian=yes], +[# try to guess the endianness by grepping values into an object file + sdcc_cv_build_bigendian=unknown + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]], +[[ _ascii (); _ebcdic (); ]])], +[if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + sdcc_cv_build_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$sdcc_cv_build_bigendian" = unknown; then + sdcc_cv_build_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + sdcc_cv_build_bigendian=unknown + fi +fi])])])]) +case $sdcc_cv_build_bigendian in + yes) + m4_default([$1], + [AC_DEFINE([BUILD_WORDS_BIGENDIAN], 1, + [Define to 1 if your processor stores words with the most significant + byte first (like Motorola and SPARC, unlike Intel and VAX).])]) ;; + no) + $2 ;; + *) + m4_default([$3], + [AC_MSG_ERROR([unknown endianness +presetting sdcc_cv_build_bigendian=no (or yes) will help])]) ;; +esac +])# SDCC_BUILD_BIGENDIAN + +SDCC_BUILD_BIGENDIAN # Set standard installation paths # =========================================================================== diff --git a/sdccconf_in.h b/sdccconf_in.h index 4c651156..dc3d30b4 100644 --- a/sdccconf_in.h +++ b/sdccconf_in.h @@ -54,7 +54,25 @@ #undef TYPE_UWORD #undef TYPE_UDWORD +/* find out the endianess of host machine */ +#if __BIG_ENDIAN__ || _BIG_ENDIAN +/* 1) trust the compiler */ +#define WORDS_BIGENDIAN 1 +#elsif __LITTLE_ENDIAN__ +/* just in case ... */ #undef WORDS_BIGENDIAN +#elif (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) +/* 2) trust the header files */ +# if BYTE_ORDER == BIG_ENDIAN +# define WORDS_BIGENDIAN 1 +# endif +#else +/* 3) assume that host machine has the same endianess as the build machine */ +# undef BUILD_WORDS_BIGENDIAN +# if (defined BUILD_WORDS_BIGENDIAN && BUILD_WORDS_BIGENDIAN) +# define WORDS_BIGENDIAN 1 +/* 4) assume that host is a little endian machine */ +#endif #undef OPT_DISABLE_MCS51 #undef OPT_DISABLE_GBZ80 diff --git a/support/regression/generate-cases.py b/support/regression/generate-cases.py index e5053cdd..e2c08cc7 100644 --- a/support/regression/generate-cases.py +++ b/support/regression/generate-cases.py @@ -165,7 +165,7 @@ class InstanceGenerator: self.readfile() self.parse() if self.writetemplate() == 0: - sys.stderr.write("Empty function list in " + outdir + "!\n") + sys.stderr.write("Empty function list in " + self.inname + "!\n") # Create the output directory if it doesn't exist createdir(outdir)